mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 18:27:56 +08:00
Remove CONFIG_NETDEV_MULTINIC. This increases code size by a little, but greatly reduces the complexity of the network code.
This commit is contained in:
+4
-38
@@ -184,8 +184,7 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
|
||||
* IPv4 address.
|
||||
*
|
||||
* Parameters:
|
||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
||||
* lipaddr - Local, bound address of a connection.
|
||||
* ripaddr - Remote address of a connection to use in the lookup
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -198,12 +197,8 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
||||
in_addr_t ripaddr);
|
||||
#else
|
||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@@ -214,8 +209,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
||||
* IPv6 address.
|
||||
*
|
||||
* Parameters:
|
||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
||||
* lipaddr - Local, bound address of a connection.
|
||||
* ripaddr - Remote address of a connection to use in the lookup
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -227,12 +221,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
||||
const net_ipv6addr_t ripaddr);
|
||||
#else
|
||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -309,11 +299,7 @@ FAR struct net_driver_s *netdev_default(void);
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
||||
# else
|
||||
void netdev_ipv4_txnotify(in_addr_t ripaddr);
|
||||
# endif
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
/****************************************************************************
|
||||
@@ -336,12 +322,8 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||
FAR const net_ipv6addr_t ripaddr);
|
||||
# else
|
||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr);
|
||||
# endif
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
|
||||
|
||||
@@ -388,11 +370,7 @@ void netdev_txnotify_dev(FAR struct net_driver_s *dev);
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_RXAVAIL)
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr);
|
||||
# else
|
||||
void netdev_ipv4_rxnotify(in_addr_t ripaddr);
|
||||
# endif
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
/****************************************************************************
|
||||
@@ -415,29 +393,17 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr);
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||
FAR const net_ipv6addr_t ripaddr);
|
||||
# else
|
||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr);
|
||||
# endif
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
#else
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
|
||||
# else
|
||||
# define netdev_ipv4_rxnotify(ripaddr)
|
||||
# endif
|
||||
# define netdev_ipv4_rxnotify(lipaddr,ripaddr)
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
|
||||
# else
|
||||
# define netdev_ipv6_rxnotify(ripaddr)
|
||||
# endif
|
||||
# define netdev_ipv6_rxnotify(lipaddr,ripaddr)
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -179,8 +179,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
* IPv4 address.
|
||||
*
|
||||
* Parameters:
|
||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
||||
* lipaddr - Local, bound address of a connection.
|
||||
* ripaddr - Remote address of a connection to use in the lookup
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -192,12 +191,8 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
|
||||
in_addr_t ripaddr)
|
||||
#else
|
||||
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
#endif
|
||||
{
|
||||
struct net_driver_s *dev;
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
@@ -209,7 +204,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
|
||||
if (net_ipv4addr_cmp(ripaddr, INADDR_BROADCAST))
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||
|
||||
if (net_ipv4addr_cmp(lipaddr, INADDR_ANY))
|
||||
@@ -232,13 +226,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
|
||||
return netdev_finddevice_ipv4addr(lipaddr);
|
||||
}
|
||||
#else
|
||||
/* If there is only a single, registered network interface, then the
|
||||
* decision is pretty easy.
|
||||
*/
|
||||
|
||||
return g_netdevices;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if the address maps to a local network */
|
||||
@@ -275,15 +262,6 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
* out subnet to a router and there is no routing information.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NETDEV_MULTINIC
|
||||
/* If there is only a single, registered network interface, then the
|
||||
* decision is pretty easy. Use that device and its default router
|
||||
* address.
|
||||
*/
|
||||
|
||||
dev = g_netdevices;
|
||||
#endif
|
||||
|
||||
/* If we will did not find the network device, then we might as well fail
|
||||
* because we are not configured properly to determine the route to the
|
||||
* destination.
|
||||
@@ -301,8 +279,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
* IPv6 address.
|
||||
*
|
||||
* Parameters:
|
||||
* lipaddr - Local, bound address of a connection. Used only if ripaddr
|
||||
* is the broadcast address. Used only if CONFIG_NETDEV_MULTINIC.
|
||||
* lipaddr - Local, bound address of a connection.
|
||||
* ripaddr - Remote address of a connection to use in the lookup
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -314,12 +291,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t ripaddr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
|
||||
const net_ipv6addr_t ripaddr)
|
||||
#else
|
||||
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
#endif
|
||||
{
|
||||
struct net_driver_s *dev;
|
||||
#ifdef CONFIG_NET_ROUTE
|
||||
@@ -335,7 +308,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
|
||||
if (ripaddr[0] == HTONS(0xff02))
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
/* Yes.. Check the local, bound address. Is it INADDR_ANY? */
|
||||
|
||||
if (net_ipv6addr_cmp(lipaddr, g_ipv6_allzeroaddr))
|
||||
@@ -358,13 +330,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
|
||||
return netdev_finddevice_ipv6addr(lipaddr);
|
||||
}
|
||||
#else
|
||||
/* If there is only a single, registered network interface, then the
|
||||
* decision is pretty easy.
|
||||
*/
|
||||
|
||||
return g_netdevices;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if the address maps to a local network */
|
||||
@@ -401,15 +366,6 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t ripaddr)
|
||||
* out subnet to a router and there is no routing information.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NETDEV_MULTINIC
|
||||
/* If there is only a single, registered network interface, then the
|
||||
* decision is pretty easy. Use that device and its default router
|
||||
* address.
|
||||
*/
|
||||
|
||||
dev = g_netdevices;
|
||||
#endif
|
||||
|
||||
/* If we will did not find the network device, then we might as well fail
|
||||
* because we are not configured properly to determine the route to the
|
||||
* destination.
|
||||
|
||||
@@ -76,7 +76,6 @@
|
||||
|
||||
FAR struct net_driver_s *netdev_findbyindex(int index)
|
||||
{
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
FAR struct net_driver_s *dev;
|
||||
int i;
|
||||
|
||||
@@ -92,9 +91,6 @@ FAR struct net_driver_s *netdev_findbyindex(int index)
|
||||
|
||||
net_unlock();
|
||||
return NULL;
|
||||
#else
|
||||
return (index == 0) ? g_netdevices : NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */
|
||||
|
||||
@@ -74,22 +74,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv4_rxnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
||||
#else
|
||||
void netdev_ipv4_rxnotify(in_addr_t ripaddr)
|
||||
#endif
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Find the device driver that serves the subnet of the remote address */
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
||||
#else
|
||||
dev = netdev_findby_ipv4addr(ripaddr);
|
||||
#endif
|
||||
|
||||
if (dev && dev->d_rxavail)
|
||||
{
|
||||
/* Notify the device driver that new RX data is available. */
|
||||
@@ -119,23 +110,14 @@ void netdev_ipv4_rxnotify(in_addr_t ripaddr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t lipaddr,
|
||||
FAR const net_ipv6addr_t ripaddr)
|
||||
#else
|
||||
void netdev_ipv6_rxnotify(FAR const net_ipv6addr_t ripaddr)
|
||||
#endif
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Find the device driver that serves the subnet of the remote address */
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||
#else
|
||||
dev = netdev_findby_ipv6addr(ripaddr);
|
||||
#endif
|
||||
|
||||
if (dev && dev->d_rxavail)
|
||||
{
|
||||
/* Notify the device driver that new RX data is available. */
|
||||
|
||||
@@ -74,22 +74,13 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
# ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
|
||||
# else
|
||||
void netdev_ipv4_txnotify(in_addr_t ripaddr)
|
||||
# endif
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Find the device driver that serves the subnet of the remote address */
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
|
||||
#else
|
||||
dev = netdev_findby_ipv4addr(ripaddr);
|
||||
#endif
|
||||
|
||||
if (dev && dev->d_txavail)
|
||||
{
|
||||
/* Notify the device driver that new TX data is available. */
|
||||
@@ -120,23 +111,14 @@ void netdev_ipv4_txnotify(in_addr_t ripaddr)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
|
||||
FAR const net_ipv6addr_t ripaddr)
|
||||
#else
|
||||
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t ripaddr)
|
||||
#endif
|
||||
{
|
||||
FAR struct net_driver_s *dev;
|
||||
|
||||
/* Find the device driver that serves the subnet of the remote address */
|
||||
|
||||
#ifdef CONFIG_NETDEV_MULTINIC
|
||||
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
|
||||
#else
|
||||
dev = netdev_findby_ipv6addr(ripaddr);
|
||||
#endif
|
||||
|
||||
if (dev && dev->d_txavail)
|
||||
{
|
||||
/* Notify the device driver that new TX data is available. */
|
||||
|
||||
Reference in New Issue
Block a user