Add debugging printfs for tftp packets
This commit is contained in:
parent
39b0033325
commit
8c25c63efd
1 changed files with 13 additions and 1 deletions
14
tftp.c
14
tftp.c
|
@ -85,7 +85,7 @@ static void pkt_mkwrq(char *pkt, const char *filename)
|
||||||
|
|
||||||
filename = leafname(filename);
|
filename = leafname(filename);
|
||||||
if (!is_netascii(filename) || strlen(filename) > 500) {
|
if (!is_netascii(filename) || strlen(filename) > 500) {
|
||||||
fprintf(stderr, "Overlong/illegal filename; using 'firmware.bin'.");
|
fprintf(stderr, "Overlong/illegal filename; using 'firmware.bin'.\n");
|
||||||
filename = "firmware.bin";
|
filename = "firmware.bin";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +157,12 @@ static ssize_t tftp_recvfrom(int sock, char *pkt, uint16_t* port,
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbosity > 2) {
|
||||||
|
printf(">> ");
|
||||||
|
pkt_print(pkt, stdout);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +193,12 @@ static ssize_t tftp_sendto(int sock, char *pkt, size_t len,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (verbosity > 2) {
|
||||||
|
printf("<< ");
|
||||||
|
pkt_print(pkt, stdout);
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
sent = sendto(sock, pkt, len, 0, (struct sockaddr*)dst, sizeof(*dst));
|
sent = sendto(sock, pkt, len, 0, (struct sockaddr*)dst, sizeof(*dst));
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
sock_perror("sendto");
|
sock_perror("sendto");
|
||||||
|
|
Loading…
Add table
Reference in a new issue