Commit Graph

91 Commits

Author SHA1 Message Date
Xiang Xiao
6a3c2aded6 Fix wait loop and void cast (#24)
* Simplify EINTR/ECANCEL error handling

1. Add semaphore uninterruptible wait function
2 .Replace semaphore wait loop with a single uninterruptible wait
3. Replace all sem_xxx to nxsem_xxx

* Unify the void cast usage

1. Remove void cast for function because many place ignore the returned value witout cast
2. Replace void cast for variable with UNUSED macro
2020-01-02 10:54:43 -06:00
Xiang Xiao
90c52e6f8f Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>

    Run all .h and .c files modified in last PR through nxstyle.

Author: Xiang Xiao <xiaoxiang@xiaomi.com>

    Net cleanup (#17)

    * Fix the semaphore usage issue found in tcp/udp

    1. The count semaphore need disable priority inheritance
    2. Loop again if net_lockedwait return -EINTR
    3. Call nxsem_trywait to avoid the race condition
    4. Call nxsem_post instead of sem_post

    * Put the work notifier into free list to avoid the heap fragment in the long run.  Since the allocation strategy is encapsulated internally, we can even refine the implementation later.

    * Network stack shouldn't allocate memory in the poll implementation to avoid the heap fragment in the long run, other modification include:

    1. Select MM_IOB automatically since ICMP[v6] socket can't work without the read ahead buffer
    2. Remove the net lock since xxx_callback_free already do the same thing
    3. TCP/UDP poll should work even the read ahead buffer isn't enabled at all

    * Add NET_ prefix for UDP_NOTIFIER and TCP_NOTIFIER option to align with other UDP/TCP option convention

    * Remove the unused _SF_[IDLE|ACCEPT|SEND|RECV|MASK] flags since there are code to set/clear these flags, but nobody check them.
2019-12-31 09:26:14 -06:00
liuhuahang
ce634578dd This change implements the SO_ERROR socket option that is used to obtain the last error reported by the network.
Squashed commit of the following:

Author: Gregory Nutt <gnutt@nuttx.org>

    net/: Trivial changes to PR from review.  Biggest difference:  type of s_error changed to int16_t to save a byte or two.

Author: liuhuahang <liuhuahang@xiaomi.com>

    Implement SO_ERROR for getsockopt()
2019-12-24 08:09:55 -06:00
Gregory Nutt
b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt
af072d52bc Adds OS internal functions nx_send(), ns_recv(), and nx_recvfrom() which are functionally equivalent to send(), recv(), and recvfrom() except that they do not set the errno variable and do not cause cancellation points. 2017-10-11 09:25:43 -06:00
Gregory Nutt
2c2aa94b7d Squashed commit of the following:
net/: psock_recvfrom() is an internal interface and should not set the errno nor should it be a cancellation point.

    net/: psock_accept() is not a cancellation point.

    net/: psock_getsockopt() and psock_socket*9 are an internal interfaces and should not set the errno.

    net/: psock_getsockopt() is an internal interface and should not set the errno.

    net/: psock_listen() is an internal interface and should not set the errno.

    net/: psock_connect(( is an internal interface and should not set the errno nor should it be a cancellation point.

    net/: psock_bind() is an internal interface and should not set the errno.

    net/: psock_accept() is an internal interface and should not set the errno.
2017-09-30 08:18:08 -06:00
Bruno Herrera
24767a0c66 Fixes for problems found by Coverity in the nuttx repository:
net/socket/recvfrom.c: Check fromlen integrity before using it.

    net/socket/net_sockets.c: Always check for valid psock before using.

    net/tcp/tcp_send_unbuffered.c:  Avoid using psock beforing checking its integrity.

    sched/timer/timer_create.c: Fix watchdog resource leak if cannot allocate a new timer.
2017-09-25 07:17:09 -06:00
Jussi Kivilinna
61878848ad net/sock: recvfrom: Fix double leave_cancellation_point on error path 2017-09-12 07:17:53 -06:00
Gregory Nutt
85b1ae4cf0 Socket interface: Added bind() and connect() interfaces. 2017-07-13 09:28:18 -06:00
Gregory Nutt
a71c504142 Socket I/F: Add recvfrom() method to interface. 2017-07-12 17:36:05 -06:00
Gregory Nutt
2043e1a114 IOBs: Move from driver/iob to a better location in mm/iob 2017-05-09 07:35:30 -06:00
Gregory Nutt
d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -06:00
Gregory Nutt
bcc6b61fc1 Move include/nuttx/net/iob.h to include/drivers/iob.h; rename CONFIG_NET_IOB to CONFIG_DRIVERS_IOB 2017-04-20 14:53:30 -06:00
Jussi Kivilinna
cd3c9634c8 Add user-space networking stack API (usrsock)
User-space networking stack API allows user-space daemon to
provide TCP/IP stack implementation for NuttX network.

Main use for this is to allow use and seamless integration of
HW-provided TCP/IP stacks to NuttX.

For example, user-space daemon can translate /dev/usrsock
API requests to HW TCP/IP API requests while rest of the
user-space can access standard socket API, with socket
descriptors that can be used with NuttX system calls.
2017-03-31 08:58:14 -06:00
Janne Rosberg
3331e9c49a STM32 OTGHS host: stm32_in_transfer() fails and returns NAK if a short transfer is received. This causes problems from class drivers like CDC/ACM where short packets are expected. In those protocols, any transfer may be terminated by sending short or NUL packet. 2017-03-07 06:58:59 -06:00
Gregory Nutt
b52e4e5ecd Move cancellation point definitions to their own header file. 2016-12-10 09:08:26 -06:00
Gregory Nutt
bc3ca25cc7 Cancellation points: Close up some logic to eliminte some race conditions. 2016-12-10 08:36:58 -06:00
Gregory Nutt
16be9b332e More cancellation points 2016-12-09 15:17:58 -06:00
Gregory Nutt
7467329a98 Eliminate CONFIG_NO_NOINTS. Lots of files changed -> lots of testing needed. 2016-12-03 16:28:19 -06:00
Gregory Nutt
2d057c28c8 net: Disable priority inheritance on all semaphores used for signaling 2016-11-03 12:17:02 -06:00
Gregory Nutt
2a751068e6 Without lowsyslog() *llerr() is not useful. Eliminate and replace with *err(). 2016-06-20 12:44:38 -06:00
Gregory Nutt
43eb04bb8f Without lowsyslog() *llinfo() is not useful. Eliminate and replace with *info(). 2016-06-20 11:59:15 -06:00
Gregory Nutt
a1469a3e95 Add CONFIG_DEBUG_ERROR. Change names of *dbg() * *err() 2016-06-11 15:50:49 -06:00
Gregory Nutt
e99301d7c2 Rename *lldbg to *llerr 2016-06-11 14:55:27 -06:00
Gregory Nutt
86b79b33cf Reserver the name 'err' for other purposes 2016-06-11 14:40:07 -06:00
Gregory Nutt
1cdc746726 Rename CONFIG_DEBUG to CONFIG_DEBUG_FEATURES 2016-06-11 14:14:08 -06:00
Gregory Nutt
fc3540cffe Replace all occurrences of vdbg with vinfo 2016-06-11 11:59:51 -06:00
Gregory Nutt
4f208600aa Replace confusing references to uIP with just 'the network' 2016-05-30 09:31:44 -06:00
Gregory Nutt
3ca5a94515 VNC: Add basic message receipt logic 2016-04-17 09:17:37 -06:00
Gregory Nutt
8db55f6493 Back out most of previous commit 2016-02-26 06:45:37 -06:00
Gregory Nutt
0b441ff1f4 net/: Add basic IEEE 802.15-4 socket support 2016-02-25 14:01:22 -06:00
Gregory Nutt
f348e68069 Update to use 64-bit timer when available 2016-01-21 11:54:26 -06:00
Gregory Nutt
6209c51206 net/: More clean-up of spacing/alignment issues 2015-10-08 15:10:04 -06:00
Gregory Nutt
0b12dbf95d Fix some spacing problems 2015-10-04 15:04:00 -06:00
Gregory Nutt
fec3d2cf62 recvfrom: Fixes for compilation with only raw, packet sockets 2015-09-14 09:06:08 -06:00
Gregory Nutt
63071a563a Costmetic changes 2015-08-27 10:38:43 -06:00
Gregory Nutt
89b5ef8d35 wdogs: Fix counting of free, pre-allocated wdog timers. The could could get decremented below zero in some situations 2015-08-21 11:30:22 -06:00
Pavel Pisa
12b1c04508 recvfrom(): Correct wait for new data when NET_UDP_READAHEAD is enabled. Fix size accounting when recvfrom_udpreadahead() sets state.rf_recvlen == -1. I have not checked if data are accumulated to the right position in the buffer however.
Signed-off-by: Pavel Pisa <ppisa@pikron.com>
2015-08-21 09:15:06 -06:00
Max Neklyudov
7d04104485 Networking: Allow receipt of empty UDP packets. From Max Neklyudov 2015-08-11 08:34:16 -06:00
Gregory Nutt
fca919f3d2 Networking: Fix some compilation issues noted with network is build with CONFIG_BUILD_KERNEL 2015-07-05 11:18:56 -06:00
Gregory Nutt
a47a0d237c Costmetic changes to networking logic 2015-05-31 10:29:53 -06:00
Gregory Nutt
04a661a97c TCP networking: Add support for network driver events 2015-05-30 09:12:27 -06:00
Gregory Nutt
2102892e7b Fix missing file and some compilation errors from the last UDP committ 2015-05-29 10:45:41 -06:00
Gregory Nutt
e672bcebfd UDP Networking: Add support for device event notification for UDP transfers. 2015-05-29 10:21:06 -06:00
Gregory Nutt
e28a8b1416 Raw sockets: Correct some compile issues; better modularized device-related logic 2015-05-29 08:47:21 -06:00
Gregory Nutt
d319b7c6f0 Networking: PKT logic now uses the device event list 2015-05-28 12:40:05 -06:00
Gregory Nutt
b94321cfb4 Extend device specific callbacks to ICMPv6 and ARP. Fix some IPv6 compilation errors that have crept in 2015-05-27 11:39:44 -06:00
Gregory Nutt
621eae86b1 Networking: If IPV6 is not enabled, an warning occurs for an unused variable, which is currently used inside the IPV6 block, but declared outside. From ObitalFox. 2015-04-27 11:28:28 -06:00
Gregory Nutt
db741dd695 Move some useful internal logic from recvfrom.c and udp_callback.c and put them in ip.h where they can be used more generally 2015-02-17 07:37:44 -06:00
Gregory Nutt
eb8f5e548f Purely cosmetic changes resulting from last review IPv6 UDP change 2015-02-16 15:23:02 -06:00