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