diff --git a/slirp/tftp.c b/slirp/tftp.c index 082f5d0..b7c9e97 100644 --- a/slirp/tftp.c +++ b/slirp/tftp.c @@ -101,6 +101,7 @@ static int tftp_read_data(struct tftp_session *spt, u_int16_t block_nr, fd = open(spt->filename, O_RDONLY | O_BINARY); if (fd < 0) { + printf ("failed\n"); return -1; } @@ -150,6 +151,7 @@ static int tftp_send_oack(struct tftp_session *spt, m->m_len = sizeof(struct tftp_t) - 514 + n - sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); + printf("tftp_send_oack: %s=%u\n", key, value); return 0; } @@ -163,6 +165,8 @@ static void tftp_send_error(struct tftp_session *spt, struct tftp_t *tp; int nobytes; + printf ("tftp_send_error: TFTP error: %s\n", msg); + m = m_get(spt->slirp); if (!m) { @@ -246,6 +250,7 @@ static int tftp_send_data(struct tftp_session *spt, sizeof(struct ip) - sizeof(struct udphdr); udp_output2(NULL, m, &saddr, &daddr, IPTOS_LOWDELAY); + printf ("tftp_send_data: sent block %u\n", htons(tp->x.tp_data.tp_block_nr)); if (nobytes == 512) { tftp_session_update(spt); @@ -290,7 +295,8 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen) /* get name */ req_fname = spt->filename + prefix_len + 1; - + printf ("tftp_handle_rrq: %s\n", spt->filename); + while (1) { if (k >= TFTP_FILENAME_MAX || k >= pktlen) { tftp_send_error(spt, 2, "Access violation", tp); @@ -358,7 +364,7 @@ static void tftp_handle_rrq(Slirp *slirp, struct tftp_t *tp, int pktlen) else { tftp_send_error(spt, 1, "File not found", tp); return; - } + } } tftp_send_oack(spt, "tsize", tsize, tp); @@ -374,6 +380,7 @@ static void tftp_handle_ack(Slirp *slirp, struct tftp_t *tp, int pktlen) s = tftp_session_find(slirp, tp); + printf ("tftp_handle_ack: session %u, block %u\n", s, ntohs(tp->x.tp_data.tp_block_nr)); if (s < 0) { return; }