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