Commit Graph

79 Commits

Author SHA1 Message Date
Alin Jerpelea cd2fcf5252 include: 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-10-04 08:18:42 +08:00
wangyingdong 1fe0542711 Expose IPTOS_xxx to the application layer
Signed-off-by: wangyingdong <wangyingdong@xiaomi.com>
2024-09-12 17:15:31 +08:00
zhanghongyu 986ddc83ce netinet/in.h: add macro definitions to resolve compilation errors
solve the compiling problem of the third-party library,
add IN6_IS_ADDR_MC_LINKLOCAL and IN6_IS_ADDR_SITELOCAL definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2024-08-19 19:49:42 +08:00
Xiang Xiao ca5a9c711a Remove @ and % tag from all comments
and format the multiple line comments

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-11 17:00:10 -03:00
Zhe Weng 3e4d847f42 net/netdev: Support managing multiple IPv6 addresses by ioctl
1. Supporting `SIOCSIFADDR` and `SIOCDIFADDR` with Linux in6_ifreq struct to manage ipv6 addresses.
   Ref: https://man7.org/linux/man-pages/man7/netdevice.7.html
2. Supporting alias like 'eth0:0' for multiple IPv6 addresses, to keep previous ioctl `SIOCGLIFADDR`, `SIOCSLIFADDR`, `SIOCGLIFNETMASK` and `SIOCSLIFNETMASK` working.
   Ref: https://man7.org/linux/man-pages/man8/ifconfig.8.html

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-11-07 19:30:36 +08:00
Xiang Xiao b7e14c7490 endian: Make all endian related functions use the expicit type
so the printf can give the unambiguous format specifier

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-20 09:46:21 +08:00
fangxinyong da3a75da2c libc/net: compatible with Android for htonq/ntohq
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2023-08-02 22:47:29 -07:00
Xiang Xiao 7990f90915 Indent the define statement by two spaces
follow the code style convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-05-21 09:52:08 -03:00
zhanghongyu e0816ff050 in.h: add SOL_IPV6 protocol-level socket option IPV6_RECVHOPLIMIT
added IPV6_RECVHOPLIMIT support so that fd of SOCK_RAW ICMPV6 can obtain ttl
information, some network related tools use this feature.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-10 18:00:15 +08:00
zhanghongyu e10fda570b udp: change PKTINFO flag to socket_conn_s struct
move the IPPROTO_IP/IPPROTO_IPV6 flag into the socket_conn_s structure to
make it more than just control udp.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-09 07:53:56 +02:00
zhanghongyu 40d62a40a1 include: header definition changed to nuttx format
fix header definition format

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 18:04:33 +03:00
zhanghongyu f6fdf888a9 if_ether: add ether_arp definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:38:29 +08:00
zhanghongyu fc0ecd4e9e if_arp: add arphdr definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:37:58 +08:00
zhanghongyu 586c89b754 icmp6: add icmp6-related definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:37:21 +08:00
zhanghongyu e565868eb4 udp: add udphdr definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:36:27 +08:00
zhanghongyu 0acd3078ff ip6: add ip6-related definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:35:43 +08:00
zhanghongyu f387b138d9 ip: add iphdr definition
adapts to third-party code compilation. in the process of porting ConnMan,
we encounter some situations where the structure is not defined, or the
returned data types do not match the expectations. Refer to the common
implementation of other systems and add relevant definitions.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-05-04 19:35:16 +08:00
Takeyoshi Kikuchi 6447064d81 netinet: in.h: add support for Nimlang compatibility.
Without this POSIX-compatible definition, support for nativesockets module in Nimlang is problematic.

.nimcache/(snip)@spure@snativesockets.nim.c: In function 'toInt__pureZnativesockets_69':
.nimcache/(snip): error: 'IPPROTO_ICMPV6' undeclared (first use in this function); did you mean 'IPPROTO_ICMP6'?
  291 |   result = IPPROTO_ICMPV6;
      |            ^~~~~~~~~~~~~~
      |            IPPROTO_ICMP6

