|
@ -79,7 +79,7 @@ static const int tftperrmap[] = { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
#define TIMEOUT 2 /* secs between rexmts */ |
|
|
#define TIMEOUT 2 /* secs between rexmts */ |
|
|
#define MAXREXMT 10 /* no of rexmts */ |
|
|
#define MAXREXMT 0x7fffffff /* no of rexmts */ |
|
|
#define PKTSIZE (SEGSIZE+4) |
|
|
#define PKTSIZE (SEGSIZE+4) |
|
|
|
|
|
|
|
|
struct tftpfile { |
|
|
struct tftpfile { |
|
@ -135,21 +135,6 @@ static int synchnet (int f); |
|
|
|
|
|
|
|
|
extern char activeif_name[]; |
|
|
extern char activeif_name[]; |
|
|
|
|
|
|
|
|
#ifdef TFTP_TIMEOUT |
|
|
|
|
|
static int myret; |
|
|
|
|
|
#define RECVFROM(a1,a2,a3,a4,a5,a6) (timeout(mytimeout,__LINE__,200),myret=recvfrom(a1,a2,a3,a4,a5,a6),untimeout(mytimeout,__LINE__),myret) |
|
|
|
|
|
#define SENDTO(a1,a2,a3,a4,a5,a6) (timeout(mytimeout,__LINE__,200),myret=sendto(a1,a2,a3,a4,a5,a6),untimeout(mytimeout,__LINE__),myret) |
|
|
|
|
|
|
|
|
|
|
|
static void myifup(); |
|
|
|
|
|
static mytimeout(void *n) |
|
|
|
|
|
{ |
|
|
|
|
|
fprintf(serialout,"timeout at line %d\n",(int)n); |
|
|
|
|
|
myifup(); |
|
|
|
|
|
} |
|
|
|
|
|
#else |
|
|
|
|
|
#define RECVFROM recvfrom |
|
|
|
|
|
#define SENDTO sendto |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
static void myifup() |
|
|
static void myifup() |
|
|
{ |
|
|
{ |
|
@ -456,7 +441,7 @@ tftpclose (fd) |
|
|
if (tftptrace) |
|
|
if (tftptrace) |
|
|
tpacket("sent", tp, length); |
|
|
tpacket("sent", tp, length); |
|
|
#endif |
|
|
#endif |
|
|
if (SENDTO(tfp->sock, tp, length, 0, (struct sockaddr *)&tfp->sin, |
|
|
if (sendto(tfp->sock, tp, length, 0, (struct sockaddr *)&tfp->sin, |
|
|
sizeof (tfp->sin)) != length) |
|
|
sizeof (tfp->sin)) != length) |
|
|
perror("sendto(eof)"); |
|
|
perror("sendto(eof)"); |
|
|
} |
|
|
} |
|
@ -496,7 +481,7 @@ tftprrq (tfp, req, size) |
|
|
if (tftptrace) |
|
|
if (tftptrace) |
|
|
tpacket("sent", req, size); |
|
|
tpacket("sent", req, size); |
|
|
#endif |
|
|
#endif |
|
|
if (SENDTO(tfp->sock, req, size, 0, (struct sockaddr *)&tfp->sin, |
|
|
if (sendto(tfp->sock, req, size, 0, (struct sockaddr *)&tfp->sin, |
|
|
sizeof (tfp->sin)) != size) { |
|
|
sizeof (tfp->sin)) != size) { |
|
|
perror("tftp: sendto"); |
|
|
perror("tftp: sendto"); |
|
|
return (-1); |
|
|
return (-1); |
|
@ -525,7 +510,7 @@ tftprrq (tfp, req, size) |
|
|
|
|
|
|
|
|
fromlen = sizeof (from); |
|
|
fromlen = sizeof (from); |
|
|
rp = (struct tftphdr *) tfp->buf; |
|
|
rp = (struct tftphdr *) tfp->buf; |
|
|
n = RECVFROM(tfp->sock, rp, PKTSIZE, 0, |
|
|
n = recvfrom(tfp->sock, rp, PKTSIZE, 0, |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
if (n < 0) { |
|
|
if (n < 0) { |
|
|
perror("tftp: recvfrom"); |
|
|
perror("tftp: recvfrom"); |
|
@ -593,7 +578,7 @@ int size; |
|
|
if (tftptrace) |
|
|
if (tftptrace) |
|
|
tpacket("sent", req, size); |
|
|
tpacket("sent", req, size); |
|
|
#endif |
|
|
#endif |
|
|
if (SENDTO(tfp->sock, req, size+4, 0, (struct sockaddr *)&tfp->sin, |
|
|
if (sendto(tfp->sock, req, size+4, 0, (struct sockaddr *)&tfp->sin, |
|
|
sizeof (tfp->sin)) != size+4) { |
|
|
sizeof (tfp->sin)) != size+4) { |
|
|
perror("tftp: sendto"); |
|
|
perror("tftp: sendto"); |
|
|
return (-1); |
|
|
return (-1); |
|
@ -618,7 +603,7 @@ int size; |
|
|
|
|
|
|
|
|
fromlen = sizeof (from); |
|
|
fromlen = sizeof (from); |
|
|
rp = (struct tftphdr *) ackbuf; |
|
|
rp = (struct tftphdr *) ackbuf; |
|
|
n = RECVFROM(tfp->sock, rp, PKTSIZE, 0, |
|
|
n = recvfrom(tfp->sock, rp, PKTSIZE, 0, |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
if (n < 0) { |
|
|
if (n < 0) { |
|
|
perror("tftp: recvfrom"); |
|
|
perror("tftp: recvfrom"); |
|
@ -745,11 +730,11 @@ static int |
|
|
struct sockaddr_in from; |
|
|
struct sockaddr_in from; |
|
|
int fromlen; |
|
|
int fromlen; |
|
|
while (1) { |
|
|
while (1) { |
|
|
(void) soc_ioctl(f, FIONREAD, &i); |
|
|
(void) ioctl(f, FIONREAD, &i); |
|
|
if (i) { |
|
|
if (i) { |
|
|
j++; |
|
|
j++; |
|
|
fromlen = sizeof from; |
|
|
fromlen = sizeof from; |
|
|
(void) RECVFROM(f, rbuf, sizeof (rbuf), 0, |
|
|
(void) recvfrom(f, rbuf, sizeof (rbuf), 0, |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
(struct sockaddr *)&from, &fromlen); |
|
|
} else { |
|
|
} else { |
|
|
return(j); |
|
|
return(j); |
|
|