net: move device buffer define to common header

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2022-10-26 12:35:08 +08:00
committed by hartmannathan
parent 6908b6823c
commit a8d3286258
62 changed files with 185 additions and 444 deletions
+14 -17
View File
@@ -113,11 +113,6 @@
# define BUF ((FAR struct eth_hdr_s *)priv->dev.d_buf)
#endif
/* This is a helper pointer for accessing the contents of the ip header */
#define IPv4BUF ((FAR struct ipv4_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
****************************************************************************/
@@ -619,16 +614,18 @@ static void tun_net_receive_tap(FAR struct tun_device_s *priv)
static void tun_net_receive_tun(FAR struct tun_device_s *priv)
{
/* Copy the data data from the hardware to priv->dev.d_buf. Set amount of
* data in priv->dev.d_len
FAR struct net_driver_s *dev = &priv->dev;
/* Copy the data data from the hardware to dev->d_buf. Set amount of
* data in dev->d_len
*/
NETDEV_RXPACKETS(&priv->dev);
NETDEV_RXPACKETS(dev);
#ifdef CONFIG_NET_PKT
/* When packet sockets are enabled, feed the frame into the tap */
pkt_input(&priv->dev);
pkt_input(dev);
#endif
/* We only accept IP packets of the configured type */
@@ -637,11 +634,11 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
{
ninfo("IPv4 frame\n");
NETDEV_RXIPV4(&priv->dev);
NETDEV_RXIPV4(dev);
/* Give the IPv4 packet to the network layer. */
ipv4_input(&priv->dev);
ipv4_input(dev);
}
else
#endif
@@ -649,26 +646,26 @@ static void tun_net_receive_tun(FAR struct tun_device_s *priv)
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
{
ninfo("IPv6 frame\n");
NETDEV_RXIPV6(&priv->dev);
NETDEV_RXIPV6(dev);
/* Give the IPv6 packet to the network layer. */
ipv6_input(&priv->dev);
ipv6_input(dev);
}
else
#endif
{
NETDEV_RXDROPPED(&priv->dev);
priv->dev.d_len = 0;
NETDEV_RXDROPPED(dev);
dev->d_len = 0;
}
/* If the above function invocation resulted in data that should be
* sent out on the network, d_len field will set to a value > 0.
*/
if (priv->dev.d_len > 0)
if (dev->d_len > 0)
{
priv->write_d_len = priv->dev.d_len;
priv->write_d_len = dev->d_len;
tun_fd_transmit(priv);
}
}