2 *------------------------------------------------------------------
5 * Copyright (c) 2009-2013 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #ifndef __CNAT_V4_PPTP_ALG_H__
21 #define __CNAT_V4_PPTP_ALG_H__
23 /* Debug utils of PPTP */
24 #define PPTP_DBG(debug, ...) \
25 if(PREDICT_FALSE(cnat_pptp_debug_flag >= debug)) { \
26 PLATFORM_DEBUG_PRINT("%s:%s:%d - ", \
27 __FILE__, __FUNCTION__, __LINE__);\
28 PLATFORM_DEBUG_PRINT(__VA_ARGS__);\
29 PLATFORM_DEBUG_PRINT("\n"); \
32 #define PPTP_DUMP_PACKET(ip, len) pptp_hex_dump(ip, len)
35 #define PPTP_DISABLED 0
36 #define PPTP_ENABLED 1
38 #define PPTP_GRE_TIMEOUT 60 /*sec */
40 #define TCP_PPTP_PORT 1723
47 #define PPTP_MSG_TYPE_CONTROL 1
48 #define PPTP_MSG_TYPE_MGMT 2
50 /* PPTP control messages */
52 /* control connection mgmt */
53 #define PPTP_START_CC_RQ 1
54 #define PPTP_START_CC_RP 2
55 #define PPTP_STOP_CC_RQ 3
56 #define PPTP_STOP_CC_RP 4
57 #define PPTP_ECHO_RQ 5
58 #define PPTP_ECHO_RP 6
61 #define PPTP_OBOUND_CALL_RQ 7
62 #define PPTP_OBOUND_CALL_RP 8
63 #define PPTP_IBOUND_CALL_RQ 9
64 #define PPTP_IBOUND_CALL_RP 10
65 #define PPTP_IBOUND_CALL_CN 11
66 #define PPTP_CALL_CLEAR_RQ 12
67 #define PPTP_CALL_DISCON_NT 13
71 #define PPTP_WAN_ERR_NT 14
72 #define PPTP_SET_LINK_INF 15
74 #define PPTP_MIN_HDR_LEN 8
76 /* Byte offsets from start of TCP Data(PPTP header) */
78 #define PPTP_CTRL_MGMT_TYPE_OFFSET 0x02
79 #define PPTP_CC_TYPE_OFFSET 0x08
80 #define PPTP_HDR_CALL_ID_OFFSET 0x0c
81 #define PPTP_HDR_PEER_CALL_ID_OFFSET 0x0e
83 #define PPTP_HDR_RESULT_CODE_OFFSET_STCCRP 0x0e
84 #define PPTP_HDR_RESULT_CODE_OFFSET 0x10
87 /* Offset of control/mgmt msg types
88 from start of TCP header */
90 #define TCP_HEADER_SIZE(tcp) \
91 ((tcp->hdr_len>>4) << 2)
94 #define PPTP_MSG_START_OFFSET(tcp) \
95 ((u8*)tcp + TCP_HEADER_SIZE(tcp))
98 #define PPTP_CC_MSG_TYPE_OFFSET(tcp) \
99 (PPTP_MSG_START_OFFSET(tcp) + \
100 PPTP_CC_TYPE_OFFSET )
102 #define PPTP_MGMT_MSG_TYPE_OFFSET(tcp) \
103 ( PPTP_MSG_START_OFFSET(tcp) + \
104 PPTP_CTRL_MGMT_TYPE_OFFSET )
106 #define PPTP_CALL_ID_OFFSET(tcp) \
107 ( PPTP_MSG_START_OFFSET(tcp) + \
108 PPTP_HDR_CALL_ID_OFFSET )
110 #define PPTP_PEER_CALL_ID_OFFSET(tcp) \
111 ( PPTP_MSG_START_OFFSET(tcp) + \
112 PPTP_HDR_PEER_CALL_ID_OFFSET )
114 #define PPTP_RESULT_CODE_OFFSET(tcp) \
115 ( PPTP_MSG_START_OFFSET(tcp) + \
116 PPTP_HDR_RESULT_CODE_OFFSET )
118 #define PPTP_RESULT_CODE_OFFSET_STCCRP(tcp) \
119 ( PPTP_MSG_START_OFFSET(tcp) + \
120 PPTP_HDR_RESULT_CODE_OFFSET_STCCRP)
123 #define PPTP_CC_MSG_TYPE(tcp) \
124 (u16*)PPTP_CC_MSG_TYPE_OFFSET(tcp)
126 #define PPTP_MGMT_MSG_TYPE(tcp) \
127 (u16*)PPTP_MGMT_MSG_TYPE_OFFSET(tcp)
129 #define PPTP_CALL_ID(tcp) \
130 (u16*)PPTP_CALL_ID_OFFSET(tcp)
132 #define PPTP_PEER_CALL_ID(tcp) \
133 (u16*)PPTP_PEER_CALL_ID_OFFSET(tcp)
135 #define PPTP_RESULT_CODE(tcp) \
136 *(u8*)PPTP_RESULT_CODE_OFFSET(tcp);
138 #define PPTP_RESULT_CODE_STCCRP(tcp) \
139 *(u8*)PPTP_RESULT_CODE_OFFSET_STCCRP(tcp);
143 #define PPTP_CHAN_SUCCESS 1
146 /* Data structures */
148 extern u32 cnat_pptp_debug_flag;
150 #endif /* __CNAT_V4_PPTP_ALG_H__ */