blob: 6a205ec2b7179f8859bb36d3784c1e6693527960 [file] [log] [blame]
Carmelo Cascone4f011022017-06-05 01:41:02 -04001metadata intrinsic_metadata_t intrinsic_metadata;
2
3parser start {
4 return parse_ethernet;
5}
6
7#define ETHERTYPE_IPV4 0x0800
8
9header ethernet_t ethernet;
10
11parser parse_ethernet {
12 extract(ethernet);
13 return select(latest.etherType) {
14 ETHERTYPE_IPV4 : parse_ipv4;
15 default : ingress;
16 }
17}
18
19header ipv4_t ipv4;
20
21#define IP_PROTOCOLS_TCP 6
22#define IP_PROTOCOLS_UDP 17
23
24parser parse_ipv4 {
25 extract(ipv4);
26 return select(latest.fragOffset, latest.protocol) {
27 IP_PROTOCOLS_TCP : parse_tcp;
28 IP_PROTOCOLS_UDP : parse_udp;
29 default: ingress;
30 }
31}
32
33header tcp_t tcp;
34
35parser parse_tcp {
36 extract(tcp);
37 return ingress;
38}
39
40header udp_t udp;
41
42parser parse_udp {
43 extract(udp);
44 return ingress;
45}