mirror of
https://github.com/apache/nuttx.git
synced 2026-05-20 20:44:39 +08:00
netdev/ioctl: Add support for simple VLAN ioctl
Supporting ADD_VLAN_CMD and DEL_VLAN_CMD of SIOCSIFVLAN Ref: https://github.com/torvalds/linux/blob/v6.12/net/8021q/vlan.c#L621 Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
@@ -1133,6 +1133,40 @@ int netdev_upper_wireless_ioctl(FAR struct netdev_lowerhalf_s *lower,
|
||||
}
|
||||
#endif /* CONFIG_NETDEV_WIRELESS_HANDLER */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_upper_vlan_ioctl
|
||||
*
|
||||
* Description:
|
||||
* Support for VLAN handlers in ioctl.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NET_VLAN
|
||||
int netdev_upper_vlan_ioctl(FAR struct netdev_lowerhalf_s *lower,
|
||||
int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct vlan_ioctl_args *args =
|
||||
(FAR struct vlan_ioctl_args *)(uintptr_t)arg;
|
||||
|
||||
if (cmd != SIOCSIFVLAN && cmd != SIOCGIFVLAN)
|
||||
{
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
switch (args->cmd)
|
||||
{
|
||||
case ADD_VLAN_CMD:
|
||||
return vlan_register(lower, args->u.VID);
|
||||
|
||||
case DEL_VLAN_CMD:
|
||||
vlan_unregister(lower);
|
||||
return OK;
|
||||
}
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif /* CONFIG_NET_VLAN */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_upper_ifup/ifdown/addmac/rmmac/ioctl
|
||||
*
|
||||
@@ -1241,11 +1275,12 @@ static int netdev_upper_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
{
|
||||
FAR struct netdev_upperhalf_s *upper = dev->d_private;
|
||||
FAR struct netdev_lowerhalf_s *lower = upper->lower;
|
||||
int ret = -ENOTTY;
|
||||
|
||||
#ifdef CONFIG_NETDEV_WIRELESS_HANDLER
|
||||
if (lower->iw_ops)
|
||||
{
|
||||
int ret = netdev_upper_wireless_ioctl(lower, cmd, arg);
|
||||
ret = netdev_upper_wireless_ioctl(lower, cmd, arg);
|
||||
if (ret != -ENOTTY)
|
||||
{
|
||||
return ret;
|
||||
@@ -1253,12 +1288,20 @@ static int netdev_upper_ioctl(FAR struct net_driver_s *dev, int cmd,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_VLAN
|
||||
ret = netdev_upper_vlan_ioctl(lower, cmd, arg);
|
||||
if (ret != -ENOTTY)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (lower->ops->ioctl)
|
||||
{
|
||||
return lower->ops->ioctl(lower, cmd, arg);
|
||||
}
|
||||
|
||||
return -ENOTTY;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user