Signed-off-by: Takeyoshi Kikuchi <kikuchi@centurysys.co.jp>
2023-02-13 09:28:52 +08:00
梁超众 5012195bde support ipv4 ToS and ipv6 TrafficClass
Signed-off-by: 梁超众 <liangchaozhong@xiaomi.com>
2023-01-29 13:43:44 +08:00
zhanghongyu ec28082e5d arp.h: add some ARPHRD definition
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-01-06 22:20:19 +08:00
Xiang Xiao d5689e070b net/arp: Remove nuttx/net/arp.h
1.move ARPHRD_ETHER to netinet/arp.h
1.move arp_entry_s to net/arp/arp.h
2.move arp_input to nuttx/net/netdev.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-12-16 22:10:59 +02:00
Xiang Xiao 53466c6d46 net: Add IN6_IS_ADDR_LINKLOCAL macro
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2022-09-21 18:28:40 +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
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
Peter van der Perk 013a562478 Net thread-safe ntoa functions
Apply suggestions from code review

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2022-08-02 21:04:19 +08:00
Nimish Telang 903a186304 Use builtins for byteswapping
Make use of XCHG/BSWAP on x86, REV16 and REV on ARMv6-m and above,
and whatever other optimized instructions on other platforms.

Defines extra CONFIG variables, and removes the unused functions for
endian-swapping. Fixes some oversights in using the macros.
2022-06-29 11:32:59 +08:00
anjiahao 4db9513658 inculude/netinet:add net mask define
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2021-11-27 06:19:10 -06:00
Huang Qi c303a12f26 include/netinet: Add missing IP_TTL definition
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
Change-Id: Ic0c4bcb840952a4ccf7f262306ba0c3d43e01811
2021-07-12 16:30:37 -03:00
chao.an fdf325c7e3 netinet: move the byte ordering convert functions to "netinet/in.h"
Signed-off-by: chao.an <anchao@xiaomi.com>
2021-06-09 12:04:25 -05:00
Alin Jerpelea 9b9be7e1f0 include: Author: Gregory Nutt: update licenses to Apache 2.0
Update files from Gregory Nutt to Apache 2.0 license.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-04 03:33:58 -08:00
Alin Jerpelea 861c0071bd include: nuttx: fix nxstyle errors
Fix nxstyle errors to pass CI

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2021-02-04 03:33:58 -08:00
chao.an 866bb35d2d libs/libc/net: implement ether_aton/ether_aton_r
Reference here:
https://www.unix.com/man-page/linux/3/ether_aton

