Lines 47-52
extern int rexmtval;
Link Here
|
47 |
extern int maxtimeout; |
47 |
extern int maxtimeout; |
48 |
extern int segsize; |
48 |
extern int segsize; |
49 |
|
49 |
|
|
|
50 |
/* functions from tftpsubs */ |
51 |
extern int readit(FILE *file, struct tftphdr **dpp, int convert); |
52 |
extern int read_ahead(FILE *file, int convert); |
53 |
extern int writeit(FILE *file, struct tftphdr **dpp, int ct, int convert); |
54 |
extern int write_behind( FILE *file, int convert); |
55 |
extern int synchnet(int f); |
56 |
|
50 |
#define PKTSIZE (1432+4) /* SEGSIZE+4 */ |
57 |
#define PKTSIZE (1432+4) /* SEGSIZE+4 */ |
51 |
char ackbuf[PKTSIZE]; |
58 |
char ackbuf[PKTSIZE]; |
52 |
int timeout; |
59 |
int timeout; |
Lines 57-62
jmp_buf timeoutbuf;
Link Here
|
57 |
#define OACK 6 |
64 |
#define OACK 6 |
58 |
#endif |
65 |
#endif |
59 |
|
66 |
|
|
|
67 |
/* functions declared herein */ |
68 |
void timer(int sig); |
69 |
void parseoack(char *cp, int sz); |
70 |
void sendfile(int fd, char *name, char *mode, char *linkpass); |
71 |
void recvfile(int fd, char *name, char *mode, char *linkpass); |
72 |
int makerequest(int request, char *name, struct tftphdr *tp, char *mode, char *linkpass); |
73 |
void nak(int error); |
74 |
void topts(char *cp, int sz); |
75 |
void tpacket(char *s, struct tftphdr *tp, int n); |
76 |
void startclock(); |
77 |
void stopclock(); |
78 |
void printstats(char *direction, unsigned long amount); |
79 |
|
60 |
void timer(int sig) |
80 |
void timer(int sig) |
61 |
{ |
81 |
{ |
62 |
|
82 |
|
Lines 72-80
void timer(int sig)
Link Here
|
72 |
/* |
92 |
/* |
73 |
* Parse an OACK package and set blocksize accordingly |
93 |
* Parse an OACK package and set blocksize accordingly |
74 |
*/ |
94 |
*/ |
75 |
parseoack(cp, sz) |
95 |
void parseoack(char *cp, int sz) |
76 |
char *cp; |
|
|
77 |
int sz; |
78 |
{ |
96 |
{ |
79 |
int n; |
97 |
int n; |
80 |
|
98 |
|
Lines 106-116
parseoack(cp, sz)
Link Here
|
106 |
/* |
124 |
/* |
107 |
* Send the requested file. |
125 |
* Send the requested file. |
108 |
*/ |
126 |
*/ |
109 |
sendfile(fd, name, mode, linkpass) |
127 |
void sendfile(int fd, char *name, char *mode, char *linkpass) |
110 |
int fd; |
|
|
111 |
char *name; |
112 |
char *mode; |
113 |
char *linkpass; |
114 |
{ |
128 |
{ |
115 |
register struct tftphdr *ap; /* data and ack packets */ |
129 |
register struct tftphdr *ap; /* data and ack packets */ |
116 |
struct tftphdr *r_init(), *dp; |
130 |
struct tftphdr *r_init(), *dp; |
Lines 211-217
send_data:
Link Here
|
211 |
printf("protocol violation\n"); |
225 |
printf("protocol violation\n"); |
212 |
longjmp(toplevel, -1); |
226 |
longjmp(toplevel, -1); |
213 |
} |
227 |
} |
214 |
parseoack(&ap->th_stuff, n - 2); |
228 |
parseoack(ap->th_stuff, n - 2); |
215 |
break; |
229 |
break; |
216 |
} |
230 |
} |
217 |
} |
231 |
} |
Lines 231-241
abort:
Link Here
|
231 |
/* |
245 |
/* |
232 |
* Receive a file. |
246 |
* Receive a file. |
233 |
*/ |
247 |
*/ |
234 |
recvfile(fd, name, mode, linkpass) |
248 |
void recvfile(int fd, char *name, char *mode, char *linkpass) |
235 |
int fd; |
|
|
236 |
char *name; |
237 |
char *mode; |
238 |
char *linkpass; |
239 |
{ |
249 |
{ |
240 |
register struct tftphdr *ap; |
250 |
register struct tftphdr *ap; |
241 |
struct tftphdr *dp, *w_init(); |
251 |
struct tftphdr *dp, *w_init(); |
Lines 336-342
send_ack:
Link Here
|
336 |
longjmp(toplevel, -1); |
346 |
longjmp(toplevel, -1); |
337 |
} |
347 |
} |
338 |
waitforoack = 0; |
348 |
waitforoack = 0; |
339 |
parseoack(&dp->th_stuff, n - 2); |
349 |
parseoack(dp->th_stuff, n - 2); |
340 |
ap->th_opcode = htons((u_short)ACK); |
350 |
ap->th_opcode = htons((u_short)ACK); |
341 |
ap->th_block = htons(0); |
351 |
ap->th_block = htons(0); |
342 |
size = 4; |
352 |
size = 4; |
Lines 362-371
abort:
Link Here
|
362 |
printstats("Received", amount); |
372 |
printstats("Received", amount); |
363 |
} |
373 |
} |
364 |
|
374 |
|
365 |
makerequest(request, name, tp, mode, linkpass) |
375 |
int makerequest(int request, char *name, struct tftphdr *tp, char *mode, char *linkpass) |
366 |
int request; |
|
|
367 |
char *name, *mode, *linkpass; |
368 |
struct tftphdr *tp; |
369 |
{ |
376 |
{ |
370 |
register char *cp; |
377 |
register char *cp; |
371 |
|
378 |
|
Lines 404-411
struct errmsg {
Link Here
|
404 |
* standard TFTP codes, or a UNIX errno |
411 |
* standard TFTP codes, or a UNIX errno |
405 |
* offset by 100. |
412 |
* offset by 100. |
406 |
*/ |
413 |
*/ |
407 |
nak(error) |
414 |
void nak(int error) |
408 |
int error; |
|
|
409 |
{ |
415 |
{ |
410 |
register struct tftphdr *tp; |
416 |
register struct tftphdr *tp; |
411 |
int length; |
417 |
int length; |
Lines 431-439
nak(error)
Link Here
|
431 |
perror("nak"); |
437 |
perror("nak"); |
432 |
} |
438 |
} |
433 |
|
439 |
|
434 |
topts(cp, sz) |
440 |
void topts(char *cp, int sz) |
435 |
char *cp; |
|
|
436 |
int sz; |
437 |
{ |
441 |
{ |
438 |
int n, i = 0; |
442 |
int n, i = 0; |
439 |
|
443 |
|
Lines 454-463
topts(cp, sz)
Link Here
|
454 |
} |
458 |
} |
455 |
} |
459 |
} |
456 |
|
460 |
|
457 |
tpacket(s, tp, n) |
461 |
void tpacket(char *s, struct tftphdr *tp, int n) |
458 |
char *s; |
|
|
459 |
struct tftphdr *tp; |
460 |
int n; |
461 |
{ |
462 |
{ |
462 |
static char *opcodes[] = |
463 |
static char *opcodes[] = |
463 |
{ "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" }; |
464 |
{ "#0", "RRQ", "WRQ", "DATA", "ACK", "ERROR", "OACK" }; |
Lines 505-521
struct timeval tstart;
Link Here
|
505 |
struct timeval tstop; |
506 |
struct timeval tstop; |
506 |
struct timezone zone; |
507 |
struct timezone zone; |
507 |
|
508 |
|
508 |
startclock() { |
509 |
void startclock() { |
509 |
gettimeofday(&tstart, &zone); |
510 |
gettimeofday(&tstart, &zone); |
510 |
} |
511 |
} |
511 |
|
512 |
|
512 |
stopclock() { |
513 |
void stopclock() { |
513 |
gettimeofday(&tstop, &zone); |
514 |
gettimeofday(&tstop, &zone); |
514 |
} |
515 |
} |
515 |
|
516 |
|
516 |
printstats(direction, amount) |
517 |
void printstats(char *direction, unsigned long amount) |
517 |
char *direction; |
|
|
518 |
unsigned long amount; |
519 |
{ |
518 |
{ |
520 |
double delta; |
519 |
double delta; |
521 |
/* compute delta in 1/10's second units */ |
520 |
/* compute delta in 1/10's second units */ |