From bd7c84b23e1a07a914f27675b8fe2e1b61d35283 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 8 Aug 2017 14:24:12 -0600 Subject: [PATCH] Remove CONFIG_NETDEV_MULTINIC. This increases code size by a little, but greatly reduces the complexity of the network code. --- arch/arm/src/sama5/Kconfig | 4 - configs/sim/ipforward/defconfig | 1 - configs/sim/pktradio/defconfig | 1 - configs/sim/sixlowpan/defconfig | 1 - drivers/net/Kconfig | 11 --- drivers/net/phy_notify.c | 15 +--- include/nuttx/net/ip.h | 4 - include/nuttx/net/sixlowpan.h | 5 +- net/Kconfig | 5 -- net/arp/arp.h | 2 - net/arp/arp_send.c | 12 +-- net/devif/Make.defs | 2 - net/devif/devif_forward.c | 4 +- net/devif/devif_poll.c | 4 +- net/devif/ipv6_input.c | 16 ---- net/icmp/icmp_ping.c | 4 - net/icmpv6/icmpv6_autoconfig.c | 4 - net/icmpv6/icmpv6_neighbor.c | 17 +---- net/icmpv6/icmpv6_ping.c | 4 - net/icmpv6/icmpv6_rnotify.c | 53 ------------- net/inet/inet_close.c | 8 -- net/inet/inet_connect.c | 2 - net/inet/inet_monitor.c | 2 - net/inet/inet_recvfrom.c | 10 --- net/inet/inet_sendfile.c | 10 --- net/inet/inet_sockif.c | 12 +-- net/inet/ipv4_getsockname.c | 29 +------ net/inet/ipv6_getsockname.c | 23 +----- net/ipforward/Kconfig | 4 +- net/ipforward/Make.defs | 6 +- net/ipforward/ipforward.h | 16 ---- net/ipforward/ipfwd_alloc.c | 4 +- net/ipforward/ipfwd_dropstats.c | 2 - net/ipforward/ipfwd_forward.c | 5 +- net/ipforward/ipfwd_poll.c | 4 +- net/ipforward/ipv4_forward.c | 27 +------ net/ipforward/ipv6_forward.c | 25 ++---- net/netdev/netdev.h | 42 +--------- net/netdev/netdev_findbyaddr.c | 48 +----------- net/netdev/netdev_findbyindex.c | 4 - net/netdev/netdev_rxnotify.c | 18 ----- net/netdev/netdev_txnotify.c | 18 ----- net/pkt/pkt_finddev.c | 14 +--- net/sixlowpan/sixlowpan_send.c | 3 - net/sixlowpan/sixlowpan_tcpsend.c | 20 +---- net/sixlowpan/sixlowpan_udpsend.c | 14 ---- net/tcp/tcp.h | 39 ++-------- net/tcp/tcp_conn.c | 123 +++--------------------------- net/tcp/tcp_devpoll.c | 2 - net/tcp/tcp_finddev.c | 34 +-------- net/tcp/tcp_send_buffered.c | 10 --- net/tcp/tcp_send_unbuffered.c | 10 --- net/tcp/tcp_timer.c | 7 +- net/udp/udp_conn.c | 48 +----------- net/udp/udp_finddev.c | 48 ++---------- 55 files changed, 84 insertions(+), 776 deletions(-) diff --git a/arch/arm/src/sama5/Kconfig b/arch/arm/src/sama5/Kconfig index 58b0c3860a..ae701198f1 100644 --- a/arch/arm/src/sama5/Kconfig +++ b/arch/arm/src/sama5/Kconfig @@ -649,7 +649,6 @@ config SAMA5_GMAC default n depends on SAMA5_HAVE_GMAC select NETDEVICES - select NETDEV_MULTINIC if SAMA5_EMAC select ARCH_HAVE_PHY config SAMA5_EMACA @@ -657,7 +656,6 @@ config SAMA5_EMACA default n depends on SAMA5_HAVE_EMACA select NETDEVICES - select NETDEV_MULTINIC if SAMA5_GMAC select ARCH_HAVE_PHY config SAMA5_EMACB @@ -670,7 +668,6 @@ config SAMA5_EMAC0 depends on SAMA5_HAVE_EMACB select SAMA5_EMACB select NETDEVICES - select NETDEV_MULTINIC if SAMA5_EMAC1 select ARCH_HAVE_PHY config SAMA5_EMAC1 @@ -679,7 +676,6 @@ config SAMA5_EMAC1 depends on SAMA5_HAVE_EMACB && SAMA5_HAVE_EMAC1 select SAMA5_EMACB select NETDEVICES - select NETDEV_MULTINIC if SAMA5_EMAC0 select ARCH_HAVE_PHY config SAMA5_LCDC diff --git a/configs/sim/ipforward/defconfig b/configs/sim/ipforward/defconfig index e54586a77c..071fe7dc6a 100644 --- a/configs/sim/ipforward/defconfig +++ b/configs/sim/ipforward/defconfig @@ -44,7 +44,6 @@ CONFIG_NET_TCP=y CONFIG_NET_TCPBACKLOG=y CONFIG_NET_TUN=y CONFIG_NET=y -CONFIG_NETDEV_MULTINIC=y CONFIG_NETDEVICES=y CONFIG_NFILE_DESCRIPTORS=32 CONFIG_NSH_ARCHINIT=y diff --git a/configs/sim/pktradio/defconfig b/configs/sim/pktradio/defconfig index 402ea8c292..913e47e3c0 100644 --- a/configs/sim/pktradio/defconfig +++ b/configs/sim/pktradio/defconfig @@ -71,7 +71,6 @@ CONFIG_NET_TCPBACKLOG=y CONFIG_NET_UDP=y CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y -CONFIG_NETDEV_MULTINIC=y CONFIG_NETDEV_PHY_IOCTL=y CONFIG_NETDEV_STATISTICS=y CONFIG_NETDEV_TELNET=y diff --git a/configs/sim/sixlowpan/defconfig b/configs/sim/sixlowpan/defconfig index efe6dc36ee..6ccde8f815 100644 --- a/configs/sim/sixlowpan/defconfig +++ b/configs/sim/sixlowpan/defconfig @@ -73,7 +73,6 @@ CONFIG_NET_TCPBACKLOG=y CONFIG_NET_UDP=y CONFIG_NET=y CONFIG_NETDB_DNSCLIENT=y -CONFIG_NETDEV_MULTINIC=y CONFIG_NETDEV_PHY_IOCTL=y CONFIG_NETDEV_STATISTICS=y CONFIG_NETDEV_TELNET=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index d5466386ef..a41d7ef1ea 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -63,16 +63,6 @@ config TELNET_DUMPBUFFER endif # NETDEV_TELNET -config NETDEV_MULTINIC - bool "Multiple network interface support" - default n if !NETDEV_LOOPBACK - default y if NETDEV_LOOPBACK - ---help--- - Select this option if you board and/or MCU are capable of supporting - multiple link layer drivers. NOTE that the local loopback device - is considered to be a a link layer driver so if local loopback - support is used you probably need to select this option. - config ARCH_HAVE_NETDEV_STATISTICS bool default n @@ -525,7 +515,6 @@ endchoice choice prompt "Board PHY Selection (ETH1)" default ETH1_PHY_NONE - depends on NETDEV_MULTINIC ---help--- Identify the PHY on your board. This setting is not used by all Ethernet drivers nor do all Ethernet drivers support all PHYs. diff --git a/drivers/net/phy_notify.c b/drivers/net/phy_notify.c index 6cc8e739df..7f0a27d7b3 100644 --- a/drivers/net/phy_notify.c +++ b/drivers/net/phy_notify.c @@ -102,9 +102,7 @@ struct phy_notify_s { bool assigned; uint8_t signo; -#ifdef CONFIG_NETDEV_MULTINIC char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1]; -#endif pid_t pid; FAR void *arg; phy_enable_t enable; @@ -174,9 +172,7 @@ static FAR struct phy_notify_s *phy_find_unassigned(void) client->assigned = true; client->signo = 0; -#ifdef CONFIG_NETDEV_MULTINIC client->intf[0] = '\0'; -#endif client->pid = -1; client->arg = NULL; client->enable = NULL; @@ -210,11 +206,8 @@ static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf, for (i = 0; i < CONFIG_PHY_NOTIFICATION_NCLIENTS; i++) { client = &g_notify_clients[i]; - if (client->assigned && client->pid == pid -#ifdef CONFIG_NETDEV_MULTINIC - && strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0 -#endif - ) + if (client->assigned && client->pid == pid && + strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0) { /* Return the matching client entry to the caller */ @@ -344,10 +337,8 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo, client->signo = signo; client->pid = pid; client->arg = arg; -#ifdef CONFIG_NETDEV_MULTINIC snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf); client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0'; -#endif /* Attach/re-attach the PHY interrupt */ @@ -407,9 +398,7 @@ int phy_notify_unsubscribe(FAR const char *intf, pid_t pid) client->assigned = false; client->signo = 0; -#ifdef CONFIG_NETDEV_MULTINIC client->intf[0] = '\0'; -#endif client->pid = -1; client->arg = NULL; diff --git a/include/nuttx/net/ip.h b/include/nuttx/net/ip.h index f2cdbc52fb..3a5c14212b 100644 --- a/include/nuttx/net/ip.h +++ b/include/nuttx/net/ip.h @@ -129,9 +129,7 @@ union ip_binding_u struct { -#ifdef CONFIG_NETDEV_MULTINIC in_addr_t laddr; /* The bound local IPv4 address */ -#endif in_addr_t raddr; /* The IPv4 address of the remote host */ } ipv4; #endif /* CONFIG_NET_IPv4 */ @@ -141,9 +139,7 @@ union ip_binding_u struct { -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_t laddr; /* The bound local IPv6 address */ -#endif net_ipv6addr_t raddr; /* The IPv6 address of the remote host */ } ipv6; #endif /* CONFIG_NET_IPv6 */ diff --git a/include/nuttx/net/sixlowpan.h b/include/nuttx/net/sixlowpan.h index e38bf32b28..64a075d5cf 100644 --- a/include/nuttx/net/sixlowpan.h +++ b/include/nuttx/net/sixlowpan.h @@ -388,9 +388,8 @@ struct sixlowpan_properties_s * This is accomplished by "inheriting" the standard 'struct net_driver_s' * and appending the frame buffer as well as other metadata needed to * manage the fragmentation. 'struct sixlowpan_driver_s' is cast - * compatible with 'struct net_driver_s' when CONFIG_NET_MULTINIC is not - * defined or when dev->d_lltype == NET_LL_IEEE802154 or dev->d_lltype == - * NET_LL_PKTRADIO. + * compatible with 'struct net_driver_s' when dev->d_lltype == + * NET_LL_IEEE802154 or dev->d_lltype == NET_LL_PKTRADIO. * * The radio network driver has reponsibility for initializing this * structure. In general, all fields must be set to NULL. In addition: diff --git a/net/Kconfig b/net/Kconfig index 83d87ce74f..28c2ee286d 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -124,7 +124,6 @@ config NET_USER_DEVFMT config NET_ETHERNET bool "Ethernet support" default y - select NETDEV_MULTINIC if NET_6LOWPAN || NET_LOOPBACK || NET_SLIP || NET_TUN select NET_MULTILINK if NET_6LOWPAN || NET_LOOPBACK || NET_SLIP || NET_TUN ---help--- If NET_SLIP is not selected, then Ethernet will be used (there is @@ -134,7 +133,6 @@ config NET_ETHERNET config NET_6LOWPAN bool "6LoWPAN support" default n - select NETDEV_MULTINIC if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN select NET_MULTILINK if NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN select NET_MULTILINK if WIRELESS_IEEE802 && WIRELESS_PKTRADIO select NETDEV_IOCTL @@ -147,7 +145,6 @@ config NET_6LOWPAN config NET_LOOPBACK bool "Local loopback" default n - select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_SLIP || NET_TUN select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_SLIP || NET_TUN ---help--- Add support for the local network loopback device, lo. @@ -155,7 +152,6 @@ config NET_LOOPBACK config NET_SLIP bool "SLIP support" default n - select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_TUN select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_TUN ---help--- Enables building of the SLIP driver. SLIP requires @@ -202,7 +198,6 @@ endif # NET_SLIP config NET_TUN bool "TUN Virtual Network Device support" default n - select NETDEV_MULTINIC if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_SLIP select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_SLIP select ARCH_HAVE_NETDEV_STATISTICS diff --git a/net/arp/arp.h b/net/arp/arp.h index 4aca859476..fcd47708c3 100644 --- a/net/arp/arp.h +++ b/net/arp/arp.h @@ -137,9 +137,7 @@ struct arp_send_s sem_t snd_sem; /* Used to wake up the waiting thread */ uint8_t snd_retries; /* Retry count */ volatile bool snd_sent; /* True: if request sent */ -#ifdef CONFIG_NETDEV_MULTINIC uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */ -#endif int16_t snd_result; /* The result of the send operation */ in_addr_t snd_ipaddr; /* The IP address to be queried */ }; diff --git a/net/arp/arp_send.c b/net/arp/arp_send.c index 92de47e806..a2208180d2 100644 --- a/net/arp/arp_send.c +++ b/net/arp/arp_send.c @@ -223,11 +223,7 @@ int arp_send(in_addr_t ipaddr) /* Get the device that can route this request */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv4addr(INADDR_ANY, ipaddr); -#else - dev = netdev_findby_ipv4addr(ipaddr); -#endif if (!dev) { nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr); @@ -237,10 +233,8 @@ int arp_send(in_addr_t ipaddr) #ifdef CONFIG_NET_MULTILINK /* ARP support is only built if the Ethernet data link is supported. - * However, if we are supporting multiple network devices and using - * different link level protocols then we can get here for other - * link protocols as well. Continue and send the ARP request only - * if this device uses the Ethernet data link protocol. + * Continue and send the ARP request only if this device uses the + * Ethernet data link protocol. */ if (dev->d_lltype != NET_LL_ETHERNET) @@ -304,11 +298,9 @@ int arp_send(in_addr_t ipaddr) state.snd_retries = 0; /* No retries yet */ state.snd_ipaddr = ipaddr; /* IP address to query */ -#ifdef CONFIG_NETDEV_MULTINIC /* Remember the routing device name */ strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ); -#endif /* Now loop, testing if the address mapping is in the ARP table and re-sending the ARP request if it is not. */ diff --git a/net/devif/Make.defs b/net/devif/Make.defs index cb1e16e433..9d66378ee3 100644 --- a/net/devif/Make.defs +++ b/net/devif/Make.defs @@ -50,10 +50,8 @@ endif # IP forwarding ifeq ($(CONFIG_NET_IPFORWARD),y) -ifeq ($(CONFIG_NETDEV_MULTINIC),y) NET_CSRCS += devif_forward.c endif -endif # I/O buffer chain support required? diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 8a1a1bd855..ecab12a730 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -47,7 +47,7 @@ #include "ipforward/ipforward.h" #include "devif/devif.h" -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD /**************************************************************************** * Public Functions @@ -92,4 +92,4 @@ void devif_forward(FAR struct forward_s *fwd) fwd->f_dev->d_len = offset; } -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPFORWARD */ diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 8d53a08bab..496c55dcc7 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -299,7 +299,7 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev, * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD static inline int devif_poll_forward(FAR struct net_driver_s *dev, devif_poll_callback_t callback) { @@ -575,7 +575,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) if (!bstop) #endif -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD { /* Traverse all of the tasks waiting to forward a packet to this device. */ diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index 6c45de38fa..947232259c 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -128,7 +128,6 @@ * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg) { FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)arg; @@ -146,7 +145,6 @@ static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg) return 0; } -#endif /**************************************************************************** * Name: check_destipaddr @@ -171,9 +169,7 @@ static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg) static bool check_destipaddr(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { -#ifdef CONFIG_NETDEV_MULTINIC int ret; -#endif /* For IPv6, packet reception is a little trickier as we need to make sure * that we listen to certain multicast addresses (all hosts multicast @@ -192,7 +188,6 @@ static bool check_destipaddr(FAR struct net_driver_s *dev, return true; } -#ifdef CONFIG_NETDEV_MULTINIC /* We will also allow for a perverse case where we receive a packet * addressed to us, but on a different device. Can that really happen? */ @@ -207,17 +202,6 @@ static bool check_destipaddr(FAR struct net_driver_s *dev, return true; } -#else - /* There is only one network device. If this packet is addressed to us, - * then the IPv6 destination address must be the address of assigned to - * this device. - */ - - if (net_ipv6addr_cmp(ipv6->destipaddr, dev->d_ipv6addr)) - { - return true; - } -#endif return false; } diff --git a/net/icmp/icmp_ping.c b/net/icmp/icmp_ping.c index ca16f12663..45bfe9fcbb 100644 --- a/net/icmp/icmp_ping.c +++ b/net/icmp/icmp_ping.c @@ -340,11 +340,7 @@ int icmp_ping(in_addr_t addr, uint16_t id, uint16_t seqno, uint16_t datalen, /* Get the device that will be used to route this ICMP ECHO request */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv4addr(INADDR_ANY, addr); -#else - dev = netdev_findby_ipv4addr(addr); -#endif if (dev == 0) { nerr("ERROR: Not reachable\n"); diff --git a/net/icmpv6/icmpv6_autoconfig.c b/net/icmpv6/icmpv6_autoconfig.c index 2a9e4f0162..c4464c1f77 100644 --- a/net/icmpv6/icmpv6_autoconfig.c +++ b/net/icmpv6/icmpv6_autoconfig.c @@ -81,9 +81,7 @@ struct icmpv6_router_s sem_t snd_sem; /* Used to wake up the waiting thread */ volatile bool snd_sent; /* True: if request sent */ bool snd_advertise; /* True: Send Neighbor Advertisement */ -#ifdef CONFIG_NETDEV_MULTINIC uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */ -#endif int16_t snd_result; /* Result of the send */ }; @@ -217,12 +215,10 @@ static int icmpv6_send_message(FAR struct net_driver_s *dev, bool advertise) (void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */ sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE); -#ifdef CONFIG_NETDEV_MULTINIC /* Remember the routing device name */ strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ); -#endif /* Allocate resources to receive a callback. This and the following * initialization is performed with the network lock because we don't diff --git a/net/icmpv6/icmpv6_neighbor.c b/net/icmpv6/icmpv6_neighbor.c index 6d9c5bd70e..cdd3548892 100644 --- a/net/icmpv6/icmpv6_neighbor.c +++ b/net/icmpv6/icmpv6_neighbor.c @@ -85,9 +85,7 @@ struct icmpv6_neighbor_s sem_t snd_sem; /* Used to wake up the waiting thread */ uint8_t snd_retries; /* Retry count */ volatile bool snd_sent; /* True: if request sent */ -#ifdef CONFIG_NETDEV_MULTINIC uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */ -#endif net_ipv6addr_t snd_ipaddr; /* The IPv6 address to be queried */ }; @@ -109,7 +107,6 @@ static uint16_t icmpv6_neighbor_interrupt(FAR struct net_driver_s *dev, if (state) { -#ifdef CONFIG_NETDEV_MULTINIC /* Is this the device that we need to route this request? */ if (strncmp((FAR const char *)dev->d_ifname, @@ -120,8 +117,6 @@ static uint16_t icmpv6_neighbor_interrupt(FAR struct net_driver_s *dev, return flags; } -#endif - /* Check if the outgoing packet is available. It may have been claimed * by a send interrupt serving a different thread -OR- if the output * buffer currently contains unprocessed incoming data. In these cases @@ -226,11 +221,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) /* Get the device that can route this request */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, ipaddr); -#else - dev = netdev_findby_ipv6addr(ipaddr); -#endif if (!dev) { nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr); @@ -239,10 +230,8 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) } #ifdef CONFIG_NET_MULTILINK - /* If we are supporting multiple network devices and using different - * link level protocols then we can get here for other link protocols - * as well. Continue and send the Neighbor Solicitation request only - * if this device uses the Ethernet data link protocol. + * Continue and send the Neighbor Solicitation request only if this + * device uses the Ethernet data link protocol. * * REVISIT: Other link layer protocols may require Neighbor Discovery * as well (but not SLIP which is the only other option at the moment). @@ -318,12 +307,10 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr) state.snd_retries = 0; /* No retries yet */ net_ipv6addr_copy(state.snd_ipaddr, lookup); /* IP address to query */ -#ifdef CONFIG_NETDEV_MULTINIC /* Remember the routing device name */ strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ); -#endif /* Now loop, testing if the address mapping is in the Neighbor Table and * re-sending the Neighbor Solicitation if it is not. diff --git a/net/icmpv6/icmpv6_ping.c b/net/icmpv6/icmpv6_ping.c index 3dacab04b8..60819eda79 100644 --- a/net/icmpv6/icmpv6_ping.c +++ b/net/icmpv6/icmpv6_ping.c @@ -425,11 +425,7 @@ int icmpv6_ping(net_ipv6addr_t addr, uint16_t id, uint16_t seqno, /* Get the device that will be used to route this ICMP ECHO request */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, addr); -#else - dev = netdev_findby_ipv6addr(addr); -#endif if (dev == 0) { nerr("ERROR: Not reachable\n"); diff --git a/net/icmpv6/icmpv6_rnotify.c b/net/icmpv6/icmpv6_rnotify.c index 49f0199e01..74409ccd3c 100644 --- a/net/icmpv6/icmpv6_rnotify.c +++ b/net/icmpv6/icmpv6_rnotify.c @@ -160,7 +160,6 @@ static void icmpv6_setaddresses(FAR struct net_driver_s *dev, void icmpv6_rwait_setup(FAR struct net_driver_s *dev, FAR struct icmpv6_rnotify_s *notify) { -#ifdef CONFIG_NETDEV_MULTINIC irqstate_t flags; /* Initialize the wait structure */ @@ -181,26 +180,6 @@ void icmpv6_rwait_setup(FAR struct net_driver_s *dev, notify->rn_flink = g_icmpv6_rwaiters; g_icmpv6_rwaiters = notify; leave_critical_section(flags); - -#else - /* If there is only a single network device, then there can be only a - * single waiter. - */ - - /* Initialize and remember wait structure */ - - notify->rn_result = -ETIMEDOUT; - - /* This semaphore is used for signaling and, hence, should not have - * priority inheritance enabled. - */ - - (void)sem_init(¬ify->rn_sem, 0, 0); - sem_setprotocol(¬ify->rn_sem, SEM_PRIO_NONE); - - DEBUGASSERT(g_icmpv6_rwaiters == NULL); - g_icmpv6_rwaiters = notify; -#endif } /**************************************************************************** @@ -219,7 +198,6 @@ void icmpv6_rwait_setup(FAR struct net_driver_s *dev, int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify) { -#ifdef CONFIG_NETDEV_MULTINIC FAR struct icmpv6_rnotify_s *curr; FAR struct icmpv6_rnotify_s *prev; irqstate_t flags; @@ -254,18 +232,6 @@ int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify) leave_critical_section(flags); (void)sem_destroy(¬ify->rn_sem); return ret; - -#else - ninfo("Cancelling...\n"); - - /* If there is only one network device, then there can be only one entry - * in the list of waiters. - */ - - g_icmpv6_rwaiters = NULL; - (void)sem_destroy(¬ify->rn_sem); - return OK; -#endif } /**************************************************************************** @@ -345,7 +311,6 @@ int icmpv6_rwait(FAR struct icmpv6_rnotify_s *notify, void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr, const net_ipv6addr_t prefix, unsigned int preflen) { -#ifdef CONFIG_NETDEV_MULTINIC FAR struct icmpv6_rnotify_s *curr; ninfo("Notified\n"); @@ -373,24 +338,6 @@ void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr, break; } } - -#else - FAR struct icmpv6_rnotify_s *waiter = g_icmpv6_rwaiters; - - ninfo("Notified\n"); - - if (waiter) - { - /* Set the new network addresses. */ - - icmpv6_setaddresses(dev, draddr, prefix, preflen); - - /* And signal the waiting, returning success */ - - waiter->rn_result = OK; - sem_post(&waiter->rn_sem); - } -#endif } #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ diff --git a/net/inet/inet_close.c b/net/inet/inet_close.c index 88765e56b2..4e2e357dfb 100644 --- a/net/inet/inet_close.c +++ b/net/inet/inet_close.c @@ -291,11 +291,7 @@ static inline void tcp_close_txnotify(FAR struct socket *psock, { /* Notify the device driver that send data is available */ -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -307,11 +303,7 @@ static inline void tcp_close_txnotify(FAR struct socket *psock, /* Notify the device driver that send data is available */ DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_txnotify(conn->u.ipv6.raddr); -#endif } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/inet/inet_connect.c b/net/inet/inet_connect.c index 8ad0d433bf..237ffbcfcb 100644 --- a/net/inet/inet_connect.c +++ b/net/inet/inet_connect.c @@ -304,7 +304,6 @@ static uint16_t psock_connect_interrupt(FAR struct net_driver_s *dev, } #endif /* CONFIG_NET_IPv6 */ -#ifdef CONFIG_NETDEV_MULTINIC /* We now have to filter all outgoing transfers so that they use only * the MSS of this device. */ @@ -313,7 +312,6 @@ static uint16_t psock_connect_interrupt(FAR struct net_driver_s *dev, pstate->tc_conn->dev == dev); pstate->tc_conn->dev = dev; -#endif /* CONFIG_NETDEV_MULTINIC */ #endif /* CONFIG_NET_MULTILINK */ /* Wake up the waiting thread */ diff --git a/net/inet/inet_monitor.c b/net/inet/inet_monitor.c index 5ff501b716..883df71900 100644 --- a/net/inet/inet_monitor.c +++ b/net/inet/inet_monitor.c @@ -164,14 +164,12 @@ static uint16_t connection_event(FAR struct net_driver_s *dev, else if ((flags & TCP_CONNECTED) != 0) { #if 0 /* REVISIT: Assertion fires. Why? */ -#ifdef CONFIG_NETDEV_MULTINIC FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)psock->s_conn; /* Make sure that this is the device bound to the connection */ DEBUGASSERT(conn->dev == NULL || conn->dev == dev); conn->dev = dev; -#endif #endif /* If there is no local address assigned to the socket (perhaps diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c index dc076f7068..a91cfc91b3 100644 --- a/net/inet/inet_recvfrom.c +++ b/net/inet/inet_recvfrom.c @@ -636,7 +636,6 @@ static uint16_t inet_tcp_interrupt(FAR struct net_driver_s *dev, FAR struct inet_recvfrom_s *pstate = (struct inet_recvfrom_s *)pvpriv; #if 0 /* REVISIT: The assertion fires. Why? */ -#ifdef CONFIG_NETDEV_MULTINIC FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn; /* The TCP socket is connected and, hence, should be bound to a device. @@ -648,7 +647,6 @@ static uint16_t inet_tcp_interrupt(FAR struct net_driver_s *dev, { return flags; } -#endif #endif ninfo("flags: %04x\n", flags); @@ -1198,11 +1196,7 @@ static inline void inet_udp_rxnotify(FAR struct socket *psock, { /* Notify the device driver of the receive ready */ -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_rxnotify(conn->u.ipv4.raddr); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -1214,11 +1208,7 @@ static inline void inet_udp_rxnotify(FAR struct socket *psock, /* Notify the device driver of the receive ready */ DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_rxnotify(conn->u.ipv6.raddr); -#endif } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/inet/inet_sendfile.c b/net/inet/inet_sendfile.c index c88cafd271..e953c4077e 100644 --- a/net/inet/inet_sendfile.c +++ b/net/inet/inet_sendfile.c @@ -328,7 +328,6 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon FAR struct sendfile_s *pstate = (FAR struct sendfile_s *)pvpriv; int ret; -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP socket is connected and, hence, should be bound to a device. * Make sure that the polling device is the own that we are bound to. */ @@ -338,7 +337,6 @@ static uint16_t sendfile_interrupt(FAR struct net_driver_s *dev, FAR void *pvcon { return flags; } -#endif ninfo("flags: %04x acked: %d sent: %d\n", flags, pstate->snd_acked, pstate->snd_sent); @@ -508,11 +506,7 @@ static inline void sendfile_txnotify(FAR struct socket *psock, { /* Notify the device driver that send data is available */ -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -524,11 +518,7 @@ static inline void sendfile_txnotify(FAR struct socket *psock, /* Notify the device driver that send data is available */ DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_txnotify(conn->u.ipv6.raddr); -#endif } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/inet/inet_sockif.c b/net/inet/inet_sockif.c index ac22559a69..7abea2204f 100644 --- a/net/inet/inet_sockif.c +++ b/net/inet/inet_sockif.c @@ -904,14 +904,14 @@ static ssize_t inet_send(FAR struct socket *psock, FAR const void *buf, ret = psock_6lowpan_tcp_send(psock, buf, len); -#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_TCP_HAVE_STACK) +#ifdef NET_TCP_HAVE_STACK if (ret < 0) { /* TCP/IP packet send */ ret = psock_tcp_send(psock, buf, len); } -#endif /* CONFIG_NETDEV_MULTINIC && NET_TCP_HAVE_STACK */ +#endif /* NET_TCP_HAVE_STACK */ #elif defined(NET_TCP_HAVE_STACK) ret = psock_tcp_send(psock, buf, len); #else @@ -929,14 +929,14 @@ static ssize_t inet_send(FAR struct socket *psock, FAR const void *buf, ret = psock_6lowpan_udp_send(psock, buf, len); -#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_UDP_HAVE_STACK) +#ifdef NET_UDP_HAVE_STACK if (ret < 0) { /* UDP/IP packet send */ ret = psock_udp_send(psock, buf, len); } -#endif /* CONFIG_NETDEV_MULTINIC && NET_UDP_HAVE_STACK */ +#endif /* NET_UDP_HAVE_STACK */ #elif defined(NET_UDP_HAVE_STACK) /* Only UDP/IP packet send */ @@ -1035,14 +1035,14 @@ static ssize_t inet_sendto(FAR struct socket *psock, FAR const void *buf, nsent = psock_6lowpan_udp_sendto(psock, buf, len, flags, to, tolen); -#if defined(CONFIG_NETDEV_MULTINIC) && defined(NET_UDP_HAVE_STACK) +#ifdef NET_UDP_HAVE_STACK if (nsent < 0) { /* UDP/IP packet sendto */ nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen); } -#endif /* CONFIG_NETDEV_MULTINIC && NET_UDP_HAVE_STACK */ +#endif /* NET_UDP_HAVE_STACK */ #elif defined(NET_UDP_HAVE_STACK) nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen); #else diff --git a/net/inet/ipv4_getsockname.c b/net/inet/ipv4_getsockname.c index 063f5227d5..c4185323c3 100644 --- a/net/inet/ipv4_getsockname.c +++ b/net/inet/ipv4_getsockname.c @@ -83,10 +83,8 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, { FAR struct sockaddr_in *outaddr = (FAR struct sockaddr_in *)addr; FAR struct net_driver_s *dev; -#ifdef CONFIG_NETDEV_MULTINIC in_addr_t lipaddr; in_addr_t ripaddr; -#endif /* Check if enough space has been provided for the full address */ @@ -110,11 +108,8 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, FAR struct tcp_conn_s *tcp_conn = (FAR struct tcp_conn_s *)psock->s_conn; outaddr->sin_port = tcp_conn->lport; /* Already in network byte order */ - -#ifdef CONFIG_NETDEV_MULTINIC - lipaddr = tcp_conn->u.ipv4.laddr; - ripaddr = tcp_conn->u.ipv4.raddr; -#endif + lipaddr = tcp_conn->u.ipv4.laddr; + ripaddri = tcp_conn->u.ipv4.raddr; } break; #endif @@ -125,11 +120,8 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, FAR struct udp_conn_s *udp_conn = (FAR struct udp_conn_s *)psock->s_conn; outaddr->sin_port = udp_conn->lport; /* Already in network byte order */ - -#ifdef CONFIG_NETDEV_MULTINIC - lipaddr = udp_conn->u.ipv4.laddr; - ripaddr = udp_conn->u.ipv4.raddr; -#endif + lipaddr = udp_conn->u.ipv4.laddr; + ripaddr = udp_conn->u.ipv4.raddr; } break; #endif @@ -138,12 +130,6 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, return -EOPNOTSUPP; } -#ifdef CONFIG_NETDEV_MULTINIC - /* The socket/connection does not know its IP address unless - * CONFIG_NETDEV_MULTINIC is selected. Otherwise the design supports only - * a single network device and only the network device knows the IP address. - */ - if (lipaddr == 0) { outaddr->sin_family = psock->s_domain; @@ -152,11 +138,9 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, return OK; } -#endif net_lock(); -#ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv4 address in the connection structure. * NOTE: listening sockets have no ripaddr. Work around is to use the * lipaddr when ripaddr is not available. @@ -168,11 +152,6 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, } dev = netdev_findby_ipv4addr(lipaddr, ripaddr); -#else - /* There is only one, the first network device in the list. */ - - dev = g_netdevices; -#endif if (dev == NULL) { diff --git a/net/inet/ipv6_getsockname.c b/net/inet/ipv6_getsockname.c index a6d93d5e23..799f511695 100644 --- a/net/inet/ipv6_getsockname.c +++ b/net/inet/ipv6_getsockname.c @@ -83,10 +83,8 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, { FAR struct sockaddr_in6 *outaddr = (FAR struct sockaddr_in6 *)addr; FAR struct net_driver_s *dev; -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_t *lipaddr; net_ipv6addr_t *ripaddr; -#endif /* Check if enough space has been provided for the full address */ @@ -108,12 +106,10 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, case SOCK_STREAM: { FAR struct tcp_conn_s *tcp_conn = (FAR struct tcp_conn_s *)psock->s_conn; - outaddr->sin6_port = tcp_conn->lport; /* Already in network byte order */ -#ifdef CONFIG_NETDEV_MULTINIC + outaddr->sin6_port = tcp_conn->lport; /* Already in network byte order */ lipaddr = &tcp_conn->u.ipv6.laddr; ripaddr = &tcp_conn->u.ipv6.raddr; -#endif } break; #endif @@ -122,12 +118,10 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, case SOCK_DGRAM: { FAR struct udp_conn_s *udp_conn = (FAR struct udp_conn_s *)psock->s_conn; - outaddr->sin6_port = udp_conn->lport; /* Already in network byte order */ -#ifdef CONFIG_NETDEV_MULTINIC + outaddr->sin6_port = udp_conn->lport; /* Already in network byte order */ lipaddr = &udp_conn->u.ipv6.laddr; ripaddr = &udp_conn->u.ipv6.raddr; -#endif } break; #endif @@ -136,11 +130,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, return -EOPNOTSUPP; } -#ifdef CONFIG_NETDEV_MULTINIC - /* The socket/connection does not know its IP address unless - * CONFIG_NETDEV_MULTINIC is selected. Otherwise the design supports only - * a single network device and only the network device knows the IP address. - */ + /* Check if bound to local INADDR6_ANY */ if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr)) { @@ -150,11 +140,9 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, return OK; } -#endif net_lock(); -#ifdef CONFIG_NETDEV_MULTINIC /* Find the device matching the IPv6 address in the connection structure. * NOTE: listening sockets have no ripaddr. Work around is to use the * lipaddr when ripaddr is not available. @@ -166,11 +154,6 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr, } dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr); -#else - /* There is only one, the first network device in the list. */ - - dev = g_netdevices; -#endif if (!dev) { diff --git a/net/ipforward/Kconfig b/net/ipforward/Kconfig index 2fc3ddbdc7..cbf7f3bb6b 100644 --- a/net/ipforward/Kconfig +++ b/net/ipforward/Kconfig @@ -14,7 +14,7 @@ config NET_IPFORWARD config NET_IPFORWARD_BROADCAST bool "Forward broadcast/multicast packets" default n - depends on NET_IPFORWARD && NETDEV_MULTINIC + depends on NET_IPFORWARD ---help--- If selected, broadcast packets received on one network device will be forwarded though other network devices. @@ -22,7 +22,7 @@ config NET_IPFORWARD_BROADCAST config NET_IPFORWARD_NSTRUCT int "Number of pre-allocated forwarding structures" default 4 - depends on NET_IPFORWARD && NETDEV_MULTINIC + depends on NET_IPFORWARD ---help--- When packets are forwarded from on device to another, a structure must be allocated to hold the state of forwarding across several diff --git a/net/ipforward/Make.defs b/net/ipforward/Make.defs index c8ad408c56..916198a1ea 100644 --- a/net/ipforward/Make.defs +++ b/net/ipforward/Make.defs @@ -37,6 +37,8 @@ ifeq ($(CONFIG_NET_IPFORWARD),y) +NET_CSRCS += ipfwd_alloc.c ipfwd_forward.c ipfwd_poll.c + ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_forward.c endif @@ -45,10 +47,6 @@ ifeq ($(CONFIG_NET_IPv6),y) NET_CSRCS += ipv6_forward.c endif -ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += ipfwd_alloc.c ipfwd_forward.c ipfwd_poll.c -endif - ifeq ($(CONFIG_NET_STATISTICS),y) NET_CSRCS += ipfwd_dropstats.c endif diff --git a/net/ipforward/ipforward.h b/net/ipforward/ipforward.h index 27a7375e28..4fee2e7be6 100644 --- a/net/ipforward/ipforward.h +++ b/net/ipforward/ipforward.h @@ -47,12 +47,6 @@ #undef HAVE_FWDALLOC #ifdef CONFIG_NET_IPFORWARD -/* Must of the logic in this header file applies only for configurations - * will multiple network devices. - */ - -#ifdef CONFIG_NETDEV_MULTINIC - /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -279,16 +273,6 @@ void ipfwd_dropstats(FAR struct forward_s *fwd); # define ipfwd_dropstats(fwd) #endif -#endif /* CONFIG_NETDEV_MULTINIC */ - -/* Duplicates some forward references that are only available when - * CONFIG_NETDEV_MULTINIC is enabled. - */ - -struct net_driver_s; /* Forward reference */ -struct ipv4_hdr_s; /* Forward reference */ -struct ipv6_hdr_s; /* Forward reference */ - /**************************************************************************** * Name: ipv4_forward * diff --git a/net/ipforward/ipfwd_alloc.c b/net/ipforward/ipfwd_alloc.c index e2265db19f..517321a1b8 100644 --- a/net/ipforward/ipfwd_alloc.c +++ b/net/ipforward/ipfwd_alloc.c @@ -51,7 +51,7 @@ #include "ipforward/ipforward.h" -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD /**************************************************************************** * Pre-processor Definitions @@ -170,4 +170,4 @@ void ipfwd_free(FAR struct forward_s *fwd) g_fwdfree = fwd; } -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPFORWARD */ diff --git a/net/ipforward/ipfwd_dropstats.c b/net/ipforward/ipfwd_dropstats.c index 469a95b8d9..c6ebc68626 100644 --- a/net/ipforward/ipfwd_dropstats.c +++ b/net/ipforward/ipfwd_dropstats.c @@ -174,7 +174,6 @@ void ipv4_dropstats(FAR struct ipv4_hdr_s *ipv4) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC void ipfwd_dropstats(FAR struct forward_s *fwd) { #ifdef CONFIG_NET_IPv4 @@ -194,6 +193,5 @@ void ipfwd_dropstats(FAR struct forward_s *fwd) } #endif } -#endif #endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_STATISTICS */ diff --git a/net/ipforward/ipfwd_forward.c b/net/ipforward/ipfwd_forward.c index 9899fadcc7..ca6e2c7867 100644 --- a/net/ipforward/ipfwd_forward.c +++ b/net/ipforward/ipfwd_forward.c @@ -55,8 +55,7 @@ #include "neighbor/neighbor.h" #include "ipforward/ipforward.h" -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) - +#ifdef CONFIG_NET_IPFORWARD /**************************************************************************** * Public Functions ****************************************************************************/ @@ -349,4 +348,4 @@ int ipfwd_forward(FAR struct forward_s *fwd) return -EBUSY; } -#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPFORWARD */ diff --git a/net/ipforward/ipfwd_poll.c b/net/ipforward/ipfwd_poll.c index 6042404a9b..65a470eb6e 100644 --- a/net/ipforward/ipfwd_poll.c +++ b/net/ipforward/ipfwd_poll.c @@ -46,7 +46,7 @@ #include "devif/devif.h" #include "ipforward/ipforward.h" -#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD /**************************************************************************** * Private Functions @@ -206,4 +206,4 @@ void ipfwd_poll(FAR struct net_driver_s *dev) #endif } -#endif /* CONFIG_NET_ARP_SEND && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_ARP_SEND */ diff --git a/net/ipforward/ipv4_forward.c b/net/ipforward/ipv4_forward.c index 2c1e5f8756..641f5ff3e5 100644 --- a/net/ipforward/ipv4_forward.c +++ b/net/ipforward/ipv4_forward.c @@ -77,7 +77,7 @@ * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) +#ifdef CONFIG_DEBUG_NET_WARNx) static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) { /* Size is determined by the following protocol header, */ @@ -144,7 +144,6 @@ static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) { uint16_t sum; @@ -185,7 +184,6 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) ipv4->ipchksum = ~sum; return ttl; } -#endif /**************************************************************************** * Name: ipv4_dev_forward @@ -209,7 +207,6 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static int ipv4_dev_forward(FAR struct net_driver_s *dev, FAR struct net_driver_s *fwddev, FAR struct ipv4_hdr_s *ipv4) @@ -338,7 +335,6 @@ errout_with_fwd: errout: return ret; } -#endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** * Name: ipv4_forward_callback @@ -360,8 +356,7 @@ errout: * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ - defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD_BROADCAST int ipv4_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg) { FAR struct net_driver_s *dev = (FAR struct net_driver_s *)arg; @@ -432,33 +427,22 @@ int ipv4_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg) int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) { in_addr_t destipaddr; -#ifdef CONFIG_NETDEV_MULTINIC in_addr_t srcipaddr; -#endif FAR struct net_driver_s *fwddev; int ret; - /* Search for a device that can forward this packet. This is a trivial - * search if there is only a single network device (CONFIG_NETDEV_MULTINIC - * not defined). But netdev_findby_ipv4addr() will still assure - * routability in that case. - */ + /* Search for a device that can forward this packet. */ destipaddr = net_ip4addr_conv32(ipv4->destipaddr); -#ifdef CONFIG_NETDEV_MULTINIC srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr); fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr); -#else - fwddev = netdev_findby_ipv4addr(destipaddr); -#endif if (fwddev == NULL) { nwarn("WARNING: Not routable\n"); return (ssize_t)-ENETUNREACH; } -#if defined(CONFIG_NETDEV_MULTINIC) /* Check if we are forwarding on the same device that we received the * packet from. */ @@ -475,8 +459,6 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) } } else -#endif /* CONFIG_NETDEV_MULTINIC */ - { /* Single network device. The use case here is where an endpoint acts * as a hub in a star configuration. This is typical for a wireless star @@ -538,8 +520,7 @@ drop: * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ - defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD_BROADCAST void ipv4_forward_broadcast(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4) { diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index 49a233c68d..d4793d232f 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -84,7 +84,7 @@ * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) && defined(CONFIG_DEBUG_NET_WARN) +#ifdef CONFIG_DEBUG_NET_WARN static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) { /* Size is determined by the following protocol header, */ @@ -151,7 +151,7 @@ static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6) * ****************************************************************************/ -#if defined(CONFIG_NETDEV_MULTINIC) || defined(CONFIG_NET_6LOWPAN) +#ifdef CONFIG_NET_6LOWPAN static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6) { int ttl = (int)ipv6->ttl - 1; @@ -342,7 +342,6 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static int ipv6_dev_forward(FAR struct net_driver_s *dev, FAR struct net_driver_s *fwddev, FAR struct ipv6_hdr_s *ipv6) @@ -482,7 +481,6 @@ errout_with_fwd: errout: return ret; } -#endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** * Name: ipv6_forward_callback @@ -504,8 +502,7 @@ errout: * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ - defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD_BROADCAST int ipv6_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg) { FAR struct net_driver_s *dev = (FAR struct net_driver_s *)arg; @@ -578,24 +575,15 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) FAR struct net_driver_s *fwddev; int ret; - /* Search for a device that can forward this packet. This is a trivial - * search if there is only a single network device (CONFIG_NETDEV_MULTINIC - * not defined). But netdev_findby_ipv6addr() will still assure - * routability in that case. - */ + /* Search for a device that can forward this packet. */ -#ifdef CONFIG_NETDEV_MULTINIC fwddev = netdev_findby_ipv6addr(ipv6->srcipaddr, ipv6->destipaddr); -#else - fwddev = netdev_findby_ipv6addr(ipv6->destipaddr); -#endif if (fwddev == NULL) { nwarn("WARNING: Not routable\n"); return (ssize_t)-ENETUNREACH; } -#if defined(CONFIG_NETDEV_MULTINIC) /* Check if we are forwarding on the same device that we received the * packet from. */ @@ -612,8 +600,6 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) } } else -#endif /* CONFIG_NETDEV_MULTINIC */ - #if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */ { /* Single network device. The use case here is where an endpoint acts @@ -705,8 +691,7 @@ drop: * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \ - defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPFORWARD_BROADCAST void ipv6_forward_broadcast(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6) { diff --git a/net/netdev/netdev.h b/net/netdev/netdev.h index 83aa7c5f80..0a8eef370f 100644 --- a/net/netdev/netdev.h +++ b/net/netdev/netdev.h @@ -184,8 +184,7 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg); * IPv4 address. * * Parameters: - * lipaddr - Local, bound address of a connection. Used only if ripaddr - * is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC. + * lipaddr - Local, bound address of a connection. * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: @@ -198,12 +197,8 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg); #if CONFIG_NSOCKET_DESCRIPTORS > 0 #ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr, in_addr_t ripaddr); -#else -FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr); -#endif #endif /**************************************************************************** @@ -214,8 +209,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr); * IPv6 address. * * Parameters: - * lipaddr - Local, bound address of a connection. Used only if ripaddr - * is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC. + * lipaddr - Local, bound address of a connection. * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: @@ -227,12 +221,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr); ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr, const net_ipv6addr_t ripaddr); -#else -FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr); -#endif #endif #endif @@ -309,11 +299,7 @@ FAR struct net_driver_s *netdev_default(void); #if CONFIG_NSOCKET_DESCRIPTORS > 0 #ifdef CONFIG_NET_IPv4 -# ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr); -# else -void netdev_ipv4_txnotify(in_addr_t ripaddr); -# endif #endif /* CONFIG_NET_IPv4 */ /**************************************************************************** @@ -336,12 +322,8 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr); ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -# ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr, FAR const net_ipv6addr_t ripaddr); -# else -void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr); -# endif #endif /* CONFIG_NET_IPv6 */ #endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */ @@ -388,11 +370,7 @@ void netdev_txnotify_dev(FAR struct net_driver_s *dev); #if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL) #ifdef CONFIG_NET_IPv4 -# ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr); -# else -void netdev_ipv4_rxnotify(in_addr_t ripaddr); -# endif #endif /* CONFIG_NET_IPv4 */ /**************************************************************************** @@ -415,29 +393,17 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr); ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -# ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr, FAR const net_ipv6addr_t ripaddr); -# else -void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr); -# endif #endif /* CONFIG_NET_IPv6 */ #else #ifdef CONFIG_NET_IPv4 -# ifdef CONFIG_NETDEV_MULTINIC -# define netdev_ipv4_rxnotify(lipaddr,ripaddr) -# else -# define netdev_ipv4_rxnotify(ripaddr) -# endif +# define netdev_ipv4_rxnotify(lipaddr,ripaddr) #endif /* CONFIG_NET_IPv4 */ #ifdef CONFIG_NET_IPv6 -# ifdef CONFIG_NETDEV_MULTINIC -# define netdev_ipv6_rxnotify(lipaddr,ripaddr) -# else -# define netdev_ipv6_rxnotify(ripaddr) -# endif +# define netdev_ipv6_rxnotify(lipaddr,ripaddr) #endif /* CONFIG_NET_IPv6 */ #endif diff --git a/net/netdev/netdev_findbyaddr.c b/net/netdev/netdev_findbyaddr.c index 51f59d029f..ad10e13ec1 100644 --- a/net/netdev/netdev_findbyaddr.c +++ b/net/netdev/netdev_findbyaddr.c @@ -179,8 +179,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr) * IPv4 address. * * Parameters: - * lipaddr - Local, bound address of a connection. Used only if ripaddr - * is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC. + * lipaddr - Local, bound address of a connection. * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: @@ -192,12 +191,8 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr) ****************************************************************************/ #ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr, in_addr_t ripaddr) -#else -FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) -#endif { struct net_driver_s *dev; #ifdef CONFIG_NET_ROUTE @@ -209,7 +204,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) if (net_ipv4addr_cmp(ripaddr, INADDR_BROADCAST)) { -#ifdef CONFIG_NETDEV_MULTINIC /* Yes.. Check the local, bound address. Is it INADDR_ANY? */ if (net_ipv4addr_cmp(lipaddr, INADDR_ANY)) @@ -232,13 +226,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) return netdev_finddevice_ipv4addr(lipaddr); } -#else - /* If there is only a single, registered network interface, then the - * decision is pretty easy. - */ - - return g_netdevices; -#endif } /* Check if the address maps to a local network */ @@ -275,15 +262,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) * out subnet to a router and there is no routing information. */ -#ifndef CONFIG_NETDEV_MULTINIC - /* If there is only a single, registered network interface, then the - * decision is pretty easy. Use that device and its default router - * address. - */ - - dev = g_netdevices; -#endif - /* If we will did not find the network device, then we might as well fail * because we are not configured properly to determine the route to the * destination. @@ -301,8 +279,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) * IPv6 address. * * Parameters: - * lipaddr - Local, bound address of a connection. Used only if ripaddr - * is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC. + * lipaddr - Local, bound address of a connection. * ripaddr - Remote address of a connection to use in the lookup * * Returned Value: @@ -314,12 +291,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr) ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr, const net_ipv6addr_t ripaddr) -#else -FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr) -#endif { struct net_driver_s *dev; #ifdef CONFIG_NET_ROUTE @@ -335,7 +308,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr) if (ripaddr[0] == HTONS(0xff02)) { -#ifdef CONFIG_NETDEV_MULTINIC /* Yes.. Check the local, bound address. Is it INADDR_ANY? */ if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr)) @@ -358,13 +330,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr) return netdev_finddevice_ipv6addr(lipaddr); } -#else - /* If there is only a single, registered network interface, then the - * decision is pretty easy. - */ - - return g_netdevices; -#endif } /* Check if the address maps to a local network */ @@ -401,15 +366,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr) * out subnet to a router and there is no routing information. */ -#ifndef CONFIG_NETDEV_MULTINIC - /* If there is only a single, registered network interface, then the - * decision is pretty easy. Use that device and its default router - * address. - */ - - dev = g_netdevices; -#endif - /* If we will did not find the network device, then we might as well fail * because we are not configured properly to determine the route to the * destination. diff --git a/net/netdev/netdev_findbyindex.c b/net/netdev/netdev_findbyindex.c index 2496d2b902..a1d966d447 100644 --- a/net/netdev/netdev_findbyindex.c +++ b/net/netdev/netdev_findbyindex.c @@ -76,7 +76,6 @@ FAR struct net_driver_s *netdev_findbyindex(int index) { -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *dev; int i; @@ -92,9 +91,6 @@ FAR struct net_driver_s *netdev_findbyindex(int index) net_unlock(); return NULL; -#else - return (index == 0) ? g_netdevices : NULL; -#endif } #endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */ diff --git a/net/netdev/netdev_rxnotify.c b/net/netdev/netdev_rxnotify.c index 1c18bb51d1..b497788243 100644 --- a/net/netdev/netdev_rxnotify.c +++ b/net/netdev/netdev_rxnotify.c @@ -74,22 +74,13 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv4 -#ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr) -#else -void netdev_ipv4_rxnotify(in_addr_t ripaddr) -#endif { FAR struct net_driver_s *dev; /* Find the device driver that serves the subnet of the remote address */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv4addr(lipaddr, ripaddr); -#else - dev = netdev_findby_ipv4addr(ripaddr); -#endif - if (dev && dev->d_rxavail) { /* Notify the device driver that new RX data is available. */ @@ -119,23 +110,14 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr) ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr, FAR const net_ipv6addr_t ripaddr) -#else -void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr) -#endif { FAR struct net_driver_s *dev; /* Find the device driver that serves the subnet of the remote address */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv6addr(lipaddr, ripaddr); -#else - dev = netdev_findby_ipv6addr(ripaddr); -#endif - if (dev && dev->d_rxavail) { /* Notify the device driver that new RX data is available. */ diff --git a/net/netdev/netdev_txnotify.c b/net/netdev/netdev_txnotify.c index fca1b9d070..6d8d02cfef 100644 --- a/net/netdev/netdev_txnotify.c +++ b/net/netdev/netdev_txnotify.c @@ -74,22 +74,13 @@ ****************************************************************************/ #ifdef CONFIG_NET_IPv4 -# ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr) -# else -void netdev_ipv4_txnotify(in_addr_t ripaddr) -# endif { FAR struct net_driver_s *dev; /* Find the device driver that serves the subnet of the remote address */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv4addr(lipaddr, ripaddr); -#else - dev = netdev_findby_ipv4addr(ripaddr); -#endif - if (dev && dev->d_txavail) { /* Notify the device driver that new TX data is available. */ @@ -120,23 +111,14 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr) ****************************************************************************/ #ifdef CONFIG_NET_IPv6 -#ifdef CONFIG_NETDEV_MULTINIC void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr, FAR const net_ipv6addr_t ripaddr) -#else -void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr) -#endif { FAR struct net_driver_s *dev; /* Find the device driver that serves the subnet of the remote address */ -#ifdef CONFIG_NETDEV_MULTINIC dev = netdev_findby_ipv6addr(lipaddr, ripaddr); -#else - dev = netdev_findby_ipv6addr(ripaddr); -#endif - if (dev && dev->d_txavail) { /* Notify the device driver that new TX data is available. */ diff --git a/net/pkt/pkt_finddev.c b/net/pkt/pkt_finddev.c index 19e7fedd13..69f53ec2cf 100644 --- a/net/pkt/pkt_finddev.c +++ b/net/pkt/pkt_finddev.c @@ -65,23 +65,11 @@ FAR struct net_driver_s *pkt_find_device(FAR struct pkt_conn_s *conn) { -#ifdef CONFIG_NETDEV_MULTINIC FAR struct net_driver_s *dev; - /* There are multiple network devices. - * - * REVISIT: This is bogus. A better network device lookup is needed. - */ + /* REVISIT: This is bogus. A better network device lookup is needed. */ return netdev_findbyname("eth0"); - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return g_netdevices; -#endif } #endif /* CONFIG_NET && CONFIG_NET_PKT */ diff --git a/net/sixlowpan/sixlowpan_send.c b/net/sixlowpan/sixlowpan_send.c index 14a5ec2940..189cfcffcd 100644 --- a/net/sixlowpan/sixlowpan_send.c +++ b/net/sixlowpan/sixlowpan_send.c @@ -172,14 +172,11 @@ static uint16_t send_interrupt(FAR struct net_driver_s *dev, } #endif -#ifdef CONFIG_NETDEV_MULTINIC /* REVISIT: Verify that this is the correct IEEE802.15.4 network driver to * route the outgoing frame(s). Chances are that there is only one * IEEE802.15.4 network driver */ -#endif - /* Check if the IEEE802.15.4 network driver went down */ if ((flags & NETDEV_DOWN) != 0) diff --git a/net/sixlowpan/sixlowpan_tcpsend.c b/net/sixlowpan/sixlowpan_tcpsend.c index c1f9df2a1c..b1ef39c073 100644 --- a/net/sixlowpan/sixlowpan_tcpsend.c +++ b/net/sixlowpan/sixlowpan_tcpsend.c @@ -219,13 +219,11 @@ static int sixlowpan_tcp_header(FAR struct tcp_conn_s *conn, /* Copy the source and destination addresses */ net_ipv6addr_hdrcopy(ipv6tcp->ipv6.destipaddr, conn->u.ipv6.raddr); -#ifdef CONFIG_NETDEV_MULTINIC if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr)) { net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, conn->u.ipv6.laddr); } else -#endif { net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, dev->d_ipv6addr); } @@ -363,7 +361,6 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev, } #endif -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP socket is connected and, hence, should be bound to a device. * Make sure that the polling device is the one that we are bound to. */ @@ -371,10 +368,9 @@ static uint16_t tcp_send_interrupt(FAR struct net_driver_s *dev, DEBUGASSERT(conn->dev != NULL); if (dev != conn->dev) { - ninfo("Not the connecte device\n"); + ninfo("Not the connected device\n"); return flags; } -#endif /* Check if the IEEE802.15.4 network driver went down */ @@ -800,9 +796,6 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf, /* Route outgoing message to the correct device */ -#ifdef CONFIG_NETDEV_MULTINIC - /* There are multiple network devices */ - dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr); if (dev == NULL) { @@ -823,17 +816,6 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf, } #endif -#else - /* There is a single network device */ - - dev = netdev_findby_ipv6addr(conn->u.ipv6.raddr); - if (dev == NULL) - { - nwarn("WARNING: Not routable\n"); - return (ssize_t)-ENETUNREACH; - } -#endif - #ifdef CONFIG_NET_ICMPv6_NEIGHBOR /* Make sure that the IP address mapping is in the Neighbor Table */ diff --git a/net/sixlowpan/sixlowpan_udpsend.c b/net/sixlowpan/sixlowpan_udpsend.c index 699189ccfe..bc73c72f67 100644 --- a/net/sixlowpan/sixlowpan_udpsend.c +++ b/net/sixlowpan/sixlowpan_udpsend.c @@ -205,9 +205,6 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock, /* Route outgoing message to the correct device */ -#ifdef CONFIG_NETDEV_MULTINIC - /* There are multiple network devices */ - dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, to6->sin6_addr.in6_u.u6_addr16); if (dev == NULL) @@ -229,15 +226,6 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock, } #endif -#else - dev = netdev_findby_ipv6addr(to6->sin6_addr.in6_u.u6_addr16); - if (dev == NULL) - { - nwarn("WARNING: Not routable\n"); - return (ssize_t)-ENETUNREACH; - } -#endif - #ifdef CONFIG_NET_ICMPv6_NEIGHBOR /* Make sure that the IP address mapping is in the Neighbor Table */ @@ -268,13 +256,11 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock, /* Copy the source and destination addresses */ net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, to6->sin6_addr.in6_u.u6_addr16); -#ifdef CONFIG_NETDEV_MULTINIC if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr)) { net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, conn->u.ipv6.laddr); } else -#endif { net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, dev->d_ipv6addr); } diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h index f13170668d..1553a5199f 100644 --- a/net/tcp/tcp.h +++ b/net/tcp/tcp.h @@ -65,44 +65,23 @@ /* Allocate a new TCP data callback */ -#ifdef CONFIG_NETDEV_MULTINIC /* These macros allocate and free callback structures used for receiving * notifications of TCP data-related events. */ -# define tcp_callback_alloc(conn) \ - devif_callback_alloc((conn)->dev, &(conn)->list) -# define tcp_callback_free(conn,cb) \ - devif_conn_callback_free((conn)->dev, (cb), &(conn)->list) +#define tcp_callback_alloc(conn) \ + devif_callback_alloc((conn)->dev, &(conn)->list) +#define tcp_callback_free(conn,cb) \ + devif_conn_callback_free((conn)->dev, (cb), &(conn)->list) /* These macros allocate and free callback structures used for receiving * notifications of device-related events. */ -# define tcp_monitor_callback_alloc(conn) \ - devif_callback_alloc((conn)->dev, NULL) -# define tcp_monitor_callback_free(conn,cb) \ - devif_conn_callback_free((conn)->dev, (cb), NULL) - -#else -/* These macros allocate and free callback structures used for receiving - * notifications of TCP data-related events. - */ - -# define tcp_callback_alloc(conn) \ - devif_callback_alloc(g_netdevices, &(conn)->list) -# define tcp_callback_free(conn,cb) \ - devif_conn_callback_free(g_netdevices, (cb), &(conn)->list) - -/* These macros allocate and free callback structures used for receiving - * notifications of device-related events. - */ - -# define tcp_monitor_callback_alloc(conn) \ - devif_callback_alloc(g_netdevices, NULL) -# define tcp_monitor_callback_free(conn,cb) \ - devif_conn_callback_free(g_netdevices, (cb), NULL) -#endif +#define tcp_monitor_callback_alloc(conn) \ + devif_callback_alloc((conn)->dev, NULL) +#define tcp_monitor_callback_free(conn,cb) \ + devif_conn_callback_free((conn)->dev, (cb), NULL) #ifdef CONFIG_NET_TCP_WRITE_BUFFERS /* TCP write buffer access macros */ @@ -175,14 +154,12 @@ struct tcp_conn_s uint16_t unacked; /* Number bytes sent but not yet ACKed */ #endif -#ifdef CONFIG_NETDEV_MULTINIC /* If the TCP socket is bound to a local address, then this is * a reference to the device that routes traffic on the corresponding * network. */ FAR struct net_driver_s *dev; -#endif #ifdef CONFIG_NET_TCP_READAHEAD /* Read-ahead buffering. diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c index edaf6e205c..e7df27fd46 100644 --- a/net/tcp/tcp_conn.c +++ b/net/tcp/tcp_conn.c @@ -106,7 +106,7 @@ static uint16_t g_last_tcp_port; * ****************************************************************************/ -#if defined(CONFIG_NET_IPv4) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPv4 static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr, uint16_t portno) { @@ -143,7 +143,7 @@ static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr, return NULL; } -#endif /* CONFIG_NET_IPv4 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPv4 */ /**************************************************************************** * Name: tcp_ipv6_listener @@ -157,7 +157,7 @@ static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr, * ****************************************************************************/ -#if defined(CONFIG_NET_IPv6) && defined(CONFIG_NETDEV_MULTINIC) +#ifdef CONFIG_NET_IPv6 static inline FAR struct tcp_conn_s * tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno) { @@ -194,7 +194,7 @@ tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno) return NULL; } -#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */ +#endif /* CONFIG_NET_IPv6 */ /**************************************************************************** * Name: tcp_listener @@ -208,7 +208,6 @@ tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static FAR struct tcp_conn_s * tcp_listener(uint8_t domain, FAR const union ip_addr_u *ipaddr, uint16_t portno) @@ -232,35 +231,6 @@ static FAR struct tcp_conn_s * #endif /* CONFIG_NET_IPv6 */ } -#else /* CONFIG_NETDEV_MULTINIC */ - -static FAR struct tcp_conn_s *tcp_listener(uint16_t portno) -{ - FAR struct tcp_conn_s *conn; - int i; - - /* Check if this port number is in use by any active UIP TCP connection */ - - for (i = 0; i < CONFIG_NET_TCP_CONNS; i++) - { - conn = &g_tcp_connections[i]; - - /* Check if this connection is open and the local port assignment - * matches the requested port number. - */ - - if (conn->tcpstateflags != TCP_CLOSED && conn->lport == portno) - { - /* The port number is in use, return the connection */ - - return conn; - } - } - - return NULL; -} -#endif /* CONFIG_NETDEV_MULTINIC */ - /**************************************************************************** * Name: tcp_selectport * @@ -287,12 +257,8 @@ static FAR struct tcp_conn_s *tcp_listener(uint16_t portno) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static int tcp_selectport(uint8_t domain, FAR const union ip_addr_u *ipaddr, uint16_t portno) -#else -static int tcp_selectport(uint16_t portno) -#endif { if (portno == 0) { @@ -317,11 +283,7 @@ static int tcp_selectport(uint16_t portno) g_last_tcp_port = 4096; } } -#ifdef CONFIG_NETDEV_MULTINIC while (tcp_listener(domain, ipaddr, htons(g_last_tcp_port))); -#else - while (tcp_listener(htons(g_last_tcp_port))); -#endif } else { @@ -329,11 +291,7 @@ static int tcp_selectport(uint16_t portno) * connection is using this local port. */ -#ifdef CONFIG_NETDEV_MULTINIC if (tcp_listener(domain, ipaddr, portno)) -#else - if (tcp_listener(portno)) -#endif { /* It is in use... return EADDRINUSE */ @@ -365,15 +323,11 @@ static inline FAR struct tcp_conn_s * FAR struct ipv4_hdr_s *ip = IPv4BUF; FAR struct tcp_conn_s *conn; in_addr_t srcipaddr; -#ifdef CONFIG_NETDEV_MULTINIC in_addr_t destipaddr; -#endif conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head; srcipaddr = net_ip4addr_conv32(ip->srcipaddr); -#ifdef CONFIG_NETDEV_MULTINIC destipaddr = net_ip4addr_conv32(ip->destipaddr); -#endif while (conn) { @@ -384,11 +338,9 @@ static inline FAR struct tcp_conn_s * * number in the received packet. * - The remote port number is checked if the connection is bound * to a remote port. - * - If multiple network interfaces are supported, then the local - * IP address is available and we will insist that the - * destination IP matches the bound address. If a socket is - * bound to INADDRY_ANY, then it should receive all packets - * directed to the port. + * - Insist that the destination IP matches the bound address. If + * a socket is bound to INADDRY_ANY, then it should receive all + * packets directed to the port. * - Finally, if the connection is bound to a remote IP address, * the source IP address of the packet is checked. * @@ -399,10 +351,8 @@ static inline FAR struct tcp_conn_s * if (conn->tcpstateflags != TCP_CLOSED && tcp->destport == conn->lport && tcp->srcport == conn->rport && -#ifdef CONFIG_NETDEV_MULTINIC (net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY) || net_ipv4addr_cmp(destipaddr, conn->u.ipv4.laddr)) && -#endif net_ipv4addr_cmp(srcipaddr, conn->u.ipv4.raddr)) { /* Matching connection found.. break out of the loop and return a @@ -440,15 +390,11 @@ static inline FAR struct tcp_conn_s * FAR struct ipv6_hdr_s *ip = IPv6BUF; FAR struct tcp_conn_s *conn; net_ipv6addr_t *srcipaddr; -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_t *destipaddr; -#endif conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head; srcipaddr = (net_ipv6addr_t *)ip->srcipaddr; -#ifdef CONFIG_NETDEV_MULTINIC destipaddr = (net_ipv6addr_t *)ip->destipaddr; -#endif while (conn) { @@ -459,11 +405,9 @@ static inline FAR struct tcp_conn_s * * number in the received packet. * - The remote port number is checked if the connection is bound * to a remote port. - * - If multiple network interfaces are supported, then the local - * IP address is available and we will insist that the - * destination IP matches the bound address. If a socket is - * bound to INADDRY_ANY, then it should receive all packets - * directed to the port. + * - Insist that the destination IP matches the bound address. If + * a socket is bound to INADDRY_ANY, then it should receive all + * packets directed to the port. * - Finally, if the connection is bound to a remote IP address, * the source IP address of the packet is checked. * @@ -474,10 +418,8 @@ static inline FAR struct tcp_conn_s * if (conn->tcpstateflags != TCP_CLOSED && tcp->destport == conn->lport && tcp->srcport == conn->rport && -#ifdef CONFIG_NETDEV_MULTINIC (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) || net_ipv6addr_cmp(*destipaddr, conn->u.ipv6.laddr)) && -#endif net_ipv6addr_cmp(*srcipaddr, conn->u.ipv6.raddr)) { /* Matching connection found.. break out of the loop and return a @@ -524,14 +466,9 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, /* Verify or select a local port (host byte order) */ -#ifdef CONFIG_NETDEV_MULTINIC port = tcp_selectport(PF_INET, (FAR const union ip_addr_u *)&addr->sin_addr.s_addr, ntohs(addr->sin_port)); -#else - port = tcp_selectport(ntohs(addr->sin_port)); -#endif - if (port < 0) { nerr("ERROR: tcp_selectport failed: %d\n", port); @@ -541,9 +478,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, /* Save the local address in the connection structure (network byte order). */ conn->lport = htons(port); -#ifdef CONFIG_NETDEV_MULTINIC net_ipv4addr_copy(conn->u.ipv4.laddr, addr->sin_addr.s_addr); -#endif /* Find the device that can receive packets on the network associated with * this local address. @@ -559,9 +494,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn, /* Back out the local address setting */ conn->lport = 0; -#ifdef CONFIG_NETDEV_MULTINIC net_ipv4addr_copy(conn->u.ipv4.laddr, INADDR_ANY); -#endif return ret; } @@ -598,20 +531,11 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, /* Verify or select a local port (host byte order) */ -#ifdef CONFIG_NETDEV_MULTINIC /* The port number must be unique for this address binding */ port = tcp_selectport(PF_INET6, (FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16, ntohs(addr->sin6_port)); -#else - /* There is only one network device; the port number can be globally - * unique. - */ - - port = tcp_selectport(ntohs(addr->sin6_port)); -#endif - if (port < 0) { nerr("ERROR: tcp_selectport failed: %d\n", port); @@ -621,9 +545,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, /* Save the local address in the connection structure (network byte order). */ conn->lport = htons(port); -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_copy(conn->u.ipv6.laddr, addr->sin6_addr.in6_u.u6_addr16); -#endif /* Find the device that can receive packets on the network * associated with this local address. @@ -639,9 +561,7 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn, /* Back out the local address setting */ conn->lport = 0; -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_allzeroaddr); -#endif return ret; } @@ -1000,7 +920,6 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, conn->mss = TCP_IPv6_INITIAL_MSS(dev); net_ipv6addr_copy(conn->u.ipv6.raddr, ip->srcipaddr); -#ifdef CONFIG_NETDEV_MULTINIC net_ipv6addr_copy(conn->u.ipv6.laddr, ip->destipaddr); /* We now have to filter all outgoing transfers so that they use @@ -1009,7 +928,6 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, DEBUGASSERT(conn->dev == NULL || conn->dev == dev); conn->dev = dev; -#endif /* Find the device that can receive packets on the network * associated with this local address. @@ -1032,7 +950,6 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, net_ipv4addr_copy(conn->u.ipv4.raddr, net_ip4addr_conv32(ip->srcipaddr)); -#ifdef CONFIG_NETDEV_MULTINIC /* Set the local address as well */ net_ipv4addr_copy(conn->u.ipv4.laddr, @@ -1044,7 +961,6 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct net_driver_s *dev, DEBUGASSERT(conn->dev == NULL || conn->dev == dev); conn->dev = dev; -#endif /* Find the device that can receive packets on the network * associated with this local address. @@ -1201,15 +1117,6 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) net_lock(); -#ifdef CONFIG_NETDEV_MULTINIC - /* If there are multiple network devices, then we need to pass the local, - * bound address. This is needed because port unique-ness is only for a - * given network. - * - * This is complicated by the fact that the local address may be either an - * IPv4 or an IPv6 address. - */ - #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (conn->domain == PF_INET) @@ -1240,16 +1147,6 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr) } #endif /* CONFIG_NET_IPv6 */ -#else /* CONFIG_NETDEV_MULTINIC */ - /* Select the next available port number. This is only one network device - * so we do not have to bother with all of the IPv4/IPv6 local address - * silliness. - */ - - port = tcp_selectport(ntohs(conn->lport)); - -#endif /* CONFIG_NETDEV_MULTINIC */ - /* Did we have a port assignment? */ if (port < 0) diff --git a/net/tcp/tcp_devpoll.c b/net/tcp/tcp_devpoll.c index d292d46473..ee00d7f7d1 100644 --- a/net/tcp/tcp_devpoll.c +++ b/net/tcp/tcp_devpoll.c @@ -91,7 +91,6 @@ void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED) { -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP connection is established and, hence, should be bound * to a device. Make sure that the polling device is the one that * we are bound to. @@ -99,7 +98,6 @@ void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) DEBUGASSERT(conn->dev != NULL); if (dev == conn->dev) -#endif { /* Set up for the callback. We can't know in advance if the * application is going to send a IPv4 or an IPv6 packet, so this diff --git a/net/tcp/tcp_finddev.c b/net/tcp/tcp_finddev.c index d68ccd953a..411e5c9c3d 100644 --- a/net/tcp/tcp_finddev.c +++ b/net/tcp/tcp_finddev.c @@ -73,7 +73,6 @@ #ifdef CONFIG_NET_IPv4 static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr) { -#ifdef CONFIG_NETDEV_MULTINIC /* Do nothing if a device is already bound to the connection */ if (conn->dev != NULL) @@ -92,8 +91,8 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr) return OK; } - /* There are multiple network devices. We need to select the device that - * is going to route the TCP packet based on the provided IP address. + /* We need to select the device that is going to route the TCP packet + * based on the provided IP address. */ conn->dev = netdev_findby_ipv4addr(addr, addr); @@ -101,14 +100,6 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr) /* Return success if we found the device */ return conn->dev != NULL ? OK : -ENETUNREACH; - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return (g_netdevices != NULL) ? OK : -ENETUNREACH; -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -132,7 +123,6 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr) static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn, const net_ipv6addr_t addr) { -#ifdef CONFIG_NETDEV_MULTINIC /* Do nothing if a device is already bound to the connection */ if (conn->dev != NULL) @@ -151,8 +141,8 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn, return OK; } - /* There are multiple network devices. We need to select the device that - * is going to route the TCP packet based on the provided IP address. + /* We need to select the device that is going to route the TCP packet + * based on the provided IP address. */ conn->dev = netdev_findby_ipv6addr(addr, addr); @@ -160,14 +150,6 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn, /* Return success if we found the device */ return conn->dev != NULL ? OK : -ENETUNREACH; -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return (g_netdevices != NULL) ? OK : -ENETUNREACH; -#endif - } #endif /* CONFIG_NET_IPv6 */ @@ -195,11 +177,7 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn, #ifdef CONFIG_NET_IPv4 int tcp_local_ipv4_device(FAR struct tcp_conn_s *conn) { -#ifdef CONFIG_NETDEV_MULTINIC return tcp_find_ipv4_device(conn, conn->u.ipv4.laddr); -#else - return tcp_find_ipv4_device(conn, 0); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -246,11 +224,7 @@ int tcp_remote_ipv4_device(FAR struct tcp_conn_s *conn) #ifdef CONFIG_NET_IPv6 int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn) { -#ifdef CONFIG_NETDEV_MULTINIC return tcp_find_ipv6_device(conn, conn->u.ipv6.laddr); -#else - return tcp_find_ipv6_device(conn, NULL); -#endif } #endif /* CONFIG_NET_IPv6 */ diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 2ee02debfb..d0d736b64c 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -349,7 +349,6 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn; FAR struct socket *psock = (FAR struct socket *)pvpriv; -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP socket is connected and, hence, should be bound to a device. * Make sure that the polling device is the one that we are bound to. */ @@ -359,7 +358,6 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev, { return flags; } -#endif ninfo("flags: %04x\n", flags); @@ -868,11 +866,7 @@ static inline void send_txnotify(FAR struct socket *psock, { /* Notify the device driver that send data is available */ -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -884,11 +878,7 @@ static inline void send_txnotify(FAR struct socket *psock, /* Notify the device driver that send data is available */ DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_txnotify(conn->u.ipv6.raddr); -#endif } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index b2df0b163a..10d0d0a75f 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -300,7 +300,6 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn; FAR struct send_s *pstate = (FAR struct send_s *)pvpriv; -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP socket is connected and, hence, should be bound to a device. * Make sure that the polling device is the one that we are bound to. */ @@ -310,7 +309,6 @@ static uint16_t tcpsend_interrupt(FAR struct net_driver_s *dev, { return flags; } -#endif ninfo("flags: %04x acked: %d sent: %d\n", flags, pstate->snd_acked, pstate->snd_sent); @@ -637,11 +635,7 @@ static inline void send_txnotify(FAR struct socket *psock, { /* Notify the device driver that send data is available */ -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -653,11 +647,7 @@ static inline void send_txnotify(FAR struct socket *psock, /* Notify the device driver that send data is available */ DEBUGASSERT(psock->s_domain == PF_INET6); -#ifdef CONFIG_NETDEV_MULTINIC netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); -#else - netdev_ipv6_txnotify(conn->u.ipv6.raddr); -#endif } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 3c760c1429..eb01092bde 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -146,7 +146,6 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, conn->timer = TCP_TIME_WAIT_TIMEOUT; -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP connection was established and, hence, should be bound * to a device. Make sure that the polling device is the one that * we are bound to. @@ -161,7 +160,6 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, ninfo("TCP: TCP_CLOSED pending\n"); } else -#endif { conn->tcpstateflags = TCP_CLOSED; @@ -202,7 +200,6 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, conn->timer = 0; -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP is connected and, hence, should be bound to a * device. Make sure that the polling device is the one that * we are bound to. @@ -217,7 +214,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, ninfo("TCP: TCP_CLOSED pending\n"); goto done; } -#endif + /* Check for a timeout on connection in the TCP_SYN_RCVD state. * On such timeouts, we would normally resend the SYNACK until * the ACK is received, completing the 3-way handshake. But if @@ -354,7 +351,6 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, * application for new data. */ -#ifdef CONFIG_NETDEV_MULTINIC /* The TCP connection is established and, hence, should be bound * to a device. Make sure that the polling device is the one that * we are bound to. @@ -362,7 +358,6 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, DEBUGASSERT(conn->dev != NULL); if (dev == conn->dev) -#endif { result = tcp_callback(dev, conn, TCP_POLL); tcp_appsend(dev, conn, result); diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 514d2ac059..66b5c011a7 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -130,13 +130,9 @@ static inline void _udp_semtake(FAR sem_t *sem) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static FAR struct udp_conn_s *udp_find_conn(uint8_t domain, FAR union ip_binding_u *ipaddr, uint16_t portno) -#else -static FAR struct udp_conn_s *udp_find_conn(uint16_t portno) -#endif { FAR struct udp_conn_s *conn; int i; @@ -147,7 +143,6 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno) { conn = &g_udp_connections[i]; -#ifdef CONFIG_NETDEV_MULTINIC /* If the port local port number assigned to the connections matches * AND the IP address of the connection matches, then return a * reference to the connection structure. INADDR_ANY is a special @@ -181,17 +176,6 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno) } } #endif /* CONFIG_NET_IPv6 */ - -#else /* CONFIG_NETDEV_MULTINIC */ - /* If the port local port number assigned to the connections matches, - * then return a reference to the connection structure. - */ - - if (conn->lport == portno) - { - return conn; - } -#endif /* CONFIG_NETDEV_MULTINIC */ } return NULL; @@ -217,11 +201,7 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno) * ****************************************************************************/ -#ifdef CONFIG_NETDEV_MULTINIC static uint16_t udp_select_port(uint8_t domain, FAR union ip_binding_u *u) -#else -static uint16_t udp_select_port(void) -#endif { uint16_t portno; @@ -245,11 +225,7 @@ static uint16_t udp_select_port(void) g_last_udp_port = 4096; } } -#ifdef CONFIG_NETDEV_MULTINIC while (udp_find_conn(domain, u, htons(g_last_udp_port))); -#else - while (udp_find_conn(htons(g_last_udp_port))); -#endif /* Initialize and return the connection structure, bind it to the * port number @@ -278,7 +254,7 @@ static inline FAR struct udp_conn_s * udp_ipv4_active(FAR struct net_driver_s *dev, FAR struct udp_hdr_s *udp) { #ifdef CONFIG_NET_BROADCAST - static const inaddr_t bcast = INADDR_BROADCAST; + static const in_addr_t bcast = INADDR_BROADCAST; #endif FAR struct ipv4_hdr_s *ip = IPv4BUF; FAR struct udp_conn_s *conn; @@ -319,7 +295,6 @@ static inline FAR struct udp_conn_s * if (conn->lport != 0 && udp->destport == conn->lport && (conn->rport == 0 || udp->srcport == conn->rport) && -#ifdef CONFIG_NETDEV_MULTINIC /* Local port accepts any address on this port or there * is an exact match in destipaddr and the bound local * address. This catches the receipt of a broadcast when @@ -328,7 +303,7 @@ static inline FAR struct udp_conn_s * (net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY) || net_ipv4addr_hdrcmp(ip->destipaddr, &conn->u.ipv4.laddr)) && -#endif + /* If not connected to a remote address, or a broadcast address * destipaddr was received, or there is an exact match between the * srcipaddr and the bound IP address, then accept the packet. @@ -408,7 +383,6 @@ static inline FAR struct udp_conn_s * if (conn->lport != 0 && udp->destport == conn->lport && (conn->rport == 0 || udp->srcport == conn->rport) && -#ifdef CONFIG_NETDEV_MULTINIC /* Local port accepts any address on this port or there * is an exact match in destipaddr and the bound local * address. This catches the cast of the all nodes multicast @@ -417,7 +391,7 @@ static inline FAR struct udp_conn_s * (net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) || net_ipv6addr_hdrcmp(ip->destipaddr, conn->u.ipv6.laddr)) && -#endif + /* If not connected to a remote address, or a all-nodes multicast * destipaddr was received, or there is an exact match between the * srcipaddr and the bound remote IP address, then accept the @@ -639,14 +613,12 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) portno = inaddr->sin_port; -#ifdef CONFIG_NETDEV_MULTINIC /* Bind the local IP address to the connection. NOTE this address may * be INADDR_ANY meaning, essentially, that we are binding to all * interfaces for receiving (Sending will use the default port). */ net_ipv4addr_copy(conn->u.ipv4.laddr, inaddr->sin_addr.s_addr); -#endif /* CONFIG_NETDEV_MULTINIC */ } #endif /* CONFIG_NET_IPv4 */ @@ -662,14 +634,12 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) portno = inaddr->sin6_port; -#ifdef CONFIG_NETDEV_MULTINIC /* Bind the local IP address to the connection. NOTE this address may * be INADDR_ANY meaning, essentially, that we are binding to all * interfaces for receiving (Sending will use the default port). */ net_ipv6addr_copy(conn->u.ipv6.laddr, inaddr->sin6_addr.in6_u.u6_addr16); -#endif /* CONFIG_NETDEV_MULTINIC */ } #endif /* CONFIG_NET_IPv6 */ @@ -679,11 +649,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) { /* Yes.. Select any unused local port number */ -#ifdef CONFIG_NETDEV_MULTINIC conn->lport = htons(udp_select_port(conn->domain, &conn->u)); -#else - conn->lport = htons(udp_select_port()); -#endif ret = OK; } else @@ -694,11 +660,7 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) /* Is any other UDP connection already bound to this address and port? */ -#ifdef CONFIG_NETDEV_MULTINIC if (!udp_find_conn(conn->domain, &conn->u, portno)) -#else - if (!udp_find_conn(portno)) -#endif { /* No.. then bind the socket to the port */ @@ -749,11 +711,7 @@ int udp_connect(FAR struct udp_conn_s *conn, FAR const struct sockaddr *addr) * connection structure. */ -#ifdef CONFIG_NETDEV_MULTINIC conn->lport = htons(udp_select_port(conn->domain, &conn->u)); -#else - conn->lport = htons(udp_select_port()); -#endif } /* Is there a remote port (rport)? */ diff --git a/net/udp/udp_finddev.c b/net/udp/udp_finddev.c index 7412089ae5..8e2d014ea4 100644 --- a/net/udp/udp_finddev.c +++ b/net/udp/udp_finddev.c @@ -72,7 +72,6 @@ FAR struct net_driver_s *udp_find_ipv4_device(FAR struct udp_conn_s *conn, in_addr_t ipv4addr) { -#ifdef CONFIG_NETDEV_MULTINIC /* Return NULL if the address is INADDR_ANY. In this case, there may * be multiple devices that can provide data so the exceptional events * from any particular device are not important. @@ -86,19 +85,11 @@ FAR struct net_driver_s *udp_find_ipv4_device(FAR struct udp_conn_s *conn, return NULL; } - /* There are multiple network devices. We need to select the device that - * is going to route the UDP packet based on the provided IP address. + /* We need to select the device that is going to route the UDP packet + * based on the provided IP address. */ return netdev_findby_ipv4addr(conn->u.ipv4.laddr, ipv4addr); - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return g_netdevices; -#endif } #endif /* CONFIG_NET_IPv4 */ @@ -121,7 +112,6 @@ FAR struct net_driver_s *udp_find_ipv4_device(FAR struct udp_conn_s *conn, FAR struct net_driver_s *udp_find_ipv6_device(FAR struct udp_conn_s *conn, net_ipv6addr_t ipv6addr) { -#ifdef CONFIG_NETDEV_MULTINIC /* Return NULL if the address is IN6ADDR_ANY. In this case, there may * be multiple devices that can provide data so the exceptional events * from any particular device are not important. @@ -135,19 +125,11 @@ FAR struct net_driver_s *udp_find_ipv6_device(FAR struct udp_conn_s *conn, return NULL; } - /* There are multiple network devices. We need to select the device that - * is going to route the UDP packet based on the provided IP address. + /* We need to select the device that is going to route the UDP packet + * based on the provided IP address. */ return netdev_findby_ipv6addr(conn->u.ipv6.laddr, ipv6addr); - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return g_netdevices; -#endif } #endif /* CONFIG_NET_IPv6 */ @@ -168,7 +150,6 @@ FAR struct net_driver_s *udp_find_ipv6_device(FAR struct udp_conn_s *conn, FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn) { -#ifdef CONFIG_NETDEV_MULTINIC /* There are multiple network devices. We need to select the device that * is going to route the UDP packet based on the provided IP address. */ @@ -190,14 +171,6 @@ FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn) return udp_find_ipv6_device(conn, conn->u.ipv6.laddr); } #endif - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return g_netdevices; -#endif } /**************************************************************************** @@ -217,9 +190,8 @@ FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn) FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn) { -#ifdef CONFIG_NETDEV_MULTINIC - /* There are multiple network devices. We need to select the device that - * is going to route the UDP packet based on the provided IP address. + /* We need to select the device that is going to route the UDP packet + * based on the provided IP address. */ #ifdef CONFIG_NET_IPv4 @@ -239,14 +211,6 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn) return udp_find_ipv6_device(conn, conn->u.ipv6.raddr); } #endif - -#else - /* There is only a single network device... the one at the head of the - * g_netdevices list. - */ - - return g_netdevices; -#endif } #endif /* CONFIG_NET && CONFIG_NET_UDP */