From f387b138d9da5f0a4bdde77e4556e2039730e9b0 Mon Sep 17 00:00:00 2001 From: zhanghongyu Date: Thu, 13 Apr 2023 23:34:44 +0800 Subject: [PATCH] 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 --- include/netinet/ip.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/netinet/ip.h b/include/netinet/ip.h index aa8b98ca06..8aa9660a25 100644 --- a/include/netinet/ip.h +++ b/include/netinet/ip.h @@ -32,6 +32,33 @@ * Public Type Definitions ****************************************************************************/ +#define IPVERSION 4 /* IP version number */ +#define IPDEFTTL 64 /* default ttl, from RFC 1340 */ + +struct iphdr +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned int ihl:4; + unsigned int version:4; +#elif __BYTE_ORDER == __BIG_ENDIAN + unsigned int version:4; + unsigned int ihl:4; +#else +# error "unknown endian" +#endif + uint8_t tos; + uint16_t tot_len; + uint16_t id; + uint16_t frag_off; + uint8_t ttl; + uint8_t protocol; + uint16_t check; + uint32_t saddr; + uint32_t daddr; + + /* The options start here. */ +}; + /**************************************************************************** * Public Function Prototypes ****************************************************************************/