Skip to content

Commit f387b13

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
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 <[email protected]>
1 parent 88d62a1 commit f387b13

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

include/netinet/ip.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@
3232
* Public Type Definitions
3333
****************************************************************************/
3434

35+
#define IPVERSION 4 /* IP version number */
36+
#define IPDEFTTL 64 /* default ttl, from RFC 1340 */
37+
38+
struct iphdr
39+
{
40+
#if __BYTE_ORDER == __LITTLE_ENDIAN
41+
unsigned int ihl:4;
42+
unsigned int version:4;
43+
#elif __BYTE_ORDER == __BIG_ENDIAN
44+
unsigned int version:4;
45+
unsigned int ihl:4;
46+
#else
47+
# error "unknown endian"
48+
#endif
49+
uint8_t tos;
50+
uint16_t tot_len;
51+
uint16_t id;
52+
uint16_t frag_off;
53+
uint8_t ttl;
54+
uint8_t protocol;
55+
uint16_t check;
56+
uint32_t saddr;
57+
uint32_t daddr;
58+
59+
/* The options start here. */
60+
};
61+
3562
/****************************************************************************
3663
* Public Function Prototypes
3764
****************************************************************************/

0 commit comments

Comments
 (0)