net: icmpv4 : calculate ipv4 header chksum

In icmpv4, after calling setup_ipv4_header() function,
only calculate ICMP chksum, not calculate ipv4 header chksum,
ipv4 header chksum still 0, the other side will drop this pack.

Change-Id: I1550a4c8c7ab63132d70ba6ce19a7caf78ad84e6
Signed-off-by: li zj <279939902@qq.com>
This commit is contained in:
li zj 2017-01-12 16:55:56 +08:00 committed by Tomasz Bursztyka
commit 9a87e403ac

View file

@ -94,6 +94,9 @@ static inline void setup_ipv4_header(struct net_buf *buf, uint8_t extra_len,
net_nbuf_set_ip_hdr_len(buf, sizeof(struct net_ipv4_hdr)); net_nbuf_set_ip_hdr_len(buf, sizeof(struct net_ipv4_hdr));
NET_IPV4_BUF(buf)->chksum = 0;
NET_IPV4_BUF(buf)->chksum = ~net_calc_chksum_ipv4(buf);
NET_ICMP_BUF(buf)->type = icmp_type; NET_ICMP_BUF(buf)->type = icmp_type;
NET_ICMP_BUF(buf)->code = icmp_code; NET_ICMP_BUF(buf)->code = icmp_code;