Commit Graph

46 Commits

Author SHA1 Message Date
ligd c4ed55c6df socket: divide errno & s_error
Reference:
https: //man7.org/linux/man-pages/man2/connect.2.html

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-02-23 16:40:19 +01:00
chao an f2a7711ef8 net/soerr: add new _SO_CONN_SETERRNO() macro
support so error code set from conn instance

Signed-off-by: chao an <anchao@xiaomi.com>
2022-11-24 22:57:42 +08:00
chao.an 9cb17841d8 net/sockopt: move BINDTODEVICE to socket level
rename the UDP_BINDTODEVICE to SO_BINDTODEVICE to follow the linux
style to be compatible with non-UDP protocol binding requirements

Signed-off-by: chao.an <anchao@xiaomi.com>
2022-08-25 17:56:52 +08:00
chao.an 1659513edb net/inet: move socket error into socket_conn_s
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
Petro Karashchenko 8d3bf05fd2 include: fix double include pre-processor guards
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-16 11:11:14 -03: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
Peter van der Perk 55d9e5f7af net: Add SocketCAN support 2020-06-15 08:07:19 -06:00
chao.an 0376cddd6d net: move the _SF*/_SS* definitions to net.h
Build break caused by 23b8b39799
2020-03-04 21:37:34 -06:00
chao.an d07afc934e fcntl: add O_CLOEXEC/FD_CLOEXEC support 2020-02-20 08:20:38 -06:00
Xiang Xiao c1b0aa118c Remove psock_send and sockfd_socket from net/socket/socket.h
Since both is already declared in include/nuttx/net/net.h and fix other minor issue in network socket layer.
2020-01-31 13:45:15 -06:00
Xiang Xiao 9f9566c0eb Rename net_clone/net_dupsd[2] to psock_dup2/net_dup[2] like vfs 2020-01-31 13:45:14 -06:00
Xiang Xiao 5c5c08efcd network: simplify the timeout process logic
1.Consolidate absolute to relative timeout conversion into one place(_net_timedwait)
2.Drive the wait timeout logic by net_timedwait instead of devif_timer
This patch help us remove devif_timer(period tick) to save the power in the future.

Change-Id: I534748a5d767ca6da8a7843c3c2f993ed9ea77d4
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-01-11 08:24:49 -06:00
junmin-kim db3826bf2c Fix typo in the sockfd_socket description 2020-01-09 07:38:02 -03: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 6941f916ce net/socket: For consistency in naming, change the name of sock_release() to psock_release(). 2018-11-27 07:50:09 -06:00
Gregory Nutt 8fdbb1e0a4 Elimate use of the non-standard type systime_t and replace it the equivalent, standard type clock_t
Squashed commit of the following:

    sched:  Rename all use of system_t to clock_t.
    syscall:  Rename all use of system_t to clock_t.
    net:  Rename all use of system_t to clock_t.
    libs:  Rename all use of system_t to clock_t.
    fs:  Rename all use of system_t to clock_t.
    drivers:  Rename all use of system_t to clock_t.
    arch:  Rename all use of system_t to clock_t.
    include:  Remove definition of systime_t; rename all use of system_t to clock_t.
2018-06-16 12:16:13 -06:00
Gregory Nutt 091e3f732e net/udp: Fix several issues using connected UDP sockets: sendto() should not accept and address. Normally send() should be used instead. recvfrom() is no longer necessary. recvfrom() and poll() should not reset to accept any addresses but should, instead, only accept inputs and events from the connected remore peer. On of these issues was noted by 李桂丁 <liguiding@pinecone.net>. Changes were made as summarized here: http://www.masterraghu.com/subjects/np/introduction/unix_network_programming_v1.3/ch08lev1sec11.html 2018-04-25 08:43:38 -06:00
Gregory Nutt b54ffe858a Standardization of some function headers. 2018-03-13 09:52:27 -06:00
Gregory Nutt f81ef55834 Trivial re-ordering of socket option bit numbers to match order presented on OpenGroup.org. 2017-11-12 08:17:46 -06:00
Gregory Nutt cccc86da09 This change adds support for semi-standard IPPROTO_ICMP AF_INET datagram sockets. This replaces the old ad hoc, nonstandard way of implementing ping with a more standard, socket interface.
Squashed commit of the following:

    net/icmp:  Finishes off icmp_recvfrom().
    net/icmp:  Add readahead support for IPPROTO_ICMP sockets.
    net/icmp:  Add poll() support for IPPROTO_ICMP sockets.
    net/icmp:  Add a connection structure for IPPROTO_ICMP sockets.
    net/icmp:  Implements sendto for the IPPROTO_ICMP socket.
    net/icmp:  Move icmp_sendto() and icmp_recvfrom() to separate files.  They are likely to be complex (when they are implemented).
    net/icmp:  Hook IPPROTO_ICMP sockets into network.  Fix some naming collisions.  Still missing basic ICMP send/receive logic.
    configs: apps/system/ping current need poll() enabled.
    configs: All defconfig files that use to enable low-level support must now enabled CONFIG_SYSTEM_PING.
    net/icmp:  Adds basic build framework to support IPPROTO_ICMP sockets.
