--- netcat-4.0.20061122/usr.bin/nc/nc.1 +++ netcat-4.0.20061122/usr.bin/nc/nc.1 @@ -146,6 +146,8 @@ instead of sequentially within a range or in the order that the system assigns them. .It Fl S Enables the RFC 2385 TCP MD5 signature option. +.Ar NOTE: +This option is supported under OpenBSD, but not under Linux now. .It Fl s Ar source_ip_address Specifies the IP of the interface which is used to send the packets. It is an error to use this option in conjunction with the --- netcat-4.0.20061122/usr.bin/nc/netcat.c +++ netcat-4.0.20061122/usr.bin/nc/netcat.c @@ -56,6 +56,14 @@ #include "atomicio.h" #include +#if defined(TCP_MD5SIG) +#define HAVE_TCP_MD5SIG 1 +#endif + +#if defined(SO_JUMBO) +#define HAVE_SO_JUMBO 1 +#endif + #ifndef SUN_LEN #define SUN_LEN(su) \ (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) @@ -67,7 +75,9 @@ /* Command Line Options */ int dflag; /* detached, no stdin */ unsigned int iflag; /* Interval Flag */ +#if defined(HAVE_SO_JUMBO) int jflag; /* use jumbo frames if we can */ +#endif int kflag; /* More than one connect */ int lflag; /* Bind to local port */ int nflag; /* Don't do name look up */ @@ -81,7 +91,9 @@ int vflag; /* Verbosity */ int xflag; /* Socks proxy */ int zflag; /* Port Scan Flag */ int Dflag; /* sodebug */ +#if defined(HAVE_TCP_MD5SIG) int Sflag; /* TCP MD5 signature option */ +#endif int Tflag = -1; /* IP Type of Service */ int timeout = -1; @@ -160,7 +172,11 @@ main(int argc, char *argv[]) errx(1, "interval %s: %s", errstr, optarg); break; case 'j': +#if defined(HAVE_SO_JUMBO) jflag = 1; +#else + errx(1, "-j requires SO_JUMBO kernel support that's missing under Linux now"); +#endif break; case 'k': kflag = 1; @@ -211,7 +227,11 @@ main(int argc, char *argv[]) Dflag = 1; break; case 'S': +#if defined(HAVE_TCP_MD5SIG) Sflag = 1; +#else + errx(1, "-S requires TCP_MD5SIG kernel support that's missing under Linux now"); +#endif break; case 'T': Tflag = parse_iptos(optarg); @@ -311,7 +331,11 @@ main(int argc, char *argv[]) struct sockaddr_storage z; len = sizeof(z); +#if defined(HAVE_SO_JUMBO) plen = jflag ? 8192 : 1024; +#else + plen = sizeof(buf); +#endif rv = recvfrom(s, buf, plen, MSG_PEEK, (struct sockaddr *)&z, &len); if (rv < 0) @@ -608,7 +632,11 @@ readwrite(int nfd) int lfd = fileno(stdout); int plen; +#if defined(HAVE_SO_JUMBO) plen = jflag ? 8192 : 1024; +#else + plen = sizeof(buf); +#endif /* Setup Network FD */ pfd[0].fd = nfd; @@ -772,26 +800,32 @@ set_common_sockopts(int s) { int x = 1; +#if defined(HAVE_TCP_MD5SIG) if (Sflag) { if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, &x, sizeof(x)) == -1) err(1, NULL); } +#endif if (Dflag) { if (setsockopt(s, SOL_SOCKET, SO_DEBUG, &x, sizeof(x)) == -1) err(1, NULL); } +#if defined(HAVE_SO_JUMBO) if (jflag) { if (setsockopt(s, SOL_SOCKET, SO_JUMBO, &x, sizeof(x)) == -1) err(1, NULL); } +#endif if (Tflag != -1) { if (setsockopt(s, IPPROTO_IP, IP_TOS, &Tflag, sizeof(Tflag)) == -1) err(1, "set IP ToS"); } + + return; } int @@ -827,9 +861,13 @@ help(void) \t-n Suppress name/port resolutions\n\ \t-P proxyuser\tUsername for proxy authentication\n\ \t-p port\t Specify local port for remote connects\n\ - \t-r Randomize remote ports\n\ - \t-S Enable the TCP MD5 signature option\n\ - \t-s addr\t Local source address\n\ + \t-r Randomize remote ports\n" +#if defined (HAVE_TCP_MD5SIG) +" \t-S Enable the TCP MD5 signature option\n" +#else +" \t-S Enable the TCP MD5 signature option (BSD only!)\n" +#endif +" \t-s addr\t Local source address\n\ \t-T ToS\t Set IP Type of Service\n\ \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\