net/netdev: All utility functions that lookup network devices should begin with netdev_findby_. Also correct some comments and the name of a formal parameter.

This commit is contained in:
Gregory Nutt 2018-10-29 12:20:44 -06:00
parent ad887ec34c
commit 7d2b250cbc
16 changed files with 64 additions and 65 deletions

View file

@ -223,7 +223,7 @@ int arp_send(in_addr_t ipaddr)
/* Get the device that can route this request */
dev = netdev_findby_ipv4addr(INADDR_ANY, ipaddr);
dev = netdev_findby_ripv4addr(INADDR_ANY, ipaddr);
if (!dev)
{
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);

View file

@ -397,7 +397,7 @@ ssize_t icmp_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
/* Get the device that will be used to route this ICMP ECHO request */
dev = netdev_findby_ipv4addr(INADDR_ANY, inaddr->sin_addr.s_addr);
dev = netdev_findby_ripv4addr(INADDR_ANY, inaddr->sin_addr.s_addr);
if (dev == NULL)
{
nerr("ERROR: Not reachable\n");

View file

@ -222,7 +222,7 @@ int icmpv6_neighbor(const net_ipv6addr_t ipaddr)
/* Get the device that can route this request */
dev = netdev_findby_ipv6addr(g_ipv6_unspecaddr, ipaddr);
dev = netdev_findby_ripv6addr(g_ipv6_unspecaddr, ipaddr);
if (!dev)
{
nerr("ERROR: Unreachable: %08lx\n", (unsigned long)ipaddr);

View file

@ -389,7 +389,7 @@ ssize_t icmpv6_sendto(FAR struct socket *psock, FAR const void *buf, size_t len,
/* Get the device that will be used to route this ICMPv6 ECHO request */
dev = netdev_findby_ipv6addr(g_ipv6_unspecaddr,
dev = netdev_findby_ripv6addr(g_ipv6_unspecaddr,
inaddr->sin6_addr.s6_addr16);
if (dev == NULL)
{

View file

@ -154,7 +154,7 @@ int ipv4_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
ripaddr = lipaddr;
}
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
dev = netdev_findby_ripv4addr(lipaddr, ripaddr);
if (dev == NULL)
{

View file

@ -155,7 +155,7 @@ int ipv6_getsockname(FAR struct socket *psock, FAR struct sockaddr *addr,
ripaddr = lipaddr;
}
dev = netdev_findby_ipv6addr(*lipaddr, *ripaddr);
dev = netdev_findby_ripv6addr(*lipaddr, *ripaddr);
if (!dev)
{
net_unlock();

View file

@ -436,7 +436,7 @@ int ipv4_forward(FAR struct net_driver_s *dev, FAR struct ipv4_hdr_s *ipv4)
destipaddr = net_ip4addr_conv32(ipv4->destipaddr);
srcipaddr = net_ip4addr_conv32(ipv4->srcipaddr);
fwddev = netdev_findby_ipv4addr(srcipaddr, destipaddr);
fwddev = netdev_findby_ripv4addr(srcipaddr, destipaddr);
if (fwddev == NULL)
{
nwarn("WARNING: Not routable\n");

View file

@ -573,7 +573,7 @@ int ipv6_forward(FAR struct net_driver_s *dev, FAR struct ipv6_hdr_s *ipv6)
/* Search for a device that can forward this packet. */
fwddev = netdev_findby_ipv6addr(ipv6->srcipaddr, ipv6->destipaddr);
fwddev = netdev_findby_ripv6addr(ipv6->srcipaddr, ipv6->destipaddr);
if (fwddev == NULL)
{
nwarn("WARNING: Not routable\n");

View file

@ -1,7 +1,7 @@
/****************************************************************************
* net/netdev/netdev.h
*
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -178,8 +178,10 @@ FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname);
int netdev_foreach(netdev_callback_t callback, FAR void *arg);
#if CONFIG_NSOCKET_DESCRIPTORS > 0
/****************************************************************************
* Name: netdev_finddevice_ipv4addr
* Name: netdev_findby_lipv4addr
*
* Description:
* Find a previously registered network device by matching a local address
@ -187,7 +189,7 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
* (since a "down" device has no meaningful address).
*
* Input Parameters:
* ripaddr - Remote address of a connection to use in the lookup
* lipaddr - Local, IPv4 address of assigned to the device
*
* Returned Value:
* Pointer to driver on success; null on failure
@ -195,11 +197,11 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg);
****************************************************************************/
#ifdef CONFIG_NET_IPv4
FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr);
FAR struct net_driver_s *netdev_findby_lipv4addr(in_addr_t lipaddr);
#endif
/****************************************************************************
* Name: netdev_finddevice_ipv6addr
* Name: netdev_findby_lipv6addr
*
* Description:
* Find a previously registered network device by matching a local address
@ -207,7 +209,7 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr);
* (since a "down" device has no meaningful address).
*
* Input Parameters:
* ripaddr - Remote address of a connection to use in the lookup
* lipaddr - Local, IPv6 address of assigned to the device
*
* Returned Value:
* Pointer to driver on success; null on failure
@ -215,12 +217,11 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr);
****************************************************************************/
#ifdef CONFIG_NET_IPv6
FAR struct net_driver_s *
netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr);
FAR struct net_driver_s *netdev_findby_lipv6addr(const net_ipv6addr_t lipaddr);
#endif
/****************************************************************************
* Name: netdev_findby_ipv4addr
* Name: netdev_findby_ripv4addr
*
* Description:
* Find a previously registered network device by matching the remote
@ -235,14 +236,13 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr);
*
****************************************************************************/
#if CONFIG_NSOCKET_DESCRIPTORS > 0
#ifdef CONFIG_NET_IPv4
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
in_addr_t ripaddr);
FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr,
in_addr_t ripaddr);
#endif
/****************************************************************************
* Name: netdev_findby_ipv6addr
* Name: netdev_findby_ripv6addr
*
* Description:
* Find a previously registered network device by matching the remote
@ -258,10 +258,10 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
****************************************************************************/
#ifdef CONFIG_NET_IPv6
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
const net_ipv6addr_t ripaddr);
#endif
FAR struct net_driver_s *netdev_findby_ripv6addr(const net_ipv6addr_t lipaddr,
const net_ipv6addr_t ripaddr);
#endif
#endif /* CONFIG_NSOCKET_DESCRIPTORS > 0 */
/****************************************************************************
* Name: netdev_findbyindex

View file

@ -62,7 +62,7 @@
****************************************************************************/
/****************************************************************************
* Name: netdev_finddevice_ipv4addr
* Name: netdev_findby_lipv4addr
*
* Description:
* Find a previously registered network device by matching a local address
@ -70,7 +70,7 @@
* (since a "down" device has no meaningful address).
*
* Input Parameters:
* ripaddr - Remote address of a connection to use in the lookup
* lipaddr - Local, IPv4 address of assigned to the device
*
* Returned Value:
* Pointer to driver on success; null on failure
@ -78,7 +78,7 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv4
FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
FAR struct net_driver_s *netdev_findby_lipv4addr(in_addr_t lipaddr)
{
FAR struct net_driver_s *dev;
@ -93,7 +93,7 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
{
/* Yes.. check for an address match (under the netmask) */
if (net_ipv4addr_maskcmp(dev->d_ipaddr, ripaddr,
if (net_ipv4addr_maskcmp(dev->d_ipaddr, lipaddr,
dev->d_netmask))
{
/* Its a match */
@ -112,7 +112,7 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
* Name: netdev_finddevice_ipv6addr
* Name: netdev_findby_lipv6addr
*
* Description:
* Find a previously registered network device by matching a local address
@ -120,7 +120,7 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
* (since a "down" device has no meaningful address).
*
* Input Parameters:
* ripaddr - Remote address of a connection to use in the lookup
* lipaddr - Local, IPv6 address of assigned to the device
*
* Returned Value:
* Pointer to driver on success; null on failure
@ -128,8 +128,7 @@ FAR struct net_driver_s *netdev_finddevice_ipv4addr(in_addr_t ripaddr)
****************************************************************************/
#ifdef CONFIG_NET_IPv6
FAR struct net_driver_s *
netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
FAR struct net_driver_s *netdev_findby_lipv6addr(const net_ipv6addr_t lipaddr)
{
FAR struct net_driver_s *dev;
@ -144,7 +143,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
{
/* Yes.. check for an address match (under the netmask) */
if (net_ipv6addr_maskcmp(dev->d_ipv6addr, ripaddr,
if (net_ipv6addr_maskcmp(dev->d_ipv6addr, lipaddr,
dev->d_ipv6netmask))
{
/* Its a match */
@ -163,7 +162,7 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
#endif /* CONFIG_NET_IPv6 */
/****************************************************************************
* Name: netdev_findby_ipv4addr
* Name: netdev_findby_ripv4addr
*
* Description:
* Find a previously registered network device by matching the remote
@ -179,8 +178,8 @@ netdev_finddevice_ipv6addr(const net_ipv6addr_t ripaddr)
****************************************************************************/
#ifdef CONFIG_NET_IPv4
FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
in_addr_t ripaddr)
FAR struct net_driver_s *netdev_findby_ripv4addr(in_addr_t lipaddr,
in_addr_t ripaddr)
{
struct net_driver_s *dev;
#ifdef CONFIG_NET_ROUTE
@ -208,13 +207,13 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
{
/* Return the device associated with the local address */
return netdev_finddevice_ipv4addr(lipaddr);
return netdev_findby_lipv4addr(lipaddr);
}
}
/* Check if the address maps to a locally available network */
dev = netdev_finddevice_ipv4addr(ripaddr);
dev = netdev_findby_lipv4addr(ripaddr);
if (dev)
{
return dev;
@ -234,7 +233,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
* router address
*/
dev = netdev_finddevice_ipv4addr(router);
dev = netdev_findby_lipv4addr(router);
if (dev)
{
return dev;
@ -252,7 +251,7 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
* Name: netdev_findby_ipv6addr
* Name: netdev_findby_ripv6addr
*
* Description:
* Find a previously registered network device by matching the remote
@ -268,8 +267,8 @@ FAR struct net_driver_s *netdev_findby_ipv4addr(in_addr_t lipaddr,
****************************************************************************/
#ifdef CONFIG_NET_IPv6
FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
const net_ipv6addr_t ripaddr)
FAR struct net_driver_s *netdev_findby_ripv6addr(const net_ipv6addr_t lipaddr,
const net_ipv6addr_t ripaddr)
{
struct net_driver_s *dev;
#ifdef CONFIG_NET_ROUTE
@ -299,13 +298,13 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
{
/* Return the device associated with the local address */
return netdev_finddevice_ipv6addr(lipaddr);
return netdev_findby_lipv6addr(lipaddr);
}
}
/* Check if the address maps to a locally available network */
dev = netdev_finddevice_ipv6addr(ripaddr);
dev = netdev_findby_lipv6addr(ripaddr);
if (dev)
{
return dev;
@ -325,7 +324,7 @@ FAR struct net_driver_s *netdev_findby_ipv6addr(const net_ipv6addr_t lipaddr,
* router address
*/
dev = netdev_finddevice_ipv6addr(router);
dev = netdev_findby_lipv6addr(router);
if (dev)
{
return dev;

View file

@ -1134,7 +1134,7 @@ static FAR struct net_driver_s *netdev_imsfdev(FAR struct ip_msfilter *imsf)
* of the local device.
*/
return netdev_finddevice_ipv4addr(imsf->imsf_interface.s_addr);
return netdev_findby_lipv4addr(imsf->imsf_interface.s_addr);
}
#endif

View file

@ -77,7 +77,7 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
/* Find the device driver that serves the subnet of the remote address */
dev = netdev_findby_ipv4addr(lipaddr, ripaddr);
dev = netdev_findby_ripv4addr(lipaddr, ripaddr);
if (dev && dev->d_txavail)
{
/* Notify the device driver that new TX data is available. */
@ -112,7 +112,7 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
/* Find the device driver that serves the subnet of the remote address */
dev = netdev_findby_ipv6addr(lipaddr, ripaddr);
dev = netdev_findby_ripv6addr(lipaddr, ripaddr);
if (dev && dev->d_txavail)
{
/* Notify the device driver that new TX data is available. */

View file

@ -813,7 +813,7 @@ ssize_t psock_6lowpan_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* Route outgoing message to the correct device */
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
dev = netdev_findby_ripv6addr(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
if (dev == NULL)
{
nwarn("WARNING: Not routable\n");

View file

@ -206,8 +206,8 @@ ssize_t psock_6lowpan_udp_sendto(FAR struct socket *psock,
/* Route outgoing message to the correct device */
dev = netdev_findby_ipv6addr(conn->u.ipv6.laddr,
to6->sin6_addr.in6_u.u6_addr16);
dev = netdev_findby_ripv6addr(conn->u.ipv6.laddr,
to6->sin6_addr.in6_u.u6_addr16);
if (dev == NULL)
{
nwarn("WARNING: Not routable\n");

View file

@ -95,7 +95,7 @@ static int tcp_find_ipv4_device(FAR struct tcp_conn_s *conn, in_addr_t addr)
* based on the provided IP address.
*/
conn->dev = netdev_findby_ipv4addr(addr, addr);
conn->dev = netdev_findby_ripv4addr(addr, addr);
/* Return success if we found the device */
@ -145,7 +145,7 @@ static int tcp_find_ipv6_device(FAR struct tcp_conn_s *conn,
* based on the provided IP address.
*/
conn->dev = netdev_findby_ipv6addr(addr, addr);
conn->dev = netdev_findby_ripv6addr(addr, addr);
/* Return success if we found the device */

View file

@ -154,8 +154,8 @@ FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn)
}
else
{
return netdev_findby_ipv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.laddr);
return netdev_findby_ripv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.laddr);
}
}
#endif
@ -177,8 +177,8 @@ FAR struct net_driver_s *udp_find_laddr_device(FAR struct udp_conn_s *conn)
}
else
{
return netdev_findby_ipv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.laddr);
return netdev_findby_ripv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.laddr);
}
}
#endif
@ -234,8 +234,8 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn)
}
else
{
return netdev_findby_ipv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.laddr);
return netdev_findby_ripv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.laddr);
}
}
@ -247,8 +247,8 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn)
{
/* Normal lookup using the verified remote address */
return netdev_findby_ipv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.raddr);
return netdev_findby_ripv4addr(conn->u.ipv4.laddr,
conn->u.ipv4.raddr);
}
else
{
@ -286,8 +286,8 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn)
}
else
{
return netdev_findby_ipv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.laddr);
return netdev_findby_ripv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.laddr);
}
}
@ -299,8 +299,8 @@ FAR struct net_driver_s *udp_find_raddr_device(FAR struct udp_conn_s *conn)
{
/* Normal lookup using the verified remote address */
return netdev_findby_ipv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.raddr);
return netdev_findby_ripv6addr(conn->u.ipv6.laddr,
conn->u.ipv6.raddr);
}
else
{