-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpc.h
170 lines (140 loc) · 2.83 KB
/
pc.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
164
165
166
167
168
169
170
#include <stdio.h>
#include <stdint.h>
#define TABLE_LENGTH 8
#define MAXDIMENSIONS 5
#define MAX_CUT_FIELD 5
#define NUM_INDEX TABLE_LENGTH
#define NO_DIV
#define STACK_OP
//#define HYPERCUTS
//#define FAST
//#define ABCII
//#define HICUTS
struct boundary2{
uint32_t min[2];
};
struct range{
unsigned long long low;
unsigned long long high;
};
struct rule_boundary
{
struct range field[MAXDIMENSIONS];
};
struct realrange{
uint32_t low;
uint32_t high;
};
struct dump_node{
int depth;
struct rule_boundary boundary;
int rules_inside;
int cuts[MAXDIMENSIONS];
int ub_mask[MAXDIMENSIONS];
int fuse_array[MAX_CUT_FIELD][NUM_INDEX];
int fuse_array_num[MAX_CUT_FIELD];
int no;
int node_has_rules;
int rule_in_node;
int isLeaf;
int pointer_size;
};
#ifndef NO_DIV
struct node{
uint8_t type;
uint8_t rules_inside;
uint8_t dim[2];
uint16_t num[2];
struct boundary2 b;
void *ps;
uint32_t s[2];
uint16_t comp_table[2][8];
#ifdef FAST
uint64_t epb;
#endif
}__attribute__((__aligned__(64)));
#else
struct node{
uint8_t type;
uint8_t rules_inside;
uint8_t dim[2];
uint8_t s[2];
uint16_t num[2];
struct boundary2 b;
void *ps;
#ifdef HYBRID
uint16_t comp_table[2][8];
#endif
#ifdef HYPERCUTS
int rule_in_node;
#endif
#ifdef ABCII
int rule_in_node;
uint32_t cuts[2];
#endif
#ifdef FAST
uint64_t epb;
#endif
}__attribute__((__aligned__(64)));
#endif
struct hinode{
uint8_t type;
uint8_t s;
uint16_t num;
uint32_t min;
void *ps;
#ifdef FAST
uint64_t epb;
#endif
};
// type -> 1 bits leaf,
// -> 6 bits for cut dim
// cuts -> 4 bits for dim 1
// cuts -> 4 bits for dim 2
//
struct hnode{
uint8_t type;
uint8_t cuts;
uint8_t num;
uint32_t filter;
void *ps;
uint64_t epb;
};
struct tree_info {
int node_cnt;
int level_cnt;
int *level_node_cnt;
struct node **level_node;
};
struct tree_info_hi {
int node_cnt;
int level_cnt;
int *level_node_cnt;
struct hinode **level_node;
};
//abc-II tree
//
struct anode{
uint16_t csb[2];
uint32_t filter;
void *ps;
uint64_t epb;
uint8_t type;
uint8_t num;
};
struct pc_rule{
struct realrange field[MAXDIMENSIONS];
};
void node_dim(struct dump_node*, int*, int*);
uint32_t calc_s(struct dump_node*, int);
int real_cuts(struct dump_node*, int, unsigned long long*);
void dump2node(struct dump_node *dn, struct node *curr_node);
void dump2hinode(struct dump_node *dn, struct hinode *curr_node);
struct hinode * load_tree_hi(FILE *fp, struct tree_info_hi *info);
/********************API implement********************************/
/*
fpr_name : rule_set file
ifp_name : fib file
*/
void packet_classifier_init(char *fpr_name, char *ifp_name);
int packet_classifier_search(uint32_t *ft);