Skip to content

Commit

Permalink
net/icmpv6, neighbor, and netdev: Rename netdev_dev_lladdrsize() to n…
Browse files Browse the repository at this point in the history
…etdev_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.
  • Loading branch information
xiaoxiang781216 authored and gregory-nutt committed Nov 9, 2018
1 parent a139b7f commit 71e1056
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
16 changes: 16 additions & 0 deletions include/nuttx/net/netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,4 +744,20 @@ uint16_t ipv6_chksum(FAR struct net_driver_s *dev);
# define netdev_ipv6_hdrlen(dev) dev->d_llhdrlen
#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 */
2 changes: 1 addition & 1 deletion net/icmpv6/icmpv6_advertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void icmpv6_advertise(FAR struct net_driver_s *dev,

/* Length excludes the IPv6 header */

lladdrsize = netdev_dev_lladdrsize(dev);
lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_NEIGHBOR_ADVERTISE_S(lladdrsize);
ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff);
Expand Down
2 changes: 1 addition & 1 deletion net/icmpv6/icmpv6_linkipaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
switch (netdev_dev_lladdrsize(dev))
switch (netdev_lladdrsize(dev))
{
case 1:
icmpv6_linkipaddr_1(&dev->d_mac, ipaddr);
Expand Down
2 changes: 1 addition & 1 deletion net/icmpv6/icmpv6_radvertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void icmpv6_radvertise(FAR struct net_driver_s *dev)

/* Length excludes the IPv6 header */

lladdrsize = netdev_dev_lladdrsize(dev);
lladdrsize = netdev_lladdrsize(dev);
l3size = sizeof(struct icmpv6_router_advertise_s) +
SIZEOF_ICMPV6_SRCLLADDR_S(lladdrsize) +
sizeof(struct icmpv6_mtu_s) +
Expand Down
2 changes: 1 addition & 1 deletion net/icmpv6/icmpv6_rsolicit.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void icmpv6_rsolicit(FAR struct net_driver_s *dev)

/* Length excludes the IPv6 header */

lladdrsize = netdev_dev_lladdrsize(dev);
lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_ROUTER_SOLICIT_S(lladdrsize);
ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff);
Expand Down
2 changes: 1 addition & 1 deletion net/icmpv6/icmpv6_solicit.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void icmpv6_solicit(FAR struct net_driver_s *dev,

/* Length excludes the IPv6 header */

lladdrsize = netdev_dev_lladdrsize(dev);
lladdrsize = netdev_lladdrsize(dev);
l3size = SIZEOF_ICMPV6_NEIGHBOR_SOLICIT_S(lladdrsize);
ipv6->len[0] = (l3size >> 8);
ipv6->len[1] = (l3size & 0xff);
Expand Down
2 changes: 1 addition & 1 deletion net/neighbor/neighbor_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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,
g_neighbors[oldest_ndx].ne_addr.na_llsize);
Expand Down
2 changes: 1 addition & 1 deletion net/neighbor/neighbor_lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static int neighbor_match(FAR struct net_driver_s *dev, FAR void *arg)
if (info->ni_laddr != NULL)
{
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);
}

Expand Down
16 changes: 0 additions & 16 deletions net/netdev/netdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,22 +499,6 @@ struct lifconf; /* Forward reference */
int netdev_ipv6_ifconf(FAR struct lifconf *lifc);
#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
*
Expand Down
4 changes: 2 additions & 2 deletions net/netdev/netdev_lladdrsize.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static inline int netdev_pktradio_addrlen(FAR struct net_driver_s *dev)
****************************************************************************/

/****************************************************************************
* Name: netdev_dev_lladdrsize
* Name: netdev_lladdrsize
*
* Description:
* Returns the size of the MAC address associated with a network device.
Expand All @@ -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);

Expand Down

0 comments on commit 71e1056

Please sign in to comment.