Issue:
recv return 0 means peer side has already closed the connection according to
man page's description.
0 is returned without set errno when TCP rx timeout happens with current
design.
Solution:
return result instead of ir_result when ir_result is 0, then -1 will be
returned with errno set to EAGAIN for tcp rx buffer empty case.
Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
when usrsock client try to connect usrsock server local_loop
socket with an invalid port, server cannot find a listener conn
to handle this connet request, then it will response a TCP_RESET
packet via nuttx existing processing, when before conn recv this
RESET packet, it will trigger usrsock_rpmsg_server poll return
and send REMOTE_CLOSE event to usrsock client.
so usrsock connect_event fucntion need handle this event.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Support ICMP ECHO REQUEST & REPLY. Id of ICMP is processed like port of TCP in NAT. However, our ICMP stack doesn't have a method to manage id allocation like tcp_selectport(), the id is set by apps (like icmp_ping.c) without conflict avoidance, so not adding such conflict avoidance logic to ICMP stack when implementing NAT.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
Add basic functions for NAT (NAPT), remaining some logic unimplemented (UDP, ICMP, port assignment, etc). NAT for TCP can work now (unless port conflicts).
Outbound: LAN -> Forward -> NAT(only if targeting at WAN) -> WAN
Inbound: WAN -> NAT(only from WAN, change dest) -> Forward -> LAN
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
In the past, header file paths were generated by the incdir command
Now they are generated by concatenating environment variables
In this way, when executing makefile, no shell command will be executed,
it will improve the speed of executing makfile
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
net_chksum_adjust is used for fast checksum adjustment after modifying some fields in a network packet. Will be used in NAT.
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
devif/ipv6_input.c: In function 'ipv6_input':
devif/ipv6_input.c:59:33: error: 'TCPIPv6BUF' undeclared (first use in this function); did you mean 'IPv6BUF'?
59 | #define PAYLOAD ((FAR uint8_t *)TCPIPv6BUF)
| ^~~~~~~~~~
devif/ipv6_input.c:302:14: note: in expansion of macro 'PAYLOAD'
302 | payload = PAYLOAD; /* Assume payload starts right after IPv6 header */
|
Signed-off-by: chao an <anchao@xiaomi.com>
Error: route/net_del_ramroute.c:94:9: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
HTONL(match->target), HTONL(match->netmask));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/github/workspace/sources/nuttx/include/debug.h:232:23: note: expanded from macro 'ninfo'
^
/github/workspace/sources/nuttx/include/debug.h:102:43: note: expanded from macro '_none'
do { if (0) syslog(LOG_ERR, format, ##__VA_ARGS__); } while (0)
~~~~~~ ^~~~~~~~~~~
/github/workspace/sources/nuttx/include/netinet/in.h:233:17: note: expanded from macro 'HTONL'
^
/github/workspace/sources/nuttx/include/endian.h:63:25: note: expanded from macro '__swap_uint32'
^
Error: route/net_del_ramroute.c:94:31: error: format specifies type 'unsigned long' but the argument has type 'unsigned int' [-Werror,-Wformat]
HTONL(match->target), HTONL(match->netmask));
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/github/workspace/sources/nuttx/include/debug.h:232:23: note: expanded from macro 'ninfo'
^
/github/workspace/sources/nuttx/include/debug.h:102:43: note: expanded from macro '_none'
do { if (0) syslog(LOG_ERR, format, ##__VA_ARGS__); } while (0)
~~~~~~ ^~~~~~~~~~~
/github/workspace/sources/nuttx/include/netinet/in.h:233:17: note: expanded from macro 'HTONL'
^
/github/workspace/sources/nuttx/include/endian.h:63:25: note: expanded from macro '__swap_uint32'
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
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>