mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 01:21:26 +08:00
drivers/net/tun.c: Costmetic changes from review for coding style compliance.
This commit is contained in:
+37
-33
@@ -112,18 +112,18 @@
|
|||||||
* second
|
* second
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TUN_WDDELAY (1*CLK_TCK)
|
#define TUN_WDDELAY (1 * CLK_TCK)
|
||||||
|
|
||||||
/* This is a helper pointer for accessing the contents of the Ethernet header */
|
/* This is a helper pointer for accessing the contents of the Ethernet header */
|
||||||
|
|
||||||
#ifdef CONFIG_NET_ETHERNET
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
# define BUF ((struct eth_hdr_s *)priv->dev.d_buf)
|
# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This is a helper pointer for accessing the contents of the ip header */
|
/* This is a helper pointer for accessing the contents of the ip header */
|
||||||
|
|
||||||
#define IPv4BUF ((struct ipv4_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
#define IPv4BUF ((FAR struct ipv4_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
||||||
#define IPv6BUF ((struct ipv6_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
#define IPv6BUF ((FAR struct ipv6_hdr_s *)(priv->dev.d_buf + priv->dev.d_llhdrlen))
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
@@ -179,11 +179,11 @@ static void tun_unlock(FAR struct tun_device_s *priv);
|
|||||||
/* Common TX logic */
|
/* Common TX logic */
|
||||||
|
|
||||||
static int tun_fd_transmit(FAR struct tun_device_s *priv);
|
static int tun_fd_transmit(FAR struct tun_device_s *priv);
|
||||||
static int tun_txpoll(struct net_driver_s *dev);
|
static int tun_txpoll(FAR struct net_driver_s *dev);
|
||||||
#ifdef CONFIG_NET_ETHERNET
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
static int tun_txpoll_tap(struct net_driver_s *dev);
|
static int tun_txpoll_tap(FAR struct net_driver_s *dev);
|
||||||
#endif
|
#endif
|
||||||
static int tun_txpoll_tun(struct net_driver_s *dev);
|
static int tun_txpoll_tun(FAR struct net_driver_s *dev);
|
||||||
|
|
||||||
/* Interrupt handling */
|
/* Interrupt handling */
|
||||||
|
|
||||||
@@ -249,6 +249,9 @@ static const struct file_operations g_tun_file_ops =
|
|||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
tun_poll, /* poll */
|
tun_poll, /* poll */
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
|
||||||
|
0, /* unlink */
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -324,7 +327,8 @@ static void tun_unlock(FAR struct tun_device_s *priv)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_DISABLE_POLL
|
#ifndef CONFIG_DISABLE_POLL
|
||||||
static void tun_pollnotify(FAR struct tun_device_s *priv, pollevent_t eventset)
|
static void tun_pollnotify(FAR struct tun_device_s *priv,
|
||||||
|
pollevent_t eventset)
|
||||||
{
|
{
|
||||||
FAR struct pollfd *fds = priv->poll_fds;
|
FAR struct pollfd *fds = priv->poll_fds;
|
||||||
|
|
||||||
@@ -388,9 +392,9 @@ static int tun_fd_transmit(FAR struct tun_device_s *priv)
|
|||||||
* Name: tun_txpoll
|
* Name: tun_txpoll
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The transmitter is available, check if the network has any outgoing packets
|
* The transmitter is available, check if the network has any outgoing
|
||||||
* ready to send. This is a callback from devif_poll(). devif_poll() may
|
* packets ready to send. This is a callback from devif_poll().
|
||||||
* be called:
|
* devif_poll() may be called:
|
||||||
*
|
*
|
||||||
* 1. When the preceding TX packet send is complete,
|
* 1. When the preceding TX packet send is complete,
|
||||||
* 2. When the preceding TX packet send timesout and the interface is reset
|
* 2. When the preceding TX packet send timesout and the interface is reset
|
||||||
@@ -409,7 +413,7 @@ static int tun_fd_transmit(FAR struct tun_device_s *priv)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_txpoll(struct net_driver_s *dev)
|
static int tun_txpoll(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -431,9 +435,9 @@ static int tun_txpoll(struct net_driver_s *dev)
|
|||||||
* Name: tun_txpoll_tap : for tap (ethernet bridge) mode
|
* Name: tun_txpoll_tap : for tap (ethernet bridge) mode
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The transmitter is available, check if the network has any outgoing packets
|
* The transmitter is available, check if the network has any outgoing
|
||||||
* ready to send. This is a callback from devif_poll(). devif_poll() may
|
* packets ready to send. This is a callback from devif_poll().
|
||||||
* be called:
|
* devif_poll() may be called:
|
||||||
*
|
*
|
||||||
* 1. When the preceding TX packet send is complete,
|
* 1. When the preceding TX packet send is complete,
|
||||||
* 2. When the preceding TX packet send timesout and the interface is reset
|
* 2. When the preceding TX packet send timesout and the interface is reset
|
||||||
@@ -453,7 +457,7 @@ static int tun_txpoll(struct net_driver_s *dev)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_ETHERNET
|
#ifdef CONFIG_NET_ETHERNET
|
||||||
static int tun_txpoll_tap(struct net_driver_s *dev)
|
static int tun_txpoll_tap(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
|
|
||||||
@@ -504,9 +508,9 @@ static int tun_txpoll_tap(struct net_driver_s *dev)
|
|||||||
* Name: tun_txpoll_tun : for tun (IP tunneling) mode
|
* Name: tun_txpoll_tun : for tun (IP tunneling) mode
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* The transmitter is available, check if the network has any outgoing packets
|
* The transmitter is available, check if the network has any outgoing
|
||||||
* ready to send. This is a callback from devif_poll(). devif_poll() may
|
* packets ready to send. This is a callback from devif_poll().
|
||||||
* be called:
|
* devif_poll() may be called:
|
||||||
*
|
*
|
||||||
* 1. When the preceding TX packet send is complete,
|
* 1. When the preceding TX packet send is complete,
|
||||||
* 2. When the preceding TX packet send timesout and the interface is reset
|
* 2. When the preceding TX packet send timesout and the interface is reset
|
||||||
@@ -525,7 +529,7 @@ static int tun_txpoll_tap(struct net_driver_s *dev)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_txpoll_tun(struct net_driver_s *dev)
|
static int tun_txpoll_tun(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
|
|
||||||
@@ -546,8 +550,8 @@ static int tun_txpoll_tun(struct net_driver_s *dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If zero is returned, the polling will continue until all connections have
|
/* If zero is returned, the polling will continue until all connections
|
||||||
* been examined.
|
* have been examined.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -557,7 +561,8 @@ static int tun_txpoll_tun(struct net_driver_s *dev)
|
|||||||
* Name: tun_net_receive
|
* Name: tun_net_receive
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* An interrupt was received indicating the availability of a new RX packet
|
* An interrupt was received indicating the availability of a new RX
|
||||||
|
* packet
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* priv - Reference to the driver state structure
|
* priv - Reference to the driver state structure
|
||||||
@@ -716,7 +721,6 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
|||||||
{
|
{
|
||||||
NETDEV_RXDROPPED(&priv->dev);
|
NETDEV_RXDROPPED(&priv->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -724,7 +728,8 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
|
|||||||
* Name: tun_net_receive_tun : for tun (IP tunneling) mode
|
* Name: tun_net_receive_tun : for tun (IP tunneling) mode
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* An interrupt was received indicating the availability of a new RX packet
|
* An interrupt was received indicating the availability of a new RX
|
||||||
|
* packet
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* priv - Reference to the driver state structure
|
* priv - Reference to the driver state structure
|
||||||
@@ -912,7 +917,7 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_ifup(struct net_driver_s *dev)
|
static int tun_ifup(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
|
|
||||||
@@ -963,7 +968,7 @@ static int tun_ifup(struct net_driver_s *dev)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_ifdown(struct net_driver_s *dev)
|
static int tun_ifdown(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
@@ -1047,7 +1052,7 @@ static void tun_txavail_work(FAR void *arg)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int tun_txavail(struct net_driver_s *dev)
|
static int tun_txavail(FAR struct net_driver_s *dev)
|
||||||
{
|
{
|
||||||
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
|
||||||
|
|
||||||
@@ -1080,7 +1085,7 @@ static int tun_txavail(struct net_driver_s *dev)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MCASTGROUP
|
#ifdef CONFIG_NET_MCASTGROUP
|
||||||
static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
static int tun_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||||
{
|
{
|
||||||
/* Add the MAC address to the hardware multicast routing table */
|
/* Add the MAC address to the hardware multicast routing table */
|
||||||
|
|
||||||
@@ -1092,8 +1097,8 @@ static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
|||||||
* Name: tun_rmmac
|
* Name: tun_rmmac
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* NuttX Callback: Remove the specified MAC address from the hardware multicast
|
* NuttX Callback: Remove the specified MAC address from the hardware
|
||||||
* address filtering
|
* multicast address filtering
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* dev - Reference to the NuttX driver state structure
|
* dev - Reference to the NuttX driver state structure
|
||||||
@@ -1107,7 +1112,7 @@ static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_NET_MCASTGROUP
|
#ifdef CONFIG_NET_MCASTGROUP
|
||||||
static int tun_rmmac(struct net_driver_s *dev, FAR const uint8_t *mac)
|
static int tun_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac)
|
||||||
{
|
{
|
||||||
/* Add the MAC address to the hardware multicast routing table */
|
/* Add the MAC address to the hardware multicast routing table */
|
||||||
|
|
||||||
@@ -1544,4 +1549,3 @@ int tun_initialize(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_NET && CONFIG_NET_TUN */
|
#endif /* CONFIG_NET && CONFIG_NET_TUN */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user