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