diff --git a/contrib/netcat/netcat.c b/contrib/netcat/netcat.c index efbe9bb9bbd..4bd808862c0 100644 --- a/contrib/netcat/netcat.c +++ b/contrib/netcat/netcat.c @@ -46,6 +46,7 @@ #include #endif #include +#include "../../sys/netinet/cc/cc_newreno.h" #include #include @@ -100,6 +101,8 @@ int zflag; /* Port Scan Flag */ int Dflag; /* sodebug */ int Iflag; /* TCP receive buffer size */ int Oflag; /* TCP send buffer size */ +int Aflag; /* TCP abe ecn */ +int aflag; /* TCP abe loos */ int Sflag; /* TCP MD5 signature option */ int Tflag = -1; /* IP Type of Service */ int rtableid = -1; @@ -167,7 +170,7 @@ main(int argc, char *argv[]) signal(SIGPIPE, SIG_IGN); while ((ch = getopt_long(argc, argv, - "46DdEe:FhI:i:klNnoO:P:p:rSs:tT:UuV:vw:X:x:z", + "46DdEe:FhI:i:klNnoO:P:p:rSs:tT:UuV:vw:X:x:zA:a:", longopts, NULL)) != -1) { switch (ch) { case '4': @@ -285,6 +288,18 @@ main(int argc, char *argv[]) errx(1, "TCP receive window %s: %s", errstr, optarg); break; + case 'a': + aflag = strtonum(optarg, 0, 100, &errstr); + if (errstr != NULL) + errx(1, "TCP abe loss value %s: %s", + errstr, optarg); + break; + case 'A': + Aflag = strtonum(optarg, 0, 100, &errstr); + if (errstr != NULL) + errx(1, "TCP abe ecn value %s: %s", + errstr, optarg); + break; case 'O': Oflag = strtonum(optarg, 1, 65536 << 14, &errstr); if (errstr != NULL) { @@ -1184,6 +1199,7 @@ void set_common_sockopts(int s, int af) { int x = 1; + struct cc_newreno_opts nrenoopts; if (Sflag) { if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, @@ -1224,6 +1240,20 @@ set_common_sockopts(int s, int af) &FreeBSD_Oflag, sizeof(FreeBSD_Oflag)) == -1) err(1, "disable TCP options"); } + if (Aflag) { + nrenoopts.name = CC_NEWRENO_BETA_ECN; + nrenoopts.val= Aflag; + if (setsockopt(s, IPPROTO_TCP, TCP_CCALGOOPT, + &nrenoopts, sizeof(nrenoopts)) == -1) + err(1, "set TCP beta ecn"); + } + if (aflag) { + nrenoopts.name = CC_NEWRENO_BETA; + nrenoopts.val= aflag; + if (setsockopt(s, IPPROTO_TCP, TCP_CCALGOOPT, + &nrenoopts, sizeof(nrenoopts)) == -1) + err(1, "set TCP beta loss"); + } #ifdef IPSEC if (ipsec_policy[0] != NULL) add_ipsec_policy(s, af, ipsec_policy[0]);