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