-
Notifications
You must be signed in to change notification settings - Fork 0
/
walldefiner.h
164 lines (146 loc) · 3.3 KB
/
walldefiner.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*This is the definder of the header file,in which will provide the define of the structor*/
/*************************************Header File******************************************/
#define ERRBUF_SIZE 100
typedef struct ethernet_stor
{
uint8_t destnation_mac[6]; //the mac address of the destination
uint8_t source_mac[6];
uint8_t ethernet_type[2];
uint8_t data;
}ethernet_stor;
typedef struct ip_stor
{
uint8_t version;
uint8_t description;
uint8_t total_length[2];
uint8_t identification[2];
uint8_t flag_frag_offset[2];
uint8_t ttl;
uint8_t protocol;
uint8_t checksum[2];
uint8_t source_ip[4];
uint8_t destnation_ip[4];
uint8_t options_data;
}ip_stor;
typedef struct tcp_stor
{
uint8_t source_port[2];
uint8_t destination_port[2];
uint8_t seq_number[4];
uint8_t ack_number[4];
uint8_t offset_reserve_flag;
uint8_t flags;
uint8_t window_size[2];
uint8_t checksum[2];
uint8_t urg_pointer[2];
uint8_t options_data;
}tcp_stor;
typedef struct pse_tcp_stor
{
uint8_t source_ip[4];
uint8_t destination_ip[4];
uint8_t protocol;
uint8_t reseved;
uint8_t tcp_length[2];
tcp_stor *tcp_head;
}psedo_tcp_stor;
typedef struct udp_stor {
uint8_t source_port[4];
uint8_t destination_port[4];
uint8_t length[2];
uint8_t checksum[2];//УÑéºÍ
uint8_t data;
}udp_stor;
typedef struct pse_udp_stor
{
uint8_t source_ip[4];
uint8_t destination_ip[4];
uint8_t protocol;
uint8_t reserved;
uint8_t udp_length[2];
udp_stor *udp_head;
}psedo_udp_stor;
typedef struct icmp_stor
{
uint8_t type;
uint8_t code;
uint8_t checksum[2];
uint8_t reminder[4];
}icmp_stor;
typedef struct arp_stor
{
uint8_t datalink_type[2];
uint8_t protocol_type[2];
uint8_t hardware_len;
uint8_t protocol_len;
uint8_t operation[2];
uint8_t sender_hardware_addr[6];
uint8_t sender_protocol_addr[4];
uint8_t target_hardware_addr[6];
uint8_t target_protocol_addr[4];
}arp_stor;
//rules list and rules elements in order to creat a rules table to store the rules
typedef struct rules_element
{
int rules;
int direction;
int service;
uint32_t source_ip,destination_ip;
uint16_t source_port, destination_port;
uint8_t source_ip_any, destination_ip_any;
uint8_t source_port_any, destination_port_any;
void *next;
}rules_ele;
typedef struct rules_list
{
int length;
rules_ele *head;
rules_ele *tail;
}rules_list;
/****************IP block rules ******************/
typedef struct ip_group_def
{
uint32_t source_ip;
uint32_t destination_ip;
}ip_group;
typedef struct ip_port_group_def
{
uint32_t source_ip;
uint32_t destination_ip;
uint32_t source_port;
uint32_t destination_port;
}ip_port_group;
typedef struct ip_status_def
{
ip_group ip;
int service;
}ip_status;
typedef struct tcp_status_def
{
ip_port_group ip_port;
int last_state;
int fin_A, fin_B; //The object sent FIN(A->B)
struct timeval event_time;
//To record the time of this event happend
}tcp_status;
typedef struct udp_status_def {
ip_port_group ip_port;
struct timeval event_time;
}udp_status;
typedef struct icmp_status_def {
ip_group ip;
struct timeval event_time;
}icmp_status;
///////////////////////////////////////////////////
//hash node definder
typedef struct hash_element
{
void *stats;
void *next;
//this void * means that it is a pointer pointing at any kind of functions
}hash_ele;
typedef struct hash_node_def
{
int length;
hash_ele *head;
}hash_node;