summaryrefslogtreecommitdiffstats
path: root/network/linksys-tftp/linksys-tftp-1.2.1-stdc-tftp.patch
blob: e9a77ac7222b76ee5899b4d8ee08c5fbc9906530 (plain)
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
--- linksys-tftp-1.2.1/tftp.c	2024-04-16 08:27:50.328449885 -0700
+++ linksys-tftp-1.2.1/tftp.c	2024-04-15 21:26:36.259371211 -0700
@@ -47,6 +47,13 @@ extern  int     rexmtval;
 extern  int     maxtimeout;
 extern	int	segsize;
 
+/* functions from tftpsubs */
+extern int readit(FILE *file,  struct tftphdr **dpp, int convert);
+extern int read_ahead(FILE *file, int convert);
+extern int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert);
+extern int write_behind( FILE *file, int convert);
+extern int synchnet(int f);
+
 #define PKTSIZE    (1432+4) /* SEGSIZE+4 */
 char    ackbuf[PKTSIZE];
 int	timeout;
@@ -57,6 +64,19 @@ jmp_buf	timeoutbuf;
 #define OACK	6
 #endif
 
+/* functions declared herein */
+void timer(int sig);
+void parseoack(char *cp, int sz);
+void sendfile(int fd, char *name, char *mode, char *linkpass);
+void recvfile(int fd, char *name, char *mode, char *linkpass);
+int makerequest(int request, char *name, struct tftphdr *tp, char *mode, char *linkpass);
+void nak(int error);
+void topts(char *cp, int sz);
+void tpacket(char *s, struct tftphdr *tp, int n);
+void startclock();
+void stopclock();
+void printstats(char *direction, unsigned long amount);
+
 void timer(int sig)
 {
 
@@ -72,9 +92,7 @@ void timer(int sig)
 /*
  * Parse an OACK package and set blocksize accordingly
  */
-parseoack(cp, sz)
-	char *cp;
-	int sz;
+void parseoack(char *cp, int sz)
 {
 	int n;
 	
@@ -106,11 +124,7 @@ parseoack(cp, sz)
 /*
  * Send the requested file.
  */
-sendfile(fd, name, mode, linkpass)
-	int fd;
-	char *name;
-	char *mode;
-	char *linkpass;
+void sendfile(int fd, char *name, char *mode, char *linkpass)
 {
 	register struct tftphdr *ap;       /* data and ack packets */
 	struct tftphdr *r_init(), *dp;
@@ -211,7 +225,7 @@ send_data:
 					printf("protocol violation\n");
 					longjmp(toplevel, -1);
 				}
-				parseoack(&ap->th_stuff, n - 2);
+                                parseoack(ap->th_stuff, n - 2);
 				break;
 			}
 		}
@@ -231,11 +245,7 @@ abort:
 /*
  * Receive a file.
  */
-recvfile(fd, name, mode, linkpass)
-	int fd;
-	char *name;
-	char *mode;
-	char *linkpass;
+void recvfile(int fd, char *name, char *mode, char *linkpass)
 {
 	register struct tftphdr *ap;
 	struct tftphdr *dp, *w_init();
@@ -336,7 +346,7 @@ send_ack:
 					longjmp(toplevel, -1);
 				}
 				waitforoack = 0;
-				parseoack(&dp->th_stuff, n - 2);
+                                parseoack(dp->th_stuff, n - 2);
 				ap->th_opcode = htons((u_short)ACK);
 				ap->th_block = htons(0);
 				size = 4;
@@ -362,10 +372,7 @@ abort:
 		printstats("Received", amount);
 }
 
-makerequest(request, name, tp, mode, linkpass)
-	int request;
-	char *name, *mode, *linkpass;
-	struct tftphdr *tp;
+int makerequest(int request, char *name, struct tftphdr *tp, char *mode, char *linkpass)
 {
 	register char *cp;
 
@@ -404,8 +411,7 @@ struct errmsg {
  * standard TFTP codes, or a UNIX errno
  * offset by 100.
  */
-nak(error)
-	int error;
+void nak(int error)
 {
 	register struct tftphdr *tp;
 	int length;
@@ -431,9 +437,7 @@ nak(error)
 		perror("nak");
 }
 
-topts(cp, sz)
-	char *cp;
-	int sz;
+void topts(char *cp, int sz)
 {
 	int n, i = 0;
 	
@@ -454,10 +458,7 @@ topts(cp, sz)
 	}
 }
 
-tpacket(s, tp, n)
-	char *s;
-	struct tftphdr *tp;
-	int n;
+void tpacket(char *s, struct tftphdr *tp, int n)
 {
 	static char *opcodes[] =
 	   { "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" };
@@ -505,17 +506,15 @@ struct timeval tstart;
 struct timeval tstop;
 struct timezone zone;
 
-startclock() {
+void startclock() {
 	gettimeofday(&tstart, &zone);
 }
 
-stopclock() {
+void stopclock() {
 	gettimeofday(&tstop, &zone);
 }
 
-printstats(direction, amount)
-char *direction;
-unsigned long amount;
+void printstats(char *direction, unsigned long amount)
 {
 	double delta;
 			/* compute delta in 1/10's second units */