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