From 81275cbcf705b675650ca803f8c98cdb7a167fa7 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 6 Oct 2000 21:12:25 +0000 Subject: Print socket options - patch from Dave Collier-Brown @ Sun. Jeremy. (This used to be commit c18d6f8701c8e6ca03f9fff79cf28c842b3b5ff9) --- source3/lib/util_sock.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index e6aef16d16..88fe8189b0 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -51,14 +51,16 @@ BOOL is_a_socket(int fd) enum SOCK_OPT_TYPES {OPT_BOOL,OPT_INT,OPT_ON}; -struct +typedef struct smb_socket_option { char *name; int level; int option; int value; int opttype; -} socket_options[] = { +} smb_socket_option; + +smb_socket_option socket_options[] = { {"SO_KEEPALIVE", SOL_SOCKET, SO_KEEPALIVE, 0, OPT_BOOL}, {"SO_REUSEADDR", SOL_SOCKET, SO_REUSEADDR, 0, OPT_BOOL}, {"SO_BROADCAST", SOL_SOCKET, SO_BROADCAST, 0, OPT_BOOL}, @@ -94,6 +96,23 @@ struct #endif {NULL,0,0,0,0}}; +/**************************************************************************** + Print socket options. +****************************************************************************/ +static void print_socket_options(int s) +{ + int value, vlen = 4; + smb_socket_option *p = &socket_options[0]; + + for (; p->name != NULL; p++) { + if (getsockopt(s, p->level, p->option, (void *)&value, &vlen) == -1) { + DEBUG(3,("Could not test socket option %s.\n", p->name)); + } else { + DEBUG(3,("socket option %s = %d\n",p->name,value)); + } + } + } + /**************************************************************************** Set user socket options. ****************************************************************************/ @@ -145,6 +164,8 @@ void set_socket_options(int fd, char *options) if (ret != 0) DEBUG(0,("Failed to set socket option %s (Error %s)\n",tok, strerror(errno) )); } + + print_socket_options(fd); } /**************************************************************************** -- cgit