mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
Merge branch 'multinic'
This commit is contained in:
@@ -649,7 +649,6 @@ config SAMA5_GMAC
|
|||||||
default n
|
default n
|
||||||
depends on SAMA5_HAVE_GMAC
|
depends on SAMA5_HAVE_GMAC
|
||||||
select NETDEVICES
|
select NETDEVICES
|
||||||
select NETDEV_MULTINIC if SAMA5_EMAC
|
|
||||||
select ARCH_HAVE_PHY
|
select ARCH_HAVE_PHY
|
||||||
|
|
||||||
config SAMA5_EMACA
|
config SAMA5_EMACA
|
||||||
@@ -657,7 +656,6 @@ config SAMA5_EMACA
|
|||||||
default n
|
default n
|
||||||
depends on SAMA5_HAVE_EMACA
|
depends on SAMA5_HAVE_EMACA
|
||||||
select NETDEVICES
|
select NETDEVICES
|
||||||
select NETDEV_MULTINIC if SAMA5_GMAC
|
|
||||||
select ARCH_HAVE_PHY
|
select ARCH_HAVE_PHY
|
||||||
|
|
||||||
config SAMA5_EMACB
|
config SAMA5_EMACB
|
||||||
@@ -670,7 +668,6 @@ config SAMA5_EMAC0
|
|||||||
depends on SAMA5_HAVE_EMACB
|
depends on SAMA5_HAVE_EMACB
|
||||||
select SAMA5_EMACB
|
select SAMA5_EMACB
|
||||||
select NETDEVICES
|
select NETDEVICES
|
||||||
select NETDEV_MULTINIC if SAMA5_EMAC1
|
|
||||||
select ARCH_HAVE_PHY
|
select ARCH_HAVE_PHY
|
||||||
|
|
||||||
config SAMA5_EMAC1
|
config SAMA5_EMAC1
|
||||||
@@ -679,7 +676,6 @@ config SAMA5_EMAC1
|
|||||||
depends on SAMA5_HAVE_EMACB && SAMA5_HAVE_EMAC1
|
depends on SAMA5_HAVE_EMACB && SAMA5_HAVE_EMAC1
|
||||||
select SAMA5_EMACB
|
select SAMA5_EMACB
|
||||||
select NETDEVICES
|
select NETDEVICES
|
||||||
select NETDEV_MULTINIC if SAMA5_EMAC0
|
|
||||||
select ARCH_HAVE_PHY
|
select ARCH_HAVE_PHY
|
||||||
|
|
||||||
config SAMA5_LCDC
|
config SAMA5_LCDC
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ CONFIG_NET_TCP=y
|
|||||||
CONFIG_NET_TCPBACKLOG=y
|
CONFIG_NET_TCPBACKLOG=y
|
||||||
CONFIG_NET_TUN=y
|
CONFIG_NET_TUN=y
|
||||||
CONFIG_NET=y
|
CONFIG_NET=y
|
||||||
CONFIG_NETDEV_MULTINIC=y
|
|
||||||
CONFIG_NETDEVICES=y
|
CONFIG_NETDEVICES=y
|
||||||
CONFIG_NFILE_DESCRIPTORS=32
|
CONFIG_NFILE_DESCRIPTORS=32
|
||||||
CONFIG_NSH_ARCHINIT=y
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ CONFIG_NET_TCPBACKLOG=y
|
|||||||
CONFIG_NET_UDP=y
|
CONFIG_NET_UDP=y
|
||||||
CONFIG_NET=y
|
CONFIG_NET=y
|
||||||
CONFIG_NETDB_DNSCLIENT=y
|
CONFIG_NETDB_DNSCLIENT=y
|
||||||
CONFIG_NETDEV_MULTINIC=y
|
|
||||||
CONFIG_NETDEV_PHY_IOCTL=y
|
CONFIG_NETDEV_PHY_IOCTL=y
|
||||||
CONFIG_NETDEV_STATISTICS=y
|
CONFIG_NETDEV_STATISTICS=y
|
||||||
CONFIG_NETDEV_TELNET=y
|
CONFIG_NETDEV_TELNET=y
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ CONFIG_NET_TCPBACKLOG=y
|
|||||||
CONFIG_NET_UDP=y
|
CONFIG_NET_UDP=y
|
||||||
CONFIG_NET=y
|
CONFIG_NET=y
|
||||||
CONFIG_NETDB_DNSCLIENT=y
|
CONFIG_NETDB_DNSCLIENT=y
|
||||||
CONFIG_NETDEV_MULTINIC=y
|
|
||||||
CONFIG_NETDEV_PHY_IOCTL=y
|
CONFIG_NETDEV_PHY_IOCTL=y
|
||||||
CONFIG_NETDEV_STATISTICS=y
|
CONFIG_NETDEV_STATISTICS=y
|
||||||
CONFIG_NETDEV_TELNET=y
|
CONFIG_NETDEV_TELNET=y
|
||||||
|
|||||||
@@ -63,16 +63,6 @@ config TELNET_DUMPBUFFER
|
|||||||
|
|
||||||
endif # NETDEV_TELNET
|
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
|
config ARCH_HAVE_NETDEV_STATISTICS
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
@@ -525,7 +515,6 @@ endchoice
|
|||||||
choice
|
choice
|
||||||
prompt "Board PHY Selection (ETH1)"
|
prompt "Board PHY Selection (ETH1)"
|
||||||
default ETH1_PHY_NONE
|
default ETH1_PHY_NONE
|
||||||
depends on NETDEV_MULTINIC
|
|
||||||
---help---
|
---help---
|
||||||
Identify the PHY on your board. This setting is not used by all Ethernet
|
Identify the PHY on your board. This setting is not used by all Ethernet
|
||||||
drivers nor do all Ethernet drivers support all PHYs.
|
drivers nor do all Ethernet drivers support all PHYs.
|
||||||
|
|||||||
@@ -102,9 +102,7 @@ struct phy_notify_s
|
|||||||
{
|
{
|
||||||
bool assigned;
|
bool assigned;
|
||||||
uint8_t signo;
|
uint8_t signo;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
||||||
#endif
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
FAR void *arg;
|
FAR void *arg;
|
||||||
phy_enable_t enable;
|
phy_enable_t enable;
|
||||||
@@ -174,9 +172,7 @@ static FAR struct phy_notify_s *phy_find_unassigned(void)
|
|||||||
|
|
||||||
client->assigned = true;
|
client->assigned = true;
|
||||||
client->signo = 0;
|
client->signo = 0;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
client->intf[0] = '\0';
|
client->intf[0] = '\0';
|
||||||
#endif
|
|
||||||
client->pid = -1;
|
client->pid = -1;
|
||||||
client->arg = NULL;
|
client->arg = NULL;
|
||||||
client->enable = 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++)
|
for (i = 0; i < CONFIG_PHY_NOTIFICATION_NCLIENTS; i++)
|
||||||
{
|
{
|
||||||
client = &g_notify_clients[i];
|
client = &g_notify_clients[i];
|
||||||
if (client->assigned && client->pid == pid
|
if (client->assigned && client->pid == pid &&
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0)
|
||||||
&& strncmp(client->intf, intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN) == 0
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
/* Return the matching client entry to the caller */
|
/* 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->signo = signo;
|
||||||
client->pid = pid;
|
client->pid = pid;
|
||||||
client->arg = arg;
|
client->arg = arg;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf);
|
snprintf(client->intf, CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1, intf);
|
||||||
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
|
client->intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN] = '\0';
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Attach/re-attach the PHY interrupt */
|
/* 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->assigned = false;
|
||||||
client->signo = 0;
|
client->signo = 0;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
client->intf[0] = '\0';
|
client->intf[0] = '\0';
|
||||||
#endif
|
|
||||||
client->pid = -1;
|
client->pid = -1;
|
||||||
client->arg = NULL;
|
client->arg = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -129,9 +129,7 @@ union ip_binding_u
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
in_addr_t laddr; /* The bound local IPv4 address */
|
in_addr_t laddr; /* The bound local IPv4 address */
|
||||||
#endif
|
|
||||||
in_addr_t raddr; /* The IPv4 address of the remote host */
|
in_addr_t raddr; /* The IPv4 address of the remote host */
|
||||||
} ipv4;
|
} ipv4;
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
@@ -141,9 +139,7 @@ union ip_binding_u
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_t laddr; /* The bound local IPv6 address */
|
net_ipv6addr_t laddr; /* The bound local IPv6 address */
|
||||||
#endif
|
|
||||||
net_ipv6addr_t raddr; /* The IPv6 address of the remote host */
|
net_ipv6addr_t raddr; /* The IPv6 address of the remote host */
|
||||||
} ipv6;
|
} ipv6;
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|||||||
@@ -388,9 +388,8 @@ struct sixlowpan_properties_s
|
|||||||
* This is accomplished by "inheriting" the standard 'struct net_driver_s'
|
* This is accomplished by "inheriting" the standard 'struct net_driver_s'
|
||||||
* and appending the frame buffer as well as other metadata needed to
|
* and appending the frame buffer as well as other metadata needed to
|
||||||
* manage the fragmentation. 'struct sixlowpan_driver_s' is cast
|
* manage the fragmentation. 'struct sixlowpan_driver_s' is cast
|
||||||
* compatible with 'struct net_driver_s' when CONFIG_NET_MULTINIC is not
|
* compatible with 'struct net_driver_s' when dev->d_lltype ==
|
||||||
* defined or when dev->d_lltype == NET_LL_IEEE802154 or dev->d_lltype ==
|
* NET_LL_IEEE802154 or dev->d_lltype == NET_LL_PKTRADIO.
|
||||||
* NET_LL_PKTRADIO.
|
|
||||||
*
|
*
|
||||||
* The radio network driver has reponsibility for initializing this
|
* The radio network driver has reponsibility for initializing this
|
||||||
* structure. In general, all fields must be set to NULL. In addition:
|
* structure. In general, all fields must be set to NULL. In addition:
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ config NET_USER_DEVFMT
|
|||||||
config NET_ETHERNET
|
config NET_ETHERNET
|
||||||
bool "Ethernet support"
|
bool "Ethernet support"
|
||||||
default y
|
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
|
select NET_MULTILINK if NET_6LOWPAN || NET_LOOPBACK || NET_SLIP || NET_TUN
|
||||||
---help---
|
---help---
|
||||||
If NET_SLIP is not selected, then Ethernet will be used (there is
|
If NET_SLIP is not selected, then Ethernet will be used (there is
|
||||||
@@ -134,7 +133,6 @@ config NET_ETHERNET
|
|||||||
config NET_6LOWPAN
|
config NET_6LOWPAN
|
||||||
bool "6LoWPAN support"
|
bool "6LoWPAN support"
|
||||||
default n
|
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 NET_ETHERNET || NET_LOOPBACK || NET_SLIP || NET_TUN
|
||||||
select NET_MULTILINK if WIRELESS_IEEE802 && WIRELESS_PKTRADIO
|
select NET_MULTILINK if WIRELESS_IEEE802 && WIRELESS_PKTRADIO
|
||||||
select NETDEV_IOCTL
|
select NETDEV_IOCTL
|
||||||
@@ -147,7 +145,6 @@ config NET_6LOWPAN
|
|||||||
config NET_LOOPBACK
|
config NET_LOOPBACK
|
||||||
bool "Local loopback"
|
bool "Local loopback"
|
||||||
default n
|
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
|
select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_SLIP || NET_TUN
|
||||||
---help---
|
---help---
|
||||||
Add support for the local network loopback device, lo.
|
Add support for the local network loopback device, lo.
|
||||||
@@ -155,7 +152,6 @@ config NET_LOOPBACK
|
|||||||
config NET_SLIP
|
config NET_SLIP
|
||||||
bool "SLIP support"
|
bool "SLIP support"
|
||||||
default n
|
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
|
select NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_TUN
|
||||||
---help---
|
---help---
|
||||||
Enables building of the SLIP driver. SLIP requires
|
Enables building of the SLIP driver. SLIP requires
|
||||||
@@ -202,7 +198,6 @@ endif # NET_SLIP
|
|||||||
config NET_TUN
|
config NET_TUN
|
||||||
bool "TUN Virtual Network Device support"
|
bool "TUN Virtual Network Device support"
|
||||||
default n
|
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 NET_MULTILINK if NET_ETHERNET || NET_6LOWPAN || NET_LOOPBACK || NET_SLIP
|
||||||
select ARCH_HAVE_NETDEV_STATISTICS
|
select ARCH_HAVE_NETDEV_STATISTICS
|
||||||
|
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ struct arp_send_s
|
|||||||
sem_t snd_sem; /* Used to wake up the waiting thread */
|
sem_t snd_sem; /* Used to wake up the waiting thread */
|
||||||
uint8_t snd_retries; /* Retry count */
|
uint8_t snd_retries; /* Retry count */
|
||||||
volatile bool snd_sent; /* True: if request sent */
|
volatile bool snd_sent; /* True: if request sent */
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
||||||
#endif
|
|
||||||
int16_t snd_result; /* The result of the send operation */
|
int16_t snd_result; /* The result of the send operation */
|
||||||
in_addr_t snd_ipaddr; /* The IP address to be queried */
|
in_addr_t snd_ipaddr; /* The IP address to be queried */
|
||||||
};
|
};
|
||||||
|
|||||||
+2
-10
@@ -223,11 +223,7 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
|
|
||||||
/* Get the device that can route this request */
|
/* Get the device that can route this request */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv4addr(INADDR_ANY, ipaddr);
|
dev = netdev_findby_ipv4addr(INADDR_ANY, ipaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv4addr(ipaddr);
|
|
||||||
#endif
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
||||||
@@ -237,10 +233,8 @@ int arp_send(in_addr_t ipaddr)
|
|||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
/* ARP support is only built if the Ethernet data link is supported.
|
/* ARP support is only built if the Ethernet data link is supported.
|
||||||
* However, if we are supporting multiple network devices and using
|
* Continue and send the ARP request only if this device uses the
|
||||||
* different link level protocols then we can get here for other
|
* Ethernet data link protocol.
|
||||||
* link protocols as well. Continue and send the ARP request only
|
|
||||||
* if this device uses the Ethernet data link protocol.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (dev->d_lltype != NET_LL_ETHERNET)
|
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_retries = 0; /* No retries yet */
|
||||||
state.snd_ipaddr = ipaddr; /* IP address to query */
|
state.snd_ipaddr = ipaddr; /* IP address to query */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Remember the routing device name */
|
/* Remember the routing device name */
|
||||||
|
|
||||||
strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname, IFNAMSIZ);
|
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.
|
/* Now loop, testing if the address mapping is in the ARP table and re-sending the ARP request if it is not.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,10 +50,8 @@ endif
|
|||||||
# IP forwarding
|
# IP forwarding
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_IPFORWARD),y)
|
ifeq ($(CONFIG_NET_IPFORWARD),y)
|
||||||
ifeq ($(CONFIG_NETDEV_MULTINIC),y)
|
|
||||||
NET_CSRCS += devif_forward.c
|
NET_CSRCS += devif_forward.c
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
|
|
||||||
# I/O buffer chain support required?
|
# I/O buffer chain support required?
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#include "ipforward/ipforward.h"
|
#include "ipforward/ipforward.h"
|
||||||
#include "devif/devif.h"
|
#include "devif/devif.h"
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
|
#ifdef CONFIG_NET_IPFORWARD
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@@ -92,4 +92,4 @@ void devif_forward(FAR struct forward_s *fwd)
|
|||||||
fwd->f_dev->d_len = offset;
|
fwd->f_dev->d_len = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_IPFORWARD */
|
||||||
|
|||||||
@@ -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,
|
static inline int devif_poll_forward(FAR struct net_driver_s *dev,
|
||||||
devif_poll_callback_t callback)
|
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)
|
if (!bstop)
|
||||||
#endif
|
#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. */
|
/* Traverse all of the tasks waiting to forward a packet to this device. */
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,6 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
static int check_dev_destipaddr(FAR struct net_driver_s *dev, FAR void *arg)
|
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;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: check_destipaddr
|
* 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,
|
static bool check_destipaddr(FAR struct net_driver_s *dev,
|
||||||
FAR struct ipv6_hdr_s *ipv6)
|
FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
int ret;
|
int ret;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* For IPv6, packet reception is a little trickier as we need to make sure
|
/* For IPv6, packet reception is a little trickier as we need to make sure
|
||||||
* that we listen to certain multicast addresses (all hosts multicast
|
* 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* We will also allow for a perverse case where we receive a packet
|
/* 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?
|
* 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;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 */
|
/* Get the device that will be used to route this ICMP ECHO request */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv4addr(INADDR_ANY, addr);
|
dev = netdev_findby_ipv4addr(INADDR_ANY, addr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv4addr(addr);
|
|
||||||
#endif
|
|
||||||
if (dev == 0)
|
if (dev == 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Not reachable\n");
|
nerr("ERROR: Not reachable\n");
|
||||||
|
|||||||
@@ -81,9 +81,7 @@ struct icmpv6_router_s
|
|||||||
sem_t snd_sem; /* Used to wake up the waiting thread */
|
sem_t snd_sem; /* Used to wake up the waiting thread */
|
||||||
volatile bool snd_sent; /* True: if request sent */
|
volatile bool snd_sent; /* True: if request sent */
|
||||||
bool snd_advertise; /* True: Send Neighbor Advertisement */
|
bool snd_advertise; /* True: Send Neighbor Advertisement */
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
||||||
#endif
|
|
||||||
int16_t snd_result; /* Result of the send */
|
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 */
|
(void)sem_init(&state.snd_sem, 0, 0); /* Doesn't really fail */
|
||||||
sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE);
|
sem_setprotocol(&state.snd_sem, SEM_PRIO_NONE);
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Remember the routing device name */
|
/* Remember the routing device name */
|
||||||
|
|
||||||
strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname,
|
strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname,
|
||||||
IFNAMSIZ);
|
IFNAMSIZ);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Allocate resources to receive a callback. This and the following
|
/* Allocate resources to receive a callback. This and the following
|
||||||
* initialization is performed with the network lock because we don't
|
* initialization is performed with the network lock because we don't
|
||||||
|
|||||||
@@ -85,9 +85,7 @@ struct icmpv6_neighbor_s
|
|||||||
sem_t snd_sem; /* Used to wake up the waiting thread */
|
sem_t snd_sem; /* Used to wake up the waiting thread */
|
||||||
uint8_t snd_retries; /* Retry count */
|
uint8_t snd_retries; /* Retry count */
|
||||||
volatile bool snd_sent; /* True: if request sent */
|
volatile bool snd_sent; /* True: if request sent */
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
uint8_t snd_ifname[IFNAMSIZ]; /* Interface name */
|
||||||
#endif
|
|
||||||
net_ipv6addr_t snd_ipaddr; /* The IPv6 address to be queried */
|
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)
|
if (state)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Is this the device that we need to route this request? */
|
/* Is this the device that we need to route this request? */
|
||||||
|
|
||||||
if (strncmp((FAR const char *)dev->d_ifname,
|
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;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if the outgoing packet is available. It may have been claimed
|
/* Check if the outgoing packet is available. It may have been claimed
|
||||||
* by a send interrupt serving a different thread -OR- if the output
|
* by a send interrupt serving a different thread -OR- if the output
|
||||||
* buffer currently contains unprocessed incoming data. In these cases
|
* 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 */
|
/* Get the device that can route this request */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, ipaddr);
|
dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, ipaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv6addr(ipaddr);
|
|
||||||
#endif
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);
|
||||||
@@ -239,10 +230,8 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MULTILINK
|
#ifdef CONFIG_NET_MULTILINK
|
||||||
/* If we are supporting multiple network devices and using different
|
* Continue and send the Neighbor Solicitation request only if this
|
||||||
* link level protocols then we can get here for other link protocols
|
* device uses the Ethernet data link protocol.
|
||||||
* as well. 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
|
* REVISIT: Other link layer protocols may require Neighbor Discovery
|
||||||
* as well (but not SLIP which is the only other option at the moment).
|
* 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 */
|
state.snd_retries = 0; /* No retries yet */
|
||||||
net_ipv6addr_copy(state.snd_ipaddr, lookup); /* IP address to query */
|
net_ipv6addr_copy(state.snd_ipaddr, lookup); /* IP address to query */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Remember the routing device name */
|
/* Remember the routing device name */
|
||||||
|
|
||||||
strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname,
|
strncpy((FAR char *)state.snd_ifname, (FAR const char *)dev->d_ifname,
|
||||||
IFNAMSIZ);
|
IFNAMSIZ);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Now loop, testing if the address mapping is in the Neighbor Table and
|
/* Now loop, testing if the address mapping is in the Neighbor Table and
|
||||||
* re-sending the Neighbor Solicitation if it is not.
|
* re-sending the Neighbor Solicitation if it is not.
|
||||||
|
|||||||
@@ -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 */
|
/* 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);
|
dev = netdev_findby_ipv6addr(g_ipv6_allzeroaddr, addr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv6addr(addr);
|
|
||||||
#endif
|
|
||||||
if (dev == 0)
|
if (dev == 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: Not reachable\n");
|
nerr("ERROR: Not reachable\n");
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ static void icmpv6_setaddresses(FAR struct net_driver_s *dev,
|
|||||||
void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
|
void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
|
||||||
FAR struct icmpv6_rnotify_s *notify)
|
FAR struct icmpv6_rnotify_s *notify)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
/* Initialize the wait structure */
|
/* Initialize the wait structure */
|
||||||
@@ -181,26 +180,6 @@ void icmpv6_rwait_setup(FAR struct net_driver_s *dev,
|
|||||||
notify->rn_flink = g_icmpv6_rwaiters;
|
notify->rn_flink = g_icmpv6_rwaiters;
|
||||||
g_icmpv6_rwaiters = notify;
|
g_icmpv6_rwaiters = notify;
|
||||||
leave_critical_section(flags);
|
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)
|
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 *curr;
|
||||||
FAR struct icmpv6_rnotify_s *prev;
|
FAR struct icmpv6_rnotify_s *prev;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
@@ -254,18 +232,6 @@ int icmpv6_rwait_cancel(FAR struct icmpv6_rnotify_s *notify)
|
|||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
(void)sem_destroy(¬ify->rn_sem);
|
(void)sem_destroy(¬ify->rn_sem);
|
||||||
return ret;
|
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,
|
void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr,
|
||||||
const net_ipv6addr_t prefix, unsigned int preflen)
|
const net_ipv6addr_t prefix, unsigned int preflen)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct icmpv6_rnotify_s *curr;
|
FAR struct icmpv6_rnotify_s *curr;
|
||||||
|
|
||||||
ninfo("Notified\n");
|
ninfo("Notified\n");
|
||||||
@@ -373,24 +338,6 @@ void icmpv6_rnotify(FAR struct net_driver_s *dev, const net_ipv6addr_t draddr,
|
|||||||
break;
|
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 */
|
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||||
|
|||||||
@@ -291,11 +291,7 @@ static inline void tcp_close_txnotify(FAR struct socket *psock,
|
|||||||
{
|
{
|
||||||
/* Notify the device driver that send data is available */
|
/* Notify the device driver that send data is available */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#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 */
|
/* Notify the device driver that send data is available */
|
||||||
|
|
||||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv6_txnotify(conn->u.ipv6.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,6 @@ static uint16_t psock_connect_interrupt(FAR struct net_driver_s *dev,
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* We now have to filter all outgoing transfers so that they use only
|
/* We now have to filter all outgoing transfers so that they use only
|
||||||
* the MSS of this device.
|
* 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);
|
||||||
pstate->tc_conn->dev = dev;
|
pstate->tc_conn->dev = dev;
|
||||||
|
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
|
||||||
#endif /* CONFIG_NET_MULTILINK */
|
#endif /* CONFIG_NET_MULTILINK */
|
||||||
|
|
||||||
/* Wake up the waiting thread */
|
/* Wake up the waiting thread */
|
||||||
|
|||||||
@@ -164,14 +164,12 @@ static uint16_t connection_event(FAR struct net_driver_s *dev,
|
|||||||
else if ((flags & TCP_CONNECTED) != 0)
|
else if ((flags & TCP_CONNECTED) != 0)
|
||||||
{
|
{
|
||||||
#if 0 /* REVISIT: Assertion fires. Why? */
|
#if 0 /* REVISIT: Assertion fires. Why? */
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
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 */
|
/* Make sure that this is the device bound to the connection */
|
||||||
|
|
||||||
DEBUGASSERT(conn->dev == NULL || conn->dev == dev);
|
DEBUGASSERT(conn->dev == NULL || conn->dev == dev);
|
||||||
conn->dev = dev;
|
conn->dev = dev;
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If there is no local address assigned to the socket (perhaps
|
/* If there is no local address assigned to the socket (perhaps
|
||||||
|
|||||||
@@ -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;
|
FAR struct inet_recvfrom_s *pstate = (struct inet_recvfrom_s *)pvpriv;
|
||||||
|
|
||||||
#if 0 /* REVISIT: The assertion fires. Why? */
|
#if 0 /* REVISIT: The assertion fires. Why? */
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct tcp_conn_s *conn = (FAR struct tcp_conn_s *)pvconn;
|
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.
|
/* 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;
|
return flags;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ninfo("flags: %04x\n", flags);
|
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 */
|
/* Notify the device driver of the receive ready */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv4_rxnotify(conn->u.ipv4.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#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 */
|
/* Notify the device driver of the receive ready */
|
||||||
|
|
||||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv6_rxnotify(conn->u.ipv6.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
FAR struct sendfile_s *pstate = (FAR struct sendfile_s *)pvpriv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* The TCP socket is connected and, hence, should be bound to a device.
|
/* 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.
|
* 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;
|
return flags;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
ninfo("flags: %04x acked: %d sent: %d\n",
|
ninfo("flags: %04x acked: %d sent: %d\n",
|
||||||
flags, pstate->snd_acked, pstate->snd_sent);
|
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 */
|
/* Notify the device driver that send data is available */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv4_txnotify(conn->u.ipv4.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#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 */
|
/* Notify the device driver that send data is available */
|
||||||
|
|
||||||
DEBUGASSERT(psock->s_domain == PF_INET6);
|
DEBUGASSERT(psock->s_domain == PF_INET6);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||||
#else
|
|
||||||
netdev_ipv6_txnotify(conn->u.ipv6.raddr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* TCP/IP packet send */
|
/* TCP/IP packet send */
|
||||||
|
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
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)
|
#elif defined(NET_TCP_HAVE_STACK)
|
||||||
ret = psock_tcp_send(psock, buf, len);
|
ret = psock_tcp_send(psock, buf, len);
|
||||||
#else
|
#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);
|
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)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
/* UDP/IP packet send */
|
/* UDP/IP packet send */
|
||||||
|
|
||||||
ret = psock_udp_send(psock, buf, len);
|
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)
|
#elif defined(NET_UDP_HAVE_STACK)
|
||||||
/* Only UDP/IP packet send */
|
/* 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);
|
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)
|
if (nsent < 0)
|
||||||
{
|
{
|
||||||
/* UDP/IP packet sendto */
|
/* UDP/IP packet sendto */
|
||||||
|
|
||||||
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
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)
|
#elif defined(NET_UDP_HAVE_STACK)
|
||||||
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
nsent = psock_udp_sendto(psock, buf, len, flags, to, tolen);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -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 sockaddr_in *outaddr = (FAR struct sockaddr_in *)addr;
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
in_addr_t lipaddr;
|
in_addr_t lipaddr;
|
||||||
in_addr_t ripaddr;
|
in_addr_t ripaddr;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if enough space has been provided for the full address */
|
/* 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;
|
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 */
|
outaddr->sin_port = tcp_conn->lport; /* Already in network byte order */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
lipaddr = tcp_conn->u.ipv4.laddr;
|
lipaddr = tcp_conn->u.ipv4.laddr;
|
||||||
ripaddr = tcp_conn->u.ipv4.raddr;
|
ripaddri = tcp_conn->u.ipv4.raddr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#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;
|
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 */
|
outaddr->sin_port = udp_conn->lport; /* Already in network byte order */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
lipaddr = udp_conn->u.ipv4.laddr;
|
lipaddr = udp_conn->u.ipv4.laddr;
|
||||||
ripaddr = udp_conn->u.ipv4.raddr;
|
ripaddr = udp_conn->u.ipv4.raddr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -138,12 +130,6 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
return -EOPNOTSUPP;
|
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)
|
if (lipaddr == 0)
|
||||||
{
|
{
|
||||||
outaddr->sin_family = psock->s_domain;
|
outaddr->sin_family = psock->s_domain;
|
||||||
@@ -152,11 +138,9 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
net_lock();
|
net_lock();
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Find the device matching the IPv4 address in the connection structure.
|
/* Find the device matching the IPv4 address in the connection structure.
|
||||||
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
||||||
* lipaddr when ripaddr is not available.
|
* 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);
|
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)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 sockaddr_in6 *outaddr = (FAR struct sockaddr_in6 *)addr;
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_t *lipaddr;
|
net_ipv6addr_t *lipaddr;
|
||||||
net_ipv6addr_t *ripaddr;
|
net_ipv6addr_t *ripaddr;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if enough space has been provided for the full address */
|
/* 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:
|
case SOCK_STREAM:
|
||||||
{
|
{
|
||||||
FAR struct tcp_conn_s *tcp_conn = (FAR struct tcp_conn_s *)psock->s_conn;
|
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;
|
lipaddr = &tcp_conn->u.ipv6.laddr;
|
||||||
ripaddr = &tcp_conn->u.ipv6.raddr;
|
ripaddr = &tcp_conn->u.ipv6.raddr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -122,12 +118,10 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
case SOCK_DGRAM:
|
case SOCK_DGRAM:
|
||||||
{
|
{
|
||||||
FAR struct udp_conn_s *udp_conn = (FAR struct udp_conn_s *)psock->s_conn;
|
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;
|
lipaddr = &udp_conn->u.ipv6.laddr;
|
||||||
ripaddr = &udp_conn->u.ipv6.raddr;
|
ripaddr = &udp_conn->u.ipv6.raddr;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@@ -136,11 +130,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
/* Check if bound to local INADDR6_ANY */
|
||||||
/* 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 (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
net_lock();
|
net_lock();
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Find the device matching the IPv6 address in the connection structure.
|
/* Find the device matching the IPv6 address in the connection structure.
|
||||||
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
* NOTE: listening sockets have no ripaddr. Work around is to use the
|
||||||
* lipaddr when ripaddr is not available.
|
* 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);
|
dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr);
|
||||||
#else
|
|
||||||
/* There is only one, the first network device in the list. */
|
|
||||||
|
|
||||||
dev = g_netdevices;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ config NET_IPFORWARD
|
|||||||
config NET_IPFORWARD_BROADCAST
|
config NET_IPFORWARD_BROADCAST
|
||||||
bool "Forward broadcast/multicast packets"
|
bool "Forward broadcast/multicast packets"
|
||||||
default n
|
default n
|
||||||
depends on NET_IPFORWARD && NETDEV_MULTINIC
|
depends on NET_IPFORWARD
|
||||||
---help---
|
---help---
|
||||||
If selected, broadcast packets received on one network device will
|
If selected, broadcast packets received on one network device will
|
||||||
be forwarded though other network devices.
|
be forwarded though other network devices.
|
||||||
@@ -22,7 +22,7 @@ config NET_IPFORWARD_BROADCAST
|
|||||||
config NET_IPFORWARD_NSTRUCT
|
config NET_IPFORWARD_NSTRUCT
|
||||||
int "Number of pre-allocated forwarding structures"
|
int "Number of pre-allocated forwarding structures"
|
||||||
default 4
|
default 4
|
||||||
depends on NET_IPFORWARD && NETDEV_MULTINIC
|
depends on NET_IPFORWARD
|
||||||
---help---
|
---help---
|
||||||
When packets are forwarded from on device to another, a structure
|
When packets are forwarded from on device to another, a structure
|
||||||
must be allocated to hold the state of forwarding across several
|
must be allocated to hold the state of forwarding across several
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
ifeq ($(CONFIG_NET_IPFORWARD),y)
|
ifeq ($(CONFIG_NET_IPFORWARD),y)
|
||||||
|
|
||||||
|
NET_CSRCS += ipfwd_alloc.c ipfwd_forward.c ipfwd_poll.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_IPv4),y)
|
ifeq ($(CONFIG_NET_IPv4),y)
|
||||||
NET_CSRCS += ipv4_forward.c
|
NET_CSRCS += ipv4_forward.c
|
||||||
endif
|
endif
|
||||||
@@ -45,10 +47,6 @@ ifeq ($(CONFIG_NET_IPv6),y)
|
|||||||
NET_CSRCS += ipv6_forward.c
|
NET_CSRCS += ipv6_forward.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_NETDEV_MULTINIC),y)
|
|
||||||
NET_CSRCS += ipfwd_alloc.c ipfwd_forward.c ipfwd_poll.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_NET_STATISTICS),y)
|
ifeq ($(CONFIG_NET_STATISTICS),y)
|
||||||
NET_CSRCS += ipfwd_dropstats.c
|
NET_CSRCS += ipfwd_dropstats.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -47,12 +47,6 @@
|
|||||||
#undef HAVE_FWDALLOC
|
#undef HAVE_FWDALLOC
|
||||||
#ifdef CONFIG_NET_IPFORWARD
|
#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
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -279,16 +273,6 @@ void ipfwd_dropstats(FAR struct forward_s *fwd);
|
|||||||
# define ipfwd_dropstats(fwd)
|
# define ipfwd_dropstats(fwd)
|
||||||
#endif
|
#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
|
* Name: ipv4_forward
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
#include "ipforward/ipforward.h"
|
#include "ipforward/ipforward.h"
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
|
#ifdef CONFIG_NET_IPFORWARD
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@@ -170,4 +170,4 @@ void ipfwd_free(FAR struct forward_s *fwd)
|
|||||||
g_fwdfree = fwd;
|
g_fwdfree = fwd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_IPFORWARD */
|
||||||
|
|||||||
@@ -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)
|
void ipfwd_dropstats(FAR struct forward_s *fwd)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
@@ -194,6 +193,5 @@ void ipfwd_dropstats(FAR struct forward_s *fwd)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_STATISTICS */
|
#endif /* CONFIG_NET_IPFORWARD && CONFIG_NET_STATISTICS */
|
||||||
|
|||||||
@@ -55,8 +55,7 @@
|
|||||||
#include "neighbor/neighbor.h"
|
#include "neighbor/neighbor.h"
|
||||||
#include "ipforward/ipforward.h"
|
#include "ipforward/ipforward.h"
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
|
#ifdef CONFIG_NET_IPFORWARD
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -349,4 +348,4 @@ int ipfwd_forward(FAR struct forward_s *fwd)
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_IPFORWARD && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_IPFORWARD */
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
#include "devif/devif.h"
|
#include "devif/devif.h"
|
||||||
#include "ipforward/ipforward.h"
|
#include "ipforward/ipforward.h"
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC)
|
#ifdef CONFIG_NET_IPFORWARD
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@@ -206,4 +206,4 @@ void ipfwd_poll(FAR struct net_driver_s *dev)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET_ARP_SEND && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_ARP_SEND */
|
||||||
|
|||||||
@@ -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)
|
static int ipv4_hdrsize(FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
/* Size is determined by the following protocol header, */
|
/* 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)
|
static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
uint16_t sum;
|
uint16_t sum;
|
||||||
@@ -185,7 +184,6 @@ static int ipv4_decr_ttl(FAR struct ipv4_hdr_s *ipv4)
|
|||||||
ipv4->ipchksum = ~sum;
|
ipv4->ipchksum = ~sum;
|
||||||
return ttl;
|
return ttl;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ipv4_dev_forward
|
* 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,
|
static int ipv4_dev_forward(FAR struct net_driver_s *dev,
|
||||||
FAR struct net_driver_s *fwddev,
|
FAR struct net_driver_s *fwddev,
|
||||||
FAR struct ipv4_hdr_s *ipv4)
|
FAR struct ipv4_hdr_s *ipv4)
|
||||||
@@ -338,7 +335,6 @@ errout_with_fwd:
|
|||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ipv4_forward_callback
|
* Name: ipv4_forward_callback
|
||||||
@@ -360,8 +356,7 @@ errout:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \
|
#ifdef CONFIG_NET_IPFORWARD_BROADCAST
|
||||||
defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
int ipv4_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg)
|
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;
|
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)
|
int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
in_addr_t destipaddr;
|
in_addr_t destipaddr;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
in_addr_t srcipaddr;
|
in_addr_t srcipaddr;
|
||||||
#endif
|
|
||||||
FAR struct net_driver_s *fwddev;
|
FAR struct net_driver_s *fwddev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Search for a device that can forward this packet. This is a trivial
|
/* Search for a device that can forward this packet. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
destipaddr = net_ip4addr_conv32(ipv4->destipaddr);
|
destipaddr = net_ip4addr_conv32(ipv4->destipaddr);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr);
|
srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr);
|
||||||
|
|
||||||
fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr);
|
fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr);
|
||||||
#else
|
|
||||||
fwddev = netdev_findby_ipv4addr(destipaddr);
|
|
||||||
#endif
|
|
||||||
if (fwddev == NULL)
|
if (fwddev == NULL)
|
||||||
{
|
{
|
||||||
nwarn("WARNING: Not routable\n");
|
nwarn("WARNING: Not routable\n");
|
||||||
return (ssize_t)-ENETUNREACH;
|
return (ssize_t)-ENETUNREACH;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
/* Check if we are forwarding on the same device that we received the
|
/* Check if we are forwarding on the same device that we received the
|
||||||
* packet from.
|
* packet from.
|
||||||
*/
|
*/
|
||||||
@@ -475,8 +459,6 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
|
||||||
|
|
||||||
{
|
{
|
||||||
/* Single network device. The use case here is where an endpoint acts
|
/* 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
|
* 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) && \
|
#ifdef CONFIG_NET_IPFORWARD_BROADCAST
|
||||||
defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
void ipv4_forward_broadcast(FAR struct net_driver_s *dev,
|
void ipv4_forward_broadcast(FAR struct net_driver_s *dev,
|
||||||
FAR struct ipv4_hdr_s *ipv4)
|
FAR struct ipv4_hdr_s *ipv4)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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)
|
static int ipv6_hdrsize(FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
/* Size is determined by the following protocol header, */
|
/* 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)
|
static int ipv6_decr_ttl(FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
int ttl = (int)ipv6->ttl - 1;
|
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,
|
static int ipv6_dev_forward(FAR struct net_driver_s *dev,
|
||||||
FAR struct net_driver_s *fwddev,
|
FAR struct net_driver_s *fwddev,
|
||||||
FAR struct ipv6_hdr_s *ipv6)
|
FAR struct ipv6_hdr_s *ipv6)
|
||||||
@@ -482,7 +481,6 @@ errout_with_fwd:
|
|||||||
errout:
|
errout:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: ipv6_forward_callback
|
* Name: ipv6_forward_callback
|
||||||
@@ -504,8 +502,7 @@ errout:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \
|
#ifdef CONFIG_NET_IPFORWARD_BROADCAST
|
||||||
defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
int ipv6_forward_callback(FAR struct net_driver_s *fwddev, FAR void *arg)
|
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;
|
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;
|
FAR struct net_driver_s *fwddev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Search for a device that can forward this packet. This is a trivial
|
/* Search for a device that can forward this packet. */
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
fwddev = netdev_findby_ipv6addr(ipv6->srcipaddr, ipv6->destipaddr);
|
fwddev = netdev_findby_ipv6addr(ipv6->srcipaddr, ipv6->destipaddr);
|
||||||
#else
|
|
||||||
fwddev = netdev_findby_ipv6addr(ipv6->destipaddr);
|
|
||||||
#endif
|
|
||||||
if (fwddev == NULL)
|
if (fwddev == NULL)
|
||||||
{
|
{
|
||||||
nwarn("WARNING: Not routable\n");
|
nwarn("WARNING: Not routable\n");
|
||||||
return (ssize_t)-ENETUNREACH;
|
return (ssize_t)-ENETUNREACH;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
/* Check if we are forwarding on the same device that we received the
|
/* Check if we are forwarding on the same device that we received the
|
||||||
* packet from.
|
* packet from.
|
||||||
*/
|
*/
|
||||||
@@ -612,8 +600,6 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* CONFIG_NETDEV_MULTINIC */
|
|
||||||
|
|
||||||
#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */
|
#if defined(CONFIG_NET_6LOWPAN) /* REVISIT: Currently only suport for 6LoWPAN */
|
||||||
{
|
{
|
||||||
/* Single network device. The use case here is where an endpoint acts
|
/* Single network device. The use case here is where an endpoint acts
|
||||||
@@ -705,8 +691,7 @@ drop:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if defined(CONFIG_NET_IPFORWARD_BROADCAST) && \
|
#ifdef CONFIG_NET_IPFORWARD_BROADCAST
|
||||||
defined(CONFIG_NETDEV_MULTINIC)
|
|
||||||
void ipv6_forward_broadcast(FAR struct net_driver_s *dev,
|
void ipv6_forward_broadcast(FAR struct net_driver_s *dev,
|
||||||
FAR struct ipv6_hdr_s *ipv6)
|
FAR struct ipv6_hdr_s *ipv6)
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-36
@@ -184,8 +184,7 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
|
|||||||
* IPv4 address.
|
* IPv4 address.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
* lipaddr - Local, bound address of a connection.
|
||||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
|
||||||
* ripaddr - Remote address of a connection to use in the lookup
|
* ripaddr - Remote address of a connection to use in the lookup
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@@ -198,12 +197,8 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
|
|||||||
|
|
||||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
||||||
in_addr_t ripaddr);
|
in_addr_t ripaddr);
|
||||||
#else
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -214,8 +209,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
|||||||
* IPv6 address.
|
* IPv6 address.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
* lipaddr - Local, bound address of a connection.
|
||||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
|
||||||
* ripaddr - Remote address of a connection to use in the lookup
|
* ripaddr - Remote address of a connection to use in the lookup
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@@ -227,12 +221,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
||||||
const net_ipv6addr_t ripaddr);
|
const net_ipv6addr_t ripaddr);
|
||||||
#else
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -309,11 +299,7 @@ FAR struct net_driver_s *netdev_default(void);
|
|||||||
|
|
||||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
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 */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -336,12 +322,8 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
FAR const net_ipv6addr_t ripaddr);
|
FAR const net_ipv6addr_t ripaddr);
|
||||||
# else
|
|
||||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
|
|
||||||
# endif
|
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
|
#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)
|
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
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 */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -415,29 +393,17 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr);
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
FAR const net_ipv6addr_t ripaddr);
|
FAR const net_ipv6addr_t ripaddr);
|
||||||
# else
|
|
||||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
|
|
||||||
# endif
|
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
|
# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
|
||||||
# else
|
|
||||||
# define netdev_ipv4_rxnotify(ripaddr)
|
|
||||||
# endif
|
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
|
# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
|
||||||
# else
|
|
||||||
# define netdev_ipv6_rxnotify(ripaddr)
|
|
||||||
# endif
|
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -179,8 +179,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
|
|||||||
* IPv4 address.
|
* IPv4 address.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
* lipaddr - Local, bound address of a connection.
|
||||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
|
||||||
* ripaddr - Remote address of a connection to use in the lookup
|
* ripaddr - Remote address of a connection to use in the lookup
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@@ -192,12 +191,8 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
||||||
in_addr_t ripaddr)
|
in_addr_t ripaddr)
|
||||||
#else
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
struct net_driver_s *dev;
|
struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NET_ROUTE
|
#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))
|
if (net_ipv4addr_cmp(ripaddr, INADDR_BROADCAST))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||||
|
|
||||||
if (net_ipv4addr_cmp(lipaddr, 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);
|
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 */
|
/* 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.
|
* 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
|
/* 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
|
* because we are not configured properly to determine the route to the
|
||||||
* destination.
|
* destination.
|
||||||
@@ -301,8 +279,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
|||||||
* IPv6 address.
|
* IPv6 address.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
* lipaddr - Local, bound address of a connection.
|
||||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
|
||||||
* ripaddr - Remote address of a connection to use in the lookup
|
* ripaddr - Remote address of a connection to use in the lookup
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
@@ -314,12 +291,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
||||||
const net_ipv6addr_t ripaddr)
|
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;
|
struct net_driver_s *dev;
|
||||||
#ifdef CONFIG_NET_ROUTE
|
#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))
|
if (ripaddr[0] == HTONS(0xff02))
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||||
|
|
||||||
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
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);
|
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 */
|
/* 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.
|
* 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
|
/* 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
|
* because we are not configured properly to determine the route to the
|
||||||
* destination.
|
* destination.
|
||||||
|
|||||||
@@ -76,7 +76,6 @@
|
|||||||
|
|
||||||
FAR struct net_driver_s *netdev_findbyindex(int index)
|
FAR struct net_driver_s *netdev_findbyindex(int index)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -92,9 +91,6 @@ FAR struct net_driver_s *netdev_findbyindex(int index)
|
|||||||
|
|
||||||
net_unlock();
|
net_unlock();
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
|
||||||
return (index == 0) ? g_netdevices : NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||||
|
|||||||
@@ -74,22 +74,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
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;
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
/* Find the device driver that serves the subnet of the remote address */
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv4addr(ripaddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dev && dev->d_rxavail)
|
if (dev && dev->d_rxavail)
|
||||||
{
|
{
|
||||||
/* Notify the device driver that new RX data is available. */
|
/* 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_NET_IPv6
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
FAR const net_ipv6addr_t ripaddr)
|
FAR const net_ipv6addr_t ripaddr)
|
||||||
#else
|
|
||||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
/* Find the device driver that serves the subnet of the remote address */
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv6addr(ripaddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dev && dev->d_rxavail)
|
if (dev && dev->d_rxavail)
|
||||||
{
|
{
|
||||||
/* Notify the device driver that new RX data is available. */
|
/* Notify the device driver that new RX data is available. */
|
||||||
|
|||||||
@@ -74,22 +74,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
# ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
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;
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
/* Find the device driver that serves the subnet of the remote address */
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv4addr(ripaddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dev && dev->d_txavail)
|
if (dev && dev->d_txavail)
|
||||||
{
|
{
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* 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_NET_IPv6
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||||
FAR const net_ipv6addr_t ripaddr)
|
FAR const net_ipv6addr_t ripaddr)
|
||||||
#else
|
|
||||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
|
|
||||||
/* Find the device driver that serves the subnet of the remote address */
|
/* Find the device driver that serves the subnet of the remote address */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||||
#else
|
|
||||||
dev = netdev_findby_ipv6addr(ripaddr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dev && dev->d_txavail)
|
if (dev && dev->d_txavail)
|
||||||
{
|
{
|
||||||
/* Notify the device driver that new TX data is available. */
|
/* Notify the device driver that new TX data is available. */
|
||||||
|
|||||||
+1
-13
@@ -65,23 +65,11 @@
|
|||||||
|
|
||||||
FAR struct net_driver_s *pkt_find_device(FAR struct pkt_conn_s *conn)
|
FAR struct net_driver_s *pkt_find_device(FAR struct pkt_conn_s *conn)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
FAR struct net_driver_s *dev;
|
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");
|
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 */
|
#endif /* CONFIG_NET && CONFIG_NET_PKT */
|
||||||
|
|||||||
@@ -172,14 +172,11 @@ static uint16_t send_interrupt(FAR struct net_driver_s *dev,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* REVISIT: Verify that this is the correct IEEE802.15.4 network driver to
|
/* 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
|
* route the outgoing frame(s). Chances are that there is only one
|
||||||
* IEEE802.15.4 network driver
|
* IEEE802.15.4 network driver
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if the IEEE802.15.4 network driver went down */
|
/* Check if the IEEE802.15.4 network driver went down */
|
||||||
|
|
||||||
if ((flags & NETDEV_DOWN) != 0)
|
if ((flags & NETDEV_DOWN) != 0)
|
||||||
|
|||||||
@@ -219,13 +219,11 @@ static int sixlowpan_tcp_header(FAR struct tcp_conn_s *conn,
|
|||||||
/* Copy the source and destination addresses */
|
/* Copy the source and destination addresses */
|
||||||
|
|
||||||
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.destipaddr, conn->u.ipv6.raddr);
|
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))
|
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, conn->u.ipv6.laddr);
|
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, conn->u.ipv6.laddr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6tcp->ipv6.srcipaddr, dev->d_ipv6addr);
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* The TCP socket is connected and, hence, should be bound to a device.
|
/* 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.
|
* 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);
|
DEBUGASSERT(conn->dev != NULL);
|
||||||
if (dev != conn->dev)
|
if (dev != conn->dev)
|
||||||
{
|
{
|
||||||
ninfo("Not the connecte device\n");
|
ninfo("Not the connected device\n");
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Check if the IEEE802.15.4 network driver went down */
|
/* 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 */
|
/* 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);
|
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
{
|
{
|
||||||
@@ -823,17 +816,6 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
||||||
/* Make sure that the IP address mapping is in the Neighbor Table */
|
/* Make sure that the IP address mapping is in the Neighbor Table */
|
||||||
|
|
||||||
|
|||||||
@@ -205,9 +205,6 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
|||||||
|
|
||||||
/* Route outgoing message to the correct device */
|
/* Route outgoing message to the correct device */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* There are multiple network devices */
|
|
||||||
|
|
||||||
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr,
|
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr,
|
||||||
to6->sin6_addr.in6_u.u6_addr16);
|
to6->sin6_addr.in6_u.u6_addr16);
|
||||||
if (dev == NULL)
|
if (dev == NULL)
|
||||||
@@ -229,15 +226,6 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
|
|||||||
}
|
}
|
||||||
#endif
|
#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
|
#ifdef CONFIG_NET_ICMPv6_NEIGHBOR
|
||||||
/* Make sure that the IP address mapping is in the Neighbor Table */
|
/* 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 */
|
/* Copy the source and destination addresses */
|
||||||
|
|
||||||
net_ipv6addr_hdrcopy(ipv6udp.ipv6.destipaddr, to6->sin6_addr.in6_u.u6_addr16);
|
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))
|
if (!net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr))
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, conn->u.ipv6.laddr);
|
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, conn->u.ipv6.laddr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, dev->d_ipv6addr);
|
net_ipv6addr_hdrcopy(ipv6udp.ipv6.srcipaddr, dev->d_ipv6addr);
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-27
@@ -65,45 +65,24 @@
|
|||||||
|
|
||||||
/* Allocate a new TCP data callback */
|
/* Allocate a new TCP data callback */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* These macros allocate and free callback structures used for receiving
|
/* These macros allocate and free callback structures used for receiving
|
||||||
* notifications of TCP data-related events.
|
* notifications of TCP data-related events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# define tcp_callback_alloc(conn) \
|
#define tcp_callback_alloc(conn) \
|
||||||
devif_callback_alloc((conn)->dev, &(conn)->list)
|
devif_callback_alloc((conn)->dev, &(conn)->list)
|
||||||
# define tcp_callback_free(conn,cb) \
|
#define tcp_callback_free(conn,cb) \
|
||||||
devif_conn_callback_free((conn)->dev, (cb), &(conn)->list)
|
devif_conn_callback_free((conn)->dev, (cb), &(conn)->list)
|
||||||
|
|
||||||
/* These macros allocate and free callback structures used for receiving
|
/* These macros allocate and free callback structures used for receiving
|
||||||
* notifications of device-related events.
|
* notifications of device-related events.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# define tcp_monitor_callback_alloc(conn) \
|
#define tcp_monitor_callback_alloc(conn) \
|
||||||
devif_callback_alloc((conn)->dev, NULL)
|
devif_callback_alloc((conn)->dev, NULL)
|
||||||
# define tcp_monitor_callback_free(conn,cb) \
|
#define tcp_monitor_callback_free(conn,cb) \
|
||||||
devif_conn_callback_free((conn)->dev, (cb), NULL)
|
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
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||||
/* TCP write buffer access macros */
|
/* TCP write buffer access macros */
|
||||||
|
|
||||||
@@ -175,14 +154,12 @@ struct tcp_conn_s
|
|||||||
uint16_t unacked; /* Number bytes sent but not yet ACKed */
|
uint16_t unacked; /* Number bytes sent but not yet ACKed */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* If the TCP socket is bound to a local address, then this is
|
/* If the TCP socket is bound to a local address, then this is
|
||||||
* a reference to the device that routes traffic on the corresponding
|
* a reference to the device that routes traffic on the corresponding
|
||||||
* network.
|
* network.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_TCP_READAHEAD
|
#ifdef CONFIG_NET_TCP_READAHEAD
|
||||||
/* Read-ahead buffering.
|
/* Read-ahead buffering.
|
||||||
|
|||||||
+10
-113
@@ -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,
|
static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr,
|
||||||
uint16_t portno)
|
uint16_t portno)
|
||||||
{
|
{
|
||||||
@@ -143,7 +143,7 @@ static inline FAR struct tcp_conn_s *tcp_ipv4_listener(in_addr_t ipaddr,
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv4 && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tcp_ipv6_listener
|
* 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 *
|
static inline FAR struct tcp_conn_s *
|
||||||
tcp_ipv6_listener(const net_ipv6addr_t ipaddr, uint16_t portno)
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 && CONFIG_NETDEV_MULTINIC */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tcp_listener
|
* 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 *
|
static FAR struct tcp_conn_s *
|
||||||
tcp_listener(uint8_t domain, FAR const union ip_addr_u *ipaddr,
|
tcp_listener(uint8_t domain, FAR const union ip_addr_u *ipaddr,
|
||||||
uint16_t portno)
|
uint16_t portno)
|
||||||
@@ -232,35 +231,6 @@ static FAR struct tcp_conn_s *
|
|||||||
#endif /* CONFIG_NET_IPv6 */
|
#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
|
* 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,
|
static int tcp_selectport(uint8_t domain, FAR const union ip_addr_u *ipaddr,
|
||||||
uint16_t portno)
|
uint16_t portno)
|
||||||
#else
|
|
||||||
static int tcp_selectport(uint16_t portno)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
if (portno == 0)
|
if (portno == 0)
|
||||||
{
|
{
|
||||||
@@ -317,11 +283,7 @@ static int tcp_selectport(uint16_t portno)
|
|||||||
g_last_tcp_port = 4096;
|
g_last_tcp_port = 4096;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
while (tcp_listener(domain, ipaddr, htons(g_last_tcp_port)));
|
while (tcp_listener(domain, ipaddr, htons(g_last_tcp_port)));
|
||||||
#else
|
|
||||||
while (tcp_listener(htons(g_last_tcp_port)));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -329,11 +291,7 @@ static int tcp_selectport(uint16_t portno)
|
|||||||
* connection is using this local port.
|
* connection is using this local port.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
if (tcp_listener(domain, ipaddr, portno))
|
if (tcp_listener(domain, ipaddr, portno))
|
||||||
#else
|
|
||||||
if (tcp_listener(portno))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* It is in use... return EADDRINUSE */
|
/* 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 ipv4_hdr_s *ip = IPv4BUF;
|
||||||
FAR struct tcp_conn_s *conn;
|
FAR struct tcp_conn_s *conn;
|
||||||
in_addr_t srcipaddr;
|
in_addr_t srcipaddr;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
in_addr_t destipaddr;
|
in_addr_t destipaddr;
|
||||||
#endif
|
|
||||||
|
|
||||||
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
||||||
srcipaddr = net_ip4addr_conv32(ip->srcipaddr);
|
srcipaddr = net_ip4addr_conv32(ip->srcipaddr);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
destipaddr = net_ip4addr_conv32(ip->destipaddr);
|
destipaddr = net_ip4addr_conv32(ip->destipaddr);
|
||||||
#endif
|
|
||||||
|
|
||||||
while (conn)
|
while (conn)
|
||||||
{
|
{
|
||||||
@@ -384,11 +338,9 @@ static inline FAR struct tcp_conn_s *
|
|||||||
* number in the received packet.
|
* number in the received packet.
|
||||||
* - The remote port number is checked if the connection is bound
|
* - The remote port number is checked if the connection is bound
|
||||||
* to a remote port.
|
* to a remote port.
|
||||||
* - If multiple network interfaces are supported, then the local
|
* - Insist that the destination IP matches the bound address. If
|
||||||
* IP address is available and we will insist that the
|
* a socket is bound to INADDRY_ANY, then it should receive all
|
||||||
* destination IP matches the bound address. If a socket is
|
* packets directed to the port.
|
||||||
* 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,
|
* - Finally, if the connection is bound to a remote IP address,
|
||||||
* the source IP address of the packet is checked.
|
* 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 &&
|
if (conn->tcpstateflags != TCP_CLOSED &&
|
||||||
tcp->destport == conn->lport &&
|
tcp->destport == conn->lport &&
|
||||||
tcp->srcport == conn->rport &&
|
tcp->srcport == conn->rport &&
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
(net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY) ||
|
(net_ipv4addr_cmp(conn->u.ipv4.laddr, INADDR_ANY) ||
|
||||||
net_ipv4addr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
|
net_ipv4addr_cmp(destipaddr, conn->u.ipv4.laddr)) &&
|
||||||
#endif
|
|
||||||
net_ipv4addr_cmp(srcipaddr, conn->u.ipv4.raddr))
|
net_ipv4addr_cmp(srcipaddr, conn->u.ipv4.raddr))
|
||||||
{
|
{
|
||||||
/* Matching connection found.. break out of the loop and return a
|
/* 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 ipv6_hdr_s *ip = IPv6BUF;
|
||||||
FAR struct tcp_conn_s *conn;
|
FAR struct tcp_conn_s *conn;
|
||||||
net_ipv6addr_t *srcipaddr;
|
net_ipv6addr_t *srcipaddr;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_t *destipaddr;
|
net_ipv6addr_t *destipaddr;
|
||||||
#endif
|
|
||||||
|
|
||||||
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
conn = (FAR struct tcp_conn_s *)g_active_tcp_connections.head;
|
||||||
srcipaddr = (net_ipv6addr_t *)ip->srcipaddr;
|
srcipaddr = (net_ipv6addr_t *)ip->srcipaddr;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
destipaddr = (net_ipv6addr_t *)ip->destipaddr;
|
destipaddr = (net_ipv6addr_t *)ip->destipaddr;
|
||||||
#endif
|
|
||||||
|
|
||||||
while (conn)
|
while (conn)
|
||||||
{
|
{
|
||||||
@@ -459,11 +405,9 @@ static inline FAR struct tcp_conn_s *
|
|||||||
* number in the received packet.
|
* number in the received packet.
|
||||||
* - The remote port number is checked if the connection is bound
|
* - The remote port number is checked if the connection is bound
|
||||||
* to a remote port.
|
* to a remote port.
|
||||||
* - If multiple network interfaces are supported, then the local
|
* - Insist that the destination IP matches the bound address. If
|
||||||
* IP address is available and we will insist that the
|
* a socket is bound to INADDRY_ANY, then it should receive all
|
||||||
* destination IP matches the bound address. If a socket is
|
* packets directed to the port.
|
||||||
* 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,
|
* - Finally, if the connection is bound to a remote IP address,
|
||||||
* the source IP address of the packet is checked.
|
* 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 &&
|
if (conn->tcpstateflags != TCP_CLOSED &&
|
||||||
tcp->destport == conn->lport &&
|
tcp->destport == conn->lport &&
|
||||||
tcp->srcport == conn->rport &&
|
tcp->srcport == conn->rport &&
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) ||
|
(net_ipv6addr_cmp(conn->u.ipv6.laddr, g_ipv6_allzeroaddr) ||
|
||||||
net_ipv6addr_cmp(*destipaddr, conn->u.ipv6.laddr)) &&
|
net_ipv6addr_cmp(*destipaddr, conn->u.ipv6.laddr)) &&
|
||||||
#endif
|
|
||||||
net_ipv6addr_cmp(*srcipaddr, conn->u.ipv6.raddr))
|
net_ipv6addr_cmp(*srcipaddr, conn->u.ipv6.raddr))
|
||||||
{
|
{
|
||||||
/* Matching connection found.. break out of the loop and return a
|
/* 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) */
|
/* Verify or select a local port (host byte order) */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
port = tcp_selectport(PF_INET,
|
port = tcp_selectport(PF_INET,
|
||||||
(FAR const union ip_addr_u *)&addr->sin_addr.s_addr,
|
(FAR const union ip_addr_u *)&addr->sin_addr.s_addr,
|
||||||
ntohs(addr->sin_port));
|
ntohs(addr->sin_port));
|
||||||
#else
|
|
||||||
port = tcp_selectport(ntohs(addr->sin_port));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (port < 0)
|
if (port < 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: tcp_selectport failed: %d\n", port);
|
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). */
|
/* Save the local address in the connection structure (network byte order). */
|
||||||
|
|
||||||
conn->lport = htons(port);
|
conn->lport = htons(port);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv4addr_copy(conn->u.ipv4.laddr, addr->sin_addr.s_addr);
|
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
|
/* Find the device that can receive packets on the network associated with
|
||||||
* this local address.
|
* 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 */
|
/* Back out the local address setting */
|
||||||
|
|
||||||
conn->lport = 0;
|
conn->lport = 0;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv4addr_copy(conn->u.ipv4.laddr, INADDR_ANY);
|
net_ipv4addr_copy(conn->u.ipv4.laddr, INADDR_ANY);
|
||||||
#endif
|
|
||||||
return ret;
|
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) */
|
/* Verify or select a local port (host byte order) */
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* The port number must be unique for this address binding */
|
/* The port number must be unique for this address binding */
|
||||||
|
|
||||||
port = tcp_selectport(PF_INET6,
|
port = tcp_selectport(PF_INET6,
|
||||||
(FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16,
|
(FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16,
|
||||||
ntohs(addr->sin6_port));
|
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)
|
if (port < 0)
|
||||||
{
|
{
|
||||||
nerr("ERROR: tcp_selectport failed: %d\n", port);
|
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). */
|
/* Save the local address in the connection structure (network byte order). */
|
||||||
|
|
||||||
conn->lport = htons(port);
|
conn->lport = htons(port);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_copy(conn->u.ipv6.laddr, addr->sin6_addr.in6_u.u6_addr16);
|
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
|
/* Find the device that can receive packets on the network
|
||||||
* associated with this local address.
|
* 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 */
|
/* Back out the local address setting */
|
||||||
|
|
||||||
conn->lport = 0;
|
conn->lport = 0;
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_allzeroaddr);
|
net_ipv6addr_copy(conn->u.ipv6.laddr, g_ipv6_allzeroaddr);
|
||||||
#endif
|
|
||||||
return ret;
|
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);
|
conn->mss = TCP_IPv6_INITIAL_MSS(dev);
|
||||||
net_ipv6addr_copy(conn->u.ipv6.raddr, ip->srcipaddr);
|
net_ipv6addr_copy(conn->u.ipv6.raddr, ip->srcipaddr);
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
net_ipv6addr_copy(conn->u.ipv6.laddr, ip->destipaddr);
|
net_ipv6addr_copy(conn->u.ipv6.laddr, ip->destipaddr);
|
||||||
|
|
||||||
/* We now have to filter all outgoing transfers so that they use
|
/* 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);
|
DEBUGASSERT(conn->dev == NULL || conn->dev == dev);
|
||||||
conn->dev = dev;
|
conn->dev = dev;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Find the device that can receive packets on the network
|
/* Find the device that can receive packets on the network
|
||||||
* associated with this local address.
|
* 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_ipv4addr_copy(conn->u.ipv4.raddr,
|
||||||
net_ip4addr_conv32(ip->srcipaddr));
|
net_ip4addr_conv32(ip->srcipaddr));
|
||||||
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Set the local address as well */
|
/* Set the local address as well */
|
||||||
|
|
||||||
net_ipv4addr_copy(conn->u.ipv4.laddr,
|
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);
|
DEBUGASSERT(conn->dev == NULL || conn->dev == dev);
|
||||||
conn->dev = dev;
|
conn->dev = dev;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Find the device that can receive packets on the network
|
/* Find the device that can receive packets on the network
|
||||||
* associated with this local address.
|
* 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();
|
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_IPv4
|
||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
if (conn->domain == PF_INET)
|
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 */
|
#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? */
|
/* Did we have a port assignment? */
|
||||||
|
|
||||||
if (port < 0)
|
if (port < 0)
|
||||||
|
|||||||
@@ -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)
|
if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* The TCP connection is established and, hence, should be bound
|
/* The TCP connection is established and, hence, should be bound
|
||||||
* to a device. Make sure that the polling device is the one that
|
* to a device. Make sure that the polling device is the one that
|
||||||
* we are bound to.
|
* 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);
|
DEBUGASSERT(conn->dev != NULL);
|
||||||
if (dev == conn->dev)
|
if (dev == conn->dev)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* Set up for the callback. We can't know in advance if the
|
/* 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
|
* application is going to send a IPv4 or an IPv6 packet, so this
|
||||||
|
|||||||
+4
-30
@@ -73,7 +73,6 @@
|
|||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr)
|
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 */
|
/* Do nothing if a device is already bound to the connection */
|
||||||
|
|
||||||
if (conn->dev != NULL)
|
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;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are multiple network devices. We need to select the device that
|
/* We need to select the device that is going to route the TCP packet
|
||||||
* is going to route the TCP packet based on the provided IP address.
|
* based on the provided IP address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
conn->dev = netdev_findby_ipv4addr(addr, addr);
|
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 success if we found the device */
|
||||||
|
|
||||||
return conn->dev != NULL ? OK : -ENETUNREACH;
|
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 */
|
#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,
|
static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
|
||||||
const net_ipv6addr_t addr)
|
const net_ipv6addr_t addr)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
|
||||||
/* Do nothing if a device is already bound to the connection */
|
/* Do nothing if a device is already bound to the connection */
|
||||||
|
|
||||||
if (conn->dev != NULL)
|
if (conn->dev != NULL)
|
||||||
@@ -151,8 +141,8 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* There are multiple network devices. We need to select the device that
|
/* We need to select the device that is going to route the TCP packet
|
||||||
* is going to route the TCP packet based on the provided IP address.
|
* based on the provided IP address.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
conn->dev = netdev_findby_ipv6addr(addr, addr);
|
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 success if we found the device */
|
||||||
|
|
||||||
return conn->dev != NULL ? OK : -ENETUNREACH;
|
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 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
@@ -195,11 +177,7 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
|
|||||||
#ifdef CONFIG_NET_IPv4
|
#ifdef CONFIG_NET_IPv4
|
||||||
int tcp_local_ipv4_device(FAR struct tcp_conn_s *conn)
|
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);
|
return tcp_find_ipv4_device(conn, conn->u.ipv4.laddr);
|
||||||
#else
|
|
||||||
return tcp_find_ipv4_device(conn, 0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv4 */
|
#endif /* CONFIG_NET_IPv4 */
|
||||||
|
|
||||||
@@ -246,11 +224,7 @@ int tcp_remote_ipv4_device(FAR struct tcp_conn_s *conn)
|
|||||||
#ifdef CONFIG_NET_IPv6
|
#ifdef CONFIG_NET_IPv6
|
||||||
int tcp_local_ipv6_device(FAR struct tcp_conn_s *conn)
|
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);
|
return tcp_find_ipv6_device(conn, conn->u.ipv6.laddr);
|
||||||
#else
|
|
||||||
return tcp_find_ipv6_device(conn, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NET_IPv6 */
|
#endif /* CONFIG_NET_IPv6 */
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user