forked from nasa/SDN-HDTN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_v7.p4
154 lines (126 loc) · 3.67 KB
/
parse_v7.p4
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
// Dominick Ta, Stephanie Booth, Rachel Dudukovich
// NASA Glenn Research Center, Cleveland, OH
// Logic for parsing Bundle Protocol version 7 headers.
// Assumes that transport layer headers have been extracted and next byte is start of bundle (i.e. CBOR indefinite-length array start code, 0x9f)
state parse_v7 {
meta.incomingV7 = true;
pkt.extract(hdr.bpv7_start_code);
transition parse_v7_prim_block;
}
state parse_v7_prim_block {
pkt.extract(hdr.bpv7_primary_1);
transition select(hdr.bpv7_primary_1.creation_timestamp_seq_num_initial_byte) {
24 &&& CBOR_MASK_AI: parse_v7_prim_block_2_1; // Requires 1 extra byte to parse creation timestamp seq num
25 &&& CBOR_MASK_AI: parse_v7_prim_block_2_2; // Requires 2 extra bytes to parse creation timestamp seq num
26 &&& CBOR_MASK_AI: parse_v7_prim_block_2_4; // Requires 4 extra bytes to parse creation timestamp seq num
27 &&& CBOR_MASK_AI: parse_v7_prim_block_2_8; // Requires 8 extra bytes to parse creation timestamp seq num
_ : parse_v7_prim_block_3; // Timestamp Seq. Num data item was only one-byte total
}
}
state parse_v7_prim_block_2_1 {
pkt.extract(hdr.bpv7_primary_2_1);
transition parse_v7_prim_block_3;
}
state parse_v7_prim_block_2_2 {
pkt.extract(hdr.bpv7_primary_2_2);
transition parse_v7_prim_block_3;
}
state parse_v7_prim_block_2_4 {
pkt.extract(hdr.bpv7_primary_2_4);
transition parse_v7_prim_block_3;
}
state parse_v7_prim_block_2_8 {
pkt.extract(hdr.bpv7_primary_2_8);
transition parse_v7_prim_block_3;
}
state parse_v7_prim_block_3 {
pkt.extract(hdr.bpv7_primary_3);
transition parse_v7_prev_node_block;
}
state parse_v7_prev_node_block {
pkt.extract(hdr.bpv7_extension_prev_node);
transition parse_v7_ecos_block;
}
state parse_v7_ecos_block {
pkt.extract(hdr.bpv7_extension_ecos);
transition parse_v7_age_block;
}
state parse_v7_age_block {
pkt.extract(hdr.bpv7_extension_age);
transition parse_v7_payload_header;
}
state parse_v7_payload_header {
pkt.extract(hdr.bpv7_payload);
transition select(hdr.bpv7_payload.adu_initial_byte) {
1 &&& CBOR_MASK_AI: parse_v7_adu_1;
2 &&& CBOR_MASK_AI: parse_v7_adu_2;
3 &&& CBOR_MASK_AI : parse_v7_adu_3;
4 &&& CBOR_MASK_AI : parse_v7_adu_4;
5 &&& CBOR_MASK_AI : parse_v7_adu_5;
6 &&& CBOR_MASK_AI : parse_v7_adu_6;
7 &&& CBOR_MASK_AI : parse_v7_adu_7;
8 &&& CBOR_MASK_AI : parse_v7_adu_8;
9 &&& CBOR_MASK_AI : parse_v7_adu_9;
10 &&& CBOR_MASK_AI : parse_v7_adu_10;
11 &&& CBOR_MASK_AI : parse_v7_adu_11;
12 &&& CBOR_MASK_AI : parse_v7_adu_12;
13 &&& CBOR_MASK_AI : parse_v7_adu_13;
_ : accept;
}
}
state parse_v7_adu_1 {
pkt.extract(hdr.adu_1);
transition parse_v7_stop_code;
}
state parse_v7_adu_2 {
pkt.extract(hdr.adu_2);
transition parse_v7_stop_code;
}
state parse_v7_adu_3 {
pkt.extract(hdr.adu_3);
transition parse_v7_stop_code;
}
state parse_v7_adu_4 {
pkt.extract(hdr.adu_4);
transition parse_v7_stop_code;
}
state parse_v7_adu_5 {
pkt.extract(hdr.adu_5);
transition parse_v7_stop_code;
}
state parse_v7_adu_6 {
pkt.extract(hdr.adu_6);
transition parse_v7_stop_code;
}
state parse_v7_adu_7 {
pkt.extract(hdr.adu_7);
transition parse_v7_stop_code;
}
state parse_v7_adu_8 {
pkt.extract(hdr.adu_8);
transition parse_v7_stop_code;
}
state parse_v7_adu_9 {
pkt.extract(hdr.adu_9);
transition parse_v7_stop_code;
}
state parse_v7_adu_10 {
pkt.extract(hdr.adu_10);
transition parse_v7_stop_code;
}
state parse_v7_adu_11 {
pkt.extract(hdr.adu_11);
transition parse_v7_stop_code;
}
state parse_v7_adu_12 {
pkt.extract(hdr.adu_12);
transition parse_v7_stop_code;
}
state parse_v7_adu_13 {
pkt.extract(hdr.adu_13);
transition parse_v7_stop_code;
}
state parse_v7_stop_code {
pkt.extract(hdr.bpv7_stop_code);
transition accept;
}