diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-06 14:54:09 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-06 14:54:09 -0800 |
commit | aea6ac1b6a96d03fc6ccca49ab535b4e93e86a00 (patch) | |
tree | c4c717924a11f292e65d42b96229a9f3dc8fb2a3 /firmware/zpu/lib/net_common.c | |
parent | dfb3ed0311b9282043b24a2a743093907e088f3d (diff) | |
download | uhd-aea6ac1b6a96d03fc6ccca49ab535b4e93e86a00.tar.gz uhd-aea6ac1b6a96d03fc6ccca49ab535b4e93e86a00.tar.bz2 uhd-aea6ac1b6a96d03fc6ccca49ab535b4e93e86a00.zip |
usrp2: fix for icmp echo reply checksum (data was not included in checksum)
Diffstat (limited to 'firmware/zpu/lib/net_common.c')
-rw-r--r-- | firmware/zpu/lib/net_common.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/firmware/zpu/lib/net_common.c b/firmware/zpu/lib/net_common.c index ec9198090..d1b06976d 100644 --- a/firmware/zpu/lib/net_common.c +++ b/firmware/zpu/lib/net_common.c @@ -298,20 +298,28 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst, break; case ICMP_ECHO:{ + const void *icmp_data_buff = ((uint8_t*)icmp) + sizeof(struct icmp_echo_hdr); + size_t icmp_data_len = len - sizeof(struct icmp_echo_hdr); + struct icmp_echo_hdr echo_reply; echo_reply.type = 0; echo_reply.code = 0; echo_reply.chksum = 0; echo_reply.id = icmp->id; echo_reply.seqno = icmp->seqno; - echo_reply.chksum = ~chksum_buffer( - (unsigned short *)&echo_reply, - sizeof(echo_reply)/sizeof(short), - 0); + echo_reply.chksum = ~chksum_buffer( //data checksum + (unsigned short *)icmp_data_buff, + icmp_data_len/sizeof(short), + chksum_buffer( //header checksum + (unsigned short *)&echo_reply, + sizeof(echo_reply)/sizeof(short), + 0) + ); + send_ip_pkt( - src, IP_PROTO_ICMP, &echo_reply, sizeof(echo_reply), - ((uint8_t*)icmp) + sizeof(struct icmp_echo_hdr), - len - sizeof(struct icmp_echo_hdr) + src, IP_PROTO_ICMP, + &echo_reply, sizeof(echo_reply), + icmp_data_buff, icmp_data_len ); break; } |