netdev_upperhalf: add L3 packet handle
To provide support for the received L3 network packets Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
parent
85b2cbaca6
commit
92cd1c3742
1 changed files with 68 additions and 0 deletions
|
@ -405,6 +405,69 @@ static void eth_input(FAR struct net_driver_s *dev)
|
|||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ip_input
|
||||
*
|
||||
* Description:
|
||||
* Handle L3 packet input.
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - Reference to the NuttX network driver state structure
|
||||
*
|
||||
* Assumptions:
|
||||
* Called with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_MBIM
|
||||
static void ip_input(FAR struct net_driver_s *dev)
|
||||
{
|
||||
/* We only accept IP packets of the configured type */
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if ((IPv4BUF->vhl & IP_VERSION_MASK) == IPv4_VERSION)
|
||||
{
|
||||
ninfo("IPv4 frame\n");
|
||||
NETDEV_RXIPV4(dev);
|
||||
|
||||
/* Receive an IPv4 packet from the network device */
|
||||
|
||||
ipv4_input(dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if ((IPv6BUF->vtc & IP_VERSION_MASK) == IPv6_VERSION)
|
||||
{
|
||||
ninfo("IPv6 frame\n");
|
||||
NETDEV_RXIPV6(dev);
|
||||
|
||||
/* Give the IPv6 packet to the network layer */
|
||||
|
||||
ipv6_input(dev);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ninfo("INFO: Dropped, Unknown type\n");
|
||||
NETDEV_RXDROPPED(dev);
|
||||
dev->d_len = 0;
|
||||
}
|
||||
|
||||
/* If the above function invocation resulted in data
|
||||
* that should be sent out on the network,
|
||||
* the field d_len will set to a value > 0.
|
||||
*/
|
||||
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
/* And send the packet */
|
||||
|
||||
netdev_upper_txpoll(dev);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: netdev_upper_rxpoll_work
|
||||
*
|
||||
|
@ -465,6 +528,11 @@ static void netdev_upper_rxpoll_work(FAR struct netdev_upperhalf_s *upper)
|
|||
eth_input(dev);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_NET_MBIM
|
||||
case NET_LL_MBIM:
|
||||
ip_input(dev);
|
||||
break;
|
||||
#endif
|
||||
#ifdef CONFIG_NET_CAN
|
||||
case NET_LL_CAN:
|
||||
ninfo("CAN frame");
|
||||
|
|
Loading…
Reference in a new issue