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; |
Keesjan Karsten | 2336889 | 2018-05-22 10:46:01 +0000 | [diff] [blame] | 25 | bit<7> _padding; |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | @controller_header("packet_out") |
| 29 | header packet_out_header_t { |
| 30 | bit<9> egress_port; |
Keesjan Karsten | 2336889 | 2018-05-22 10:46:01 +0000 | [diff] [blame] | 31 | bit<7> _padding; |
Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 32 | } |
| 33 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 34 | header ethernet_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 35 | bit<48> dst_addr; |
| 36 | bit<48> src_addr; |
| 37 | bit<16> ether_type; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 38 | } |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 39 | const bit<8> ETH_HEADER_LEN = 14; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 40 | |
| 41 | header ipv4_t { |
| 42 | bit<4> version; |
| 43 | bit<4> ihl; |
Jonghwan Hyun | 8be0339 | 2017-12-04 15:48:44 -0800 | [diff] [blame] | 44 | bit<6> dscp; |
| 45 | bit<2> ecn; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 46 | bit<16> len; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 47 | bit<16> identification; |
| 48 | bit<3> flags; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 49 | bit<13> frag_offset; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 50 | bit<8> ttl; |
| 51 | bit<8> protocol; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 52 | bit<16> hdr_checksum; |
| 53 | bit<32> src_addr; |
| 54 | bit<32> dst_addr; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 55 | } |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 56 | const bit<8> IPV4_MIN_HEAD_LEN = 20; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 57 | |
| 58 | header tcp_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 59 | bit<16> src_port; |
| 60 | bit<16> dst_port; |
| 61 | bit<32> seq_no; |
| 62 | bit<32> ack_no; |
| 63 | bit<4> data_offset; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 64 | bit<3> res; |
| 65 | bit<3> ecn; |
| 66 | bit<6> ctrl; |
| 67 | bit<16> window; |
| 68 | bit<16> checksum; |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 69 | bit<16> urgent_ptr; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | header udp_t { |
Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 73 | bit<16> src_port; |
| 74 | bit<16> dst_port; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 75 | bit<16> length_; |
| 76 | bit<16> checksum; |
| 77 | } |
Jonghwan Hyun | 6777d53 | 2018-11-18 20:50:16 +0900 | [diff] [blame] | 78 | const bit<8> UDP_HEADER_LEN = 8; |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 79 | |
Yi Tseng | 2162993 | 2017-06-06 11:17:43 -0700 | [diff] [blame] | 80 | #endif |