License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / include / linux / netfilter / nf_conntrack_pptp.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* PPTP constants and structs */
3 #ifndef _NF_CONNTRACK_PPTP_H
4 #define _NF_CONNTRACK_PPTP_H
5
6 #include <linux/netfilter/nf_conntrack_common.h>
7
8 extern const char *const pptp_msg_name[];
9
10 /* state of the control session */
11 enum pptp_ctrlsess_state {
12         PPTP_SESSION_NONE,                      /* no session present */
13         PPTP_SESSION_ERROR,                     /* some session error */
14         PPTP_SESSION_STOPREQ,                   /* stop_sess request seen */
15         PPTP_SESSION_REQUESTED,                 /* start_sess request seen */
16         PPTP_SESSION_CONFIRMED,                 /* session established */
17 };
18
19 /* state of the call inside the control session */
20 enum pptp_ctrlcall_state {
21         PPTP_CALL_NONE,
22         PPTP_CALL_ERROR,
23         PPTP_CALL_OUT_REQ,
24         PPTP_CALL_OUT_CONF,
25         PPTP_CALL_IN_REQ,
26         PPTP_CALL_IN_REP,
27         PPTP_CALL_IN_CONF,
28         PPTP_CALL_CLEAR_REQ,
29 };
30
31 /* conntrack private data */
32 struct nf_ct_pptp_master {
33         enum pptp_ctrlsess_state sstate;        /* session state */
34         enum pptp_ctrlcall_state cstate;        /* call state */
35         __be16 pac_call_id;                     /* call id of PAC */
36         __be16 pns_call_id;                     /* call id of PNS */
37
38         /* in pre-2.6.11 this used to be per-expect. Now it is per-conntrack
39          * and therefore imposes a fixed limit on the number of maps */
40         struct nf_ct_gre_keymap *keymap[IP_CT_DIR_MAX];
41 };
42
43 struct nf_nat_pptp {
44         __be16 pns_call_id;                     /* NAT'ed PNS call id */
45         __be16 pac_call_id;                     /* NAT'ed PAC call id */
46 };
47
48 #ifdef __KERNEL__
49
50 #define PPTP_CONTROL_PORT       1723
51
52 #define PPTP_PACKET_CONTROL     1
53 #define PPTP_PACKET_MGMT        2
54
55 #define PPTP_MAGIC_COOKIE       0x1a2b3c4d
56
57 struct pptp_pkt_hdr {
58         __u16   packetLength;
59         __be16  packetType;
60         __be32  magicCookie;
61 };
62
63 /* PptpControlMessageType values */
64 #define PPTP_START_SESSION_REQUEST      1
65 #define PPTP_START_SESSION_REPLY        2
66 #define PPTP_STOP_SESSION_REQUEST       3
67 #define PPTP_STOP_SESSION_REPLY         4
68 #define PPTP_ECHO_REQUEST               5
69 #define PPTP_ECHO_REPLY                 6
70 #define PPTP_OUT_CALL_REQUEST           7
71 #define PPTP_OUT_CALL_REPLY             8
72 #define PPTP_IN_CALL_REQUEST            9
73 #define PPTP_IN_CALL_REPLY              10
74 #define PPTP_IN_CALL_CONNECT            11
75 #define PPTP_CALL_CLEAR_REQUEST         12
76 #define PPTP_CALL_DISCONNECT_NOTIFY     13
77 #define PPTP_WAN_ERROR_NOTIFY           14
78 #define PPTP_SET_LINK_INFO              15
79
80 #define PPTP_MSG_MAX                    15
81
82 /* PptpGeneralError values */
83 #define PPTP_ERROR_CODE_NONE            0
84 #define PPTP_NOT_CONNECTED              1
85 #define PPTP_BAD_FORMAT                 2
86 #define PPTP_BAD_VALUE                  3
87 #define PPTP_NO_RESOURCE                4
88 #define PPTP_BAD_CALLID                 5
89 #define PPTP_REMOVE_DEVICE_ERROR        6
90
91 struct PptpControlHeader {
92         __be16  messageType;
93         __u16   reserved;
94 };
95
96 /* FramingCapability Bitmap Values */
97 #define PPTP_FRAME_CAP_ASYNC            0x1
98 #define PPTP_FRAME_CAP_SYNC             0x2
99
100 /* BearerCapability Bitmap Values */
101 #define PPTP_BEARER_CAP_ANALOG          0x1
102 #define PPTP_BEARER_CAP_DIGITAL         0x2
103
104 struct PptpStartSessionRequest {
105         __be16  protocolVersion;
106         __u16   reserved1;
107         __be32  framingCapability;
108         __be32  bearerCapability;
109         __be16  maxChannels;
110         __be16  firmwareRevision;
111         __u8    hostName[64];
112         __u8    vendorString[64];
113 };
114
115 /* PptpStartSessionResultCode Values */
116 #define PPTP_START_OK                   1
117 #define PPTP_START_GENERAL_ERROR        2
118 #define PPTP_START_ALREADY_CONNECTED    3
119 #define PPTP_START_NOT_AUTHORIZED       4
120 #define PPTP_START_UNKNOWN_PROTOCOL     5
121
122 struct PptpStartSessionReply {
123         __be16  protocolVersion;
124         __u8    resultCode;
125         __u8    generalErrorCode;
126         __be32  framingCapability;
127         __be32  bearerCapability;
128         __be16  maxChannels;
129         __be16  firmwareRevision;
130         __u8    hostName[64];
131         __u8    vendorString[64];
132 };
133
134 /* PptpStopReasons */
135 #define PPTP_STOP_NONE                  1
136 #define PPTP_STOP_PROTOCOL              2
137 #define PPTP_STOP_LOCAL_SHUTDOWN        3
138
139 struct PptpStopSessionRequest {
140         __u8    reason;
141         __u8    reserved1;
142         __u16   reserved2;
143 };
144
145 /* PptpStopSessionResultCode */
146 #define PPTP_STOP_OK                    1
147 #define PPTP_STOP_GENERAL_ERROR         2
148
149 struct PptpStopSessionReply {
150         __u8    resultCode;
151         __u8    generalErrorCode;
152         __u16   reserved1;
153 };
154
155 struct PptpEchoRequest {
156         __be32 identNumber;
157 };
158
159 /* PptpEchoReplyResultCode */
160 #define PPTP_ECHO_OK                    1
161 #define PPTP_ECHO_GENERAL_ERROR         2
162
163 struct PptpEchoReply {
164         __be32  identNumber;
165         __u8    resultCode;
166         __u8    generalErrorCode;
167         __u16   reserved;
168 };
169
170 /* PptpFramingType */
171 #define PPTP_ASYNC_FRAMING              1
172 #define PPTP_SYNC_FRAMING               2
173 #define PPTP_DONT_CARE_FRAMING          3
174
175 /* PptpCallBearerType */
176 #define PPTP_ANALOG_TYPE                1
177 #define PPTP_DIGITAL_TYPE               2
178 #define PPTP_DONT_CARE_BEARER_TYPE      3
179
180 struct PptpOutCallRequest {
181         __be16  callID;
182         __be16  callSerialNumber;
183         __be32  minBPS;
184         __be32  maxBPS;
185         __be32  bearerType;
186         __be32  framingType;
187         __be16  packetWindow;
188         __be16  packetProcDelay;
189         __be16  phoneNumberLength;
190         __u16   reserved1;
191         __u8    phoneNumber[64];
192         __u8    subAddress[64];
193 };
194
195 /* PptpCallResultCode */
196 #define PPTP_OUTCALL_CONNECT            1
197 #define PPTP_OUTCALL_GENERAL_ERROR      2
198 #define PPTP_OUTCALL_NO_CARRIER         3
199 #define PPTP_OUTCALL_BUSY               4
200 #define PPTP_OUTCALL_NO_DIAL_TONE       5
201 #define PPTP_OUTCALL_TIMEOUT            6
202 #define PPTP_OUTCALL_DONT_ACCEPT        7
203
204 struct PptpOutCallReply {
205         __be16  callID;
206         __be16  peersCallID;
207         __u8    resultCode;
208         __u8    generalErrorCode;
209         __be16  causeCode;
210         __be32  connectSpeed;
211         __be16  packetWindow;
212         __be16  packetProcDelay;
213         __be32  physChannelID;
214 };
215
216 struct PptpInCallRequest {
217         __be16  callID;
218         __be16  callSerialNumber;
219         __be32  callBearerType;
220         __be32  physChannelID;
221         __be16  dialedNumberLength;
222         __be16  dialingNumberLength;
223         __u8    dialedNumber[64];
224         __u8    dialingNumber[64];
225         __u8    subAddress[64];
226 };
227
228 /* PptpInCallResultCode */
229 #define PPTP_INCALL_ACCEPT              1
230 #define PPTP_INCALL_GENERAL_ERROR       2
231 #define PPTP_INCALL_DONT_ACCEPT         3
232
233 struct PptpInCallReply {
234         __be16  callID;
235         __be16  peersCallID;
236         __u8    resultCode;
237         __u8    generalErrorCode;
238         __be16  packetWindow;
239         __be16  packetProcDelay;
240         __u16   reserved;
241 };
242
243 struct PptpInCallConnected {
244         __be16  peersCallID;
245         __u16   reserved;
246         __be32  connectSpeed;
247         __be16  packetWindow;
248         __be16  packetProcDelay;
249         __be32  callFramingType;
250 };
251
252 struct PptpClearCallRequest {
253         __be16  callID;
254         __u16   reserved;
255 };
256
257 struct PptpCallDisconnectNotify {
258         __be16  callID;
259         __u8    resultCode;
260         __u8    generalErrorCode;
261         __be16  causeCode;
262         __u16   reserved;
263         __u8    callStatistics[128];
264 };
265
266 struct PptpWanErrorNotify {
267         __be16  peersCallID;
268         __u16   reserved;
269         __be32  crcErrors;
270         __be32  framingErrors;
271         __be32  hardwareOverRuns;
272         __be32  bufferOverRuns;
273         __be32  timeoutErrors;
274         __be32  alignmentErrors;
275 };
276
277 struct PptpSetLinkInfo {
278         __be16  peersCallID;
279         __u16   reserved;
280         __be32  sendAccm;
281         __be32  recvAccm;
282 };
283
284 union pptp_ctrl_union {
285         struct PptpStartSessionRequest  sreq;
286         struct PptpStartSessionReply    srep;
287         struct PptpStopSessionRequest   streq;
288         struct PptpStopSessionReply     strep;
289         struct PptpOutCallRequest       ocreq;
290         struct PptpOutCallReply         ocack;
291         struct PptpInCallRequest        icreq;
292         struct PptpInCallReply          icack;
293         struct PptpInCallConnected      iccon;
294         struct PptpClearCallRequest     clrreq;
295         struct PptpCallDisconnectNotify disc;
296         struct PptpWanErrorNotify       wanerr;
297         struct PptpSetLinkInfo          setlink;
298 };
299
300 /* crap needed for nf_conntrack_compat.h */
301 struct nf_conn;
302 struct nf_conntrack_expect;
303
304 extern int
305 (*nf_nat_pptp_hook_outbound)(struct sk_buff *skb,
306                              struct nf_conn *ct, enum ip_conntrack_info ctinfo,
307                              unsigned int protoff,
308                              struct PptpControlHeader *ctlh,
309                              union pptp_ctrl_union *pptpReq);
310
311 extern int
312 (*nf_nat_pptp_hook_inbound)(struct sk_buff *skb,
313                             struct nf_conn *ct, enum ip_conntrack_info ctinfo,
314                             unsigned int protoff,
315                             struct PptpControlHeader *ctlh,
316                             union pptp_ctrl_union *pptpReq);
317
318 extern void
319 (*nf_nat_pptp_hook_exp_gre)(struct nf_conntrack_expect *exp_orig,
320                             struct nf_conntrack_expect *exp_reply);
321
322 extern void
323 (*nf_nat_pptp_hook_expectfn)(struct nf_conn *ct,
324                              struct nf_conntrack_expect *exp);
325
326 #endif /* __KERNEL__ */
327 #endif /* _NF_CONNTRACK_PPTP_H */