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 | |
| 39 | const bit<4> IP_VERSION_4 = 4; |
| 40 | const bit<4> IP_VERSION_6 = 6; |
| 41 | |
| 42 | const bit<8> PROTO_ICMP = 1; |
| 43 | const bit<8> PROTO_TCP = 6; |
| 44 | const bit<8> PROTO_UDP = 17; |
| 45 | const bit<8> PROTO_ICMPV6 = 58; |
| 46 | |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 47 | const bit<4> IPV4_MIN_IHL = 5; |
| 48 | |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 49 | #ifndef CPU_PORT |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 50 | const port_num_t CPU_PORT = 255; |
Yi Tseng | 1d84267 | 2017-11-28 16:06:52 -0800 | [diff] [blame] | 51 | #endif |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 52 | |
| 53 | const fwd_type_t FWD_BRIDGING = 0; |
| 54 | const fwd_type_t FWD_MPLS = 1; |
| 55 | const fwd_type_t FWD_IPV4_UNICAST = 2; |
| 56 | const fwd_type_t FWD_IPV4_MULTICAST = 3; |
| 57 | const fwd_type_t FWD_IPV6_UNICAST = 4; |
| 58 | const fwd_type_t FWD_IPV6_MULTICAST = 5; |
| 59 | |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 60 | const bit<8> DEFAULT_MPLS_TTL = 64; |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 61 | const bit<8> DEFAULT_IPV4_TTL = 64; |
| 62 | |
| 63 | #define ETH_HDR_SIZE 14 |
| 64 | #define IPV4_HDR_SIZE 20 |
| 65 | #define UDP_HDR_SIZE 8 |
Carmelo Cascone | 14cde40 | 2018-01-25 01:57:18 -0800 | [diff] [blame] | 66 | #define GTP_HDR_SIZE 8 |
Carmelo Cascone | b81f4be | 2018-01-16 23:24:01 -0800 | [diff] [blame] | 67 | |
| 68 | #define UDP_PORT_GTPU 2152 |
| 69 | #define GTP_GPDU 0xff |
| 70 | #define GTPU_VERSION 0x01 |
| 71 | #define GTP_PROTOCOL_TYPE_GTP 0x01 |
| 72 | |
| 73 | typedef bit direction_t; |
| 74 | typedef bit pcc_gate_status_t; |
| 75 | typedef bit<32> sdf_rule_id_t; |
| 76 | typedef bit<32> pcc_rule_id_t; |
| 77 | |
| 78 | const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0; |
| 79 | const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0; |
| 80 | |
| 81 | const direction_t DIR_UPLINK = 1w0; |
| 82 | const direction_t DIR_DOWNLINK = 1w1; |
| 83 | |
| 84 | const pcc_gate_status_t PCC_GATE_OPEN = 1w0; |
| 85 | const pcc_gate_status_t PCC_GATE_CLOSED = 1w1; |
Yi Tseng | 1b154bd | 2017-11-20 17:48:19 -0800 | [diff] [blame] | 86 | |
Yi Tseng | be34205 | 2017-11-03 10:21:23 -0700 | [diff] [blame] | 87 | #endif |