Skip to content

Commit 96eb5e7

Browse files
Laczenanchao
authored andcommitted
net: sixlowpan icmpv6 return from udp_input
When a udp frame is processed without a listener a icmp frame is returned indicating that there is no listener. The PR enables sending this icmpv6 response over sixlowpan. Signed-off-by: Laczen JMS <laczenjms@gmail.com>
1 parent 4959e26 commit 96eb5e7

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

net/devif/ipv6_input.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,35 @@ static int ipv6_in(FAR struct net_driver_s *dev)
487487
/* Forward the IPv6 UDP packet */
488488

489489
udp_ipv6_input(dev, iphdrlen);
490+
491+
#if defined(CONFIG_NET_6LOWPAN) && defined(CONFIG_NET_ICMPv6)
492+
/* udp_ipv6 processing can return a icmpv6 frame when enabled.
493+
* Logic here detects (1) if an attempt to return with d_len > 0 and
494+
* (2) that the device is an IEEE802.15.4 MAC or PKTRADIO network
495+
* driver.
496+
* Under those conditions, 6LoWPAN logic will be called to create the
497+
* IEEE80215.4 or PKTRADIO frames.
498+
*/
499+
500+
if ((dev->d_len > 0 && dev->d_lltype == NET_LL_IEEE802154) ||
501+
(dev->d_len > 0 && dev->d_lltype == NET_LL_PKTRADIO))
502+
{
503+
/* udp_ipv6_input() might update dev->d_iob. Make sure to use
504+
* the correct data by updating ipv6.
505+
*/
506+
507+
ipv6 = IPv6BUF;
508+
509+
/* Let 6LoWPAN handle the udp output */
510+
511+
sixlowpan_icmpv6_send(dev, dev, ipv6);
512+
513+
/* Drop the packet in the d_buf */
514+
515+
goto drop;
516+
}
517+
#endif /* CONFIG_NET_6LOWPAN && CONFIG_NET_ICMPV6 */
518+
490519
break;
491520
#endif
492521

@@ -517,6 +546,12 @@ static int ipv6_in(FAR struct net_driver_s *dev)
517546
if ((dev->d_len > 0 && dev->d_lltype == NET_LL_IEEE802154) ||
518547
(dev->d_len > 0 && dev->d_lltype == NET_LL_PKTRADIO))
519548
{
549+
/* icmpv6_input() might update dev->d_iob. Make sure to use the
550+
* correct data by updating ipv6.
551+
*/
552+
553+
ipv6 = IPv6BUF;
554+
520555
/* Let 6LoWPAN handle the ICMPv6 output */
521556

522557
sixlowpan_icmpv6_send(dev, dev, ipv6);

0 commit comments

Comments
 (0)