Signed-off-by: chao.an <anchao@xiaomi.com>
2020-12-10 20:37:32 -06:00
patacongo e86b516f9d
include/netinet/arp.h: Previous network changes broke the build test (#193) 2020-01-31 21:23:15 +01: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 ac9a69384d include/netinet: Add IP and TCP socket options needed by iperf3. 2019-11-17 07:37:12 -06:00
Michael Jung 4f27140331 include/netinet/in.h: Rename __pad member to sin_zero in struct sockaddr_in.
Libwebsockets initializes the 'sin_zero' member of sockaddr_in objects to zeros.
Apparently, judging from mailing list entries, there are platforms on which incliinclunot
doing this causes undefined behaviour.

On NuttX compiling respective code is broken, as the corresponding member
variable is called '__pad'.  Neither in the 'nuttx' nor in the 'apps'
respository did I find any reference to this identifier.  Thus, I believe its a
safe bet to just rename it.

UNIX Network Programming states in this regard:

"The POSIX specification requires only three members in the structure: sin_family,
sin_addr, and sin_port. It is acceptable for a POSIX-compliant implementation to
define additional structure members, and this is normal for an Internet socket
address structure. Almost all implementations add the sin_zero member so that all
socket address structures are at least 16 bytes in size."
2019-07-29 08:25:35 -06:00
Xiang Xiao 9711f6c668 Remove dup definition in nuttx/net/arp.h and include/nuttx/net/ioctl.h 2018-11-09 13:59:45 -06:00
Xiang Xiao e0e18fcc74 include/net and include/sys: align the constant values with values in the linux kernel which makes targeting the usrsock server to Linux kernel easier. 2018-11-09 11:50:00 -06:00
Gregory Nutt 25f24c2743 include/netinet/in.h: Add Linux IP_PKTINFO and IPV6_PKTINFO definitions, but not yet realized. 2018-11-09 11:46:57 -06:00
Gregory Nutt 0330743a9d net/inet: Add framework to support IPv4 and IPv6 protocol socket options (i.e., SOL_IP and SOL_IP6). This is build framework only (not actual socket options are yet handled). Handling of these socket options is a necessary step on the way to future ICMPv6 MLD support. 2018-10-31 15:59:05 -06:00
Gregory Nutt 9f754ed1dc include/sys/sockio.h, net/netdev/netdev_ioctl.c: Fix a compile error introducted with commit 34db6d1433. That commit added the semi-standard ip_msfilter structure to netinet/in.h. Howver, there was a non-standard version of that structure in sys/sockio.h. This commit removes the non-standard version of struct ip_msfilter and adapts the IOCTL and device lookup logic in net/netdev to work with the new, semi-standard version in netinet/in.h. 2018-10-29 06:50:47 -06:00
Gregory Nutt 34db6d1433 include/netinet/in.h: Add other definitions required by OpenGroup.org. Correct some typos. 2018-10-28 14:23:04 -06:00
Gregory Nutt 40f56a8a2f include/netinet/in.h: Add IPv4 SOL_IP socket options for symmetry with IPv6 definitions added in a previous commit. None of the socket options have been implemented! 2018-10-28 14:03:57 -06:00
Gregory Nutt de107c8b98 include/netinet/in.h: Per OpenGroup.org, type of sin_port in struct sockaddr_in must be in_port_t vs uint16_t. NOTE: in_port_t is typdef'ed as uint16_t anyway. Plus additional cosmetic changes for things like long lines. 2018-10-28 12:35:22 -06:00
Gregory Nutt bbd8cfbfb5 include/sys/socket.h: With increased size of struct sockaddr_in6 of commit 55f31f03f9, the size of struct sockaddr_storage in include/sys/socket.h must also be increase so that it can contain the new, larger sockaddr_in6. 2018-10-27 14:10:46 -06:00
Gregory Nutt dcc081831e Trivial, cosmetic changes from review of last PR. 2018-10-27 13:47:22 -06:00
Anthony Merlino 55f31f03f9 Merged in antmerlino/nuttx/add-ipv6-options (pull request #741)
Adds definitions for IPPROTO_IPV6 socket options to netinet/in.h Adds missing fields to sockaddr_in6.  Adds struct ipv6-mreq.

These changes all follow the opengroup standard for netinet/in.h

Approved-by: GregoryN <gnutt@nuttx.org>
2018-10-27 19:32:25 +00:00
Sebastien Lorquet 65be13bffe net/udp: Finish support for the UDP_BINDTODEVICE protocol socket option 2018-06-25 15:07:53 -06:00
Gregory Nutt c65e1aa3df Squashed commit of the following:
syscalls/:  Add syscall support for if_nametoindex() and if_indextoname()
    net/: Update some comments.
2018-06-25 12:41:28 -06:00
Gregory Nutt 251924a734 Squashed commit of the following:
net/tcp:  Add logic to send probes when SO_KEEPALIVE is enabled.
    net/tcp:  TCP socket should not have to be connected to configure KeepAlive.
    net/: Add a separate configuration to enable/disable KEEPALIVE socket options.
    net/tcp: Arguments to TCP keep-alive timing functions probably should be struct timeval as are the times for other time-related socket options.
    net/tcp:  Fix a backward conditional
    net/tcp:  Add some more checks and debug output to TCP-protocol socket options.
    net/tcp:  Cosmetic changes to some alignment.
    net/:  Adds socket options needed to manage TCP-keepalive and TCP state machine logic to detect if that the remote peer is alive.  Still missing the timer poll logic to send the keep-alive probes and the state machine logic to respond to probes.
2018-03-12 10:59:46 -06:00