diff -rN --unified=2 ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/socket_bind.c ipsvd-0.12.1/net/ipsvd-0.12.1/src/socket_bind.c --- ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/socket_bind.c 2006-02-04 11:16:48.000000000 -0800 +++ ipsvd-0.12.1/net/ipsvd-0.12.1/src/socket_bind.c 2014-04-23 20:54:30.000000000 -0700 @@ -32,2 +32,8 @@ } } + +int socket_keepalive(int s) +{ + int opt = 1; + return setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,&opt,sizeof opt); +} diff -rN --unified=2 ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/socket.h ipsvd-0.12.1/net/ipsvd-0.12.1/src/socket.h --- ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/socket.h 2006-02-04 11:16:48.000000000 -0800 +++ ipsvd-0.12.1/net/ipsvd-0.12.1/src/socket.h 2014-04-23 20:54:30.000000000 -0700 @@ -19,4 +19,5 @@ extern void socket_tryreservein(int,int); +extern int socket_keepalive(int); #endif diff -rN --unified=2 ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/tcpsvd.c ipsvd-0.12.1/net/ipsvd-0.12.1/src/tcpsvd.c --- ipsvd-0.12.1.old/net/ipsvd-0.12.1/src/tcpsvd.c 2006-02-04 11:16:47.000000000 -0800 +++ ipsvd-0.12.1/net/ipsvd-0.12.1/src/tcpsvd.c 2014-04-23 20:54:30.000000000 -0700 @@ -33,7 +33,7 @@ #ifdef SSLSVD -#define USAGE " [-Ehpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] [-U ssluser] [-/ root] [-Z cert] [-K key] host port prog" +#define USAGE " [-Ehkpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] [-U ssluser] [-/ root] [-Z cert] [-K key] host port prog" #else -#define USAGE " [-Ehpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] host port prog" +#define USAGE " [-Ehkpv] [-u user] [-c n] [-C n:msg] [-b n] [-l name] [-i dir|-x cdb] [-t sec] host port prog" #endif @@ -55,4 +55,5 @@ unsigned long cmax =30; unsigned long timeout =0; +unsigned int keepalive =0; unsigned int ucspi =1; @@ -242,4 +243,6 @@ if ((fd_move(0, c) == -1) || (fd_copy(1, 0) == -1)) drop("unable to set filedescriptor"); + if (keepalive) + socket_keepalive(0); sig_uncatch(sig_term); sig_uncatch(sig_pipe); @@ -272,8 +275,8 @@ #ifdef SSLSVD while ((opt =getopt(argc, (const char **)argv, - "c:C:i:x:u:l:Eb:hpt:vVU:/:Z:K:")) != opteof) { + "c:C:i:x:u:l:Eb:hkpt:vVU:/:Z:K:")) != opteof) { #else while ((opt =getopt(argc, (const char **)argv, - "c:C:i:x:u:l:Eb:hpt:vV")) != opteof) { + "c:C:i:x:u:l:Eb:hpkt:vV")) != opteof) { #endif switch(opt) { @@ -298,4 +301,5 @@ case 'b': scan_ulong(optarg, &backlog); break; case 'h': lookuphost =1; break; + case 'k': keepalive =1; break; case 'p': lookuphost =1; paranoid =1; break; case 't': scan_ulong(optarg, &timeout); break;