Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 1 | /* |
| 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") |
| 23 | header packet_in_header_t { |
| 24 | port_num_t ingress_port; |
| 25 | } |
| 26 | |
| 27 | @controller_header("packet_out") |
| 28 | header packet_out_header_t { |
| 29 | port_num_t egress_port; |
| 30 | } |
| 31 | |
| 32 | header ethernet_t { |
| 33 | mac_addr_t dst_addr; |
| 34 | mac_addr_t src_addr; |
| 35 | bit<16> ether_type; |
| 36 | } |
| 37 | |
| 38 | header vlan_tag_t { |
| 39 | bit<3> pri; |
| 40 | bit<1> cfi; |
| 41 | vlan_id_t vlan_id; |
| 42 | bit<16> ether_type; |
| 43 | } |
| 44 | |
| 45 | header mpls_t { |
| 46 | bit<20> label; |
| 47 | bit<3> tc; |
| 48 | bit<1> bos; |
| 49 | bit<8> ttl; |
| 50 | } |
| 51 | |
| 52 | header 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 | |
| 67 | header 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 | |
| 78 | header 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 | |
| 86 | header 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 | |
| 100 | header udp_t { |
| 101 | bit<16> src_port; |
| 102 | bit<16> dst_port; |
| 103 | bit<16> len; |
| 104 | bit<16> checksum; |
| 105 | } |
| 106 | |
| 107 | header icmp_t { |
| 108 | bit<8> icmp_type; |
| 109 | bit<8> icmp_code; |
| 110 | bit<16> checksum; |
| 111 | } |
| 112 | |
| 113 | //Custom metadata definition |
| 114 | struct fabric_metadata_t { |
| 115 | fwd_type_t fwd_type; |
| 116 | next_id_t next_id; |
| 117 | next_type_t next_type; |
| 118 | bool pop_vlan_at_egress; |
| 119 | bit<8> ip_proto; |
| 120 | bit<16> l4_src_port; |
| 121 | bit<16> l4_dst_port; |
| 122 | } |
| 123 | |
| 124 | struct parsed_headers_t { |
| 125 | ethernet_t ethernet; |
| 126 | vlan_tag_t vlan_tag; |
| 127 | vlan_tag_t inner_vlan_tag; |
| 128 | mpls_t mpls; |
| 129 | ipv4_t ipv4; |
| 130 | ipv6_t ipv6; |
| 131 | arp_t arp; |
| 132 | tcp_t tcp; |
| 133 | udp_t udp; |
| 134 | icmp_t icmp; |
| 135 | packet_out_header_t packet_out; |
| 136 | packet_in_header_t packet_in; |
| 137 | } |
| 138 | |
| 139 | #endif |