From caf83092499fd07035b05a108c423f0cda17caae Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Thu, 14 Jan 2016 00:10:34 +0100 Subject: net-snk: Remove junk at the end of IPv6 TFTP ACK and error packets While looking at the network traffic from SLOF with Wireshark, I noticed that there are some junk bytes at the end of TFTP ACK packets. The problem is that send_ack() adds sizeof(struct ethhdr) to the length of the packet that it wants to transmit. But adding the sizeof(struct ethhdr) to the length of the packet is done within send_ipv6() already, so this value got added twice. Removing it from send_ack() fixes this issue - the packets then look fine in Wireshark again. send_error() apparently suffers from the same issue, so let's also remove the sizeof(struct ethhdr) from that function. Signed-off-by: Thomas Huth Signed-off-by: Alexey Kardashevskiy --- clients/net-snk/app/netlib/tftp.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'clients/net-snk') diff --git a/clients/net-snk/app/netlib/tftp.c b/clients/net-snk/app/netlib/tftp.c index 0a7c0ec..0dfd23f 100644 --- a/clients/net-snk/app/netlib/tftp.c +++ b/clients/net-snk/app/netlib/tftp.c @@ -182,8 +182,7 @@ send_ack(int fd, int blckno, unsigned short dport) ip6 = (struct ip6hdr *) packet; udph = (struct udphdr *) (ip6 + 1); ip6_payload_len = sizeof(struct udphdr) + 4; - ip_len = sizeof(struct ethhdr) + sizeof(struct ip6hdr) + - ip6_payload_len; + ip_len = sizeof(struct ip6hdr) + ip6_payload_len; fill_ip6hdr ((uint8_t *) ip6, ip6_payload_len, IPTYPE_UDP, get_ipv6_address(), &(fn_ip->server_ip6)); } @@ -234,8 +233,7 @@ send_error(int fd, int error_code, unsigned short dport) ip6 = (struct ip6hdr *) packet; udph = (struct udphdr *) (ip6 + 1); ip6_payload_len = sizeof(struct udphdr) + 5; - ip_len = sizeof(struct ethhdr) + sizeof(struct ip6hdr) + - ip6_payload_len; + ip_len = sizeof(struct ip6hdr) + ip6_payload_len; fill_ip6hdr ((uint8_t *) ip6, ip6_payload_len, IPTYPE_UDP, get_ipv6_address(), &(fn_ip->server_ip6)); } -- cgit v1.1