Remove CONFIG_NETDEV_MULTINIC. This increases code size by a little, but greatly reduces the complexity of the network code.

This commit is contained in:
Gregory Nutt
2017-08-08 14:24:12 -06:00
parent d49d6a6aa9
commit bd7c84b23e
55 changed files with 84 additions and 776 deletions
-4
View File
@@ -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
-1
View File
@@ -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
-1
View File
@@ -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
-1
View File
@@ -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
-11
View File
@@ -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.
+2 -13
View File
@@ -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;
-4
View File
@@ -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 */
+2 -3
View File
@@ -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:
-5
View File
@@ -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
-2
View File
@@ -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 */
};
+2 -10
View File
@@ -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.
*/
-2
View File
@@ -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?
+2 -2
View File
@@ -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 */
+2 -2
View File
@@ -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. */
-16
View File
@@ -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;
}
-4
View File
@@ -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");
-4
View File
@@ -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
+2 -15
View File
@@ -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.
-4
View File
@@ -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");
-53
View File
@@ -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(&notify->rn_sem, 0, 0);
sem_setprotocol(&notify->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(&notify->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(&notify->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 */
-8
View File
@@ -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 */
}
-2
View File
@@ -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 */
-2
View File
@@ -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
-10
View File
@@ -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 */
}
-10
View File
@@ -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 */
}
+6 -6
View File
@@ -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
+4 -25
View File
@@ -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)
{
+3 -20
View File
@@ -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)
{
+2 -2
View File
@@ -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
+2 -4
View File
@@ -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
-16
View File
@@ -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
*
+2 -2
View File
@@ -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 */
-2
View File
@@ -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 */
+2 -3
View File
@@ -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 */
+2 -2
View File
@@ -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 */
+4 -23
View File
@@ -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)
{
+5 -20
View File
@@ -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)
{
+4 -38
View File
@@ -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
+2 -46
View File
@@ -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.
-4
View File
@@ -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 */
-18
View File
@@ -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. */
-18
View File
@@ -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. */
+1 -13
View File
@@ -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 */
-3
View File
@@ -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)
+1 -19
View File
@@ -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 */
-14
View File
@@ -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);
}
+8 -31
View File
@@ -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.
+10 -113
View File
@@ -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)
-2
View File
@@ -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
+4 -30
View File
@@ -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 */

Some files were not shown because too many files have changed in this diff Show More