-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpacket.h
70 lines (56 loc) · 1.2 KB
/
packet.h
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
#ifndef PACKET_H
#define PACKET_H
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/ip_icmp.h>
struct packet;
#define PACKET_MAGIC 0x11febeef
#define ICMP_EXT_OFFSET 8 /* ICMP type, code, checksum, unused */ + \
128 /* original datagram */
#define ICMP_EXT_VERSION 2
#include "sidecar.h"
#include "utils.h"
#include "context.h"
typedef struct packet{
int magic;
int type;
int refcount;
struct iphdr ip;
char * ip_opts;
int ip_opt_len;
struct tcphdr tcp;
char * tcp_opts;
int tcp_opt_len;
struct icmp_header icmp;
char * data;
int datalen;
char * extra;
int extralen;
int hasMpls;
struct mpls_header mpls;
} packet;
int packet_send_now(struct tapcontext *);
// all the rest of packet functs are defined in sidecar.h
// used to MPLS ICMP extension parsing
struct icmp_ext_cmn_hdr {
#if BYTE_ORDER == BIG_ENDIAN
u_char version:4;
u_char reserved1:4;
#else
u_char reserved1:4;
u_char version:4;
#endif
u_char reserved2;
u_short checksum;
};
/*
* ICMP extensions, object header
*/
struct icmp_ext_obj_hdr {
u_short length;
u_char class_num;
#define MPLS_STACK_ENTRY_CLASS 1
u_char c_type;
#define MPLS_STACK_ENTRY_C_TYPE 1
};
#endif