Репозитории ALT
S: | 4.0.20100725-alt3 |
5.1: | 4.0.20061122-alt2 |
4.1: | 4.0.20061122-alt1 |
4.0: | 4.0.20061122-alt1 |
3.0: | 3.6-alt2 |
Группа :: Сети/Прочее
Пакет: netcat
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: netcat-4.0.20100725-alt-bsdsockopts.patch
Скачать
Скачать
--- src/usr.bin/nc/nc.1
+++ src/usr.bin/nc/nc.1
@@ -153,6 +153,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 yet.
.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
@@ -182,6 +184,8 @@ Use UDP instead of the default option of TCP.
.It Fl V Ar rtable
Set the routing table to be used.
The default is 0.
+.Ar NOTE:
+This option is supported under OpenBSD, but not under Linux yet.
.It Fl v
Have
.Nm
--- src/usr.bin/nc/netcat.c
+++ src/usr.bin/nc/netcat.c
@@ -56,6 +56,18 @@
#include "atomicio.h"
#include <time.h>
+#ifdef TCP_MD5SIG
+# define HAVE_TCP_MD5SIG 1
+#endif
+
+#ifdef SO_JUMBO
+# define HAVE_SO_JUMBO 1
+#endif
+
+#ifdef SO_RTABLE
+# define HAVE_SO_RTABLE 1
+#endif
+
#ifndef SUN_LEN
#define SUN_LEN(su) \
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
@@ -67,7 +79,9 @@
/* Command Line Options */
int dflag; /* detached, no stdin */
unsigned int iflag; /* Interval Flag */
+#ifdef 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 */
@@ -83,9 +97,13 @@ int zflag; /* Port Scan Flag */
int Dflag; /* sodebug */
int Iflag; /* TCP receive buffer size */
int Oflag; /* TCP send buffer size */
+#ifdef HAVE_TCP_MD5SIG
int Sflag; /* TCP MD5 signature option */
+#endif
int Tflag = -1; /* IP Type of Service */
+#ifdef HAVE_SO_RTABLE
u_int rtableid;
+#endif
int timeout = -1;
int family = AF_INET;
@@ -163,7 +181,11 @@ main(int argc, char *argv[])
errx(1, "interval %s: %s", errstr, optarg);
break;
case 'j':
+#ifdef HAVE_SO_JUMBO
jflag = 1;
+#else
+ errx(1, "-j requires SO_JUMBO kernel support that is missing under Linux yet");
+#endif
break;
case 'k':
kflag = 1;
@@ -194,10 +216,14 @@ main(int argc, char *argv[])
uflag = 1;
break;
case 'V':
+#ifdef HAVE_SO_RTABLE
rtableid = (unsigned int)strtonum(optarg, 0,
RT_TABLEID_MAX, &errstr);
if (errstr)
errx(1, "rtable %s: %s", errstr, optarg);
+#else
+ errx(1, "-V requires SO_RTABLE kernel support that is missing under Linux yet");
+#endif
break;
case 'v':
vflag = 1;
@@ -232,7 +258,11 @@ main(int argc, char *argv[])
errstr, optarg);
break;
case 'S':
+#ifdef HAVE_TCP_MD5SIG
Sflag = 1;
+#else
+ errx(1, "-S requires TCP_MD5SIG kernel support that is missing under Linux yet");
+#endif
break;
case 'T':
Tflag = parse_iptos(optarg);
@@ -332,7 +362,11 @@ main(int argc, char *argv[])
struct sockaddr_storage z;
len = sizeof(z);
+#ifdef HAVE_SO_JUMBO
plen = jflag ? 16384 : 2048;
+#else
+ plen = 2048;
+#endif
rv = recvfrom(s, buf, plen, MSG_PEEK,
(struct sockaddr *)&z, &len);
if (rv < 0)
@@ -515,18 +549,22 @@ remote_connect(const char *host, const char *port, struct addrinfo hints)
res0->ai_protocol)) < 0)
continue;
+#ifdef HAVE_SO_RTABLE
if (rtableid) {
if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid,
sizeof(rtableid)) == -1)
err(1, "setsockopt SO_RTABLE");
}
+#endif
/* Bind to a local port or source address if specified. */
if (sflag || pflag) {
struct addrinfo ahints, *ares;
+#ifdef SO_BINDANY
/* try SO_BINDANY, but don't insist */
setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on));
+#endif
memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res0->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
@@ -601,11 +639,13 @@ local_listen(char *host, char *port, struct addrinfo hints)
res0->ai_protocol)) < 0)
continue;
+#ifdef HAVE_SO_RTABLE
if (rtableid) {
if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid,
sizeof(rtableid)) == -1)
err(1, "setsockopt SO_RTABLE");
}
+#endif
ret = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &x, sizeof(x));
if (ret == -1)
@@ -645,7 +685,11 @@ readwrite(int nfd)
int lfd = fileno(stdout);
int plen;
+#ifdef HAVE_SO_JUMBO
plen = jflag ? 16384 : 2048;
+#else
+ plen = 2048;
+#endif
/* Setup Network FD */
pfd[0].fd = nfd;
@@ -808,21 +852,25 @@ set_common_sockopts(int s)
{
int x = 1;
+#ifdef 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);
}
+#ifdef 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)
@@ -875,15 +923,19 @@ help(void)
\t-O length TCP send buffer length\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"
+#ifdef HAVE_TCP_MD5SIG
+" \t-S Enable the TCP MD5 signature option\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\
- \t-u UDP mode\n\
- \t-V rtable Specify alternate routing table\n\
- \t-v Verbose\n\
+ \t-u UDP mode\n"
+#ifdef HAVE_SO_RTABLE
+" \t-V rtable Specify alternate routing table\n"
+#endif
+" \t-v Verbose\n\
\t-w secs\t Timeout for connects and final net reads\n\
\t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
\t-x addr[:port]\tSpecify proxy address and port\n\
@@ -896,9 +948,9 @@ void
usage(int ret)
{
fprintf(stderr,
- "usage: netcat [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n"
+ "usage: netcat [-46DdhklnrtUuvz] [-I length] [-i interval] [-O length]\n"
" [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS]\n"
- " [-V rtable] [-w timeout] [-X proxy_protocol]\n"
+ " [-w timeout] [-X proxy_protocol]\n"
" [-x proxy_address[:port]] [hostname] [port]\n");
if (ret)
exit(1);