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 __DEFINE__ |
| 18 | #define __DEFINE__ |
| 19 | |
| 20 | #define MAX_PORTS 511 |
| 21 | |
| 22 | typedef bit<3> fwd_type_t; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 23 | typedef bit<32> next_id_t; |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 24 | typedef bit<20> mpls_label_t; |
| 25 | typedef bit<9> port_num_t; |
| 26 | typedef bit<48> mac_addr_t; |
| 27 | typedef bit<16> group_id_t; |
| 28 | typedef bit<12> vlan_id_t; |
| 29 | |
| 30 | const bit<16> ETHERTYPE_QINQ = 0x88A8; |
| 31 | const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100; |
| 32 | const bit<16> ETHERTYPE_VLAN = 0x8100; |
| 33 | const bit<16> ETHERTYPE_MPLS = 0x8847; |
| 34 | const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848; |
| 35 | const bit<16> ETHERTYPE_IPV4 = 0x0800; |
| 36 | const bit<16> ETHERTYPE_IPV6 = 0x86dd; |
| 37 | const bit<16> ETHERTYPE_ARP = 0x0806; |
| 38 | |
Yi Tseng | 3d3956d | 2018-01-31 17:28:05 -0800 | [diff] [blame] | 39 | #ifndef IP_VER_LENGTH |
| 40 | #define IP_VER_LENGTH 4 |
| 41 | #endif |
| 42 | #ifndef IP_VERSION_4 |
| 43 | #define IP_VERSION_4 4 |
| 44 | #endif |
| 45 | #ifndef IP_VERSION_6 |
| 46 | #define IP_VERSION_6 6 |
| 47 | #endif |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 48 | |
| 49 | const bit<8> PROTO_ICMP = 1; |
| 50 | const bit<8> PROTO_TCP = 6; |
| 51 | const bit<8> PROTO_UDP = 17; |
| 52 | const bit<8> PROTO_ICMPV6 = 58; |
| 53 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 54 | const bit<4> IPV4_MIN_IHL = 5; |
| 55 | |
Carmelo Cascone | b531b68 | 2018-01-30 17:55:56 -0800 | [diff] [blame] | 56 | #ifndef _PKT_OUT_HDR_ANNOT_ |
| 57 | #define _PKT_OUT_HDR_ANNOT_ |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 58 | #endif |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 59 | |
| 60 | const fwd_type_t FWD_BRIDGING = 0; |
| 61 | const fwd_type_t FWD_MPLS = 1; |
| 62 | const fwd_type_t FWD_IPV4_UNICAST = 2; |
| 63 | const fwd_type_t FWD_IPV4_MULTICAST = 3; |
| 64 | const fwd_type_t FWD_IPV6_UNICAST = 4; |
| 65 | const fwd_type_t FWD_IPV6_MULTICAST = 5; |
| 66 | |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 67 | const bit<8> DEFAULT_MPLS_TTL = 64; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 68 | const bit<8> DEFAULT_IPV4_TTL = 64; |
| 69 | |
| 70 | #define ETH_HDR_SIZE 14 |
| 71 | #define IPV4_HDR_SIZE 20 |
| 72 | #define UDP_HDR_SIZE 8 |
Carmelo Cascone | 14cde40 | 2018-01-25 01:57:18 -0800 | [diff] [blame] | 73 | #define GTP_HDR_SIZE 8 |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 74 | |
| 75 | #define UDP_PORT_GTPU 2152 |
| 76 | #define GTP_GPDU 0xff |
| 77 | #define GTPU_VERSION 0x01 |
| 78 | #define GTP_PROTOCOL_TYPE_GTP 0x01 |
| 79 | |
| 80 | typedef bit direction_t; |
| 81 | typedef bit pcc_gate_status_t; |
| 82 | typedef bit<32> sdf_rule_id_t; |
| 83 | typedef bit<32> pcc_rule_id_t; |
| 84 | |
| 85 | const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0; |
| 86 | const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0; |
| 87 | |
| 88 | const direction_t DIR_UPLINK = 1w0; |
| 89 | const direction_t DIR_DOWNLINK = 1w1; |
| 90 | |
| 91 | const pcc_gate_status_t PCC_GATE_OPEN = 1w0; |
| 92 | const pcc_gate_status_t PCC_GATE_CLOSED = 1w1; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 93 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 94 | #endif |