Commit Graph

282 Commits

Author SHA1 Message Date
chao an 85440f5db6 net/ioctl/cellular: remove redundant logic
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-15 18:34:07 +08:00
luojun1 ec4af00538 Add Cellular link layer support
1.Add cellular link layer enum definition and register flow
2.Add ioctl flow to set cellular NICs parameters

Signed-off-by: luojun1 <luojun1@xiaomi.com>
Signed-off-by: chao an <anchao@xiaomi.com>
2022-10-15 18:34:07 +08:00
chao an 8b238e0b3d net/wireless: separate command catagory of bt/pktradio from wireless ioctl
1. separate command catagory of bt/pktradio from wireless ioctl
2. Remove commoand count limit to support vendor command

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-20 01:16:22 +08:00
Nathan Hartman d09304008e net: Fix sa_family returned by SIOCGIFHWADDR
* net/netdev/netdev_ioctl.c:
  (netdev_ifr_ioctl): The ioctl SIOCGIFHWADDR provides the hardware
   address (e.g., Ethernet MAC, etc.) of a network interface. It is
   based on Linux. (BSD-based systems don't have this ioctl.) The Linux
   implementation sets sa_family to ARPHRD_ETHER for Ethernet and IEEE
   802.11 interfaces [1]. NuttX was setting it to NET_SOCK_FAMILY for
   these interface types as well as 6LoWPAN and PKTRADIO; this was
   incorrect and also the value of NET_SOCK_FAMILY varies based on
   Kconfig settings. Correcting this to ARPHRD_ETHER for Ethernet and
   IEEE 802.11 and ARPHRD_IEEE802154 for 6LoWPAN and PKTRADIO.

References:
[1] 'man 7 netdevice' on Linux.
2022-09-16 02:59:50 +08:00
Nathan Hartman 6c4bd5c5ef net: Fix memcpy() size used by SIOCSIFHWADDR for radios
* net/netdev/netdev_ioctl.c:
  (netdev_ifr_ioctl): The ioctl SIOCSIFHWADDR sets the hardware address
   (e.g., Ethernet MAC, etc.) of a network interface. Radio devices may
   have different lengths of hardware addresses, such as
   NET_6LOWPAN_EADDRSIZE (8), NET_6LOWPAN_SADDRSIZE (2), or
   RADIO_MAX_ADDRLEN (8). Also, Kconfig CONFIG_PKTRADIO_ADDRLEN allows
   the user to set any arbitrary size. Note that while the sister ioctl
   SIOCGIFHWADDR "get hardware address" copies
   `dev->d_mac.radio.nv_addrlen` bytes, SIOCSIFHWADDR was copying
   NET_6LOWPAN_ADDRSIZE bytes unconditionally. Depending on which radio
   is used, this could be incorrect. Fixing it to use
   `dev->d_mac.radio.nv_addrlen` for SIOCSIFHWADDR as well. Also adding
   DEBUGASSERT to ensure this is within bounds of source and
   destination of the copy.
2022-09-16 02:59:40 +08:00
chao an 66d9397320 netdev/ioctl: netlock/unlock() should in pairs
fix regression by:

commit fd53db56b6
Author: chao an <anchao@xiaomi.com>
Date:   Wed Sep 7 10:56:09 2022 +0800

    net/netdev: simplify handling of netdev ifr ioctl()

    1. call netdev_ifr_dev() only once
    2. unify the error code of ENODEV

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 15:50:45 +08:00
chao an fd53db56b6 net/netdev: simplify handling of netdev ifr ioctl()
1. call netdev_ifr_dev() only once
2. unify the error code of ENODEV

Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 11:05:13 +08:00
chao an 54dba40f87 net/netdev/ioctl: correct the argument length of ioctl MII/PHY
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-07 03:33:41 +08:00
Xiang Xiao 9726be616a fs: Run the default action of FIONBIO/FIOCLEX/FIONCLEX in success path
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 23:16:15 +08:00
Xiang Xiao e0bb281e7a net: Align the prototype of sock_intf_s::si_ioctl with file_operations::ioctl
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-06 22:46:37 +08:00
chao.an 162fcd10ca net: cleanup pvconn reference to avoid confuse
More reference:
https://github.com/apache/incubator-nuttx/pull/5252
https://github.com/apache/incubator-nuttx/pull/5434

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-26 20:58:11 +08:00
Fotis Panagiotopoulos 9bc47ecdce Added lock in ifr ioctl calls. 2022-08-25 14:02:20 +02:00
Huang Qi e4e3208180 Replace all strncpy with strlcpy for safety
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2022-08-25 13:38:36 +08:00
zhanghongyu 51a262150d wifi: clear IFF_RUNNING flag when ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
zhanghongyu 7467586d55 netdev: add return value for ifup / ifdown
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-25 15:29:24 +08:00
zhanghongyu c7c5c75451 net_if: add IFF_LOOPBACK/POINTOPOINT/MULTICAST/BROADCAST
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-07-03 09:57:10 -04:00
chao.an 58dcee641e net/netdev: move netdev_ifup/down to public header
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-07-03 02:28:50 +08:00
chao.an 252985fc1d netdev/carrier: check the IF stautus before carrier
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-06-25 19:52:53 +08:00
Xiang Xiao 9072eecc30 sched/wqueue: Change the return type of work_notifier_teardown to void
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-05-14 00:35:29 +03:00
JacobCrabill 4610aee973 net/netdev: Add CONFIG_NETDEV_CAN_FILTER_IOCTL 2022-05-06 08:54:58 +02:00
hejianliang3 e9648d8a73 net:fix coverity warning
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
YAMAMOTO Takashi bc0ca51243 netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression
This fixes a regression caused by the following commit,
which prevents the file flag from being updated.

```
commit 28860b5242
Author: chao.an <anchao@xiaomi.com>
Date:   Sat Mar 19 14:47:37 2022 +0800

    net/netdev: fix switch case missing break

    Signed-off-by: chao.an <anchao@xiaomi.com>
```

Note: some applications like mbedtls uses F_GETFL to confirm
the nonblock-ness of the socket. This is critical for such
applications.
2022-04-01 16:35:12 +08:00
ligd 5b027f5260 net: netdev_ioctl handle FIONBIO
Signed-off-by: ligd <liguiding1@xiaomi.com>
2022-03-28 23:26:34 +08:00
chao.an 28860b5242 net/netdev: fix switch case missing break
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-19 10:14:35 +02:00
Xiang Xiao b2c86f808d net: Remove psock_fcntl related code
since the nonblocking mode set through psock_ioctl now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-03-04 22:03:55 +02:00
chao.an b16e022ead netdev/lladdrsize: remove invalid duplicate case
error:
--------------------------------------
netdev/netdev_lladdrsize.c: In function ‘netdev_lladdrsize’:
netdev/netdev_lladdrsize.c:148:7: error: duplicate case value
  148 |       case NET_LL_BLUETOOTH:
      |       ^~~~
netdev/netdev_lladdrsize.c:119:7: note: previously used here
  119 |       case NET_LL_BLUETOOTH:
      |       ^~~~

BLUETOOTH_HDRLEN has been removed by:
---------------------------------
|commit aae0d92598
|Author: Gregory Nutt <gnutt@nuttx.org>
|Date:   Sun Apr 1 15:21:58 2018 -0600
|
|wireless/bluetooth and net/bluetooth:
|
|Clean up some garbage left in Kconfig file that broke 'make menuconfig'.
|Clean up some craziness with Bluetooth frame length definitions.

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-07 20:08:26 +08:00
chao.an 56b5ae0640 net/tcp/netdev/mld: correct the netlock handling
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-03 11:09:18 -03:00
Xiang Xiao dfcb3cea59 Replace self defined macros with NET_SOCK_[FAMILY|TYPE|PROTOCOL]
NET_SOCK_* is defined by nuttx/net/netconfig.h and then can be shared

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-21 11:02:33 -03:00
Xiang Xiao c562263205 net: Move if_nametoindex and if_indextoname to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2021-12-19 10:08:57 -06:00
ligd 4a5d577483 socket_rpmsg: add socket_rpmsg_ioctl support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2021-12-13 21:15:59 -06:00
songlinzhang 22df553443 net/arp: clean the arp table when netdev carrier off
Fix the arp address changed if netdev renew, since the
arp table should be cleared when the netdev carrier off

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>
2021-11-27 06:19:50 -06:00
Alexander Lunev 36fbedcbfc net/devif/devif_callback.c: corrected the connection event list to work as FIFO instead of LIFO.
In case of enabled packet forwarding mode, packets were forwarded in a reverse order
because of LIFO behavior of the connection event list.
The issue exposed only during high network traffic. Thus the event list started to grow
that resulted in changing the order of packets inside of groups of several packets
like the following: 3, 2, 1, 6, 5, 4, 8, 7 etc.

Remarks concerning the connection event list implementation:
* Now the queue (list) is FIFO as it should be.
* The list is singly linked.
* The list has a head pointer (inside of outer net_driver_s structure),
  and a tail pointer is added into outer net_driver_s structure.
* The list item is devif_callback_s structure.
  It still has two pointers to two different list chains (*nxtconn and *nxtdev).
* As before the first argument (*dev) of the list functions can be NULL,
  while the other argument (*list) is effective (not NULL).
* An extra (*tail) argument is added to devif_callback_alloc()
  and devif_conn_callback_free() functions.
* devif_callback_alloc() time complexity is O(1) (i.e. O(n) to fill the whole list).
* devif_callback_free() time complexity is O(n) (i.e. O(n^2) to empty the whole list).
* devif_conn_event() time complexity is O(n).
2021-09-18 21:01:39 -05:00
chao.an eabe535de7 net/inet: add support of FIONREAD
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-05 06:20:52 -05:00
Xiang Xiao 20f5a28e49 net: Add if_nameindex and if_freenameindex API
Specified here:
https://man7.org/linux/man-pages/man3/if_nameindex.3.html

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Ia5daed775bd11fa5978d54860632554da8f7b416
2021-06-26 22:37:12 +01:00
Xiang Xiao 232d65c232 net: Fix: left shift of 1 by 31 places cannot be represented in type 'long int'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Id2daa60834f7b1917b15bbad89b091b59311e988
2021-06-23 05:24:15 -07:00
chao.an 70f6eb232a net/dev: link the net device as order of registration
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-05-31 01:38:38 -05:00
chao.an a988437e90 net/dev: check the available address further
check the available address further to avoid obtain unusable device

Signed-off-by: chao.an <anchao@xiaomi.com>
2021-03-23 06:52:32 -07:00
Jiuzhu Dong 4d5a964f29 net: unify socket into file descriptor
Change-Id: I9bcd21564e6c97d3edbb38aed1748c114160ea36
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2021-03-03 19:01:41 -08:00
Alin Jerpelea 37d5c1b0d9 net: Author Gregory Nutt: update licenses to Apache
Gregory Nutt has submitted the SGA and we can migrate the licenses
 to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-20 00:38:18 -08:00
Alin Jerpelea 7dc7ef45f1 net: nxstyle fixes
Nxstyle fixes to pass CI.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-20 00:38:18 -08:00
chao.an 049c991d28 style/Kconfig: remove unnecessary trailing whitespace
N/A

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-11-28 12:20:30 +01:00
chao.an d78bf36740 net/tcp: fix tcp socket close timeout if loss wireless connection
In the current net stack implementation, there is no mechanism
for notifying the loss of the wireless connection, if the network
is disconnected then application sends data packets through tcp,
the tcp_timer will keep retrying fetch the ack for awhile, the
connection status will not be able to be switched timely.

Change-Id: I84d1121527edafc6ee6ad56ba164838694e7e11c
Signed-off-by: chao.an <anchao@xiaomi.com>
2020-10-28 11:41:16 -07:00
Yoshinori Sugino 3ac90fca79 Remove tabs and spaces at the end of lines 2020-10-24 09:38:21 +01:00
Peter van der Perk b5c5948e1c NXStyle fixes 2020-06-15 08:07:19 -06:00
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
Alan C. Assis 7609b67496 Fix issues reported on PR #1233 2020-06-15 07:13:21 -06:00
Alan C. Assis 6ff18a7f3b Rename NETDEV_WBIM_FORMAT with NETDEV_WWAM_FORMAT 2020-06-15 07:13:21 -06:00
Alan C. Assis e1be7ace4b Fix netdev and add Apache license to the file 2020-06-15 07:13:21 -06:00
Adam Porter 07c0faff59 Add support to CDC-MBIM USB host driver
This driver was created by Adam Porter and posted on NuttX
mailing list at Google Group on Nov 14 2019
2020-06-15 07:13:21 -06:00
Gregory Nutt 35efcee5c9 net/netdev/netdev_register.c: Add some comments.
This commit adds some short comments to explain some perplexing logic of PR #1047.
2020-05-15 15:48:00 +01:00