summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-10-06 21:12:25 +0000
committerJeremy Allison <jra@samba.org>2000-10-06 21:12:25 +0000
commit81275cbcf705b675650ca803f8c98cdb7a167fa7 (patch)
treead6da62e6c43b4193b3b817c5cde4cb322d92594
parent1929bcb89a8a5daf8ff9242324797e5340ec8fe9 (diff)
downloadsamba-81275cbcf705b675650ca803f8c98cdb7a167fa7.tar.gz
samba-81275cbcf705b675650ca803f8c98cdb7a167fa7.tar.bz2
samba-81275cbcf705b675650ca803f8c98cdb7a167fa7.zip
Print socket options - patch from Dave Collier-Brown @ Sun.
Jeremy. (This used to be commit c18d6f8701c8e6ca03f9fff79cf28c842b3b5ff9)
-rw-r--r--source3/lib/util_sock.c25
1 files changed, 23 insertions, 2 deletions
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},
@@ -95,6 +97,23 @@ struct
{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);
}
/****************************************************************************