mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-16 19:50:19 +01:00
4acd08adfe
Signed-off-by: B. Watson <urchlay@slackware.uk> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
168 lines
4.6 KiB
Diff
168 lines
4.6 KiB
Diff
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
|