mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 09:49:21 +08:00
net/icmpv6: Fix icmpv6_reply function
Fix icmpv6_reply logic broken by commit48311cc61f
and391b501639
. -48311cc61f
"Fix unaligned memory access when creating ICMP Port Unreachable messages" - It removed `htonl` function outside `data`, then the byte order may be wrong, so add `htons` back. -391b501639
"net: extract l3 header build code into new functions" - It mis-removed the `memmove`, and the icmpv6 has no payload copied after this commit. Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
69cbcfd19f
commit
025430a964
1 changed files with 6 additions and 2 deletions
|
@ -112,6 +112,10 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
|
|||
|
||||
dev->d_len = ipicmplen + datalen;
|
||||
|
||||
/* Copy fields from original packet */
|
||||
|
||||
memmove(icmpv6 + 1, ipv6, datalen);
|
||||
|
||||
ipv6_build_header(IPv6BUF, dev->d_len - IPv6_HDRLEN, IP_PROTO_ICMP6,
|
||||
dev->d_ipv6addr, ipv6->srcipaddr, 255);
|
||||
|
||||
|
@ -119,8 +123,8 @@ void icmpv6_reply(FAR struct net_driver_s *dev, int type, int code, int data)
|
|||
|
||||
icmpv6->type = type;
|
||||
icmpv6->code = code;
|
||||
icmpv6->data[0] = data >> 16;
|
||||
icmpv6->data[1] = data & 0xffff;
|
||||
icmpv6->data[0] = htons(data >> 16);
|
||||
icmpv6->data[1] = htons(data & 0xffff);
|
||||
|
||||
/* Calculate the ICMPv6 checksum over the ICMPv6 header and payload. */
|
||||
|
||||
|
|
Loading…
Reference in a new issue