blob: df9958bd57a64111bf6217cfdfd1709c44cc9b91 [file] [log] [blame]
Yi Tsengbe342052017-11-03 10:21:23 -07001/*
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 __HEADER__
18#define __HEADER__
19
20#include "define.p4"
21
22@controller_header("packet_in")
23header packet_in_header_t {
24 port_num_t ingress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080025 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070026}
27
28@controller_header("packet_out")
29header packet_out_header_t {
30 port_num_t egress_port;
Yi Tseng1d842672017-11-28 16:06:52 -080031 bit<7> _pad;
Yi Tsengbe342052017-11-03 10:21:23 -070032}
33
34header ethernet_t {
35 mac_addr_t dst_addr;
36 mac_addr_t src_addr;
37 bit<16> ether_type;
38}
39
40header vlan_tag_t {
41 bit<3> pri;
42 bit<1> cfi;
43 vlan_id_t vlan_id;
44 bit<16> ether_type;
45}
46
47header mpls_t {
48 bit<20> label;
49 bit<3> tc;
50 bit<1> bos;
51 bit<8> ttl;
52}
53
54header ipv4_t {
55 bit<4> version;
56 bit<4> ihl;
57 bit<8> diffserv;
58 bit<16> total_len;
59 bit<16> identification;
60 bit<3> flags;
61 bit<13> frag_offset;
62 bit<8> ttl;
63 bit<8> protocol;
64 bit<16> hdr_checksum;
65 bit<32> src_addr;
66 bit<32> dst_addr;
67}
68
69header ipv6_t {
70 bit<4> version;
71 bit<8> traffic_class;
72 bit<20> flow_label;
73 bit<16> payload_len;
74 bit<8> next_hdr;
75 bit<8> hop_limit;
76 bit<128> src_addr;
77 bit<128> dst_addr;
78}
79
80header arp_t {
81 bit<16> hw_type;
82 bit<16> proto_type;
83 bit<8> hw_addr_len;
84 bit<8> proto_addr_len;
85 bit<16> opcode;
86}
87
88header tcp_t {
89 bit<16> src_port;
90 bit<16> dst_port;
91 bit<32> seq_no;
92 bit<32> ack_no;
93 bit<4> data_offset;
94 bit<3> res;
95 bit<3> ecn;
96 bit<6> ctrl;
97 bit<16> window;
98 bit<16> checksum;
99 bit<16> urgent_ptr;
100}
101
102header udp_t {
103 bit<16> src_port;
104 bit<16> dst_port;
105 bit<16> len;
106 bit<16> checksum;
107}
108
109header icmp_t {
110 bit<8> icmp_type;
111 bit<8> icmp_code;
112 bit<16> checksum;
Yi Tsengf73a5532017-11-17 15:58:57 -0800113 bit<16> identifier;
114 bit<16> sequence_number;
115 bit<64> timestamp;
Yi Tsengbe342052017-11-03 10:21:23 -0700116}
117
118//Custom metadata definition
119struct fabric_metadata_t {
120 fwd_type_t fwd_type;
121 next_id_t next_id;
Yi Tsengbe342052017-11-03 10:21:23 -0700122 bool pop_vlan_at_egress;
123 bit<8> ip_proto;
124 bit<16> l4_src_port;
125 bit<16> l4_dst_port;
Yi Tseng1d842672017-11-28 16:06:52 -0800126 bit<16> original_ether_type;
Yi Tsengbe342052017-11-03 10:21:23 -0700127}
128
129struct parsed_headers_t {
130 ethernet_t ethernet;
131 vlan_tag_t vlan_tag;
132 vlan_tag_t inner_vlan_tag;
133 mpls_t mpls;
134 ipv4_t ipv4;
135 ipv6_t ipv6;
136 arp_t arp;
137 tcp_t tcp;
138 udp_t udp;
139 icmp_t icmp;
140 packet_out_header_t packet_out;
141 packet_in_header_t packet_in;
142}
143
144#endif