Annotation of embedaddon/mpd/src/pptp_ctrl.h, revision 1.1.1.1
1.1 misho 1:
2: /*
3: * pptp_ctrl.h
4: *
5: * Written by Archie Cobbs <archie@freebsd.org>
6: * Copyright (c) 1998-1999 Whistle Communications, Inc. All rights reserved.
7: * See ``COPYRIGHT.whistle''
8: */
9:
10: #if !defined(_PPTP_CTRL_H_) || defined(_WANT_PPTP_FIELDS)
11: #ifndef _WANT_PPTP_FIELDS
12: #define _PPTP_CTRL_H_
13:
14: /*
15: * DEFINITIONS
16: */
17:
18: /* Definitions per the spec */
19: #define PPTP_PORT 1723
20: #define PPTP_MTU 1532
21: #define PPTP_PROTO_VERS 0x0100
22: #define PPTP_MAGIC 0x1a2b3c4d
23: #define PPTP_IDLE_TIMEOUT 60
24:
25: #define PPTP_HOSTNAME_LEN 64
26: #define PPTP_VENDOR_LEN 64
27: #define PPTP_PHONE_LEN 64
28: #define PPTP_SUBADDR_LEN 64
29: #define PPTP_STATS_LEN 128
30:
31: /* Control messages */
32: #define PPTP_CTRL_MSG_TYPE 1
33:
34: enum {
35: PPTP_StartCtrlConnRequest = 1,
36: PPTP_StartCtrlConnReply = 2,
37: PPTP_StopCtrlConnRequest = 3,
38: PPTP_StopCtrlConnReply = 4,
39: PPTP_EchoRequest = 5,
40: PPTP_EchoReply = 6,
41: PPTP_OutCallRequest = 7,
42: PPTP_OutCallReply = 8,
43: PPTP_InCallRequest = 9,
44: PPTP_InCallReply = 10,
45: PPTP_InCallConn = 11,
46: PPTP_CallClearRequest = 12,
47: PPTP_CallDiscNotify = 13,
48: PPTP_WanErrorNotify = 14,
49: PPTP_SetLinkInfo = 15
50: };
51:
52: #define PPTP_MIN_CTRL_TYPE 1
53: #define PPTP_MAX_CTRL_TYPE 16
54:
55: #define PPTP_VALID_CTRL_TYPE(x) \
56: ((x) >= PPTP_MIN_CTRL_TYPE && (x) < PPTP_MAX_CTRL_TYPE)
57:
58: /* Framing capabilities */
59: #define PPTP_FRAMECAP_ASYNC 0x01
60: #define PPTP_FRAMECAP_SYNC 0x02
61: #define PPTP_FRAMECAP_ANY 0x03
62:
63: /* Bearer capabilities */
64: #define PPTP_BEARCAP_ANALOG 0x01
65: #define PPTP_BEARCAP_DIGITAL 0x02
66: #define PPTP_BEARCAP_ANY 0x03
67:
68: /* General error codes */
69: #define PPTP_ERROR_NONE 0
70: #define PPTP_ERROR_NOT_CONNECTED 1
71: #define PPTP_ERROR_BAD_FORMAT 2
72: #define PPTP_ERROR_BAD_VALUE 3
73: #define PPTP_ERROR_NO_RESOURCE 4
74: #define PPTP_ERROR_BAD_CALL_ID 5
75: #define PPTP_ERROR_PAC_ERROR 6
76:
77: /* All reserved fields have this prefix */
78: #define PPTP_RESV_PREF "resv"
79:
80: /* Message structures */
81: struct pptpMsgHead {
82: u_int16_t length; /* total length */
83: u_int16_t msgType; /* PPTP message type */
84: u_int32_t magic; /* magic cookie */
85: u_int16_t type; /* control message type */
86: u_int16_t resv0; /* reserved */
87: };
88: typedef struct pptpMsgHead *PptpMsgHead;
89:
90: #else
91: { { "len", 2 }, { "msgType", 2 }, { "magic", 4 }, { "type", 2 },
92: { PPTP_RESV_PREF "0", 2 }, { NULL, 0 } },
93: #endif
94: #ifndef _WANT_PPTP_FIELDS
95:
96: struct pptpStartCtrlConnRequest {
97: u_int16_t vers; /* protocol version */
98: u_int16_t resv0; /* reserved */
99: u_int32_t frameCap; /* framing capabilities */
100: u_int32_t bearCap; /* bearer capabilities */
101: u_int16_t maxChan; /* maximum # channels */
102: u_int16_t firmware; /* firmware revision */
103: char host[PPTP_HOSTNAME_LEN]; /* host name */
104: char vendor[PPTP_VENDOR_LEN]; /* vendor name */
105: };
106:
107: #else
108: { { "vers", 2 }, { PPTP_RESV_PREF "0", 2 }, { "frameCap", 4 },
109: { "bearCap", 4 }, { "maxChan", 2 }, { "firm", 2 },
110: { "host", PPTP_HOSTNAME_LEN }, { "vend", PPTP_VENDOR_LEN }, { NULL, 0 } },
111: #endif
112: #ifndef _WANT_PPTP_FIELDS
113:
114: struct pptpStartCtrlConnReply {
115: u_int16_t vers; /* protocol version */
116: u_int8_t result; /* result code */
117: u_int8_t err; /* error code */
118: u_int32_t frameCap; /* framing capabilities */
119: u_int32_t bearCap; /* bearer capabilities */
120: u_int16_t maxChan; /* maximum # channels */
121: u_int16_t firmware; /* firmware revision */
122: char host[PPTP_HOSTNAME_LEN]; /* host name */
123: char vendor[PPTP_VENDOR_LEN]; /* vendor name */
124: };
125:
126: #else
127: { { "vers", 2 }, { "result", 1 }, { "err", 1 }, { "frameCap", 4 },
128: { "bearCap", 4 }, { "maxChan", 2 }, { "firm", 2 },
129: { "host", PPTP_HOSTNAME_LEN }, { "vend", PPTP_VENDOR_LEN }, { NULL, 0 } },
130: #endif
131: #ifndef _WANT_PPTP_FIELDS
132:
133: #define PPTP_SCCR_RESL_OK 1 /* channel successfully established */
134: #define PPTP_SCCR_RESL_ERR 2 /* general error; see error code */
135: #define PPTP_SCCR_RESL_EXISTS 3 /* command channel already exists */
136: #define PPTP_SCCR_RESL_AUTH 4 /* not authorized */
137: #define PPTP_SCCR_RESL_VERS 5 /* incompatible protocol version */
138:
139: struct pptpStopCtrlConnRequest {
140: u_int8_t reason; /* reason */
141: u_int8_t resv0; /* reserved */
142: u_int16_t resv1; /* reserved */
143: };
144:
145: #else
146: { { "reason", 1 }, { PPTP_RESV_PREF "0", 1 }, { PPTP_RESV_PREF "1", 2 },
147: { NULL, 0 } },
148: #endif
149: #ifndef _WANT_PPTP_FIELDS
150:
151: #define PPTP_SCCR_REAS_NONE 1 /* general */
152: #define PPTP_SCCR_REAS_PROTO 2 /* can't support protocol version */
153: #define PPTP_SCCR_REAS_LOCAL 3 /* local shutdown */
154:
155: struct pptpStopCtrlConnReply {
156: u_int8_t result; /* result code */
157: u_int8_t err; /* error code */
158: u_int16_t resv0; /* reserved */
159: };
160:
161: #else
162: { { "result", 1 }, { "err", 1 }, { PPTP_RESV_PREF "0", 2 }, { NULL, 0 } },
163: #endif
164: #ifndef _WANT_PPTP_FIELDS
165:
166: struct pptpEchoRequest {
167: u_int32_t id; /* identifier */
168: };
169:
170: #else
171: { { "id", 4 }, { NULL, 0 } },
172: #endif
173: #ifndef _WANT_PPTP_FIELDS
174:
175: struct pptpEchoReply {
176: u_int32_t id; /* identifier */
177: u_int8_t result; /* result code */
178: u_int8_t err; /* error code */
179: u_int16_t resv0; /* reserved */
180: };
181:
182: #else
183: { { "id", 4 }, { "result", 1 }, { "err", 1 },
184: { "ignore", 2 }, { NULL, 0 } },
185: #endif
186: #ifndef _WANT_PPTP_FIELDS
187:
188: #define PPTP_ECHO_RESL_OK 1 /* echo reply is valid */
189: #define PPTP_ECHO_RESL_ERR 2 /* general error; see error code */
190:
191: struct pptpOutCallRequest {
192: u_int16_t cid; /* call id */
193: u_int16_t serno; /* call serial # */
194: u_int32_t minBps; /* minimum BPS */
195: u_int32_t maxBps; /* maximum BPS */
196: u_int32_t bearType; /* bearer type */
197: u_int32_t frameType; /* framing type */
198: u_int16_t recvWin; /* pkt receive window size */
199: u_int16_t ppd; /* pkt processing delay */
200: u_int16_t numLen; /* phone number length */
201: u_int16_t resv0; /* reserved */
202: char phone[PPTP_PHONE_LEN]; /* phone number */
203: char subaddr[PPTP_SUBADDR_LEN]; /* sub-address */
204: };
205:
206: #else
207: { { "cid", 2 }, { "serno", 2 }, { "minBPS", 4 }, { "maxBPS", 4 },
208: { "bearType", 4 }, { "frameType", 4 },{ "recvWin", 2 }, { "ppd", 2 },
209: { "numLen", 2 }, { PPTP_RESV_PREF "0", 2 },
210: { "phone", PPTP_PHONE_LEN }, { "subaddr", PPTP_SUBADDR_LEN },
211: { NULL, 0 } },
212: #endif
213: #ifndef _WANT_PPTP_FIELDS
214:
215: struct pptpOutCallReply {
216: u_int16_t cid; /* call id */
217: u_int16_t peerCid; /* peer call id */
218: u_int8_t result; /* result code */
219: u_int8_t err; /* error code */
220: u_int16_t cause; /* cause code */
221: u_int32_t speed; /* cause code */
222: u_int16_t recvWin; /* pkt receive window size code */
223: u_int16_t ppd; /* pkt processing delay */
224: u_int32_t channel; /* physical channel id */
225: };
226:
227: #else
228: { { "cid", 2 }, { "peerCid", 2 }, { "result", 1 }, { "err", 1 },
229: { "cause", 2 }, { "speed", 4 }, { "recvWin", 2 }, { "ppd", 2 },
230: { "channel", 4 }, { NULL, 0 } },
231: #endif
232: #ifndef _WANT_PPTP_FIELDS
233:
234: #define PPTP_OCR_RESL_OK 1 /* call established OK */
235: #define PPTP_OCR_RESL_ERR 2 /* general error; see error code */
236: #define PPTP_OCR_RESL_NOCARR 3 /* no carrier */
237: #define PPTP_OCR_RESL_BUSY 4 /* busy */
238: #define PPTP_OCR_RESL_NODIAL 5 /* no dialtone */
239: #define PPTP_OCR_RESL_TIMED 6 /* timed out */
240: #define PPTP_OCR_RESL_ADMIN 7 /* administratvely prohibited */
241:
242: struct pptpInCallRequest {
243: u_int16_t cid; /* call id */
244: u_int16_t serno; /* call serial # */
245: u_int32_t bearType; /* bearer type */
246: u_int32_t channel; /* physical channel id */
247: u_int16_t dialedLen; /* dialed number len */
248: u_int16_t dialingLen; /* dialing number len */
249: char dialed[PPTP_PHONE_LEN]; /* dialed number */
250: char dialing[PPTP_PHONE_LEN]; /* dialing number */
251: char subaddr[PPTP_SUBADDR_LEN]; /* sub-address */
252: };
253:
254: #else
255: { { "cid", 2 }, { "serno", 2 }, { "bearType", 4 }, { "channel", 4 },
256: { "dialedLen", 2 }, { "dialingLen", 2 }, { "dialed", PPTP_PHONE_LEN },
257: { "dialing", PPTP_PHONE_LEN }, { "subaddr", PPTP_SUBADDR_LEN },
258: { NULL, 0 } },
259: #endif
260: #ifndef _WANT_PPTP_FIELDS
261:
262: struct pptpInCallReply {
263: u_int16_t cid; /* call id */
264: u_int16_t peerCid; /* peer call id */
265: u_int8_t result; /* result code */
266: u_int8_t err; /* error code */
267: u_int16_t recvWin; /* pkt receive window size code */
268: u_int16_t ppd; /* pkt processing delay */
269: u_int16_t resv0; /* reserved */
270: };
271:
272: #else
273: { { "cid", 2 }, { "peerCid", 2 }, { "result", 1 }, { "err", 1 },
274: { "recvWin", 2 }, { "ppd", 2 }, { PPTP_RESV_PREF "0", 2 },
275: { NULL, 0 } },
276: #endif
277: #ifndef _WANT_PPTP_FIELDS
278:
279: #define PPTP_ICR_RESL_OK 1 /* call established OK */
280: #define PPTP_ICR_RESL_ERR 2 /* general error; see error code */
281: #define PPTP_ICR_RESL_NAK 3 /* do not accept */
282:
283: struct pptpInCallConn {
284: u_int16_t peerCid; /* peer call id */
285: u_int16_t resv0; /* reserved */
286: u_int32_t speed; /* connect speed */
287: u_int16_t recvWin; /* pkt receive window size code */
288: u_int16_t ppd; /* pkt processing delay */
289: u_int32_t frameType; /* framing type */
290: };
291:
292: #else
293: { { "peerCid", 2 }, { PPTP_RESV_PREF "0", 2 }, { "speed", 4 },
294: { "recvWin", 2 }, { "ppd", 2 }, { "frameType", 4 }, { NULL, 0 } },
295: #endif
296: #ifndef _WANT_PPTP_FIELDS
297:
298: struct pptpCallClearRequest {
299: u_int16_t cid; /* PNS assigned call id */
300: u_int16_t resv0; /* reserved */
301: };
302:
303: #else
304: { { "cid", 2 }, { PPTP_RESV_PREF "0", 2 }, { NULL, 0 } },
305: #endif
306: #ifndef _WANT_PPTP_FIELDS
307:
308: struct pptpCallDiscNotify {
309: u_int16_t cid; /* PAC assigned call id */
310: u_int8_t result; /* result code */
311: u_int8_t err; /* error code */
312: u_int16_t cause; /* cause code */
313: u_int16_t resv0; /* reserved */
314: char stats[PPTP_STATS_LEN]; /* call stats */
315: };
316:
317: #else
318: { { "cid", 2 }, { "result", 1 }, { "err", 1 }, { "cause", 2 },
319: { PPTP_RESV_PREF "0", 2 }, { "stats", PPTP_STATS_LEN },
320: { NULL, 0 } },
321: #endif
322: #ifndef _WANT_PPTP_FIELDS
323:
324: #define PPTP_CDN_RESL_CARR 1 /* lost carrier */
325: #define PPTP_CDN_RESL_ERR 2 /* general error; see error code */
326: #define PPTP_CDN_RESL_ADMIN 3 /* administrative reason */
327: #define PPTP_CDN_RESL_REQ 4 /* received disconnect request */
328:
329: struct pptpWanErrorNotify {
330: u_int16_t cid; /* PNS assigned call id */
331: u_int16_t resv0; /* reserved */
332: u_int32_t crc; /* crc errors */
333: u_int32_t frame; /* framing errors */
334: u_int32_t hdw; /* hardware errors */
335: u_int32_t ovfl; /* buffer overrun errors */
336: u_int32_t timeout; /* timeout errors */
337: u_int32_t align; /* alignment errors */
338: };
339:
340: #else
341: { { "cid", 2 }, { PPTP_RESV_PREF "0", 2 }, { "crc", 4 },
342: { "frame", 4 }, { "hdw", 4 }, { "ovfl", 4 }, { "timeout", 4 },
343: { "align", 4 }, { NULL, 0 } },
344: #endif
345: #ifndef _WANT_PPTP_FIELDS
346:
347: struct pptpSetLinkInfo {
348: u_int16_t cid; /* call id */
349: u_int16_t resv0; /* reserved */
350: u_int32_t sendAccm; /* send ACCM */
351: u_int32_t recvAccm; /* receive ACCM */
352: };
353:
354: #else
355: { { "cid", 2 }, { PPTP_RESV_PREF "0", 2 }, { "sendAccm", 4 },
356: { "recvAccm", 4 }, { NULL, 0 } },
357: #endif
358: #ifndef _WANT_PPTP_FIELDS
359:
360: #define PPTP_CTRL_MAX_FRAME \
361: (sizeof(struct pptpMsgHead) + sizeof(struct pptpInCallRequest))
362: #define PPTP_CTRL_MAX_FIELDS 14
363:
364: /* Describes one field of a PPTP control message structure */
365: struct pptpfield {
366: const char *name;
367: u_short length;
368: };
369: typedef struct pptpfield *PptpField;
370:
371: /* Link <-> control liason structures and callback function types */
372: struct pptplinkinfo { /* PPTP's info for accessing link code */
373: void *cookie; /* NULL indicates response is invalid */
374: void (*result)(void *cookie, const char *errmsg, int frameType);
375: void (*setLinkInfo)(void *cookie, u_int32_t sa, u_int32_t ra);
376: void (*cancel)(void *cookie); /* cancel outgoing call */
377: };
378: typedef struct pptplinkinfo *PptpLinkInfo;
379:
380: struct pptpctrlinfo { /* Link's info for accessing PPTP code */
381: void *cookie; /* NULL indicates response is invalid */
382: struct u_addr peer_addr; /* Peer IP address and port */
383: in_port_t peer_port;
384: void (*close)(void *cookie, int result, int err, int cause);
385: void (*answer)(void *cookie, int rs, int er, int cs, int sp);
386: void (*connected)(void *cookie, int sp);
387: void (*setLinkInfo)(void *cookie, u_int32_t sa, u_int32_t ra);
388: };
389: typedef struct pptpctrlinfo *PptpCtrlInfo;
390:
391: typedef struct pptplinkinfo (*PptpGetInLink_t)(struct pptpctrlinfo *cinfo,
392: struct u_addr *self, struct u_addr *peer, in_port_t port,
393: int bearType,
394: const char *callingNum,
395: const char *calledNum,
396: const char *subAddress);
397:
398: typedef struct pptplinkinfo (*PptpGetOutLink_t)(struct pptpctrlinfo *cinfo,
399: struct u_addr *self, struct u_addr *peer, in_port_t port,
400: int bearType, int frameType, int minBps, int maxBps,
401: const char *calledNum,
402: const char *subAddress);
403:
404: /*
405: * FUNCTIONS
406: */
407:
408: extern int PptpCtrlInit(PptpGetInLink_t getInLink,
409: PptpGetOutLink_t getOutLink);
410:
411: extern void* PptpCtrlListen(struct u_addr *ip, in_port_t port);
412: extern void PptpCtrlUnListen(void *listener);
413:
414: extern void PptpCtrlInCall(struct pptpctrlinfo *cinfo,
415: struct pptplinkinfo *linfo,
416: struct u_addr *locip, struct u_addr *ip,
417: in_port_t port, int bearType, int frameType,
418: int minBps, int maxBps,
419: const char *callingNum,
420: const char *calledNum,
421: const char *subAddress);
422:
423: extern void PptpCtrlOutCall(struct pptpctrlinfo *cinfo,
424: struct pptplinkinfo *linfo,
425: struct u_addr *locip, struct u_addr *ip,
426: in_port_t port, int bearType, int frameType,
427: int minBps, int maxBps,
428: const char *calledNum,
429: const char *subAddress);
430:
431: extern int PptpCtrlGetSessionInfo(struct pptpctrlinfo *cp,
432: struct u_addr *selfAddr,
433: struct u_addr *peerAddr,
434: u_int16_t *selfCid, u_int16_t *peerCid,
435: u_int16_t *peerWin, u_int16_t *peerPpd);
436:
437: /*
438: * Get local/remote hostnames.
439: */
440: extern int PptpCtrlGetSelfName(struct pptpctrlinfo *cp,
441: void *buf, size_t buf_len);
442: extern int PptpCtrlGetPeerName(struct pptpctrlinfo *cp,
443: void *buf, size_t buf_len);
444:
445: #endif /* #ifndef _WANT_PPTP_FIELDS */
446: #endif /* #if !defined(_PPTP_CTRL_H_) || defined(_WANT_PPTP_FIELDS) */
447:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>