Add mtu set and interface name set in ioctl
Follow LinuxOS:linux-5.10.152\include\uapi\linux\sockios.h Add SIOCSIFMTU and SIOCSIFNAME Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
This commit is contained in:
parent
fdc1aa6ae3
commit
1c7a9d282c
|
@ -47,6 +47,7 @@
|
|||
#define SIOCGIFNETMASK _SIOC(0x0007) /* Get network mask */
|
||||
#define SIOCSIFNETMASK _SIOC(0x0008) /* Set network mask */
|
||||
#define SIOCGIFMTU _SIOC(0x0009) /* Get MTU size */
|
||||
#define SIOCSIFMTU _SIOC(0x0033) /* Set MTU size */
|
||||
|
||||
/* IPv6 interface control operations */
|
||||
|
||||
|
@ -72,6 +73,7 @@
|
|||
|
||||
#define SIOCGIFNAME _SIOC(0x002A) /* Get interface name string */
|
||||
#define SIOCGIFINDEX _SIOC(0x002B) /* Get index based name string */
|
||||
#define SIOCSIFNAME _SIOC(0x0034) /* Set interface name string*/
|
||||
|
||||
/* Interface flags */
|
||||
|
||||
|
|
|
@ -643,6 +643,7 @@ static ssize_t net_ioctl_ifreq_arglen(int cmd)
|
|||
case SIOCSIFBRDADDR:
|
||||
case SIOCGIFNETMASK:
|
||||
case SIOCSIFNETMASK:
|
||||
case SIOCSIFMTU:
|
||||
case SIOCGIFMTU:
|
||||
case SIOCGIFHWADDR:
|
||||
case SIOCSIFHWADDR:
|
||||
|
@ -661,6 +662,7 @@ static ssize_t net_ioctl_ifreq_arglen(int cmd)
|
|||
case SIOCACANSTDFILTER:
|
||||
case SIOCDCANSTDFILTER:
|
||||
case SIOCSCELLNETDEV:
|
||||
case SIOCSIFNAME:
|
||||
case SIOCGIFNAME:
|
||||
case SIOCGIFINDEX:
|
||||
return sizeof(struct ifreq);
|
||||
|
@ -731,6 +733,21 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
|||
#endif
|
||||
|
||||
#ifdef CONFIG_NETDEV_IFINDEX
|
||||
case SIOCSIFNAME: /* Set interface name */
|
||||
{
|
||||
FAR struct net_driver_s *tmpdev;
|
||||
tmpdev = netdev_findbyindex(req->ifr_ifindex);
|
||||
if (tmpdev != NULL)
|
||||
{
|
||||
strlcpy(tmpdev->d_ifname, req->ifr_name, IFNAMSIZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENODEV;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SIOCGIFNAME: /* Get interface name */
|
||||
{
|
||||
FAR struct net_driver_s *tmpdev;
|
||||
|
@ -860,6 +877,13 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
|||
case SIOCGIFMTU: /* Get MTU size */
|
||||
req->ifr_mtu = NETDEV_PKTSIZE(dev);
|
||||
break;
|
||||
case SIOCSIFMTU: /* Set MTU size */
|
||||
dev = netdev_ifr_dev(req);
|
||||
if (dev)
|
||||
{
|
||||
NETDEV_PKTSIZE(dev) = req->ifr_mtu;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_NET_ICMPv6_AUTOCONF
|
||||
case SIOCIFAUTOCONF: /* Perform ICMPv6 auto-configuration */
|
||||
|
|
Loading…
Reference in New Issue