include/nuttx/net and net/: Move private prototype of netdev_foreach() from the public include/nuttx/net/net.h to the private net/netdev/ndetdev.h header file where it belongs.

This commit is contained in:
Gregory Nutt 2017-07-01 08:39:39 -06:00
parent ae1771454a
commit d280f8854e
4 changed files with 36 additions and 34 deletions

View File

@ -137,11 +137,6 @@ struct socketlist
};
#endif
/* Callback from netdev_foreach() */
struct net_driver_s; /* Forward reference. Defined in nuttx/net/netdev.h */
typedef int (*netdev_callback_t)(FAR struct net_driver_s *dev, FAR void *arg);
/****************************************************************************
* Public Data
****************************************************************************/
@ -1177,6 +1172,7 @@ int net_vfcntl(int sockfd, int cmd, va_list ap);
*
****************************************************************************/
struct net_driver_s; /* Forward reference */
int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype);
/****************************************************************************
@ -1199,28 +1195,6 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype);
int netdev_unregister(FAR struct net_driver_s *dev);
/****************************************************************************
* Name: netdev_foreach
*
* Description:
* Enumerate each registered network device.
*
* NOTE: netdev semaphore held throughout enumeration.
*
* Parameters:
* callback - Will be called for each registered device
* arg - User argument passed to callback()
*
* Returned Value:
* 0:Enumeration completed 1:Enumeration terminated early by callback
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
int netdev_foreach(netdev_callback_t callback, FAR void *arg);
#undef EXTERN
#ifdef __cplusplus
}

View File

@ -87,7 +87,6 @@
#include <net/if.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/netstats.h>
@ -242,6 +241,7 @@ static bool check_destipaddr(FAR struct net_driver_s *dev,
* to this input.
*
* Assumptions:
* The network is locked.
*
****************************************************************************/

View File

@ -70,6 +70,15 @@ extern "C"
EXTERN struct net_driver_s *g_netdevices;
#endif
/****************************************************************************
* Public Types
****************************************************************************/
/* Callback from netdev_foreach() */
struct net_driver_s; /* Forward reference */
typedef int (*netdev_callback_t)(FAR struct net_driver_s *dev, FAR void *arg);
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@ -120,6 +129,28 @@ bool netdev_verify(FAR struct net_driver_s *dev);
FAR struct net_driver_s *netdev_findbyname(FAR const char *ifname);
#endif
/****************************************************************************
* Name: netdev_foreach
*
* Description:
* Enumerate each registered network device.
*
* NOTE: netdev semaphore held throughout enumeration.
*
* Parameters:
* callback - Will be called for each registered device
* arg - User argument passed to callback()
*
* Returned Value:
* 0:Enumeration completed 1:Enumeration terminated early by callback
*
* Assumptions:
* Called from normal user mode
*
****************************************************************************/
int netdev_foreach(netdev_callback_t callback, FAR void *arg);
/****************************************************************************
* Name: netdev_findby_ipv4addr
*

View File

@ -41,7 +41,7 @@
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <debug.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netdev.h>
#include "netdev/netdev.h"
@ -66,7 +66,7 @@
* 0:Enumeration completed 1:Enumeration terminated early by callback
*
* Assumptions:
* Called from normal user mode
* The network is locked.
*
****************************************************************************/
@ -75,9 +75,8 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg)
FAR struct net_driver_s *dev;
int ret = 0;
if (callback)
if (callback != NULL)
{
net_lock();
for (dev = g_netdevices; dev; dev = dev->flink)
{
if (callback(dev, arg) != 0)
@ -86,8 +85,6 @@ int netdev_foreach(netdev_callback_t callback, FAR void *arg)
break;
}
}
net_unlock();
}
return ret;