raiden00pl
9aab92e3cf
net: unify Private Types banners
...
unify Private Types banners according to NuttX coding standard
Signed-off-by: raiden00pl <raiden00@railab.me>
2025-05-28 10:17:15 +08:00
Lars Kruse
3ce85ca54e
style: fix spelling in code comments and strings
2025-05-23 10:48:41 +08:00
chenrun1
99a1f0dc65
inet_sockif:support multiple iov recv
...
Summary:
Implement multiple iovlen recvmsg in inet_sockif, only TCP mode
support at current.
Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2025-01-20 17:12:14 +08:00
Zhe Weng
87a7714103
net: Split msg_iovlen check in recvmsg into each protocol
...
To prepare for supporting multiple iov in each protocol.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2025-01-20 17:12:14 +08:00
Peter van der Perk
faee89b966
net: fix inet #14634 regression
...
Define wasn't imported by netconfig.h move definitions
2024-11-05 18:36:02 +08:00
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
Xiang Xiao
eddd90de78
poll: pollsetup should notify only one fd passd by caller
...
since it's redundant to iterate the whole fds array in setup
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-11-21 09:07:17 +01:00
Petteri Aimonen
cb161940c2
udp: Add support for SO_TIMESTAMP
...
Adds support for timestamping received UDP packets, either in
hardware or in kernel. Builds on the existing support of SO_TIMESTAMP
for SocketCAN.
Implementation uses CLOCK_REALTIME for timestamping to match the
behavior of Linux. This could be made configurable in future if needed.
2023-11-18 03:10:29 -08:00
liqinhui
3f08f32486
net: allow icmpv6 and udp to find the dev by the ifindex with s_boundto.
...
In order to support the dhcpv6c.
Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-10-11 23:34:01 +08:00
zhanghongyu
03265caa7a
inet_sendto: correct error messages and remove the comment
...
Comment information and printing do not match the actual function.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-09-09 00:16:52 +08:00
zhanghongyu
3bd495c09d
icmp: add SOCK_RAW type support
...
Since ICMPv6 has added SOCK_RAW, a SOCK_RAW related implementation has also
been added for ICMP.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-08-19 22:04:22 +08:00
wangchen
5c798dd297
inet/inet_sockif.c:In tcp protocol, Add random ports during the listening phase, if no ports are bound
...
In tcp protocol, if no ports are bound, Add random ports during the listening phase
libuvtestcase:
TEST_IMPL(tcp_listen_without_bind) {
int r;
uv_tcp_t server;
r = uv_tcp_init(uv_default_loop(), &server);
ASSERT(r == 0);
r = uv_listen((uv_stream_t*)&server, 128, NULL);
ASSERT(r == 0);
MAKE_VALGRIND_HAPPY();
return 0;
}
Signed-off-by: wangchen <wangchen41@xiaomi.com>
2023-08-03 03:24:23 -07: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
Zhe Weng
1072b5b564
net: Limit max value for Send/Recv bufsize
...
There're some apps trying to set too large SO_SNDBUF and SO_RCVBUF, which may use all IOBs in one socket and block all other network traffic.
Note:
Linux silently limits SO_SNDBUF to be less than `sysctl_wmem_max`, so we can also do this limit without returning any error.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-07-05 13:57:08 +08:00
chao an
589d4a9f8e
net/semantic/parser: fix compile warning found by sparse
...
Reference:
https://linux.die.net/man/1/sparse
Signed-off-by: chao an <anchao@xiaomi.com>
2023-05-30 23:00:00 +08:00
zhanghongyu
91e13c47ae
net: remove conn-related casts
...
remove redundant casts associated with psock
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-10 19:32:09 -03:00
zhanghongyu
35dee8fdd2
icmpv6: add SOCK_RAW type support
...
The third-party library we are porting will send and receive ICMPV6 messages
(router_advert / router_solicit / neighbor_advert / neighbor_solicit etc.)
from the user mode itself, so we added the SOCK_RAW related implementation
for ICMPV6.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-07 22:43:10 +08:00
Xiang Xiao
74e2b75857
net: Simplify the tcp/udp existence check
...
Replace defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_NO_STACK) with NET_TCP_HAVE_STACK
Replace defined(CONFIG_NET_UDP) && !defined(CONFIG_NET_UDP_NO_STACK) with NET_UDP_HAVE_STACK
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-03 17:40:00 +03:00
Zhe Weng
61ff04b9e2
net/inet: Only setup poll for UDP when s_type == SOCK_DGRAM
...
Problem:
A SOCK_CTRL socket may be led to udp_pollsetup but never reaches
udp_pollteardown, it seems that we shouldn't call udp_pollsetup for
other socket types.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-03-29 09:18:36 -03:00
Xiang Xiao
75ecbd4382
net/local: Return the unblock handle correctly in local_accept
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-09 09:17:19 +01:00
SPRESENSE
277e0b941a
include/sys/socket.h: Add SOCK_CTRL to socket type
...
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
2023-02-16 12:13:01 +09:00
Xiang Xiao
0ef073573a
net: Remove protocol argument from si_setup callback
...
since the implementor could get the same value from socket::s_proto
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-13 22:41:19 +08:00
Masayuki Ishikawa
3f3e090716
Revert "include/sys/socket.h: Add SOCK_CTRL to socket type"
...
This reverts commit abba05a934 .
2023-02-09 09:13:14 +01:00
SPRESENSE
abba05a934
include/sys/socket.h: Add SOCK_CTRL to socket type
...
SOCK_CTRL is added to provide special control over network drivers
and daemons. Currently, SOCK_DGRAM and SOCK_STREAM perform this control,
but these use socket resources. In the case of usersocket in particular,
this is a waste of the device's limited socket resources.
2023-02-08 20:43:33 +08:00
Zhe Weng
8819eeaf15
net: Implement shutdown() interface and tcp shutdown
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +08:00
梁超众
5012195bde
support ipv4 ToS and ipv6 TrafficClass
...
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
zhanghongyu
48c9d10336
net_socket: add accept4 function
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
Zhe Weng
cbe4cb2056
net: Add set/getsockopt options compatible with iptables.
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2022-12-28 22:40:53 +08:00
dongjiuzhu1
e6f8ccda4a
net/get/setsockopt: add si_get/setsockopt interface to simply get/setsockopt
...
move private option to protocol sockif
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 15:01:54 +08:00
zhanghongyu
85ffa4bcf3
inet_sockif: errno alignment to Linux
...
cunittest error case: protocol invalid need return 123(EPROTONOSUPPORT)
now return 106(EAFNOSUPPORT)
inet_setup will check type ande protocol
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
6b955b0ef0
inet_bind: errno alignment to Linux
...
cunittest error case: addr length is short.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
chao an
3913ef2f2f
net/inet: invalid addrlen length should return EINVAL
...
https://www.freebsd.org/cgi/man.cgi?connect
[EINVAL] The namelen argument is not a valid length for the address family.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-08 09:02:30 +08:00
zhanghongyu
9bff29d7e7
udp: add IPVx_PKTINFO related support
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-09-07 10:49:47 +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
liyi
b232508bd9
make sure conn's domain is match with addr's family
2022-07-29 13:53:19 +08:00
Alexander Lunev
404ceffae2
tcp: added debug asserts and logging to investigate the rare (conn->dev == NULL) bug in callback handlers
2022-02-26 11:48:07 -03:00
chao.an
e749f6ca7e
net/tcp/monitor: do not migrate the state to close
...
1. remove the unnecessary interfaces tcp_close_monitor()
socket flags(s_flags) is a global state for net connection
remove the incorrect update for stop monitor
2. do not start the tcp monitor from duplicated psock
the tcp monitor has already registered in connect callback
------------------------------------------------------------
This patch also fix the telnet issue reported by:
https://github.com/apache/incubator-nuttx/pull/5434#issuecomment-1035600651
the orignal session fd is closed after dup, the connect state
has incorrectly migrated to close:
drivers/net/telnet.c:
977 static int telnet_session(FAR struct telnet_session_s *session)
...
1031 ret = psock_dup2(psock, &priv->td_psock);
...
1082 nx_close(session->ts_sd);
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-11 18:56:40 +09: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
Petro Karashchenko
9551de7115
net: use HTONS, NTOHS, HTONL, NTOHL macro in kernel code
...
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-01-18 10:59:47 +01:00
chao.an
940a07e1e5
net/socketpair: move socketpair implement into socket internal
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-07-08 03:05:43 -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
David Sidrane
a61f70d571
inet:sockif Fix warning
2021-05-03 16:55:48 -04:00
Peter Bee
e223f60c09
net/socket: move si_send/recv into sendmsg/recvmsg
...
Implement si_send/sendto/recvfrom with si_sendmsg/recvmsg, instead of
the other way round.
Change-Id: I7b858556996e0862df22807a6edf6d7cfe6518fc
Signed-off-by: Peter Bee <bijunda1@xiaomi.com>
2021-03-05 04:46:13 -08: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
Juha Niskanen
de1ad1fdb3
net: fix typos, incorrect comments, nxstyle
...
Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
2020-12-13 09:06:28 -06:00
Peter van der Perk
55d9e5f7af
net: Add SocketCAN support
2020-06-15 08:07:19 -06:00
Jukka Laitinen
17e45820c6
net/inet/inet_sockif.c: Fix long lines
...
Signed-off-by: Jukka Laitinen <jukka.laitinen@intel.com>
2020-06-01 21:54:06 +08:00
Jukka Laitinen
1f8de344dd
net/inet/inet_sockif.c: Fix debugassert compilation
...
Should derefer addrlen pointer, instead of comparing whether
the pointer itself is > 0
Signed-off-by: Jukka Laitinen <jukka.laitinen@intel.com>
2020-06-01 21:54:06 +08:00
Xiang Xiao
cde88cabcc
Run codespell -w with the latest dictonary again
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2020-02-23 22:27:46 +01:00