From 7a9922b4678c6407f5f13c44f5eb2ded3b17ecd7 Mon Sep 17 00:00:00 2001 From: no92 Date: Fri, 17 Jan 2025 01:43:11 +0100 Subject: [PATCH 1/2] options/glibc: stub `dn_comp` --- options/glibc/generic/resolv.cpp | 5 +++++ options/glibc/include/resolv.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/options/glibc/generic/resolv.cpp b/options/glibc/generic/resolv.cpp index 7c0723ed68..269977744c 100644 --- a/options/glibc/generic/resolv.cpp +++ b/options/glibc/generic/resolv.cpp @@ -28,6 +28,11 @@ void res_nclose(res_state) { return; } +int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **) { + __ensure(!"Not implemented"); + __builtin_unreachable(); +} + /* This is completely unused, and exists purely to satisfy broken apps. */ struct __res_state *__res_state() { diff --git a/options/glibc/include/resolv.h b/options/glibc/include/resolv.h index cb97c9b816..05176fd084 100644 --- a/options/glibc/include/resolv.h +++ b/options/glibc/include/resolv.h @@ -31,6 +31,8 @@ int res_query(const char *__dname, int __class, int __type, int res_init(void); +int dn_comp(const char *, unsigned char *, int, unsigned char **, unsigned char **); + #endif /* !__MLIBC_ABI_ONLY */ /* From musl: Unused; purely for broken apps From 266fdacad4ffae5b790adb74a5f2f42ca31f9191 Mon Sep 17 00:00:00 2001 From: no92 Date: Fri, 17 Jan 2025 12:39:38 +0100 Subject: [PATCH 2/2] options/posix: define various networking macros These are needed for iputils to compile. --- abis/linux/in.h | 10 +++++ abis/linux/ioctls.h | 1 + options/posix/include/netinet/icmp6.h | 22 ++++++++++ options/posix/include/netinet/ip.h | 41 ++++++++++++++++++ options/posix/include/netinet/ip6.h | 2 + options/posix/include/netinet/ip_icmp.h | 56 +++++++++++++++++++++++++ 6 files changed, 132 insertions(+) diff --git a/abis/linux/in.h b/abis/linux/in.h index 39f7d88ccc..c38c268dab 100644 --- a/abis/linux/in.h +++ b/abis/linux/in.h @@ -148,6 +148,7 @@ struct group_source_req { #define IP_HDRINCL 3 #define IP_OPTIONS 4 #define IP_RECVOPTS 6 +#define IP_RETOPTS 7 #define IP_PKTINFO 8 #define IP_PKTOPTIONS 9 #define IP_MTU_DISCOVER 10 @@ -166,12 +167,14 @@ struct group_source_req { #define IP_UNICAST_IF 50 #define IPV6_2292PKTOPTIONS 6 +#define IPV6_2292HOPLIMIT 8 #define IPV6_UNICAST_HOPS 16 #define IPV6_MULTICAST_IF 17 #define IPV6_MULTICAST_HOPS 18 #define IPV6_MULTICAST_LOOP 19 #define IPV6_JOIN_GROUP 20 #define IPV6_LEAVE_GROUP 21 +#define IPV6_MTU_DISCOVER 23 #define IPV6_MTU 24 #define IPV6_RECVERR 25 #define IPV6_V6ONLY 26 @@ -186,6 +189,13 @@ struct group_source_req { #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP #define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP +#define IPV6_PMTUDISC_DONT 0 +#define IPV6_PMTUDISC_WANT 1 +#define IPV6_PMTUDISC_DO 2 +#define IPV6_PMTUDISC_PROBE 3 +#define IPV6_PMTUDISC_INTERFACE 4 +#define IPV6_PMTUDISC_OMIT 5 + #define IP_PMTUDISC_DONT 0 #define IP_PMTUDISC_WANT 1 #define IP_PMTUDISC_DO 2 diff --git a/abis/linux/ioctls.h b/abis/linux/ioctls.h index 4d4a2a3be5..f3606a3212 100644 --- a/abis/linux/ioctls.h +++ b/abis/linux/ioctls.h @@ -5,6 +5,7 @@ #define TIOCNXCL 0x540D #define SIOCPROTOPRIVATE 0x89E0 +#define SIOCGSTAMP 0x8906 #define SIOCGIFNAME 0x8910 #define SIOCGIFCONF 0x8912 #define SIOCGIFFLAGS 0x8913 diff --git a/options/posix/include/netinet/icmp6.h b/options/posix/include/netinet/icmp6.h index f2b9c1ee0c..5251bbdd14 100644 --- a/options/posix/include/netinet/icmp6.h +++ b/options/posix/include/netinet/icmp6.h @@ -15,6 +15,11 @@ extern "C" { #define ICMP6_FILTER 1 +#define ICMP6_DST_UNREACH 1 +#define ICMP6_PACKET_TOO_BIG 2 +#define ICMP6_TIME_EXCEEDED 3 +#define ICMP6_PARAM_PROB 4 + #define ICMP6_FILTER_BLOCK 1 #define ICMP6_FILTER_PASS 2 #define ICMP6_FILTER_BLOCKOTHERS 3 @@ -22,6 +27,23 @@ extern "C" { #define ICMP6_ECHO_REQUEST 128 #define ICMP6_ECHO_REPLY 129 +#define MLD_LISTENER_QUERY 130 +#define MLD_LISTENER_REPORT 131 +#define MLD_LISTENER_REDUCTION 132 + +#define ICMP6_DST_UNREACH_NOROUTE 0 +#define ICMP6_DST_UNREACH_ADMIN 1 +#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 +#define ICMP6_DST_UNREACH_ADDR 3 +#define ICMP6_DST_UNREACH_NOPORT 4 + +#define ICMP6_TIME_EXCEED_TRANSIT 0 +#define ICMP6_TIME_EXCEED_REASSEMBLY 1 + +#define ICMP6_PARAMPROB_HEADER 0 +#define ICMP6_PARAMPROB_NEXTHEADER 1 +#define ICMP6_PARAMPROB_OPTION 2 + struct icmp6_filter { uint32_t icmp6_filt[8]; }; diff --git a/options/posix/include/netinet/ip.h b/options/posix/include/netinet/ip.h index 6c416b54aa..cb7c06cccb 100644 --- a/options/posix/include/netinet/ip.h +++ b/options/posix/include/netinet/ip.h @@ -21,6 +21,47 @@ extern "C" { #define IPTOS_CLASS_CS6 0xC0 #define IPTOS_DSCP_EF 0xB8 +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o) & IPOPT_COPY) +#define IPOPT_CLASS(o) ((o) & IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o) & IPOPT_NUMBER_MASK) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_DEBMEAS 0x40 +#define IPOPT_MEASUREMENT IPOPT_DEBMEAS +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_EOL 0 +#define IPOPT_END IPOPT_EOL +#define IPOPT_NOP 1 +#define IPOPT_NOOP IPOPT_NOP + +#define IPOPT_RR 7 +#define IPOPT_TS 68 +#define IPOPT_TIMESTAMP IPOPT_TS +#define IPOPT_SECURITY 130 +#define IPOPT_SEC IPOPT_SECURITY +#define IPOPT_LSRR 131 +#define IPOPT_SATID 136 +#define IPOPT_SID IPOPT_SATID +#define IPOPT_SSRR 137 +#define IPOPT_RA 148 + +#define IPOPT_OPTVAL 0 +#define IPOPT_OLEN 1 +#define IPOPT_OFFSET 2 +#define IPOPT_MINOFF 4 + +#define MAX_IPOPTLEN 40 + +#define IPOPT_TS_TSONLY 0 +#define IPOPT_TS_TSANDADDR 1 +#define IPOPT_TS_PRESPEC 3 + #define IPDEFTTL 64 struct ip { diff --git a/options/posix/include/netinet/ip6.h b/options/posix/include/netinet/ip6.h index e097acae38..268f8a2fa5 100644 --- a/options/posix/include/netinet/ip6.h +++ b/options/posix/include/netinet/ip6.h @@ -21,6 +21,8 @@ struct ip6_hdr { struct in6_addr ip6_dst; }; +#define ip6_nxt ip6_ctlun.ip6_un1.ip6_un1_nxt + #ifdef __cplusplus } #endif diff --git a/options/posix/include/netinet/ip_icmp.h b/options/posix/include/netinet/ip_icmp.h index efffda1e9c..c5fecd1b9c 100644 --- a/options/posix/include/netinet/ip_icmp.h +++ b/options/posix/include/netinet/ip_icmp.h @@ -10,8 +10,64 @@ extern "C" { #include #include +struct icmphdr { + uint8_t type; + uint8_t code; + uint16_t checksum; + union { + struct { + uint16_t id; + uint16_t sequence; + } echo; + uint32_t gateway; + struct { + uint16_t __unused; + uint16_t mtu; + } frag; + uint8_t reserved[4]; + } un; +}; + #define ICMP_ECHOREPLY 0 +#define ICMP_DEST_UNREACH 3 +#define ICMP_SOURCE_QUENCH 4 +#define ICMP_REDIRECT 5 #define ICMP_ECHO 8 +#define ICMP_TIME_EXCEEDED 11 +#define ICMP_PARAMETERPROB 12 +#define ICMP_TIMESTAMP 13 +#define ICMP_TIMESTAMPREPLY 14 +#define ICMP_INFO_REQUEST 15 +#define ICMP_INFO_REPLY 16 +#define ICMP_ADDRESS 17 +#define ICMP_ADDRESSREPLY 18 + +#define ICMP_NET_UNREACH 0 +#define ICMP_HOST_UNREACH 1 +#define ICMP_PROT_UNREACH 2 +#define ICMP_PORT_UNREACH 3 +#define ICMP_FRAG_NEEDED 4 +#define ICMP_SR_FAILED 5 +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_HOST_ISOLATED 8 +#define ICMP_NET_ANO 9 +#define ICMP_HOST_ANO 10 +#define ICMP_NET_UNR_TOS 11 +#define ICMP_HOST_UNR_TOS 12 +#define ICMP_PKT_FILTERED 13 +#define ICMP_PREC_VIOLATION 14 +#define ICMP_PREC_CUTOFF 15 +#define NR_ICMP_UNREACH 15 + +#define ICMP_REDIR_NET 0 +#define ICMP_REDIR_HOST 1 +#define ICMP_REDIR_NETTOS 2 +#define ICMP_REDIR_HOSTTOS 3 + +#define ICMP_EXC_TTL 0 +#define ICMP_EXC_FRAGTIME 1 + #define ICMP_ADVLENMIN (8 + sizeof(struct ip) + 8) struct icmp_ra_addr {