ROFL-pipeline  v0.6.0dev
protocol_constants.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef __PROTOCOL_CONSTANTS_H__
6 #define __PROTOCOL_CONSTANTS_H__
7 
8 #include <stdint.h>
9 #include "endianness.h"
10 
11 /*
12  * This header file defines some network protocol header constants
13  */
14 
15 /*
16 * Useful constants (endianness dependant)
17 */
18 #if defined(BIG_ENDIAN_DETECTED)
19  //Useful ETH_TYPE values
20  #define ETH_TYPE_MPLS_UNICAST 0x8847
21  #define ETH_TYPE_MPLS_MULTICAST 0x8848
22  #define ETH_TYPE_8021Q 0x8100
23  #define ETH_TYPE_IPV4 0x0800
24  #define ETH_TYPE_IPV6 0x86DD
25  #define ETH_TYPE_PPPOE_DISCOVERY 0x8863
26  #define ETH_TYPE_PPPOE_SESSION 0x8864
27  #define ETH_TYPE_ARP 0x0806
28  #define ETH_TYPE_PBB 0x88E7
29 
30  //VLAN values
31  #define VLAN_CTAG_ETHER_TYPE 0x8100
32  #define VLAN_STAG_ETHER_TYPE 0x88a8
33  #define VLAN_ITAG_ETHER_TYPE 0x88e7
34  //MPLS values
35 
36  //PPP values
37  #define PPP_PROT_PADDING 0x0001 // 0x00 0x01 in network byte order
38  #define PPP_PROT_LCP 0xc021 // 0xc0 0x21 in network byte order
39  #define PPP_PROT_PAP 0xc023 // 0xc0 0x23 in network byte order
40  #define PPP_PROT_LQR 0xc025 // 0xc0 0x25 in network byte order
41  #define PPP_PROT_CHAP 0xc223 // 0xc2 0x23 in network byte order
42  #define PPP_PROT_EAP 0xc227 // 0xc2 0x27 in network byte order
43  #define PPP_PROT_IPCP 0x8021 // 0x80 0x21 in network byte order
44  #define PPP_PROT_IPV4 0x0021 // 0x00 0x21 in network byte order
45  #define PPP_PROT_IPV6CP 0x8057 // 0x80 0x57 in network byte order
46  #define PPP_PROT_IPV6 0x0057 // 0x00 0x57 in network byte order
47  #define PPP_PROT_CCP 0x80fd // 0x80 0xfd in network byte order
48 
49  //Useful UDP destination port values
50  #define UDP_DST_PORT_GTPC 0x084B //2123
51  #define UDP_DST_PORT_GTPU 0x0868 //2152
52  #define UDP_DST_PORT_CAPWAPC 0x147e //5246
53  #define UDP_DST_PORT_CAPWAPU 0x147f //5247
54 
55 #elif defined(LITTLE_ENDIAN_DETECTED)
56  //Useful ETH_TYPE values
57  #define ETH_TYPE_MPLS_UNICAST 0x4788
58  #define ETH_TYPE_MPLS_MULTICAST 0x4888
59  #define ETH_TYPE_8021Q 0x0081
60  #define ETH_TYPE_IPV4 0x0008
61  #define ETH_TYPE_IPV6 0xDD86
62  #define ETH_TYPE_PPPOE_DISCOVERY 0x6388
63  #define ETH_TYPE_PPPOE_SESSION 0x6488
64  #define ETH_TYPE_ARP 0x0608
65  #define ETH_TYPE_PBB 0xE788
66 
67  //VLAN values
68  #define VLAN_CTAG_ETHER_TYPE 0x0081
69  #define VLAN_STAG_ETHER_TYPE 0xa888
70  #define VLAN_ITAG_ETHER_TYPE 0xe788
71  //MPLS values
72 
73  //PPP values
74  #define PPP_PROT_PADDING 0x0100 // 0x00 0x01 in network byte order
75  #define PPP_PROT_LCP 0x21c0 // 0xc0 0x21 in network byte order
76  #define PPP_PROT_PAP 0x23c0 // 0xc0 0x23 in network byte order
77  #define PPP_PROT_LQR 0x25c0 // 0xc0 0x25 in network byte order
78  #define PPP_PROT_CHAP 0x23c2 // 0xc2 0x23 in network byte order
79  #define PPP_PROT_EAP 0x27c2 // 0xc2 0x27 in network byte order
80  #define PPP_PROT_IPCP 0x2180 // 0x80 0x21 in network byte order
81  #define PPP_PROT_IPV4 0x2100 // 0x00 0x21 in network byte order
82  #define PPP_PROT_IPV6CP 0x5780 // 0x80 0x57 in network byte order
83  #define PPP_PROT_IPV6 0x5700 // 0x00 0x57 in network byte order
84  #define PPP_PROT_CCP 0xfd80 // 0x80 0xfd in network byte order
85 
86  //Useful UDP destination port values
87  #define UDP_DST_PORT_GTPC 0x4B08 //2123
88  #define UDP_DST_PORT_GTPU 0x6808 //2152
89  #define UDP_DST_PORT_CAPWAPC 0x7e14 //5246
90  #define UDP_DST_PORT_CAPWAPU 0x7f14 //5247
91 
92 #else
93  #error Unknwon endianness
94 #endif
95 
96 /*
97 * Endianness agnostic (8bit or less)
98 */
99 // we use this value to compare (grater or smaller)
100 // because of that we must do the comparison in HBO
101 // and therefore we don't need to define it twice
102 #define LLC_DELIMITER_HBO 0x0600
103 
104 //Useful IP_PROTO values
105 #define IP_PROTO_TCP 6
106 #define IP_PROTO_UDP 17
107 #define IP_PROTO_SCTP 132
108 #define IP_PROTO_GRE 47
109 #define IP_PROTO_ICMPV4 1
110 #define IP_PROTO_ICMPV6 58
111 
112 //PPP PROTO values
113 #define PPP_PROTO_IP4 0x21
114 #define PPP_PROTO_IP6 0x57
115 
116 
117 #endif //__PROTOCOL_CONSTANTS_H__