mirror of
https://github.com/apache/nuttx.git
synced 2026-05-25 18:27:56 +08:00
Adjust ioctl function of cellular
Add SIOCGCELLNETDEV Give a uint8_t[136] for cellular to save data Signed-off-by: tangyusong1 <tangyusong1@xiaomi.com>
This commit is contained in:
+55
-17
@@ -67,6 +67,10 @@
|
||||
# include <nuttx/wireless/pktradio.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_CELLULAR
|
||||
# include <nuttx/wireless/cellular/cellular.h>
|
||||
#endif
|
||||
|
||||
#include "arp/arp.h"
|
||||
#include "socket/socket.h"
|
||||
#include "netdev/netdev.h"
|
||||
@@ -544,6 +548,47 @@ static int netdev_pktradio_ioctl(FAR struct socket *psock, int cmd,
|
||||
}
|
||||
#endif /* HAVE_PKTRADIO_IOCTL */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_cell_ioctl
|
||||
*
|
||||
* Description:
|
||||
* Perform cell ioctl operations.
|
||||
*
|
||||
* Parameters:
|
||||
* psock Socket structure
|
||||
* cmd The ioctl command
|
||||
* arg The argument of the ioctl cmd
|
||||
*
|
||||
* Return:
|
||||
* >=0 on success (positive non-zero values are cmd-specific)
|
||||
* Negated errno returned on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
static int netdev_cell_ioctl(FAR struct socket *psock, int cmd,
|
||||
FAR struct icellreq *req)
|
||||
{
|
||||
FAR struct net_driver_s *dev = NULL;
|
||||
int ret = -ENOTTY;
|
||||
|
||||
ninfo("cmd: %d\n", cmd);
|
||||
net_lock();
|
||||
|
||||
if (_CELLIOCVALID(cmd))
|
||||
{
|
||||
dev = netdev_findbyname(req->ifr_name);
|
||||
if (dev && dev->d_ioctl)
|
||||
{
|
||||
ret = dev->d_ioctl(dev, cmd, (unsigned long)(uintptr_t)req);
|
||||
}
|
||||
}
|
||||
|
||||
net_unlock();
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: netdev_wifr_ioctl
|
||||
*
|
||||
@@ -661,7 +706,6 @@ static ssize_t net_ioctl_ifreq_arglen(int cmd)
|
||||
case SIOCDCANEXTFILTER:
|
||||
case SIOCACANSTDFILTER:
|
||||
case SIOCDCANSTDFILTER:
|
||||
case SIOCSCELLNETDEV:
|
||||
case SIOCSIFNAME:
|
||||
case SIOCGIFNAME:
|
||||
case SIOCGIFINDEX:
|
||||
@@ -1078,22 +1122,6 @@ static int netdev_ifr_ioctl(FAR struct socket *psock, int cmd,
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
case SIOCSCELLNETDEV: /* set params for cellular network devices */
|
||||
if (dev->d_ioctl)
|
||||
{
|
||||
FAR struct cell_ioctl_data_s *cell_netdev_data =
|
||||
&req->ifr_ifru.ifru_cell_data;
|
||||
ret = dev->d_ioctl(dev, cmd,
|
||||
(unsigned long)(uintptr_t)cell_netdev_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = -ENOSYS;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
@@ -1714,6 +1742,16 @@ int psock_vioctl(FAR struct socket *psock, int cmd, va_list ap)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NETDEV_IOCTL) && defined(CONFIG_NET_CELLULAR)
|
||||
/* Check for a cellular network command */
|
||||
|
||||
if (ret == -ENOTTY)
|
||||
{
|
||||
ret = netdev_cell_ioctl(psock, cmd,
|
||||
(FAR struct icellreq *)(uintptr_t)arg);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IEEE802154_IOCTL
|
||||
/* Check for a IEEE802.15.4 network device IOCTL command */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user