net/icmpv6, neighbor, and netdev: Rename netdev_dev_lladdrsize() to netdev_lladdrsize() and move the prototype to include/nuttx/nex/netdev.h, giving is global scope within the OS. Reviewer: This degrades the integrity of the modular architecture by introducing a new coupling via C function call. Not a good thing at all.

This commit is contained in:
Xiang Xiao
2018-11-09 16:05:11 -06:00
committed by Gregory Nutt
parent a139b7f9b1
commit 71e1056e6d
10 changed files with 25 additions and 25 deletions
+16
View File
@@ -744,4 +744,20 @@ uint16_t ipv6_chksum(FAR struct net_driver_s *dev);
# define netdev_ipv6_hdrlen(dev) dev->d_llhdrlen # define netdev_ipv6_hdrlen(dev) dev->d_llhdrlen
#endif /* CONFIG_NET_IPv6 */ #endif /* CONFIG_NET_IPv6 */
/****************************************************************************
* Name: netdev_lladdrsize
*
* Description:
* Returns the size of the MAC address associated with a network device.
*
* Input Parameters:
* dev - A reference to the device of interest
*
* Returned Value:
* The size of the MAC address associated with this device
*
****************************************************************************/
int netdev_lladdrsize(FAR struct net_driver_s *dev);
#endif /* __INCLUDE_NUTTX_NET_NETDEV_H */ #endif /* __INCLUDE_NUTTX_NET_NETDEV_H */
+1 -1
View File
@@ -107,7 +107,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev,
/* Length excludes the IPv6 header */ /* Length excludes the IPv6 header */
lladdrsize = netdev_dev_lladdrsize(dev); lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(lladdrsize); l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(lladdrsize);
ipv6->len[0] = (l3size >> 8); ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff); ipv6->len[1] = (l3size & 0xff);
+1 -1
View File
@@ -153,7 +153,7 @@ icmpv6_linkipaddr_8(FAR const void *mac_, net_ipv6addr_t ipaddr)
void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr) void icmpv6_linkipaddr(FAR struct net_driver_s *dev, net_ipv6addr_t ipaddr)
{ {
switch (netdev_dev_lladdrsize(dev)) switch (netdev_lladdrsize(dev))
{ {
case 1: case 1:
icmpv6_linkipaddr_1(&dev->d_mac, ipaddr); icmpv6_linkipaddr_1(&dev->d_mac, ipaddr);
+1 -1
View File
@@ -160,7 +160,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev)
/* Length excludes the IPv6 header */ /* Length excludes the IPv6 header */
lladdrsize = netdev_dev_lladdrsize(dev); lladdrsize = netdev_lladdrsize(dev);
l3size = sizeof(struct icmpv6_router_advertise_s) + l3size = sizeof(struct icmpv6_router_advertise_s) +
SIZEOF_ICMPV6_SRCLLADDR_S(lladdrsize) + SIZEOF_ICMPV6_SRCLLADDR_S(lladdrsize) +
sizeof(struct icmpv6_mtu_s) + sizeof(struct icmpv6_mtu_s) +
+1 -1
View File
@@ -103,7 +103,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev)
/* Length excludes the IPv6 header */ /* Length excludes the IPv6 header */
lladdrsize = netdev_dev_lladdrsize(dev); lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(lladdrsize); l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(lladdrsize);
ipv6->len[0] = (l3size >> 8); ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff); ipv6->len[1] = (l3size & 0xff);
+1 -1
View File
@@ -114,7 +114,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,
/* Length excludes the IPv6 header */ /* Length excludes the IPv6 header */
lladdrsize = netdev_dev_lladdrsize(dev); lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(lladdrsize); l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(lladdrsize);
ipv6->len[0] = (l3size >> 8); ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff); ipv6->len[1] = (l3size & 0xff);
+1 -1
View File
@@ -117,7 +117,7 @@ void neighbor_add(FAR struct net_driver_s *dev, FAR net_ipv6addr_t ipaddr,
net_ipv6addr_copy(g_neighbors[oldest_ndx].ne_ipaddr, ipaddr); net_ipv6addr_copy(g_neighbors[oldest_ndx].ne_ipaddr, ipaddr);
g_neighbors[oldest_ndx].ne_addr.na_lltype = lltype; g_neighbors[oldest_ndx].ne_addr.na_lltype = lltype;
g_neighbors[oldest_ndx].ne_addr.na_llsize = netdev_dev_lladdrsize(dev); g_neighbors[oldest_ndx].ne_addr.na_llsize = netdev_lladdrsize(dev);
memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr, memcpy(&g_neighbors[oldest_ndx].ne_addr.u, addr,
g_neighbors[oldest_ndx].ne_addr.na_llsize); g_neighbors[oldest_ndx].ne_addr.na_llsize);
+1 -1
View File
@@ -96,7 +96,7 @@ static int neighbor_match(FAR struct net_driver_s *dev, FAR void *arg)
if (info->ni_laddr != NULL) if (info->ni_laddr != NULL)
{ {
info->ni_laddr->na_lltype = dev->d_lltype; info->ni_laddr->na_lltype = dev->d_lltype;
info->ni_laddr->na_llsize = netdev_dev_lladdrsize(dev); info->ni_laddr->na_llsize = netdev_lladdrsize(dev);
memcpy(&info->ni_laddr->u, &dev->d_mac, info->ni_laddr->na_llsize); memcpy(&info->ni_laddr->u, &dev->d_mac, info->ni_laddr->na_llsize);
} }
-16
View File
@@ -499,22 +499,6 @@ struct lifconf; /* Forward reference */
int netdev_ipv6_ifconf(FAR struct lifconf *lifc); int netdev_ipv6_ifconf(FAR struct lifconf *lifc);
#endif #endif
/****************************************************************************
* Name: netdev_dev_lladdrsize
*
* Description:
* Returns the size of the MAC address associated with a network device.
*
* Input Parameters:
* dev - A reference to the device of interest
*
* Returned Value:
* The size of the MAC address associated with this device
*
****************************************************************************/
int netdev_dev_lladdrsize(FAR struct net_driver_s *dev);
/**************************************************************************** /****************************************************************************
* Name: netdown_notifier_setup * Name: netdown_notifier_setup
* *
+2 -2
View File
@@ -98,7 +98,7 @@ static inline int netdev_pktradio_addrlen(FAR struct net_driver_s *dev)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: netdev_dev_lladdrsize * Name: netdev_lladdrsize
* *
* Description: * Description:
* Returns the size of the MAC address associated with a network device. * Returns the size of the MAC address associated with a network device.
@@ -111,7 +111,7 @@ static inline int netdev_pktradio_addrlen(FAR struct net_driver_s *dev)
* *
****************************************************************************/ ****************************************************************************/
int netdev_dev_lladdrsize(FAR struct net_driver_s *dev) int netdev_lladdrsize(FAR struct net_driver_s *dev)
{ {
DEBUGASSERT(dev != NULL); DEBUGASSERT(dev != NULL);