summaryrefslogtreecommitdiffstats
path: root/network/tnfsd/remove_broken_tcp_support.diff
blob: 010f04baf4c67075f4dcceafb0ffc64d807bf0bf (about) (plain) (blame)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
diff -Naur tnfsd-23.0207.1_95c5b55/config.h tnfsd-23.0207.1_95c5b55.patched/config.h
--- tnfsd-23.0207.1_95c5b55/config.h	2023-02-08 13:35:32.000000000 -0500
+++ tnfsd-23.0207.1_95c5b55.patched/config.h	2023-02-08 13:37:37.069280883 -0500
@@ -28,7 +28,6 @@
 #define MAX_DHND_PER_CONN 8	/* max open directories per client */
 #define MAX_CLIENTS	4096	/* maximum number of UDP clients */
 #define MAX_CLIENTS_PER_IP 4096 /* maximum number of UDP clients from single IP */
-#define MAX_TCP_CONN	256	/* Maximum number of TCP clients */
 #define SESSION_TIMEOUT 21600 /* Sessions are thrown out after no contact for this many seconds. 0 = no timeout */
 #define TNFS_HEADERSZ	4	/* minimum header size */
 #define TNFS_MAX_PAYLOAD (MAXMSGSZ - TNFS_HEADERSZ - 1) /* Maximum usuable payload in a UDP datagram (-1 for status byte) */
diff -Naur tnfsd-23.0207.1_95c5b55/datagram.c tnfsd-23.0207.1_95c5b55.patched/datagram.c
--- tnfsd-23.0207.1_95c5b55/datagram.c	2023-02-08 13:35:32.000000000 -0500
+++ tnfsd-23.0207.1_95c5b55.patched/datagram.c	2023-02-08 13:40:57.701262001 -0500
@@ -50,7 +50,6 @@
 #include "tnfs_file.h"
 
 int sockfd;		 /* UDP global socket file descriptor */
-int tcplistenfd; /* TCP listening socket file descriptor */
 
 tnfs_cmdfunc dircmd[NUM_DIRCMDS] =
 	{&tnfs_opendir, &tnfs_readdir, &tnfs_closedir,
@@ -141,23 +140,6 @@
 	if (bind(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0)
 		die("Unable to bind");
 
-	/* Create the TCP socket */
-	tcplistenfd = socket(AF_INET, SOCK_STREAM, 0);
-	if (tcplistenfd < 0)
-	{
-		die("Unable to create TCP socket");
-	}
-
-	memset(&servaddr, 0, sizeof(servaddr));
-	servaddr.sin_family = AF_INET;
-	servaddr.sin_addr.s_addr = htons(INADDR_ANY);
-	servaddr.sin_port = htons(TNFSD_PORT);
-	if (bind(tcplistenfd, (struct sockaddr *)&servaddr,
-			 sizeof(servaddr)) < 0)
-	{
-		die("Unable to bind TCP socket");
-	}
-	listen(tcplistenfd, 5);
 }
 
 void tnfs_mainloop()
@@ -165,25 +147,13 @@
 	int readyfds, i;
 	fd_set fdset;
 	fd_set errfdset;
-	int tcpsocks[MAX_TCP_CONN];
-
-	memset(&tcpsocks, 0, sizeof(tcpsocks));
 
 	while (1)
 	{
 		FD_ZERO(&fdset);
 
-		/* add UDP socket and TCP listen socket to fdset */
+		/* add UDP socket to fdset */
 		FD_SET(sockfd, &fdset);
-		FD_SET(tcplistenfd, &fdset);
-
-		for (i = 0; i < MAX_TCP_CONN; i++)
-		{
-			if (tcpsocks[i])
-			{
-				FD_SET(tcpsocks[i], &fdset);
-			}
-		}
 
 		FD_COPY(&fdset, &errfdset);
 		if ((readyfds = select(FD_SETSIZE, &fdset, NULL, &errfdset, NULL)) != 0)
@@ -199,55 +169,10 @@
 			{
 				tnfs_handle_udpmsg();
 			}
-			/* Incoming TCP connection? */
-			else if (FD_ISSET(tcplistenfd, &fdset))
-			{
-				tcp_accept(&tcpsocks[0]);
-			}
-			else
-			{
-				for (i = 0; i < MAX_TCP_CONN; i++)
-				{
-					if (tcpsocks[i])
-					{
-						if (FD_ISSET(tcpsocks[i], &fdset))
-						{
-							tnfs_handle_tcpmsg(tcpsocks[i]);
-						}
-					}
-				}
-			}
 		}
 	}
 }
 
-void tcp_accept(int *socklist)
-{
-	int acc_fd, i;
-	struct sockaddr_in cli_addr;
-	socklen_t cli_len = sizeof(cli_addr);
-	int *fdptr;
-
-	acc_fd = accept(tcplistenfd, (struct sockaddr *)&cli_addr, &cli_len);
-	if (acc_fd < 1)
-	{
-		fprintf(stderr, "WARNING: unable to accept TCP connection\n");
-		return;
-	}
-
-	fdptr = socklist;
-	for (i = 0; i < MAX_TCP_CONN; i++)
-	{
-		if (*fdptr == 0)
-		{
-			*fdptr = acc_fd;
-			return;
-		}
-	}
-
-	/* tell the client 'too many connections' */
-}
-
 void tnfs_handle_udpmsg()
 {
 	socklen_t len;
@@ -273,15 +198,6 @@
 	*(rxbuf + rxbytes) = 0;
 }
 
-void tnfs_handle_tcpmsg(int cli_fd)
-{
-	char buf[255];
-	int sz;
-
-	sz = read(cli_fd, buf, sizeof(buf));
-	printf("DEBUG: rx of tcpmsg: %d bytes: %s\n", sz, buf);
-}
-
 void tnfs_decode(struct sockaddr_in *cliaddr, int rxbytes, unsigned char *rxbuf)
 {
 	Header hdr;
diff -Naur tnfsd-23.0207.1_95c5b55/datagram.h tnfsd-23.0207.1_95c5b55.patched/datagram.h
--- tnfsd-23.0207.1_95c5b55/datagram.h	2023-02-08 13:35:32.000000000 -0500
+++ tnfsd-23.0207.1_95c5b55.patched/datagram.h	2023-02-08 13:39:55.229267881 -0500
@@ -51,8 +51,6 @@
 void tnfs_sockinit();
 void tnfs_mainloop();
 void tnfs_handle_udpmsg();
-void tcp_accept(int *fdlist);
-void tnfs_handle_tcpmsg(int cli_fd);
 void tnfs_decode(struct sockaddr_in *cliaddr, 
 		int rxbytes, unsigned char *rxbuf);
 void tnfs_invalidsession(Header *hdr);
diff -Naur tnfsd-23.0207.1_95c5b55/tnfs.h tnfsd-23.0207.1_95c5b55.patched/tnfs.h
--- tnfsd-23.0207.1_95c5b55/tnfs.h	2023-02-08 13:35:32.000000000 -0500
+++ tnfsd-23.0207.1_95c5b55.patched/tnfs.h	2023-02-08 13:40:15.637265960 -0500
@@ -136,7 +136,6 @@
 #endif
 	int lastmsgsz;			/* last message's size inc. hdr */
 	uint8_t lastseqno;		/* last sequence number */
-	uint8_t isTCP;			/* uses the TCP transport */
 } Session;
 
 typedef struct _header