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>
This commit is contained in:
zhanghongyu 2023-04-13 23:34:44 +08:00 committed by Xiang Xiao
parent 88d62a1157
commit f387b138d9

View File

@ -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
****************************************************************************/