2017-10-23 08:45:12 -06:00
Gregory Nutt e4dd33280d Squashed commit of the following:
psock_close() and net_close() are internal OS functions and should not set the errno variable.

    psock_ioctl() and netdev_ioctl() are internal OS functions and should not set the errno variable.

    net_dupsd() and net_dupsd2() are internal OS functions and should not set the errno variable.

    net/ and fs/: net_vfcntl(), file_fcntl(), file_dup(), and file_dup2() are all internal OS interfaces and should not modify the errno value.
2017-09-30 10:41:21 -06:00
Gregory Nutt d40ee8e79d Networking: Start the network monitor for a socket when a TCP socket is dup'ed. 2017-08-29 10:53:04 -06:00
Gregory Nutt 962a9f8cf3 net/socket: Correct a typo in a macro definitions. 2017-08-18 07:51:16 -06:00
Gregory Nutt 3c6981534f Networking: Move INET socket interface out of net/sockets to its own directory net/inet 2017-08-06 14:48:19 -06:00
Jussi Kivilinna 7dfb01dbce network: Move USRSOCK specific code from from inet_sockif to usrsock_sockif 2017-07-31 09:33:59 -06:00
Gregory Nutt 6537e4ea20 Socket I/F: Misc. fixes for compile errors/warnings going back to dual IPv4+IPv6 configuration. 2017-07-14 15:52:37 -06:00
Gregory Nutt 24dd6d2905 Socket I/F: More fixes for USRSOCK. The good link fooled me because a critical file was not included in the link. 2017-07-14 15:24:18 -06:00
Gregory Nutt ef796b2d9e Socket I/F: Misc clean-up to get a clean USRSOCK build. 2017-07-14 14:41:46 -06:00
Gregory Nutt 8bf8c3fa86 Socket I/F: Add address family support for poll() and sendfile() 2017-07-14 10:57:38 -06:00
Gregory Nutt ac543648b8 Socket interface: Added getsockname[C() interfaces. 2017-07-14 09:04:19 -06:00
Gregory Nutt 833ee2275d Socket interface: Added close() interface. 2017-07-13 12:15:15 -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 1b9cb70828 Sockets: Initial steps to adde a socket interface to the networking. Each address family will have an interface that describes how to perform socket operations on that address family. Currently only a couple of methods are defined in the table as a proof of concept. More to come. Currently there are only tables for the INET/INET6 family, the Unix LOCAL family, and the raw PACKET family. Hopefully there will be AF_IEEE802154 and AF_BLUETOOTH comming down the pike. 2017-07-12 15:07:32 -06:00
Gregory Nutt d5207efb5a Be consistent... Use Name: consistent in function headers vs Function: 2017-04-21 16:33:14 -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
Gregory Nutt f348e68069 Update to use 64-bit timer when available 2016-01-21 11:54:26 -06:00
Gregory Nutt cb9e27c3b0 Standardize naming used for public data and function groupings 2015-10-02 16:30:35 -06:00
Gregory Nutt 8b029fbbee TCP networking: Hook the network monitor into the device event notification logic 2015-05-30 11:29:47 -06:00
Gregory Nutt 01d176af76 net_startmonitor.c always returned zero. In the case where a socket has already been closed, it correctly handled the disconnetion event but still returned OK. Returning OK causes the callers of net_startmonitor to assume that the connection was okay, undoing the good things that net_startmonitor did and causing the socket to be marked as connected. This behavior was noted by Pelle Windestam. 2015-05-28 08:23:51 -06:00
Gregory Nutt 0e2b6929b4 Add function headers to prototypes in net/socket/socket.h 2015-05-28 07:26:03 -06:00
Gregory Nutt caba61999a Remove CONFIG_DISABLE_CLOCK 2014-08-07 12:35:24 -06:00
Gregory Nutt 0bb153b8cb Remove all inclusion of uip.h 2014-07-04 16:58:22 -06:00
Gregory Nutt 76fa58ee00 Move all socket-related files from net/ to net/socket. Move net/net.h to net/socket/socket.h 2014-06-28 17:25:18 -06:00