version 1.6, 2000/12/07 18:13:14 |
version 1.7, 2001/03/22 01:34:01 |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
#include <err.h> |
|
|
#include "extern.h" |
#include "extern.h" |
#include "tftpsubs.h" |
#include "tftpsubs.h" |
|
|
n = sendto(f, dp, size + 4, 0, |
n = sendto(f, dp, size + 4, 0, |
(struct sockaddr *)&peeraddr, sizeof(peeraddr)); |
(struct sockaddr *)&peeraddr, sizeof(peeraddr)); |
if (n != size + 4) { |
if (n != size + 4) { |
perror("tftp: sendto"); |
warn("sendto"); |
goto abort; |
goto abort; |
} |
} |
read_ahead(file, convert); |
read_ahead(file, convert); |
|
|
} while (n <= 0); |
} while (n <= 0); |
alarm(0); |
alarm(0); |
if (n < 0) { |
if (n < 0) { |
perror("tftp: recvfrom"); |
warn("recvfrom"); |
goto abort; |
goto abort; |
} |
} |
peeraddr.sin_port = from.sin_port; /* added */ |
peeraddr.sin_port = from.sin_port; /* added */ |
|
|
if (sendto(f, ackbuf, size, 0, (struct sockaddr *)&peeraddr, |
if (sendto(f, ackbuf, size, 0, (struct sockaddr *)&peeraddr, |
sizeof(peeraddr)) != size) { |
sizeof(peeraddr)) != size) { |
alarm(0); |
alarm(0); |
perror("tftp: sendto"); |
warn("sendto"); |
goto abort; |
goto abort; |
} |
} |
write_behind(file, convert); |
write_behind(file, convert); |
|
|
} while (n <= 0); |
} while (n <= 0); |
alarm(0); |
alarm(0); |
if (n < 0) { |
if (n < 0) { |
perror("tftp: recvfrom"); |
warn("recvfrom"); |
goto abort; |
goto abort; |
} |
} |
peeraddr.sin_port = from.sin_port; /* added */ |
peeraddr.sin_port = from.sin_port; /* added */ |
|
|
register struct errmsg *pe; |
register struct errmsg *pe; |
register struct tftphdr *tp; |
register struct tftphdr *tp; |
int length; |
int length; |
char *strerror(); |
|
|
|
tp = (struct tftphdr *)ackbuf; |
tp = (struct tftphdr *)ackbuf; |
tp->th_opcode = htons((u_short)ERROR); |
tp->th_opcode = htons((u_short)ERROR); |
|
|
tpacket("sent", tp, length); |
tpacket("sent", tp, length); |
if (sendto(f, ackbuf, length, 0, (struct sockaddr *)&peeraddr, |
if (sendto(f, ackbuf, length, 0, (struct sockaddr *)&peeraddr, |
sizeof(peeraddr)) != length) |
sizeof(peeraddr)) != length) |
perror("nak"); |
warn("nak"); |
} |
} |
|
|
static void |
static void |