-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathall.h
More file actions
96 lines (79 loc) · 1.89 KB
/
all.h
File metadata and controls
96 lines (79 loc) · 1.89 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef all_h_INCLUDED
#define all_h_INCLUDED
#include <stdint.h>
typedef struct {
uint8_t dst[6];
uint8_t src[6];
uint16_t ether_type;
} eth_hdr_t;
// DLT_LINUX_SLL2 header
// https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html
// used when you capture 'any' device on some linuxes
typedef struct {
uint16_t protocol_type;
uint16_t reserved;
int32_t interface_index;
uint16_t arphrd_type;
uint8_t packet_type;
uint8_t link_layer_addrlen;
uint8_t link_layer_addr[8];
} sll2_hdr_t;
typedef struct {
uint16_t packet_type;
uint16_t arphrd_type;
uint16_t link_layer_addrlen;
uint8_t link_layer_addr[8];
uint16_t protocol_type;
} sll_hdr_t;
typedef struct {
uint8_t v_and_hl;
uint8_t tos;
uint16_t tot_len;
uint16_t id;
uint16_t frag_off;
uint8_t ttl;
uint8_t protocol;
uint16_t checksum;
uint32_t saddr;
uint32_t daddr;
// options start
} ip4_hdr_t;
typedef struct {
uint32_t flow; // 4 bits version, 8 bits tc, 20 bits flow id
uint16_t payload_len;
uint8_t next_header;
uint8_t hop_limit;
uint8_t src[16];
uint8_t dst[16];
} ip6_hdr_t;
typedef struct {
uint16_t sport;
uint16_t dport;
uint16_t len;
uint16_t checksum;
} udp_hdr_t;
typedef struct {
uint8_t magic;
uint8_t data_offset;
} udx_hdr_t;
typedef struct {
uint32_t seq;
uint32_t ack;
uint16_t size;
uint16_t transmits;
uint64_t timestamp_millis;
} udx_packet_t;
// cirbuf
typedef struct {
uint32_t size;
uint32_t mask;
udx_packet_t **values;
} udx_cirbuf_t;
void udx__cirbuf_init(udx_cirbuf_t *c, uint32_t initial_size);
void udx__cirbuf_destroy(udx_cirbuf_t *c);
void udx__cirbuf_set(udx_cirbuf_t *c, udx_packet_t *val);
udx_packet_t *
udx__cirbuf_get(udx_cirbuf_t *c, uint32_t seq);
udx_packet_t *
udx__cirbuf_remove(udx_cirbuf_t *c, uint32_t seq);
#endif // all_h_INCLUDED