-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtos.patch
68 lines (66 loc) · 2.29 KB
/
tos.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
diff -up nc110/netcat.c.3~ nc110/netcat.c
--- nc110/netcat.c.3~ 2025-01-25 18:28:40.638324015 +0100
+++ nc110/netcat.c 2025-01-25 19:04:23.002504185 +0100
@@ -212,6 +212,9 @@ USHORT o_holler_stderr = 1;
unsigned int o_wait = 0;
USHORT o_zero = 0;
int o_quit = -1; /* 0 == quit-now; >0 == quit after o_quit seconds */
+#ifdef IP_TOS
+unsigned char o_tos = 0;
+#endif
/* o_tn in optional section */
/* Debug macro: squirt whatever message and sleep a bit so we can see it go
@@ -830,6 +833,13 @@ newskt:
if (rr == -1)
holler ("nnetfd reuseport failed"); /* ??? */
#endif
+#ifdef IP_TOS
+ if (o_tos) {
+ rr = setsockopt (nnetfd, SOL_IP, IP_TOS, &o_tos, sizeof(o_tos));
+ if (rr == -1)
+ holler ("nnetfd tos failed"); /* ??? */
+ }
+#endif
#if 0
/* If you want to screw with RCVBUF/SNDBUF, do it here. Liudvikas Bukys at
Rochester sent this example, which would involve YET MORE options and is
@@ -1863,6 +1873,10 @@ options:");
-q secs quit after EOF on stdin and delay of secs\n\
-r randomize local and remote ports\n\
-s addr local source address");
+#ifdef IP_TOS
+ holler("\
+ -T tos set Type Of Service");
+#endif
#ifdef TELNET
holler ("\
-t answer TELNET negotiation");
@@ -2010,7 +2024,7 @@ main (argc, argv)
/* If your shitbox doesn't have getopt, step into the nineties already. */
/* optarg, optind = next-argv-component [i.e. flag arg]; optopt = last-char */
- while ((x = getopt (argc, argv, "46abc:e:g:G:hi:lno:p:q:rs:tuvw:z")) != EOF) {
+ while ((x = getopt (argc, argv, "46abc:e:g:G:hi:lno:p:q:rs:T:tuvw:z")) != EOF) {
/* Debug (("in go: x now %c, optarg %x optind %d", x, optarg, optind)) */
switch (x) {
#ifdef INET6
@@ -2112,6 +2126,20 @@ main (argc, argv)
timer2 = (struct timeval *) Hmalloc (sizeof (struct timeval));
timer1->tv_sec = o_wait; /* we need two. see readwrite()... */
break;
+#ifdef IP_TOS
+ case 'T':
+ if (!strcmp(optarg, "Minimize-Delay"))
+ o_tos = IPTOS_LOWDELAY;
+ else if (!strcmp(optarg, "Maximize-Throughput"))
+ o_tos = IPTOS_THROUGHPUT;
+ else if (!strcmp(optarg, "Maximize-Reliability"))
+ o_tos = IPTOS_RELIABILITY;
+ else if (!strcmp(optarg, "Minimize-Cost"))
+ o_tos = IPTOS_MINCOST;
+ else
+ o_tos = atoi(optarg);;
+ break;
+#endif
case 'z': /* little or no data xfer */
o_zero++;
break;