diff -ru ./nttcp-1.47-orig/nttcp.c ./nttcp-1.47-rude/nttcp.c --- ./nttcp-1.47-orig/nttcp.c 2000-12-18 03:16:54.000000000 -0700 +++ ./nttcp-1.47-rude/nttcp.c 2003-04-20 23:13:08.000000000 -0600 @@ -275,6 +275,7 @@ \t-T print title line (default no)\n\ \t-f give own format of what and how to print\n\ \t-c compares each received buffer with expected value\n\ +\t-e Make the socket use rudeTCP\n\ \t-s force stream pattern for UDP transmission\n\ \t-S give another initialisation for pattern generator\n\ \t-p# specify another service port\n\ @@ -355,6 +356,7 @@ char *RemHost; /* the remote host to connect to */ char *InitString; /* the stream init string */ int RemoteNumber; /* */ + int rude; /* be rude */ } Options; Options opt; /* the commandline options */ @@ -402,7 +404,7 @@ char prevChar= '\0'; struct timeval tmo; FD_ZERO(&ReadMask); - tmo.tv_sec= 10; + tmo.tv_sec= 20; /* required for some high-delay tests */ tmo.tv_usec= 0; pcnt= fdmax=0; for (p=0; p= Limit) { + if ((*val=atoi(arg)) <= 0 || *val > Limit) { /* limit is permissable */ sprintf(MsgBuf, "invalid value for %s (%.30s)\n", what, arg); fMessage(stderr, MsgBuf); Usage(); @@ -884,6 +886,7 @@ opt->Transmit=1; /* ==1: transmitting, ==0 receiveing */ opt->Format= DEFAULT_FORMAT; opt->InitString= Nil(char); + opt->rude = 0; /* don't be rude by default */ return; } @@ -946,7 +949,7 @@ "RemoteNumber"); break; case 'w': - GetSizeValue(&argc, &argv, &opt->SndWin, 10000, + GetSizeValue(&argc, &argv, &opt->SndWin, 65536, /* limit window to 64MB */ "windowsize"); opt->RcvWin = opt->SndWin= opt->SndWin*1024; opt->Window=1; @@ -970,6 +973,9 @@ case 'c': opt->Compare= 1; break; + case 'e': + opt->rude = 1; + break; case 'p': { int val; GetSizeValue(&argc, &argv, &val, 256*256, "service port"); @@ -1610,6 +1616,15 @@ if (SetTCP_NoDelay(fd) < 0) exitError("setsockopt: nodelay", 16); } + /* transmit, TCP, check rude */ + if (opt.rude) { + int rude_me=1; + if (setsockopt(fd, IPPROTO_TCP, TCP_RUDE, &rude_me, sizeof(int))<0) { + printf("ERROR: Could not set socket to be rude; %s\n", strerror(errno)); + } else { + printf("Set socket to be rude.\n"); + } + } } } else { /*Receive*/