Carmelo Cascone | c8d3486 | 2017-07-30 00:48:23 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Carmelo Cascone | c8d3486 | 2017-07-30 00:48:23 -0400 | [diff] [blame] | 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 | |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 17 | #ifndef __HEADERS__ |
| 18 | #define __HEADERS__ |
| 19 | |
| 20 | #include "defines.p4" |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 21 | |
| 22 | @controller_header("packet_in") |
| 23 | header packet_in_header_t { |
| 24 | bit<9> ingress_port; |
| 25 | } |
| 26 | |
| 27 | @controller_header("packet_out") |
| 28 | header packet_out_header_t { |
| 29 | bit<9> egress_port; |
| 30 | } |
| 31 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 32 | header ethernet_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 33 | bit<48> dst_addr; |
| 34 | bit<48> src_addr; |
| 35 | bit<16> ether_type; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | header ipv4_t { |
| 39 | bit<4> version; |
| 40 | bit<4> ihl; |
| 41 | bit<8> diffserv; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 42 | bit<16> len; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 43 | bit<16> identification; |
| 44 | bit<3> flags; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 45 | bit<13> frag_offset; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 46 | bit<8> ttl; |
| 47 | bit<8> protocol; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 48 | bit<16> hdr_checksum; |
| 49 | bit<32> src_addr; |
| 50 | bit<32> dst_addr; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | header tcp_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 54 | bit<16> src_port; |
| 55 | bit<16> dst_port; |
| 56 | bit<32> seq_no; |
| 57 | bit<32> ack_no; |
| 58 | bit<4> data_offset; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 59 | bit<3> res; |
| 60 | bit<3> ecn; |
| 61 | bit<6> ctrl; |
| 62 | bit<16> window; |
| 63 | bit<16> checksum; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 64 | bit<16> urgent_ptr; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | header udp_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 68 | bit<16> src_port; |
| 69 | bit<16> dst_port; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 70 | bit<16> length_; |
| 71 | bit<16> checksum; |
| 72 | } |
| 73 | |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 74 | struct headers_t { |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 75 | ethernet_t ethernet; |
| 76 | ipv4_t ipv4; |
| 77 | tcp_t tcp; |
| 78 | udp_t udp; |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 79 | packet_out_header_t packet_out; |
| 80 | packet_in_header_t packet_in; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 81 | } |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 82 | |
| 83 | struct local_metadata_t { |
| 84 | bit<16> l4_src_port; |
| 85 | bit<16> l4_dst_port; |
| 86 | next_hop_id_t next_hop_id; |
| 87 | bit<16> selector; |
| 88 | } |
| 89 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 90 | #endif |