Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __PARSER__ |
| 18 | #define __PARSER__ |
| 19 | |
| 20 | #include "define.p4" |
| 21 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 22 | parser FabricParser (packet_in packet, |
| 23 | out parsed_headers_t hdr, |
| 24 | inout fabric_metadata_t fabric_metadata, |
| 25 | inout standard_metadata_t standard_metadata) { |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 26 | |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 27 | bit<6> last_ipv4_dscp = 0; |
| 28 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 29 | state start { |
| 30 | transition select(standard_metadata.ingress_port) { |
Carmelo Cascone | 2388cc1 | 2021-05-26 19:30:30 +0200 | [diff] [blame] | 31 | CPU_PORT: check_packet_out; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 32 | default: parse_ethernet; |
| 33 | } |
| 34 | } |
| 35 | |
Carmelo Cascone | 2388cc1 | 2021-05-26 19:30:30 +0200 | [diff] [blame] | 36 | state check_packet_out { |
| 37 | packet_out_header_t tmp = packet.lookahead<packet_out_header_t>(); |
| 38 | transition select(tmp.do_forwarding) { |
| 39 | 0: parse_packet_out_and_accept; |
| 40 | default: strip_packet_out; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | state parse_packet_out_and_accept { |
| 45 | // Will transmit over requested egress port as-is. No need to parse further. |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 46 | packet.extract(hdr.packet_out); |
Carmelo Cascone | 2388cc1 | 2021-05-26 19:30:30 +0200 | [diff] [blame] | 47 | transition accept; |
| 48 | } |
| 49 | |
| 50 | state strip_packet_out { |
| 51 | // Remove packet-out header and process as a regular packet. |
| 52 | packet.advance(PACKET_OUT_HDR_SIZE * 8); |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 53 | transition parse_ethernet; |
| 54 | } |
| 55 | |
| 56 | state parse_ethernet { |
| 57 | packet.extract(hdr.ethernet); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 58 | fabric_metadata.vlan_id = DEFAULT_VLAN_ID; |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 59 | transition select(packet.lookahead<bit<16>>()){ |
Daniele Moro | 77654f9 | 2019-07-30 10:29:54 -0700 | [diff] [blame] | 60 | ETHERTYPE_QINQ: parse_vlan_tag; |
| 61 | ETHERTYPE_QINQ_NON_STD: parse_vlan_tag; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 62 | ETHERTYPE_VLAN: parse_vlan_tag; |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 63 | default: parse_eth_type; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 64 | } |
| 65 | } |
| 66 | |
| 67 | state parse_vlan_tag { |
| 68 | packet.extract(hdr.vlan_tag); |
Daniele Moro | b3d199b | 2019-11-01 14:01:46 -0700 | [diff] [blame] | 69 | #ifdef WITH_BNG |
| 70 | fabric_metadata.bng.s_tag = hdr.vlan_tag.vlan_id; |
| 71 | #endif // WITH_BNG |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 72 | transition select(packet.lookahead<bit<16>>()){ |
| 73 | #if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 74 | ETHERTYPE_VLAN: parse_inner_vlan_tag; |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 75 | #endif // WITH_XCONNECT || WITH_DOUBLE_VLAN_TERMINATION |
| 76 | default: parse_eth_type; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 80 | #if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 81 | state parse_inner_vlan_tag { |
| 82 | packet.extract(hdr.inner_vlan_tag); |
Daniele Moro | b3d199b | 2019-11-01 14:01:46 -0700 | [diff] [blame] | 83 | #ifdef WITH_BNG |
| 84 | fabric_metadata.bng.c_tag = hdr.inner_vlan_tag.vlan_id; |
| 85 | #endif // WITH_BNG |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 86 | transition parse_eth_type; |
| 87 | } |
| 88 | #endif // WITH_XCONNECT || WITH_DOUBLE_VLAN_TERMINATION |
| 89 | |
| 90 | state parse_eth_type { |
| 91 | packet.extract(hdr.eth_type); |
| 92 | transition select(hdr.eth_type.value) { |
Yi Tseng | bd46d05 | 2018-01-22 17:18:16 -0800 | [diff] [blame] | 93 | ETHERTYPE_MPLS: parse_mpls; |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 94 | ETHERTYPE_IPV4: parse_ipv4; |
| 95 | #ifdef WITH_IPV6 |
| 96 | ETHERTYPE_IPV6: parse_ipv6; |
| 97 | #endif // WITH_IPV6 |
Carmelo Cascone | 4d8785b | 2019-05-31 17:11:26 -0700 | [diff] [blame] | 98 | #ifdef WITH_BNG |
| 99 | ETHERTYPE_PPPOED: parse_pppoe; |
| 100 | ETHERTYPE_PPPOES: parse_pppoe; |
| 101 | #endif // WITH_BNG |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 102 | default: accept; |
| 103 | } |
| 104 | } |
| 105 | |
Carmelo Cascone | 4d8785b | 2019-05-31 17:11:26 -0700 | [diff] [blame] | 106 | #ifdef WITH_BNG |
| 107 | state parse_pppoe { |
| 108 | packet.extract(hdr.pppoe); |
| 109 | transition select(hdr.pppoe.protocol) { |
Daniele Moro | e22b574 | 2019-06-28 15:32:37 -0700 | [diff] [blame] | 110 | PPPOE_PROTOCOL_MPLS: parse_mpls; |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 111 | PPPOE_PROTOCOL_IP4: parse_ipv4; |
Carmelo Cascone | 4d8785b | 2019-05-31 17:11:26 -0700 | [diff] [blame] | 112 | #ifdef WITH_IPV6 |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 113 | PPPOE_PROTOCOL_IP6: parse_ipv6; |
Carmelo Cascone | 4d8785b | 2019-05-31 17:11:26 -0700 | [diff] [blame] | 114 | #endif // WITH_IPV6 |
| 115 | default: accept; |
| 116 | } |
| 117 | } |
| 118 | #endif // WITH_BNG |
| 119 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 120 | state parse_mpls { |
| 121 | packet.extract(hdr.mpls); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 122 | fabric_metadata.mpls_label = hdr.mpls.label; |
| 123 | fabric_metadata.mpls_ttl = hdr.mpls.ttl; |
Yi Tseng | c6844f5 | 2017-12-19 11:58:25 -0800 | [diff] [blame] | 124 | // There is only one MPLS label for this fabric. |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 125 | // Assume header after MPLS header is IPv4/IPv6 |
Yi Tseng | c6844f5 | 2017-12-19 11:58:25 -0800 | [diff] [blame] | 126 | // Lookup first 4 bits for version |
Yi Tseng | 3d3956d | 2018-01-31 17:28:05 -0800 | [diff] [blame] | 127 | transition select(packet.lookahead<bit<IP_VER_LENGTH>>()) { |
Daniele Moro | 7c3a002 | 2019-07-12 13:38:34 -0700 | [diff] [blame] | 128 | // The packet should be either IPv4 or IPv6. |
| 129 | // If we have MPLS, go directly to parsing state without |
| 130 | // moving to pre_ states, the packet is considered MPLS |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 131 | IP_VERSION_4: parse_ipv4; |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 132 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 133 | IP_VERSION_6: parse_ipv6; |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 134 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 135 | default: parse_ethernet; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | state parse_ipv4 { |
| 140 | packet.extract(hdr.ipv4); |
| 141 | fabric_metadata.ip_proto = hdr.ipv4.protocol; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 142 | fabric_metadata.ip_eth_type = ETHERTYPE_IPV4; |
Robert MacDavid | bec6b6a | 2020-05-21 21:32:38 -0400 | [diff] [blame] | 143 | fabric_metadata.ipv4_src_addr = hdr.ipv4.src_addr; |
| 144 | fabric_metadata.ipv4_dst_addr = hdr.ipv4.dst_addr; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 145 | last_ipv4_dscp = hdr.ipv4.dscp; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 146 | //Need header verification? |
| 147 | transition select(hdr.ipv4.protocol) { |
| 148 | PROTO_TCP: parse_tcp; |
| 149 | PROTO_UDP: parse_udp; |
| 150 | PROTO_ICMP: parse_icmp; |
| 151 | default: accept; |
| 152 | } |
| 153 | } |
| 154 | |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 155 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 156 | state parse_ipv6 { |
| 157 | packet.extract(hdr.ipv6); |
| 158 | fabric_metadata.ip_proto = hdr.ipv6.next_hdr; |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 159 | fabric_metadata.ip_eth_type = ETHERTYPE_IPV6; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 160 | transition select(hdr.ipv6.next_hdr) { |
| 161 | PROTO_TCP: parse_tcp; |
| 162 | PROTO_UDP: parse_udp; |
| 163 | PROTO_ICMPV6: parse_icmp; |
| 164 | default: accept; |
| 165 | } |
| 166 | } |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 167 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 168 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 169 | state parse_tcp { |
| 170 | packet.extract(hdr.tcp); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 171 | fabric_metadata.l4_sport = hdr.tcp.sport; |
| 172 | fabric_metadata.l4_dport = hdr.tcp.dport; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 173 | #ifdef WITH_INT |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 174 | transition parse_int; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 175 | #else |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 176 | transition accept; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 177 | #endif // WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | state parse_udp { |
| 181 | packet.extract(hdr.udp); |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 182 | fabric_metadata.l4_sport = hdr.udp.sport; |
| 183 | fabric_metadata.l4_dport = hdr.udp.dport; |
Carmelo Cascone | 2a308ff | 2021-06-01 18:31:57 -0700 | [diff] [blame] | 184 | gtpu_t gtpu = packet.lookahead<gtpu_t>(); |
| 185 | transition select(hdr.udp.dport, gtpu.version, gtpu.msgtype) { |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 186 | // Treat GTP control traffic as payload. |
| 187 | (UDP_PORT_GTPU, GTP_V1, GTP_GPDU): parse_gtpu; |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 188 | #ifdef WITH_INT |
| 189 | default: parse_int; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 190 | #else |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 191 | default: accept; |
| 192 | #endif // WITH_INT |
| 193 | } |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | state parse_icmp { |
| 197 | packet.extract(hdr.icmp); |
| 198 | transition accept; |
| 199 | } |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 200 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 201 | state parse_gtpu { |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 202 | packet.extract(hdr.gtpu); |
| 203 | transition parse_inner_ipv4; |
| 204 | } |
| 205 | |
| 206 | state parse_inner_ipv4 { |
| 207 | packet.extract(hdr.inner_ipv4); |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 208 | last_ipv4_dscp = hdr.inner_ipv4.dscp; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 209 | transition select(hdr.inner_ipv4.protocol) { |
Daniele Moro | ae26f0a | 2021-07-08 12:53:26 +0200 | [diff] [blame] | 210 | PROTO_TCP: parse_inner_tcp; |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 211 | PROTO_UDP: parse_inner_udp; |
Daniele Moro | ae26f0a | 2021-07-08 12:53:26 +0200 | [diff] [blame] | 212 | PROTO_ICMP: parse_inner_icmp; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 213 | default: accept; |
| 214 | } |
| 215 | } |
| 216 | |
Carmelo Cascone | 9b0171b | 2018-08-14 01:43:57 -0700 | [diff] [blame] | 217 | state parse_inner_udp { |
| 218 | packet.extract(hdr.inner_udp); |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 219 | #ifdef WITH_SPGW |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 220 | fabric_metadata.inner_l4_sport = hdr.inner_udp.sport; |
| 221 | fabric_metadata.inner_l4_dport = hdr.inner_udp.dport; |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 222 | #endif // WITH_SPGW |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 223 | #ifdef WITH_INT |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 224 | transition parse_int; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 225 | #else |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 226 | transition accept; |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 227 | #endif // WITH_INT |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 228 | } |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 229 | |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 230 | state parse_inner_tcp { |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 231 | packet.extract(hdr.inner_tcp); |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 232 | #ifdef WITH_SPGW |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 233 | fabric_metadata.inner_l4_sport = hdr.inner_tcp.sport; |
| 234 | fabric_metadata.inner_l4_dport = hdr.inner_tcp.dport; |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 235 | #endif // WITH_SPGW |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 236 | transition accept; |
| 237 | } |
| 238 | |
Wailok Shum | 4f51bde | 2021-06-11 22:48:41 +0800 | [diff] [blame] | 239 | state parse_inner_icmp { |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 240 | packet.extract(hdr.inner_icmp); |
| 241 | transition accept; |
| 242 | } |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 243 | |
| 244 | #ifdef WITH_INT |
| 245 | state parse_int { |
| 246 | transition select(last_ipv4_dscp) { |
| 247 | INT_DSCP &&& INT_DSCP: parse_intl4_shim; |
| 248 | default: accept; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | state parse_intl4_shim { |
| 253 | packet.extract(hdr.intl4_shim); |
| 254 | transition parse_int_header; |
| 255 | } |
| 256 | |
| 257 | state parse_int_header { |
| 258 | packet.extract(hdr.int_header); |
| 259 | // If there is no INT metadata but the INT header (plus shim and tail) |
| 260 | // exists, default value of length field in shim header should be |
| 261 | // INT_HEADER_LEN_WORDS. |
| 262 | transition select (hdr.intl4_shim.len_words) { |
| 263 | INT_HEADER_LEN_WORDS: parse_intl4_tail; |
| 264 | default: parse_int_data; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | state parse_int_data { |
| 269 | #ifdef WITH_INT_SINK |
| 270 | // Parse INT metadata stack, but not tail |
| 271 | packet.extract(hdr.int_data, (bit<32>) (hdr.intl4_shim.len_words - INT_HEADER_LEN_WORDS) << 5); |
| 272 | transition parse_intl4_tail; |
| 273 | #else // not interested in INT data |
| 274 | transition accept; |
| 275 | #endif // WITH_INT_SINK |
| 276 | } |
| 277 | |
| 278 | state parse_intl4_tail { |
| 279 | packet.extract(hdr.intl4_tail); |
| 280 | transition accept; |
| 281 | } |
| 282 | #endif // WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 285 | control FabricDeparser(packet_out packet,in parsed_headers_t hdr) { |
| 286 | |
Yi Tseng | 3d3956d | 2018-01-31 17:28:05 -0800 | [diff] [blame] | 287 | apply { |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 288 | packet.emit(hdr.packet_in); |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 289 | #ifdef WITH_INT_SINK |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 290 | packet.emit(hdr.report_ethernet); |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 291 | packet.emit(hdr.report_eth_type); |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 292 | packet.emit(hdr.report_ipv4); |
| 293 | packet.emit(hdr.report_udp); |
| 294 | packet.emit(hdr.report_fixed_header); |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 295 | #endif // WITH_INT_SINK |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 296 | packet.emit(hdr.ethernet); |
| 297 | packet.emit(hdr.vlan_tag); |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 298 | #if defined(WITH_XCONNECT) || defined(WITH_DOUBLE_VLAN_TERMINATION) |
Carmelo Cascone | b5324e7 | 2018-11-25 02:26:32 -0800 | [diff] [blame] | 299 | packet.emit(hdr.inner_vlan_tag); |
Daniele Moro | 5a2de71 | 2019-09-24 14:34:07 -0700 | [diff] [blame] | 300 | #endif // WITH_XCONNECT || WITH_DOUBLE_VLAN_TERMINATION |
| 301 | packet.emit(hdr.eth_type); |
Carmelo Cascone | 4d8785b | 2019-05-31 17:11:26 -0700 | [diff] [blame] | 302 | #ifdef WITH_BNG |
| 303 | packet.emit(hdr.pppoe); |
| 304 | #endif // WITH_BNG |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 305 | packet.emit(hdr.mpls); |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 306 | #ifdef WITH_SPGW |
| 307 | packet.emit(hdr.gtpu_ipv4); |
| 308 | packet.emit(hdr.gtpu_udp); |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 309 | packet.emit(hdr.outer_gtpu); |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 310 | #endif // WITH_SPGW |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 311 | packet.emit(hdr.ipv4); |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 312 | #ifdef WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 313 | packet.emit(hdr.ipv6); |
Carmelo Cascone | ed88f2b | 2018-01-26 17:36:34 -0800 | [diff] [blame] | 314 | #endif // WITH_IPV6 |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 315 | packet.emit(hdr.tcp); |
| 316 | packet.emit(hdr.udp); |
Yi Tseng | f73a553 | 2017-11-17 15:58:57 -0800 | [diff] [blame] | 317 | packet.emit(hdr.icmp); |
Robert MacDavid | de12b98 | 2020-07-15 18:38:59 -0700 | [diff] [blame] | 318 | // if we parsed a GTPU packet but did not decap it |
| 319 | packet.emit(hdr.gtpu); |
| 320 | packet.emit(hdr.inner_ipv4); |
| 321 | packet.emit(hdr.inner_tcp); |
| 322 | packet.emit(hdr.inner_udp); |
| 323 | packet.emit(hdr.inner_icmp); |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 324 | #ifdef WITH_INT |
| 325 | packet.emit(hdr.intl4_shim); |
| 326 | packet.emit(hdr.int_header); |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 327 | #ifdef WITH_INT_TRANSIT |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 328 | packet.emit(hdr.int_switch_id); |
| 329 | packet.emit(hdr.int_port_ids); |
| 330 | packet.emit(hdr.int_hop_latency); |
| 331 | packet.emit(hdr.int_q_occupancy); |
| 332 | packet.emit(hdr.int_ingress_tstamp); |
| 333 | packet.emit(hdr.int_egress_tstamp); |
| 334 | packet.emit(hdr.int_q_congestion); |
| 335 | packet.emit(hdr.int_egress_tx_util); |
Carmelo Cascone | 79a3a31 | 2018-08-16 17:14:43 -0700 | [diff] [blame] | 336 | #endif // WITH_INT_TRANSIT |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 337 | #ifdef WITH_INT_SINK |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 338 | packet.emit(hdr.int_data); |
Carmelo Cascone | 8e5818d | 2018-10-26 11:45:23 -0700 | [diff] [blame] | 339 | #endif // WITH_INT_SINK |
Jonghwan Hyun | ed478dc | 2018-08-06 15:35:18 +0900 | [diff] [blame] | 340 | packet.emit(hdr.intl4_tail); |
| 341 | #endif // WITH_INT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 342 | } |
| 343 | } |
| 344 | |
Robert MacDavid | bec6b6a | 2020-05-21 21:32:38 -0400 | [diff] [blame] | 345 | #endif |