1 /*
2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
22 */
23
24 #define NETDISSECT_REWORKED
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28
29 #include <tcpdump-stdinc.h>
30
31 #include "interface.h"
32 #include "extract.h"
33
34 static const char tstr[] = " [|pptp]";
35
36 #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
37 #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
38 #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
39
40 #define PPTP_CTRL_MSG_TYPE_SCCRQ 1
41 #define PPTP_CTRL_MSG_TYPE_SCCRP 2
42 #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
43 #define PPTP_CTRL_MSG_TYPE_StopCCRP 4
44 #define PPTP_CTRL_MSG_TYPE_ECHORQ 5
45 #define PPTP_CTRL_MSG_TYPE_ECHORP 6
46 #define PPTP_CTRL_MSG_TYPE_OCRQ 7
47 #define PPTP_CTRL_MSG_TYPE_OCRP 8
48 #define PPTP_CTRL_MSG_TYPE_ICRQ 9
49 #define PPTP_CTRL_MSG_TYPE_ICRP 10
50 #define PPTP_CTRL_MSG_TYPE_ICCN 11
51 #define PPTP_CTRL_MSG_TYPE_CCRQ 12
52 #define PPTP_CTRL_MSG_TYPE_CDN 13
53 #define PPTP_CTRL_MSG_TYPE_WEN 14
54 #define PPTP_CTRL_MSG_TYPE_SLI 15
55
56 #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
57 #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
58
59 #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
60 #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
61
62 static const char *pptp_message_type_string[] = {
63 "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
64 "SCCRQ", /* 1 Start-Control-Connection-Request */
65 "SCCRP", /* 2 Start-Control-Connection-Reply */
66 "StopCCRQ", /* 3 Stop-Control-Connection-Request */
67 "StopCCRP", /* 4 Stop-Control-Connection-Reply */
68 "ECHORQ", /* 5 Echo Request */
69 "ECHORP", /* 6 Echo Reply */
70
71 "OCRQ", /* 7 Outgoing-Call-Request */
72 "OCRP", /* 8 Outgoing-Call-Reply */
73 "ICRQ", /* 9 Incoming-Call-Request */
74 "ICRP", /* 10 Incoming-Call-Reply */
75 "ICCN", /* 11 Incoming-Call-Connected */
76 "CCRQ", /* 12 Call-Clear-Request */
77 "CDN", /* 13 Call-Disconnect-Notify */
78
79 "WEN", /* 14 WAN-Error-Notify */
80
81 "SLI" /* 15 Set-Link-Info */
82 #define PPTP_MAX_MSGTYPE_INDEX 16
83 };
84
85 /* common for all PPTP control messages */
86 struct pptp_hdr {
87 uint16_t length;
88 uint16_t msg_type;
89 uint32_t magic_cookie;
90 uint16_t ctrl_msg_type;
91 uint16_t reserved0;
92 };
93
94 struct pptp_msg_sccrq {
95 uint16_t proto_ver;
96 uint16_t reserved1;
97 uint32_t framing_cap;
98 uint32_t bearer_cap;
99 uint16_t max_channel;
100 uint16_t firm_rev;
101 u_char hostname[64];
102 u_char vendor[64];
103 };
104
105 struct pptp_msg_sccrp {
106 uint16_t proto_ver;
107 uint8_t result_code;
108 uint8_t err_code;
109 uint32_t framing_cap;
110 uint32_t bearer_cap;
111 uint16_t max_channel;
112 uint16_t firm_rev;
113 u_char hostname[64];
114 u_char vendor[64];
115 };
116
117 struct pptp_msg_stopccrq {
118 uint8_t reason;
119 uint8_t reserved1;
120 uint16_t reserved2;
121 };
122
123 struct pptp_msg_stopccrp {
124 uint8_t result_code;
125 uint8_t err_code;
126 uint16_t reserved1;
127 };
128
129 struct pptp_msg_echorq {
130 uint32_t id;
131 };
132
133 struct pptp_msg_echorp {
134 uint32_t id;
135 uint8_t result_code;
136 uint8_t err_code;
137 uint16_t reserved1;
138 };
139
140 struct pptp_msg_ocrq {
141 uint16_t call_id;
142 uint16_t call_ser;
143 uint32_t min_bps;
144 uint32_t max_bps;
145 uint32_t bearer_type;
146 uint32_t framing_type;
147 uint16_t recv_winsiz;
148 uint16_t pkt_proc_delay;
149 uint16_t phone_no_len;
150 uint16_t reserved1;
151 u_char phone_no[64];
152 u_char subaddr[64];
153 };
154
155 struct pptp_msg_ocrp {
156 uint16_t call_id;
157 uint16_t peer_call_id;
158 uint8_t result_code;
159 uint8_t err_code;
160 uint16_t cause_code;
161 uint32_t conn_speed;
162 uint16_t recv_winsiz;
163 uint16_t pkt_proc_delay;
164 uint32_t phy_chan_id;
165 };
166
167 struct pptp_msg_icrq {
168 uint16_t call_id;
169 uint16_t call_ser;
170 uint32_t bearer_type;
171 uint32_t phy_chan_id;
172 uint16_t dialed_no_len;
173 uint16_t dialing_no_len;
174 u_char dialed_no[64]; /* DNIS */
175 u_char dialing_no[64]; /* CLID */
176 u_char subaddr[64];
177 };
178
179 struct pptp_msg_icrp {
180 uint16_t call_id;
181 uint16_t peer_call_id;
182 uint8_t result_code;
183 uint8_t err_code;
184 uint16_t recv_winsiz;
185 uint16_t pkt_proc_delay;
186 uint16_t reserved1;
187 };
188
189 struct pptp_msg_iccn {
190 uint16_t peer_call_id;
191 uint16_t reserved1;
192 uint32_t conn_speed;
193 uint16_t recv_winsiz;
194 uint16_t pkt_proc_delay;
195 uint32_t framing_type;
196 };
197
198 struct pptp_msg_ccrq {
199 uint16_t call_id;
200 uint16_t reserved1;
201 };
202
203 struct pptp_msg_cdn {
204 uint16_t call_id;
205 uint8_t result_code;
206 uint8_t err_code;
207 uint16_t cause_code;
208 uint16_t reserved1;
209 u_char call_stats[128];
210 };
211
212 struct pptp_msg_wen {
213 uint16_t peer_call_id;
214 uint16_t reserved1;
215 uint32_t crc_err;
216 uint32_t framing_err;
217 uint32_t hardware_overrun;
218 uint32_t buffer_overrun;
219 uint32_t timeout_err;
220 uint32_t align_err;
221 };
222
223 struct pptp_msg_sli {
224 uint16_t peer_call_id;
225 uint16_t reserved1;
226 uint32_t send_accm;
227 uint32_t recv_accm;
228 };
229
230 /* attributes that appear more than once in above messages:
231
232 Number of
233 occurence attributes
234 --------------------------------------
235 2 uint32_t bearer_cap;
236 2 uint32_t bearer_type;
237 6 uint16_t call_id;
238 2 uint16_t call_ser;
239 2 uint16_t cause_code;
240 2 uint32_t conn_speed;
241 6 uint8_t err_code;
242 2 uint16_t firm_rev;
243 2 uint32_t framing_cap;
244 2 uint32_t framing_type;
245 2 u_char hostname[64];
246 2 uint32_t id;
247 2 uint16_t max_channel;
248 5 uint16_t peer_call_id;
249 2 uint32_t phy_chan_id;
250 4 uint16_t pkt_proc_delay;
251 2 uint16_t proto_ver;
252 4 uint16_t recv_winsiz;
253 2 uint8_t reserved1;
254 9 uint16_t reserved1;
255 6 uint8_t result_code;
256 2 u_char subaddr[64];
257 2 u_char vendor[64];
258
259 so I will prepare print out functions for these attributes (except for
260 reserved*).
261 */
262
263 /******************************************/
264 /* Attribute-specific print out functions */
265 /******************************************/
266
267 /* In these attribute-specific print-out functions, it't not necessary
268 to do ND_TCHECK because they are already checked in the caller of
269 these functions. */
270
271 static void
pptp_bearer_cap_print(netdissect_options * ndo,const uint32_t * bearer_cap)272 pptp_bearer_cap_print(netdissect_options *ndo,
273 const uint32_t *bearer_cap)
274 {
275 ND_PRINT((ndo, " BEARER_CAP(%s%s)",
276 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
277 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
278 }
279
280 static const struct tok pptp_btype_str[] = {
281 { 1, "A" }, /* Analog */
282 { 2, "D" }, /* Digital */
283 { 3, "Any" },
284 { 0, NULL }
285 };
286
287 static void
pptp_bearer_type_print(netdissect_options * ndo,const uint32_t * bearer_type)288 pptp_bearer_type_print(netdissect_options *ndo,
289 const uint32_t *bearer_type)
290 {
291 ND_PRINT((ndo, " BEARER_TYPE(%s)",
292 tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
293 }
294
295 static void
pptp_call_id_print(netdissect_options * ndo,const uint16_t * call_id)296 pptp_call_id_print(netdissect_options *ndo,
297 const uint16_t *call_id)
298 {
299 ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
300 }
301
302 static void
pptp_call_ser_print(netdissect_options * ndo,const uint16_t * call_ser)303 pptp_call_ser_print(netdissect_options *ndo,
304 const uint16_t *call_ser)
305 {
306 ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
307 }
308
309 static void
pptp_cause_code_print(netdissect_options * ndo,const uint16_t * cause_code)310 pptp_cause_code_print(netdissect_options *ndo,
311 const uint16_t *cause_code)
312 {
313 ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
314 }
315
316 static void
pptp_conn_speed_print(netdissect_options * ndo,const uint32_t * conn_speed)317 pptp_conn_speed_print(netdissect_options *ndo,
318 const uint32_t *conn_speed)
319 {
320 ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
321 }
322
323 static const struct tok pptp_errcode_str[] = {
324 { 0, "None" },
325 { 1, "Not-Connected" },
326 { 2, "Bad-Format" },
327 { 3, "Bad-Value" },
328 { 4, "No-Resource" },
329 { 5, "Bad-Call-ID" },
330 { 6, "PAC-Error" },
331 { 0, NULL }
332 };
333
334 static void
pptp_err_code_print(netdissect_options * ndo,const uint8_t * err_code)335 pptp_err_code_print(netdissect_options *ndo,
336 const uint8_t *err_code)
337 {
338 ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
339 if (ndo->ndo_vflag) {
340 ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
341 }
342 ND_PRINT((ndo, ")"));
343 }
344
345 static void
pptp_firm_rev_print(netdissect_options * ndo,const uint16_t * firm_rev)346 pptp_firm_rev_print(netdissect_options *ndo,
347 const uint16_t *firm_rev)
348 {
349 ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
350 }
351
352 static void
pptp_framing_cap_print(netdissect_options * ndo,const uint32_t * framing_cap)353 pptp_framing_cap_print(netdissect_options *ndo,
354 const uint32_t *framing_cap)
355 {
356 ND_PRINT((ndo, " FRAME_CAP("));
357 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
358 ND_PRINT((ndo, "A")); /* Async */
359 }
360 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
361 ND_PRINT((ndo, "S")); /* Sync */
362 }
363 ND_PRINT((ndo, ")"));
364 }
365
366 static const struct tok pptp_ftype_str[] = {
367 { 1, "A" }, /* Async */
368 { 2, "S" }, /* Sync */
369 { 3, "E" }, /* Either */
370 { 0, NULL }
371 };
372
373 static void
pptp_framing_type_print(netdissect_options * ndo,const uint32_t * framing_type)374 pptp_framing_type_print(netdissect_options *ndo,
375 const uint32_t *framing_type)
376 {
377 ND_PRINT((ndo, " FRAME_TYPE(%s)",
378 tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
379 }
380
381 static void
pptp_hostname_print(netdissect_options * ndo,const u_char * hostname)382 pptp_hostname_print(netdissect_options *ndo,
383 const u_char *hostname)
384 {
385 ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
386 }
387
388 static void
pptp_id_print(netdissect_options * ndo,const uint32_t * id)389 pptp_id_print(netdissect_options *ndo,
390 const uint32_t *id)
391 {
392 ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
393 }
394
395 static void
pptp_max_channel_print(netdissect_options * ndo,const uint16_t * max_channel)396 pptp_max_channel_print(netdissect_options *ndo,
397 const uint16_t *max_channel)
398 {
399 ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
400 }
401
402 static void
pptp_peer_call_id_print(netdissect_options * ndo,const uint16_t * peer_call_id)403 pptp_peer_call_id_print(netdissect_options *ndo,
404 const uint16_t *peer_call_id)
405 {
406 ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
407 }
408
409 static void
pptp_phy_chan_id_print(netdissect_options * ndo,const uint32_t * phy_chan_id)410 pptp_phy_chan_id_print(netdissect_options *ndo,
411 const uint32_t *phy_chan_id)
412 {
413 ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
414 }
415
416 static void
pptp_pkt_proc_delay_print(netdissect_options * ndo,const uint16_t * pkt_proc_delay)417 pptp_pkt_proc_delay_print(netdissect_options *ndo,
418 const uint16_t *pkt_proc_delay)
419 {
420 ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
421 }
422
423 static void
pptp_proto_ver_print(netdissect_options * ndo,const uint16_t * proto_ver)424 pptp_proto_ver_print(netdissect_options *ndo,
425 const uint16_t *proto_ver)
426 {
427 ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
428 EXTRACT_16BITS(proto_ver) >> 8,
429 EXTRACT_16BITS(proto_ver) & 0xff));
430 }
431
432 static void
pptp_recv_winsiz_print(netdissect_options * ndo,const uint16_t * recv_winsiz)433 pptp_recv_winsiz_print(netdissect_options *ndo,
434 const uint16_t *recv_winsiz)
435 {
436 ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
437 }
438
439 static const struct tok pptp_scrrp_str[] = {
440 { 1, "Successful channel establishment" },
441 { 2, "General error" },
442 { 3, "Command channel already exists" },
443 { 4, "Requester is not authorized to establish a command channel" },
444 { 5, "The protocol version of the requester is not supported" },
445 { 0, NULL }
446 };
447
448 static const struct tok pptp_echorp_str[] = {
449 { 1, "OK" },
450 { 2, "General Error" },
451 { 0, NULL }
452 };
453
454 static const struct tok pptp_ocrp_str[] = {
455 { 1, "Connected" },
456 { 2, "General Error" },
457 { 3, "No Carrier" },
458 { 4, "Busy" },
459 { 5, "No Dial Tone" },
460 { 6, "Time-out" },
461 { 7, "Do Not Accept" },
462 { 0, NULL }
463 };
464
465 static const struct tok pptp_icrp_str[] = {
466 { 1, "Connect" },
467 { 2, "General Error" },
468 { 3, "Do Not Accept" },
469 { 0, NULL }
470 };
471
472 static const struct tok pptp_cdn_str[] = {
473 { 1, "Lost Carrier" },
474 { 2, "General Error" },
475 { 3, "Admin Shutdown" },
476 { 4, "Request" },
477 { 0, NULL }
478 };
479
480 static void
pptp_result_code_print(netdissect_options * ndo,const uint8_t * result_code,int ctrl_msg_type)481 pptp_result_code_print(netdissect_options *ndo,
482 const uint8_t *result_code, int ctrl_msg_type)
483 {
484 ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
485 if (ndo->ndo_vflag) {
486 const struct tok *dict =
487 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
488 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
489 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
490 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
491 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
492 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
493 NULL; /* assertion error */
494 if (dict != NULL)
495 ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
496 }
497 ND_PRINT((ndo, ")"));
498 }
499
500 static void
pptp_subaddr_print(netdissect_options * ndo,const u_char * subaddr)501 pptp_subaddr_print(netdissect_options *ndo,
502 const u_char *subaddr)
503 {
504 ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
505 }
506
507 static void
pptp_vendor_print(netdissect_options * ndo,const u_char * vendor)508 pptp_vendor_print(netdissect_options *ndo,
509 const u_char *vendor)
510 {
511 ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
512 }
513
514 /************************************/
515 /* PPTP message print out functions */
516 /************************************/
517 static void
pptp_sccrq_print(netdissect_options * ndo,const u_char * dat)518 pptp_sccrq_print(netdissect_options *ndo,
519 const u_char *dat)
520 {
521 struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
522
523 ND_TCHECK(ptr->proto_ver);
524 pptp_proto_ver_print(ndo, &ptr->proto_ver);
525 ND_TCHECK(ptr->reserved1);
526 ND_TCHECK(ptr->framing_cap);
527 pptp_framing_cap_print(ndo, &ptr->framing_cap);
528 ND_TCHECK(ptr->bearer_cap);
529 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
530 ND_TCHECK(ptr->max_channel);
531 pptp_max_channel_print(ndo, &ptr->max_channel);
532 ND_TCHECK(ptr->firm_rev);
533 pptp_firm_rev_print(ndo, &ptr->firm_rev);
534 ND_TCHECK(ptr->hostname);
535 pptp_hostname_print(ndo, &ptr->hostname[0]);
536 ND_TCHECK(ptr->vendor);
537 pptp_vendor_print(ndo, &ptr->vendor[0]);
538
539 return;
540
541 trunc:
542 ND_PRINT((ndo, "%s", tstr));
543 }
544
545 static void
pptp_sccrp_print(netdissect_options * ndo,const u_char * dat)546 pptp_sccrp_print(netdissect_options *ndo,
547 const u_char *dat)
548 {
549 struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
550
551 ND_TCHECK(ptr->proto_ver);
552 pptp_proto_ver_print(ndo, &ptr->proto_ver);
553 ND_TCHECK(ptr->result_code);
554 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
555 ND_TCHECK(ptr->err_code);
556 pptp_err_code_print(ndo, &ptr->err_code);
557 ND_TCHECK(ptr->framing_cap);
558 pptp_framing_cap_print(ndo, &ptr->framing_cap);
559 ND_TCHECK(ptr->bearer_cap);
560 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
561 ND_TCHECK(ptr->max_channel);
562 pptp_max_channel_print(ndo, &ptr->max_channel);
563 ND_TCHECK(ptr->firm_rev);
564 pptp_firm_rev_print(ndo, &ptr->firm_rev);
565 ND_TCHECK(ptr->hostname);
566 pptp_hostname_print(ndo, &ptr->hostname[0]);
567 ND_TCHECK(ptr->vendor);
568 pptp_vendor_print(ndo, &ptr->vendor[0]);
569
570 return;
571
572 trunc:
573 ND_PRINT((ndo, "%s", tstr));
574 }
575
576 static void
pptp_stopccrq_print(netdissect_options * ndo,const u_char * dat)577 pptp_stopccrq_print(netdissect_options *ndo,
578 const u_char *dat)
579 {
580 struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
581
582 ND_TCHECK(ptr->reason);
583 ND_PRINT((ndo, " REASON(%u", ptr->reason));
584 if (ndo->ndo_vflag) {
585 switch (ptr->reason) {
586 case 1:
587 ND_PRINT((ndo, ":None"));
588 break;
589 case 2:
590 ND_PRINT((ndo, ":Stop-Protocol"));
591 break;
592 case 3:
593 ND_PRINT((ndo, ":Stop-Local-Shutdown"));
594 break;
595 default:
596 ND_PRINT((ndo, ":?"));
597 break;
598 }
599 }
600 ND_PRINT((ndo, ")"));
601 ND_TCHECK(ptr->reserved1);
602 ND_TCHECK(ptr->reserved2);
603
604 return;
605
606 trunc:
607 ND_PRINT((ndo, "%s", tstr));
608 }
609
610 static void
pptp_stopccrp_print(netdissect_options * ndo,const u_char * dat)611 pptp_stopccrp_print(netdissect_options *ndo,
612 const u_char *dat)
613 {
614 struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
615
616 ND_TCHECK(ptr->result_code);
617 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
618 ND_TCHECK(ptr->err_code);
619 pptp_err_code_print(ndo, &ptr->err_code);
620 ND_TCHECK(ptr->reserved1);
621
622 return;
623
624 trunc:
625 ND_PRINT((ndo, "%s", tstr));
626 }
627
628 static void
pptp_echorq_print(netdissect_options * ndo,const u_char * dat)629 pptp_echorq_print(netdissect_options *ndo,
630 const u_char *dat)
631 {
632 struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
633
634 ND_TCHECK(ptr->id);
635 pptp_id_print(ndo, &ptr->id);
636
637 return;
638
639 trunc:
640 ND_PRINT((ndo, "%s", tstr));
641 }
642
643 static void
pptp_echorp_print(netdissect_options * ndo,const u_char * dat)644 pptp_echorp_print(netdissect_options *ndo,
645 const u_char *dat)
646 {
647 struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
648
649 ND_TCHECK(ptr->id);
650 pptp_id_print(ndo, &ptr->id);
651 ND_TCHECK(ptr->result_code);
652 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
653 ND_TCHECK(ptr->err_code);
654 pptp_err_code_print(ndo, &ptr->err_code);
655 ND_TCHECK(ptr->reserved1);
656
657 return;
658
659 trunc:
660 ND_PRINT((ndo, "%s", tstr));
661 }
662
663 static void
pptp_ocrq_print(netdissect_options * ndo,const u_char * dat)664 pptp_ocrq_print(netdissect_options *ndo,
665 const u_char *dat)
666 {
667 struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
668
669 ND_TCHECK(ptr->call_id);
670 pptp_call_id_print(ndo, &ptr->call_id);
671 ND_TCHECK(ptr->call_ser);
672 pptp_call_ser_print(ndo, &ptr->call_ser);
673 ND_TCHECK(ptr->min_bps);
674 ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
675 ND_TCHECK(ptr->max_bps);
676 ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
677 ND_TCHECK(ptr->bearer_type);
678 pptp_bearer_type_print(ndo, &ptr->bearer_type);
679 ND_TCHECK(ptr->framing_type);
680 pptp_framing_type_print(ndo, &ptr->framing_type);
681 ND_TCHECK(ptr->recv_winsiz);
682 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
683 ND_TCHECK(ptr->pkt_proc_delay);
684 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
685 ND_TCHECK(ptr->phone_no_len);
686 ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
687 ND_TCHECK(ptr->reserved1);
688 ND_TCHECK(ptr->phone_no);
689 ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
690 ND_TCHECK(ptr->subaddr);
691 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
692
693 return;
694
695 trunc:
696 ND_PRINT((ndo, "%s", tstr));
697 }
698
699 static void
pptp_ocrp_print(netdissect_options * ndo,const u_char * dat)700 pptp_ocrp_print(netdissect_options *ndo,
701 const u_char *dat)
702 {
703 struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
704
705 ND_TCHECK(ptr->call_id);
706 pptp_call_id_print(ndo, &ptr->call_id);
707 ND_TCHECK(ptr->peer_call_id);
708 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
709 ND_TCHECK(ptr->result_code);
710 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
711 ND_TCHECK(ptr->err_code);
712 pptp_err_code_print(ndo, &ptr->err_code);
713 ND_TCHECK(ptr->cause_code);
714 pptp_cause_code_print(ndo, &ptr->cause_code);
715 ND_TCHECK(ptr->conn_speed);
716 pptp_conn_speed_print(ndo, &ptr->conn_speed);
717 ND_TCHECK(ptr->recv_winsiz);
718 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
719 ND_TCHECK(ptr->pkt_proc_delay);
720 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
721 ND_TCHECK(ptr->phy_chan_id);
722 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
723
724 return;
725
726 trunc:
727 ND_PRINT((ndo, "%s", tstr));
728 }
729
730 static void
pptp_icrq_print(netdissect_options * ndo,const u_char * dat)731 pptp_icrq_print(netdissect_options *ndo,
732 const u_char *dat)
733 {
734 struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
735
736 ND_TCHECK(ptr->call_id);
737 pptp_call_id_print(ndo, &ptr->call_id);
738 ND_TCHECK(ptr->call_ser);
739 pptp_call_ser_print(ndo, &ptr->call_ser);
740 ND_TCHECK(ptr->bearer_type);
741 pptp_bearer_type_print(ndo, &ptr->bearer_type);
742 ND_TCHECK(ptr->phy_chan_id);
743 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
744 ND_TCHECK(ptr->dialed_no_len);
745 ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
746 ND_TCHECK(ptr->dialing_no_len);
747 ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
748 ND_TCHECK(ptr->dialed_no);
749 ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
750 ND_TCHECK(ptr->dialing_no);
751 ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
752 ND_TCHECK(ptr->subaddr);
753 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
754
755 return;
756
757 trunc:
758 ND_PRINT((ndo, "%s", tstr));
759 }
760
761 static void
pptp_icrp_print(netdissect_options * ndo,const u_char * dat)762 pptp_icrp_print(netdissect_options *ndo,
763 const u_char *dat)
764 {
765 struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
766
767 ND_TCHECK(ptr->call_id);
768 pptp_call_id_print(ndo, &ptr->call_id);
769 ND_TCHECK(ptr->peer_call_id);
770 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
771 ND_TCHECK(ptr->result_code);
772 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
773 ND_TCHECK(ptr->err_code);
774 pptp_err_code_print(ndo, &ptr->err_code);
775 ND_TCHECK(ptr->recv_winsiz);
776 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
777 ND_TCHECK(ptr->pkt_proc_delay);
778 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
779 ND_TCHECK(ptr->reserved1);
780
781 return;
782
783 trunc:
784 ND_PRINT((ndo, "%s", tstr));
785 }
786
787 static void
pptp_iccn_print(netdissect_options * ndo,const u_char * dat)788 pptp_iccn_print(netdissect_options *ndo,
789 const u_char *dat)
790 {
791 struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
792
793 ND_TCHECK(ptr->peer_call_id);
794 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
795 ND_TCHECK(ptr->reserved1);
796 ND_TCHECK(ptr->conn_speed);
797 pptp_conn_speed_print(ndo, &ptr->conn_speed);
798 ND_TCHECK(ptr->recv_winsiz);
799 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
800 ND_TCHECK(ptr->pkt_proc_delay);
801 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
802 ND_TCHECK(ptr->framing_type);
803 pptp_framing_type_print(ndo, &ptr->framing_type);
804
805 return;
806
807 trunc:
808 ND_PRINT((ndo, "%s", tstr));
809 }
810
811 static void
pptp_ccrq_print(netdissect_options * ndo,const u_char * dat)812 pptp_ccrq_print(netdissect_options *ndo,
813 const u_char *dat)
814 {
815 struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
816
817 ND_TCHECK(ptr->call_id);
818 pptp_call_id_print(ndo, &ptr->call_id);
819 ND_TCHECK(ptr->reserved1);
820
821 return;
822
823 trunc:
824 ND_PRINT((ndo, "%s", tstr));
825 }
826
827 static void
pptp_cdn_print(netdissect_options * ndo,const u_char * dat)828 pptp_cdn_print(netdissect_options *ndo,
829 const u_char *dat)
830 {
831 struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
832
833 ND_TCHECK(ptr->call_id);
834 pptp_call_id_print(ndo, &ptr->call_id);
835 ND_TCHECK(ptr->result_code);
836 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
837 ND_TCHECK(ptr->err_code);
838 pptp_err_code_print(ndo, &ptr->err_code);
839 ND_TCHECK(ptr->cause_code);
840 pptp_cause_code_print(ndo, &ptr->cause_code);
841 ND_TCHECK(ptr->reserved1);
842 ND_TCHECK(ptr->call_stats);
843 ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
844
845 return;
846
847 trunc:
848 ND_PRINT((ndo, "%s", tstr));
849 }
850
851 static void
pptp_wen_print(netdissect_options * ndo,const u_char * dat)852 pptp_wen_print(netdissect_options *ndo,
853 const u_char *dat)
854 {
855 struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
856
857 ND_TCHECK(ptr->peer_call_id);
858 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
859 ND_TCHECK(ptr->reserved1);
860 ND_TCHECK(ptr->crc_err);
861 ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
862 ND_TCHECK(ptr->framing_err);
863 ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
864 ND_TCHECK(ptr->hardware_overrun);
865 ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
866 ND_TCHECK(ptr->buffer_overrun);
867 ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
868 ND_TCHECK(ptr->timeout_err);
869 ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
870 ND_TCHECK(ptr->align_err);
871 ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
872
873 return;
874
875 trunc:
876 ND_PRINT((ndo, "%s", tstr));
877 }
878
879 static void
pptp_sli_print(netdissect_options * ndo,const u_char * dat)880 pptp_sli_print(netdissect_options *ndo,
881 const u_char *dat)
882 {
883 struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
884
885 ND_TCHECK(ptr->peer_call_id);
886 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
887 ND_TCHECK(ptr->reserved1);
888 ND_TCHECK(ptr->send_accm);
889 ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
890 ND_TCHECK(ptr->recv_accm);
891 ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
892
893 return;
894
895 trunc:
896 ND_PRINT((ndo, "%s", tstr));
897 }
898
899 void
pptp_print(netdissect_options * ndo,const u_char * dat)900 pptp_print(netdissect_options *ndo,
901 const u_char *dat)
902 {
903 const struct pptp_hdr *hdr;
904 uint32_t mc;
905 uint16_t ctrl_msg_type;
906
907 ND_PRINT((ndo, ": pptp"));
908
909 hdr = (struct pptp_hdr *)dat;
910
911 ND_TCHECK(hdr->length);
912 if (ndo->ndo_vflag) {
913 ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
914 }
915 ND_TCHECK(hdr->msg_type);
916 if (ndo->ndo_vflag) {
917 switch(EXTRACT_16BITS(&hdr->msg_type)) {
918 case PPTP_MSG_TYPE_CTRL:
919 ND_PRINT((ndo, " CTRL-MSG"));
920 break;
921 case PPTP_MSG_TYPE_MGMT:
922 ND_PRINT((ndo, " MGMT-MSG"));
923 break;
924 default:
925 ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
926 break;
927 }
928 }
929
930 ND_TCHECK(hdr->magic_cookie);
931 mc = EXTRACT_32BITS(&hdr->magic_cookie);
932 if (mc != PPTP_MAGIC_COOKIE) {
933 ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
934 }
935 if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
936 ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
937 }
938 ND_TCHECK(hdr->ctrl_msg_type);
939 ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
940 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
941 ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
942 pptp_message_type_string[ctrl_msg_type]));
943 } else {
944 ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
945 }
946 ND_TCHECK(hdr->reserved0);
947
948 dat += 12;
949
950 switch(ctrl_msg_type) {
951 case PPTP_CTRL_MSG_TYPE_SCCRQ:
952 pptp_sccrq_print(ndo, dat);
953 break;
954 case PPTP_CTRL_MSG_TYPE_SCCRP:
955 pptp_sccrp_print(ndo, dat);
956 break;
957 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
958 pptp_stopccrq_print(ndo, dat);
959 break;
960 case PPTP_CTRL_MSG_TYPE_StopCCRP:
961 pptp_stopccrp_print(ndo, dat);
962 break;
963 case PPTP_CTRL_MSG_TYPE_ECHORQ:
964 pptp_echorq_print(ndo, dat);
965 break;
966 case PPTP_CTRL_MSG_TYPE_ECHORP:
967 pptp_echorp_print(ndo, dat);
968 break;
969 case PPTP_CTRL_MSG_TYPE_OCRQ:
970 pptp_ocrq_print(ndo, dat);
971 break;
972 case PPTP_CTRL_MSG_TYPE_OCRP:
973 pptp_ocrp_print(ndo, dat);
974 break;
975 case PPTP_CTRL_MSG_TYPE_ICRQ:
976 pptp_icrq_print(ndo, dat);
977 break;
978 case PPTP_CTRL_MSG_TYPE_ICRP:
979 pptp_icrp_print(ndo, dat);
980 break;
981 case PPTP_CTRL_MSG_TYPE_ICCN:
982 pptp_iccn_print(ndo, dat);
983 break;
984 case PPTP_CTRL_MSG_TYPE_CCRQ:
985 pptp_ccrq_print(ndo, dat);
986 break;
987 case PPTP_CTRL_MSG_TYPE_CDN:
988 pptp_cdn_print(ndo, dat);
989 break;
990 case PPTP_CTRL_MSG_TYPE_WEN:
991 pptp_wen_print(ndo, dat);
992 break;
993 case PPTP_CTRL_MSG_TYPE_SLI:
994 pptp_sli_print(ndo, dat);
995 break;
996 default:
997 /* do nothing */
998 break;
999 }
1000
1001 return;
1002
1003 trunc:
1004 ND_PRINT((ndo, "%s", tstr));
1005 }
1006