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
c288752bef
recvmsg: control msg support multi-attribute return
...
adapts to third-party code compilation. in the process of porting ConnMan,
multiple control message options are enabled, such as IPV6_RECVPKTINFO and
IPV6_RECVHOPLIMIT, so I changed the Filling implementation of the control
message.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 12:04:11 +02:00
zhanghongyu
93c3b8f19e
tcp: add TCP_MAXSEG support
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-04-22 01:42:47 +08: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
Xiang Xiao
3c3dea5d7a
net: Make si_poll callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
Xiang Xiao
c39be172da
net: Make si_accept callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02: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
Xiang Xiao
a97e2523a4
net: Make si_listen callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
Xiang Xiao
2553b7701c
net: Remove the empty si_getpeername implementation
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
Xiang Xiao
9b3715050b
net: Make si_getsockname callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
Xiang Xiao
b3c1c55805
net: Make si_bind callback optional
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-03-06 20:58:27 +02:00
Xiang Xiao
2c5f653bfd
Remove the tail spaces from all files except Documentation
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-02-26 13:24:24 -08: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
Fotis Panagiotopoulos
9b4d784307
Improvements in sockets allocation.
2023-02-20 09:06:46 +08: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
Zhe Weng
d3dd349649
net: Implement shutdown() for usrsock
...
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-01-31 11:15:01 +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
chao an
1f75d02bb5
net/tcp: correct behavior of SO_LINGER
...
1. Remove tcp_txdrain() from close() to avoid indefinitely block
2. Send TCP_RST immediately if linger timeout
Signed-off-by: chao an <anchao@xiaomi.com>
2023-01-18 02:47:12 +08:00
Xiang Xiao
695f42f8d2
net: Move accept to libc after https://github.com/apache/nuttx/pull/8083
...
since accept can simply forward to kernel accept4 function
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-01-13 11:23:42 +02:00
zhanghongyu
48c9d10336
net_socket: add accept4 function
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-11 23:28:08 +08:00
zhanghongyu
ec8cc6db37
net: add parameter check in psock_setsockopt
...
0 0x565a60bd in memmove (dest=0xf7fbaabe, src=0x0, count=3) at string/lib_memmove.c:58
1 0x565d8b90 in usrsock_iovec_do (srcdst=0xf7fbaab0, srcdstlen=2018, iov=0xf3de798c, iovcnt=0, pos=0, from_iov=true, done=0xf3de78e7) at usrsock/usrsock_devif.c:155
2 0x565d9349 in usrsock_iovec_get (dst=0xf7fbaab0, dstlen=2032, iov=0xf3de797c, iovcnt=2, pos=0, done=0xf3de78e7) at usrsock/usrsock_devif.c:612
3 0x5659f4b9 in usrsock_request (iov=0xf3de797c, iovcnt=2) at usrsock/usrsock_rpmsg.c:210
4 0x565d9436 in usrsock_do_request (conn=0x566316c0 <g_usrsock_connections>, iov=0xf3de797c, iovcnt=2) at usrsock/usrsock_devif.c:659
5 0x565dcfe9 in do_setsockopt_request (conn=0x566316c0 <g_usrsock_connections>, level=1, option=7, value=0x0, value_len=4) at usrsock/usrsock_setsockopt.c:131
6 0x565dd11e in usrsock_setsockopt (psock=0xf3dea840, level=1, option=7, value=0x0, value_len=4) at usrsock/usrsock_setsockopt.c:208
7 0x565d4d31 in psock_setsockopt (psock=0xf3dea840, level=1, option=7, value=0x0, value_len=4) at socket/setsockopt.c:310
8 0x565d4dde in setsockopt (sockfd=3, level=1, option=7, value=0x0, value_len=4) at socket/setsockopt.c:396
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-11-29 00:20:09 +08:00
Xiang Xiao
c38d6f1ae4
net: Remove usrsock specific process from common code as much as possible
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-11-28 16:32:41 +09: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
dongjiuzhu1
d5b08a7ef1
net/usrsock: fix get/setsockopt issue about usrsock protocol
...
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2022-11-23 21:27:15 +09: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
f00c11aec4
socket: separation error code EBADF and ENOTSOCK
...
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-29 08:18:02 +02:00
Xiang Xiao
1047b65ab5
net: Remove the unused nx_[send|recv]msg
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-28 08:27:29 +02:00
Xiang Xiao
05d40eeeff
net: Remove the unused nx_recv[from] to prefer psock_recv[from] for kernel
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
Xiang Xiao
3e982b6556
net: Remove the unused nx_send to prefer psock_send for kernel
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-10-27 16:47:32 +02:00
zhanghongyu
ae3e1d8ec5
setsockopt: Change return errno to EFAULT when value is NULL
...
behavior alignment to Linux for some testsuite
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
dc577b66e4
psock_socket: Add type field check
...
behavior alignment to Linux
Return EINVAL when type field include nonsupport bit
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
zhanghongyu
2be529121a
socketpair: Add SOCK_NONBLOCK support into type field
...
behavior alignment to Linux
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2022-10-21 16:57:20 +08:00
Xiang Xiao
386547676d
net: Return -ENOPROTOOPT for unsupported/unknown socket option
...
so usrsock implementation could support more option than built-in stack
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-28 20:47:48 +09:00
Xiang Xiao
f4812e0a83
net: Implement SO_RCVBUF and SO_SNDBUF for getsockopt
...
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-21 09:03:20 +02:00
chao an
fe7badf2ac
net/getsockname: small addrlen should be a valid value
...
fix usrsock getsockname fail
nsh> usrsocktest
...
Testing group "basic_getsockname" =>
[TEST ASSERT FAILED!]
In function "basic_getsockname_open":
line 170: Assertion `(ssize_t)((ret)) == (ssize_t)((0))' failed.
got value: -1
should be: 0
Group "basic_getsockname": [FAILED]
...
Reference:
GETSOCKNAME(2)
NAME
getsockname - get socket name
...
DESCRIPTION
...
The returned address is truncated if the buffer provided is too small;
in this case, addrlen will return a value greater than was supplied to the call.
Signed-off-by: chao an <anchao@xiaomi.com>
2022-09-01 01:19:09 +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
hejianliang3
e9648d8a73
net:fix coverity warning
...
Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>
2022-04-03 14:37:53 +03:00
chao.an
660b80b329
net/sockopt: bypass the SO_RCVBUF/SO_SNDBUF to usrsock
...
SO_RCVBUF/SO_SNDBUF tightly coupled with stack
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-03-18 00:19:31 +08: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
c73df52c46
net/socket: fix shadow variable
...
socket/setsockopt.c: In function ‘psock_socketlevel_option’:
socket/setsockopt.c:168:38: warning: declaration of ‘conn’ shadows a previous local [-Wshadow]
168 | FAR struct tcp_conn_s *conn;
| ^~~~
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-17 17:55:16 +01: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
0d19a3a248
net/inet: move socket timestamp into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
9317626c32
net/inet: move socket linger into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
3fce144aeb
net/inet: move recv/send timeout into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03:00
chao.an
cc6add58dc
net/inet: move socket options into socket_conn_s
...
Signed-off-by: chao.an <anchao@xiaomi.com>
2022-02-10 15:04:33 -03: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
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
chao.an
39e142243d
net/tcp/udp: move the send callback into tcp/udp structure
...
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
chao.an
b10dcf7c0d
net/udp: fix the invaild udp destination address
...
If the udp socket not connected, it is possible to have
multi-different destination address in each iob entry,
update the remote address every time to avoid sent to the
incorrect destination.
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-12-17 11:25:06 -06:00