mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 18:56:10 +08:00
Networking: Improve naming and simplify some logic of previous commit.
This commit is contained in:
@@ -39,7 +39,7 @@ NETDEV_CSRCS += netdev_register.c netdev_ioctl.c netdev_txnotify.c
|
||||
NETDEV_CSRCS += netdev_findbyname.c netdev_findbyaddr.c netdev_findbyindex.c
|
||||
NETDEV_CSRCS += netdev_count.c netdev_foreach.c netdev_unregister.c
|
||||
NETDEV_CSRCS += netdev_carrier.c netdev_default.c netdev_verify.c
|
||||
NETDEV_CSRCS += netdev_l1size.c
|
||||
NETDEV_CSRCS += netdev_lladdrsize.c
|
||||
|
||||
ifeq ($(CONFIG_NET_RXAVAIL),y)
|
||||
NETDEV_CSRCS += netdev_rxnotify.c
|
||||
|
||||
+48
-7
@@ -47,6 +47,31 @@
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* If there is only one supported link layer, then the size of the link
|
||||
* layer address is a constant.
|
||||
*
|
||||
* NOTE: Literal constants are used here to avoid bringing in all of the
|
||||
* header files where they are correctly defined.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_NET_MULTILINK
|
||||
# if defined(CONFIG_NET_ETHERNET)
|
||||
# define NETDEV_LLADDRSIZE 6 /* IFHWADDRLEN */
|
||||
# elif defined(CONFIG_NET_6LOWPAN)
|
||||
# ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
# define NETDEV_LLADDRSIZE 10 /* NET_6LOWPAN_EADDRSIZE */
|
||||
# else
|
||||
# define NETDEV_LLADDRSIZE 2 /* NET_6LOWPAN_SADDRSIZE */
|
||||
# endif
|
||||
# else
|
||||
# define NETDEV_LLADDRSIZE 0 /* No link layer address */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -438,15 +463,12 @@ int netdev_count(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_dev_l1size and netdev_type_llsize
|
||||
* Name: netdev_type_lladdrsize
|
||||
*
|
||||
* Description:
|
||||
* Size of the MAC address associated with a device or with a link layer
|
||||
* type.
|
||||
* Returns the size of the MAC address associated with a link layer type.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A reference to the device of interest
|
||||
* OR
|
||||
* lltype - link layer type code
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -454,8 +476,27 @@ int netdev_count(void);
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int netdev_type_l1size(uint8_t lltype);
|
||||
int netdev_dev_l1size(FAR struct net_driver_s *dev);
|
||||
int netdev_type_lladdrsize(uint8_t lltype);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_dev_lladdrsize
|
||||
*
|
||||
* Description:
|
||||
* Returns the size of the MAC address associated with a network device.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A reference to the device of interest
|
||||
*
|
||||
* Returned Value:
|
||||
* The size of the MAC address associated with this device
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_MULTILINK
|
||||
# define netdev_dev_lladdrsize(dev) netdev_type_lladdrsize((dev)->d_lltype)
|
||||
#else
|
||||
# define netdev_dev_lladdrsize(dev) NETDEV_LLADDRSIZE
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* net/netdev/netdev_l1size.c
|
||||
* net/netdev/netdev_lladdrsize.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
@@ -54,15 +54,12 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_dev_l1size and netdev_type_llsize
|
||||
* Name: netdev_type_lladdrsize
|
||||
*
|
||||
* Description:
|
||||
* Size of the MAC address associated with a device or with a link layer
|
||||
* type.
|
||||
* Returns the size of the MAC address associated with a link layer type.
|
||||
*
|
||||
* Parameters:
|
||||
* dev - A reference to the device of interest
|
||||
* OR
|
||||
* lltype - link layer type code
|
||||
*
|
||||
* Returned Value:
|
||||
@@ -70,13 +67,15 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int netdev_type_l1size(uint8_t lltype)
|
||||
int netdev_type_lladdrsize(uint8_t lltype)
|
||||
{
|
||||
/* Get the length of the address for this link layer type */
|
||||
|
||||
#ifdef CONFIG_NET_ETHERNET
|
||||
if (lltype == NET_LL_ETHERNET)
|
||||
{
|
||||
/* size of the Ethernet MAC address */
|
||||
|
||||
return IFHWADDRLEN;
|
||||
}
|
||||
else
|
||||
@@ -84,6 +83,10 @@ int netdev_type_l1size(uint8_t lltype)
|
||||
#ifdef CONFIG_NET_6LOWPAN
|
||||
if (lltype == NET_LL_IEEE802154)
|
||||
{
|
||||
/* 6LoWPAN can be configured to use either extended or short
|
||||
* addressing.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
return NET_6LOWPAN_EADDRSIZE;
|
||||
#else
|
||||
@@ -93,25 +96,10 @@ int netdev_type_l1size(uint8_t lltype)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
/* Either the link layer type associated with lltype has no address,
|
||||
* or support for that link layer type is not enabled.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int netdev_dev_l1size(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* Get the length of the address for this device */
|
||||
|
||||
#if defined(CONFIG_NET_MULTILINK)
|
||||
return netdev_type_l1size(dev->d_lltype);
|
||||
#elif defined(CONFIG_NET_ETHERNET)
|
||||
return IFHWADDRLEN;
|
||||
#elif defined(CONFIG_NET_6LOWPAN)
|
||||
#ifdef CONFIG_NET_6LOWPAN_EXTENDEDADDR
|
||||
return NET_6LOWPAN_EADDRSIZE;
|
||||
#else
|
||||
return NET_6LOWPAN_SADDRSIZE;
|
||||
#endif
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user