Alin Jerpelea
67d02a45eb
net: migrate to SPDX identifier
...
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-09-12 01:08:11 +08:00
wangchen
14202651b2
net:Resolve udp disconnection, status not synchronized error
...
libuvtestcase:
TEST_IMPL(udp_connect) {
RETURN_SKIP(
"IBMi PASE's UDP connection can not be disconnected with AF_UNSPEC.");
uv_udp_send_t req;
struct sockaddr_in ext_addr;
struct sockaddr_in tmp_addr;
int r;
int addrlen;
close_cb_called = 0;
cl_send_cb_called = 0;
sv_recv_cb_called = 0;
ASSERT(0 == uv_ip4_addr("[0.0.0.0](http://0.0.0.0/ )", TEST_PORT, &lo_addr));
r = uv_udp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_udp_bind(&server, (const struct sockaddr*) &lo_addr, 0);
ASSERT(r == 0);
r = uv_udp_recv_start(&server, alloc_cb, sv_recv_cb);
ASSERT(r == 0);
r = uv_udp_init(uv_default_loop(), &client);
ASSERT(r == 0);
buf = uv_buf_init("EXIT", 4);
/* connect() to INADDR_ANY fails on Windows wih WSAEADDRNOTAVAIL */
ASSERT_EQ(0, uv_ip4_addr("[0.0.0.0](http://0.0.0.0/ )", TEST_PORT, &tmp_addr));
r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr);
ASSERT_EQ(r, UV_EADDRNOTAVAIL);
ASSERT_EQ(r, 0);
r = uv_udp_connect(&client, NULL);
ASSERT_EQ(r, 0);
ASSERT(0 == uv_ip4_addr("[8.8.8.8](http://8.8.8.8/ )", TEST_PORT, &ext_addr));
ASSERT(0 == uv_ip4_addr("[127.0.0.1](http://127.0.0.1/ )", TEST_PORT, &lo_addr));
r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr);
ASSERT(r == 0);
r = uv_udp_connect(&client, (const struct sockaddr*) &ext_addr);
ASSERT(r == UV_EISCONN);
addrlen = sizeof(tmp_addr);
r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen);
ASSERT(r == 0);
/* To send messages in connected UDP sockets addr must be NULL */
r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr);
ASSERT(r == UV_EISCONN);
r = uv_udp_try_send(&client, &buf, 1, NULL);
ASSERT(r == 4);
r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &ext_addr);
ASSERT(r == UV_EISCONN);
r = uv_udp_connect(&client, NULL);
ASSERT(r == 0);
r = uv_udp_connect(&client, NULL);
ASSERT(r == UV_ENOTCONN);
addrlen = sizeof(tmp_addr);
r = uv_udp_getpeername(&client, (struct sockaddr*) &tmp_addr, &addrlen);
ASSERT(r == UV_ENOTCONN);
/* To send messages in disconnected UDP sockets addr must be set */
r = uv_udp_try_send(&client, &buf, 1, (const struct sockaddr*) &lo_addr);
ASSERT(r == 4);
r = uv_udp_try_send(&client, &buf, 1, NULL);
ASSERT(r == UV_EDESTADDRREQ);
r = uv_udp_connect(&client, (const struct sockaddr*) &lo_addr);
ASSERT(r == 0);
r = uv_udp_send(&req,
&client,
&buf,
1,
(const struct sockaddr*) &lo_addr,
cl_send_cb);
ASSERT(r == UV_EISCONN);
r = uv_udp_send(&req, &client, &buf, 1, NULL, cl_send_cb);
ASSERT(r == 0);
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
ASSERT(close_cb_called == 2);
ASSERT(sv_recv_cb_called == 4);
ASSERT(cl_send_cb_called == 2);
ASSERT(client.send_queue_size == 0);
ASSERT(server.send_queue_size == 0);
MAKE_VALGRIND_HAPPY();
return 0;
}
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-03 03:12:17 -07:00
Xiang Xiao
5dd037c599
net: Make si_connect callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
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
zhanghongyu
f00c11aec4
socket: separation error code EBADF and ENOTSOCK
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-29 08:18:02 +02:00
hejianliang3
e9648d8a73
net:fix coverity warning
...
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
chao.an
99cde13a11
net/inet: move socket flags into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -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
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
Xiang Xiao
6e6c670190
Move _SF_BOUND and _SF_CONNECTED modification to common place
2020-01-31 13:45:14 -06:00
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
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
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
Gregory Nutt
cca15891c9
Networking: Fix some errors found by Coverity
2017-09-13 13:04:26 -06:00
Gregory Nutt
85b1ae4cf0
Socket interface: Added bind() and connect() interfaces.
2017-07-13 09:28:18 -06:00
Gregory Nutt
755b05ff30
TCP/IPv6: Fix a compile issue when IPv6, but not IPv4 is enabled.
2017-03-31 10:45:39 -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
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
43eb04bb8f
Without lowsyslog() *llinfo() is not useful. Eliminate and replace with *info().
2016-06-20 11:59:15 -06:00
Gregory Nutt
86b79b33cf
Reserver the name 'err' for other purposes
2016-06-11 14:40:07 -06:00
Gregory Nutt
fc3540cffe
Replace all occurrences of vdbg with vinfo
2016-06-11 11:59:51 -06:00
Gregory Nutt
6209c51206
net/: More clean-up of spacing/alignment issues
2015-10-08 15:10:04 -06:00
Gregory Nutt
b1e09d4847
net/socket and net/tcp: Fix a problem in whent there are multiple network devices. Polls were being sent to all TCP sockets before. This is not good because it means that packets may sometimes be sent out on the wrong device. That is inefficient because it will cause retransmissions and bad performance. But, worse, when one of the devices is not Ethernet, it will have a different MSS and, as a result, incorrect data transfers can cause crashes. The fix is to lock into a single device once the MSS is locked locked down.
2015-08-27 09:06:46 -06:00
Gregory Nutt
530d229361
net/udp: Add support for send() with connected UDP sockets
2015-08-11 19:17:55 -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
e22deff1ab
TCP connect. Move the location where the socket is marked as connected in order to avoid a potential race condition
2015-05-31 12:24:24 -06:00
Gregory Nutt
b493dde4cf
TCP networking: In the TCP connection operation, it was trying to setup the network monitor BEFORE the socket was successfully connected. This, of course, has ALWAYS failed because the socket is not yet connected and the TCP state is not yet correct for a connected socket. However, because of other changes net_startmonitor(0 no returns a failure condition that causes worse problems when trying to connect. The fix is to move the logic that starts the network monitor to AFTER the socket has been successfully connected.
2015-05-31 11:35:28 -06:00
Gregory Nutt
04a661a97c
TCP networking: Add support for network driver events
2015-05-30 09:12:27 -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
0fc8d2fcc5
Unix domain: Add options to build in stream or datagram support separately
2015-01-31 07:58:51 -06:00
Gregory Nutt
62b706fa68
If a Unix domain socket is non-blocking, then the underlying FIFO should also be opened non-blocking
2015-01-30 12:43:37 -06:00
Gregory Nutt
ca2102febb
Unix domain: A few fixes from early integration
2015-01-27 16:39:30 -06:00
Gregory Nutt
cbf0608513
Various fixes to get Unix domain sockets to build on the simulator without Ethernet
2015-01-27 14:11:46 -06:00
Gregory Nutt
c3f2023089
Networking: Add local Unix domain socket connection logic
2015-01-25 12:37:40 -06:00
Gregory Nutt
1c8dae4eee
Correct calculation of initial MSS
2015-01-22 12:29:49 -06:00
Gregory Nutt
b187b4f381
Networking: Straighten up use if IPv6/IPv4 in TCP connection logic
2015-01-17 15:17:35 -06:00
Gregory Nutt
b80cdb3880
Fix a few warnings introduced with the last commit
2015-01-17 14:25:40 -06:00
Gregory Nutt
8f8259a0d6
Networking: UDP and TCP MSS depends on the IP header size (as well as the link layer header size) and cannot be represented with a single value.
2015-01-16 15:03:10 -06:00
Gregory Nutt
08de18c1a6
Network: Various fixes for clean compile with both Ethernet and SLIP
2014-11-15 13:52:39 -06:00
Gregory Nutt
2e55db369d
Network: All logic will now handle varialbe length link layer protocol headers within incoming packets. This permits use of multiple network interfaces with differing data links. For example, ETHERNET + SLIP
2014-11-15 13:13:23 -06:00
Gregory Nutt
73f3ecf7e2
NET: Rename network interrupt event flags more appropriately: TCP_, UDP_, ICMP_, or PKT_ vs UIP_
2014-07-06 17:22:02 -06:00
Gregory Nutt
2d52d70d4c
NET: Move private definitions from include/nuttx/net/tcp to net/tcp/tcp.h
2014-07-06 12:34:27 -06:00
Gregory Nutt
60246e613b
NET: emoved all includes of uip.h; added includes of ip.h wherever needed. Tried to fix problems of the now missing sneak inclusions because uip.h was removed. There are probably a few of these that were missed.
2014-07-04 19:13:08 -06:00
Gregory Nutt
a6b39d1879
NET: in-progress change... don't use
2014-07-04 16:38:51 -06:00