From ebb5fb7480c67637bfa2164f4f76ceff6f509d24 Mon Sep 17 00:00:00 2001 From: Juha Niskanen Date: Tue, 24 Nov 2020 17:08:32 +0200 Subject: [PATCH] net/neighbor/neighbor_ethernet_out.c: fix build error without ICMPv6 Patch fixes following build error when CONFIG_NET_IPv6 && !CONFIG_NET_ICMPv6 && CONFIG_NET_ETHERNET: nuttx/staging/libnet.a(neighbor_ethernet_out.o): In function `neighbor_ethernet_out': nuttx/net/neighbor/neighbor_ethernet_out.c:188: undefined reference to `icmpv6_solicit' IPv6 without ICMPv6 is not very useful, but at least this patch allows neighbor_ethernet_out() to be used with a packet socket or with multicast address (point-to-point IPv6 links) even in that case. Signed-off-by: Juha Niskanen --- net/neighbor/neighbor_ethernet_out.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/net/neighbor/neighbor_ethernet_out.c b/net/neighbor/neighbor_ethernet_out.c index 9456adfbf48..082bf292348 100644 --- a/net/neighbor/neighbor_ethernet_out.c +++ b/net/neighbor/neighbor_ethernet_out.c @@ -174,18 +174,28 @@ void neighbor_ethernet_out(FAR struct net_driver_s *dev) net_ipv6addr_copy(ipaddr, ip->destipaddr); } - /* Check if we already have this destination address in the Neighbor Table */ + /* Check if we already have this destination address in the + * Neighbor Table. + */ if (neighbor_lookup(ipaddr, &laddr) < 0) { +#ifdef CONFIG_NET_ICMPv6 ninfo("IPv6 Neighbor solicitation for IPv6\n"); /* The destination address was not in our Neighbor Table, so we - * overwrite the IPv6 packet with an ICMDv6 Neighbor Solicitation + * overwrite the IPv6 packet with an ICMPv6 Neighbor Solicitation * message. */ icmpv6_solicit(dev, ipaddr); +#else + /* What to do here? We need the laddr, but no way to get it. */ + + nerr("ERROR: IPv6 needs link layer address for ethernet.\n"); + DEBUGPANIC(); + return; +#endif } } @@ -198,7 +208,8 @@ void neighbor_ethernet_out(FAR struct net_driver_s *dev) } else { - memcpy(eth->dest, laddr.u.na_ethernet.ether_addr_octet, ETHER_ADDR_LEN); + memcpy(eth->dest, laddr.u.na_ethernet.ether_addr_octet, + ETHER_ADDR_LEN); } /* Finish populating the Ethernet header */