-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathip.h
More file actions
39 lines (28 loc) · 635 Bytes
/
Copy pathip.h
File metadata and controls
39 lines (28 loc) · 635 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#ifndef _IP_H
#define _IP_H
#include <sys/types.h>
struct ipv4_hdr {
uint8_t version : 4;
uint8_t ihl : 4;
uint8_t tos;
uint16_t len;
uint16_t id;
uint16_t flags : 3;
uint16_t frag_offs : 13;
uint8_t ttl;
uint8_t proto;
uint16_t csum;
uint32_t saddr;
uint32_t daddr;
} __attribute__ ((packed));
typedef struct ipv4_hdr ipv4_hdr_t;
#define IPV4 4
uint16_t ip_csum(void *buf, int len);
int ip_process(struct net_buf *buf);
void *ipv42buf(ipv4_hdr_t *iph);
int iphlen(void *buf);
void *ip_data(ipv4_hdr_t *iph);
#define IP_P_ICMP 1
#define IP_P_TCP 6
#define IP_P_UDP 17
#endif