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