blob: d3a781124c9db93272d8970e96665f5dbabbcd1f [file] [log] [blame]
Yi Tsengbe342052017-11-03 10:21:23 -07001/*
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
22typedef bit<3> fwd_type_t;
Yi Tseng1b154bd2017-11-20 17:48:19 -080023typedef bit<32> next_id_t;
Yi Tsengbe342052017-11-03 10:21:23 -070024typedef bit<20> mpls_label_t;
25typedef bit<9> port_num_t;
26typedef bit<48> mac_addr_t;
27typedef bit<16> group_id_t;
28typedef bit<12> vlan_id_t;
29
30const bit<16> ETHERTYPE_QINQ = 0x88A8;
31const bit<16> ETHERTYPE_QINQ_NON_STD = 0x9100;
32const bit<16> ETHERTYPE_VLAN = 0x8100;
33const bit<16> ETHERTYPE_MPLS = 0x8847;
34const bit<16> ETHERTYPE_MPLS_MULTICAST =0x8848;
35const bit<16> ETHERTYPE_IPV4 = 0x0800;
36const bit<16> ETHERTYPE_IPV6 = 0x86dd;
37const bit<16> ETHERTYPE_ARP = 0x0806;
38
39const bit<4> IP_VERSION_4 = 4;
40const bit<4> IP_VERSION_6 = 6;
41
42const bit<8> PROTO_ICMP = 1;
43const bit<8> PROTO_TCP = 6;
44const bit<8> PROTO_UDP = 17;
45const bit<8> PROTO_ICMPV6 = 58;
46
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080047const bit<4> IPV4_MIN_IHL = 5;
48
Yi Tseng1d842672017-11-28 16:06:52 -080049#ifndef CPU_PORT
Yi Tsengbe342052017-11-03 10:21:23 -070050const port_num_t CPU_PORT = 255;
Yi Tseng1d842672017-11-28 16:06:52 -080051#endif
Yi Tsengbe342052017-11-03 10:21:23 -070052
53const fwd_type_t FWD_BRIDGING = 0;
54const fwd_type_t FWD_MPLS = 1;
55const fwd_type_t FWD_IPV4_UNICAST = 2;
56const fwd_type_t FWD_IPV4_MULTICAST = 3;
57const fwd_type_t FWD_IPV6_UNICAST = 4;
58const fwd_type_t FWD_IPV6_MULTICAST = 5;
59
Yi Tseng1b154bd2017-11-20 17:48:19 -080060const bit<8> DEFAULT_MPLS_TTL = 64;
Carmelo Casconeb81f4be2018-01-16 23:24:01 -080061const 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
66
67#define UDP_PORT_GTPU 2152
68#define GTP_GPDU 0xff
69#define GTPU_VERSION 0x01
70#define GTP_PROTOCOL_TYPE_GTP 0x01
71
72typedef bit direction_t;
73typedef bit pcc_gate_status_t;
74typedef bit<32> sdf_rule_id_t;
75typedef bit<32> pcc_rule_id_t;
76
77const sdf_rule_id_t DEFAULT_SDF_RULE_ID = 0;
78const pcc_rule_id_t DEFAULT_PCC_RULE_ID = 0;
79
80const direction_t DIR_UPLINK = 1w0;
81const direction_t DIR_DOWNLINK = 1w1;
82
83const pcc_gate_status_t PCC_GATE_OPEN = 1w0;
84const pcc_gate_status_t PCC_GATE_CLOSED = 1w1;
Yi Tseng1b154bd2017-11-20 17:48:19 -080085
Yi Tsengbe342052017-11-03 10:21:23 -070086#endif