Expand PMF_FN_* macros.
[netbsd-mini2440.git] / dist / tcpdump / print-pptp.c
blob3061c58b29d34dd575ef6893ffcda85212dfde06
1 /* $NetBSD$ */
3 /*
4 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
27 #include <sys/cdefs.h>
28 #ifndef lint
29 #if 0
30 static const char rcsid[] _U_ =
31 "@(#) Header: /tcpdump/master/tcpdump/print-pptp.c,v 1.11.2.1 2006/06/23 02:07:27 hannes Exp";
32 #else
33 __RCSID("$NetBSD: tcpdump2rcsid.ex,v 1.1 2001/06/25 20:09:58 itojun Exp $");
34 #endif
35 #endif
37 #ifdef HAVE_CONFIG_H
38 #include "config.h"
39 #endif
41 #include <tcpdump-stdinc.h>
43 #include <stdio.h>
45 #include "interface.h"
46 #include "extract.h"
48 static char tstr[] = " [|pptp]";
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 */
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
70 #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
71 #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
73 #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
74 #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
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 */
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 */
93 "WEN", /* 14 WAN-Error-Notify */
95 "SLI" /* 15 Set-Link-Info */
96 #define PPTP_MAX_MSGTYPE_INDEX 16
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;
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];
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];
131 struct pptp_msg_stopccrq {
132 u_int8_t reason;
133 u_int8_t reserved1;
134 u_int16_t reserved2;
137 struct pptp_msg_stopccrp {
138 u_int8_t result_code;
139 u_int8_t err_code;
140 u_int16_t reserved1;
143 struct pptp_msg_echorq {
144 u_int32_t id;
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;
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];
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;
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];
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;
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;
212 struct pptp_msg_ccrq {
213 u_int16_t call_id;
214 u_int16_t reserved1;
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];
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;
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;
244 /* attributes that appear more than once in above messages:
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];
273 so I will prepare print out functions for these attributes (except for
274 reserved*).
277 /******************************************/
278 /* Attribute-specific print out functions */
279 /******************************************/
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. */
285 static void
286 pptp_bearer_cap_print(const u_int32_t *bearer_cap)
288 printf(" BEARER_CAP(");
289 if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK) {
290 printf("D");
292 if (EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK) {
293 printf("A");
295 printf(")");
298 static void
299 pptp_bearer_type_print(const u_int32_t *bearer_type)
301 printf(" BEARER_TYPE(");
302 switch (EXTRACT_32BITS(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;
316 printf(")");
319 static void
320 pptp_call_id_print(const u_int16_t *call_id)
322 printf(" CALL_ID(%u)", EXTRACT_16BITS(call_id));
325 static void
326 pptp_call_ser_print(const u_int16_t *call_ser)
328 printf(" CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser));
331 static void
332 pptp_cause_code_print(const u_int16_t *cause_code)
334 printf(" CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code));
337 static void
338 pptp_conn_speed_print(const u_int32_t *conn_speed)
340 printf(" CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed));
343 static void
344 pptp_err_code_print(const u_int8_t *err_code)
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;
375 printf(")");
378 static void
379 pptp_firm_rev_print(const u_int16_t *firm_rev)
381 printf(" FIRM_REV(%u)", EXTRACT_16BITS(firm_rev));
384 static void
385 pptp_framing_cap_print(const u_int32_t *framing_cap)
387 printf(" FRAME_CAP(");
388 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
389 printf("A"); /* Async */
391 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
392 printf("S"); /* Sync */
394 printf(")");
397 static void
398 pptp_framing_type_print(const u_int32_t *framing_type)
400 printf(" FRAME_TYPE(");
401 switch (EXTRACT_32BITS(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;
415 printf(")");
418 static void
419 pptp_hostname_print(const u_char *hostname)
421 printf(" HOSTNAME(%.64s)", hostname);
424 static void
425 pptp_id_print(const u_int32_t *id)
427 printf(" ID(%u)", EXTRACT_32BITS(id));
430 static void
431 pptp_max_channel_print(const u_int16_t *max_channel)
433 printf(" MAX_CHAN(%u)", EXTRACT_16BITS(max_channel));
436 static void
437 pptp_peer_call_id_print(const u_int16_t *peer_call_id)
439 printf(" PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id));
442 static void
443 pptp_phy_chan_id_print(const u_int32_t *phy_chan_id)
445 printf(" PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id));
448 static void
449 pptp_pkt_proc_delay_print(const u_int16_t *pkt_proc_delay)
451 printf(" PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay));
454 static void
455 pptp_proto_ver_print(const u_int16_t *proto_ver)
457 printf(" PROTO_VER(%u.%u)", /* Version.Revision */
458 EXTRACT_16BITS(proto_ver) >> 8,
459 EXTRACT_16BITS(proto_ver) & 0xff);
462 static void
463 pptp_recv_winsiz_print(const u_int16_t *recv_winsiz)
465 printf(" RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz));
468 static void
469 pptp_result_code_print(const u_int8_t *result_code, int ctrl_msg_type)
471 printf(" RESULT_CODE(%u", *result_code);
472 if (vflag) {
473 switch (ctrl_msg_type) {
474 case PPTP_CTRL_MSG_TYPE_SCCRP:
475 switch (*result_code) {
476 case 1:
477 printf(":Successful channel establishment");
478 break;
479 case 2:
480 printf(":General error");
481 break;
482 case 3:
483 printf(":Command channel already exists");
484 break;
485 case 4:
486 printf(":Requester is not authorized to establish a command channel");
487 break;
488 case 5:
489 printf(":The protocol version of the requester is not supported");
490 break;
491 default:
492 printf(":?");
493 break;
495 break;
496 case PPTP_CTRL_MSG_TYPE_StopCCRP:
497 case PPTP_CTRL_MSG_TYPE_ECHORP:
498 switch (*result_code) {
499 case 1:
500 printf(":OK");
501 break;
502 case 2:
503 printf(":General Error");
504 break;
505 default:
506 printf(":?");
507 break;
509 break;
510 case PPTP_CTRL_MSG_TYPE_OCRP:
511 switch (*result_code) {
512 case 1:
513 printf(":Connected");
514 break;
515 case 2:
516 printf(":General Error");
517 break;
518 case 3:
519 printf(":No Carrier");
520 break;
521 case 4:
522 printf(":Busy");
523 break;
524 case 5:
525 printf(":No Dial Tone");
526 break;
527 case 6:
528 printf(":Time-out");
529 break;
530 case 7:
531 printf(":Do Not Accept");
532 break;
533 default:
534 printf(":?");
535 break;
537 break;
538 case PPTP_CTRL_MSG_TYPE_ICRP:
539 switch (*result_code) {
540 case 1:
541 printf(":Connect");
542 break;
543 case 2:
544 printf(":General Error");
545 break;
546 case 3:
547 printf(":Do Not Accept");
548 break;
549 default:
550 printf(":?");
551 break;
553 break;
554 case PPTP_CTRL_MSG_TYPE_CDN:
555 switch (*result_code) {
556 case 1:
557 printf(":Lost Carrier");
558 break;
559 case 2:
560 printf(":General Error");
561 break;
562 case 3:
563 printf(":Admin Shutdown");
564 break;
565 case 4:
566 printf(":Request");
567 default:
568 printf(":?");
569 break;
570 break;
572 default:
573 /* assertion error */
574 break;
577 printf(")");
580 static void
581 pptp_subaddr_print(const u_char *subaddr)
583 printf(" SUB_ADDR(%.64s)", subaddr);
586 static void
587 pptp_vendor_print(const u_char *vendor)
589 printf(" VENDOR(%.64s)", vendor);
592 /************************************/
593 /* PPTP message print out functions */
594 /************************************/
595 static void
596 pptp_sccrq_print(const u_char *dat)
598 struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
600 TCHECK(ptr->proto_ver);
601 pptp_proto_ver_print(&ptr->proto_ver);
602 TCHECK(ptr->reserved1);
603 TCHECK(ptr->framing_cap);
604 pptp_framing_cap_print(&ptr->framing_cap);
605 TCHECK(ptr->bearer_cap);
606 pptp_bearer_cap_print(&ptr->bearer_cap);
607 TCHECK(ptr->max_channel);
608 pptp_max_channel_print(&ptr->max_channel);
609 TCHECK(ptr->firm_rev);
610 pptp_firm_rev_print(&ptr->firm_rev);
611 TCHECK(ptr->hostname);
612 pptp_hostname_print(&ptr->hostname[0]);
613 TCHECK(ptr->vendor);
614 pptp_vendor_print(&ptr->vendor[0]);
616 return;
618 trunc:
619 printf("%s", tstr);
622 static void
623 pptp_sccrp_print(const u_char *dat)
625 struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
627 TCHECK(ptr->proto_ver);
628 pptp_proto_ver_print(&ptr->proto_ver);
629 TCHECK(ptr->result_code);
630 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
631 TCHECK(ptr->err_code);
632 pptp_err_code_print(&ptr->err_code);
633 TCHECK(ptr->framing_cap);
634 pptp_framing_cap_print(&ptr->framing_cap);
635 TCHECK(ptr->bearer_cap);
636 pptp_bearer_cap_print(&ptr->bearer_cap);
637 TCHECK(ptr->max_channel);
638 pptp_max_channel_print(&ptr->max_channel);
639 TCHECK(ptr->firm_rev);
640 pptp_firm_rev_print(&ptr->firm_rev);
641 TCHECK(ptr->hostname);
642 pptp_hostname_print(&ptr->hostname[0]);
643 TCHECK(ptr->vendor);
644 pptp_vendor_print(&ptr->vendor[0]);
646 return;
648 trunc:
649 printf("%s", tstr);
652 static void
653 pptp_stopccrq_print(const u_char *dat)
655 struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
657 TCHECK(ptr->reason);
658 printf(" REASON(%u", ptr->reason);
659 if (vflag) {
660 switch (ptr->reason) {
661 case 1:
662 printf(":None");
663 break;
664 case 2:
665 printf(":Stop-Protocol");
666 break;
667 case 3:
668 printf(":Stop-Local-Shutdown");
669 break;
670 default:
671 printf(":?");
672 break;
675 printf(")");
676 TCHECK(ptr->reserved1);
677 TCHECK(ptr->reserved2);
679 return;
681 trunc:
682 printf("%s", tstr);
685 static void
686 pptp_stopccrp_print(const u_char *dat)
688 struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
690 TCHECK(ptr->result_code);
691 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
692 TCHECK(ptr->err_code);
693 pptp_err_code_print(&ptr->err_code);
694 TCHECK(ptr->reserved1);
696 return;
698 trunc:
699 printf("%s", tstr);
702 static void
703 pptp_echorq_print(const u_char *dat)
705 struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
707 TCHECK(ptr->id);
708 pptp_id_print(&ptr->id);
710 return;
712 trunc:
713 printf("%s", tstr);
716 static void
717 pptp_echorp_print(const u_char *dat)
719 struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
721 TCHECK(ptr->id);
722 pptp_id_print(&ptr->id);
723 TCHECK(ptr->result_code);
724 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
725 TCHECK(ptr->err_code);
726 pptp_err_code_print(&ptr->err_code);
727 TCHECK(ptr->reserved1);
729 return;
731 trunc:
732 printf("%s", tstr);
735 static void
736 pptp_ocrq_print(const u_char *dat)
738 struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
740 TCHECK(ptr->call_id);
741 pptp_call_id_print(&ptr->call_id);
742 TCHECK(ptr->call_ser);
743 pptp_call_ser_print(&ptr->call_ser);
744 TCHECK(ptr->min_bps);
745 printf(" MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps));
746 TCHECK(ptr->max_bps);
747 printf(" MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps));
748 TCHECK(ptr->bearer_type);
749 pptp_bearer_type_print(&ptr->bearer_type);
750 TCHECK(ptr->framing_type);
751 pptp_framing_type_print(&ptr->framing_type);
752 TCHECK(ptr->recv_winsiz);
753 pptp_recv_winsiz_print(&ptr->recv_winsiz);
754 TCHECK(ptr->pkt_proc_delay);
755 pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
756 TCHECK(ptr->phone_no_len);
757 printf(" PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len));
758 TCHECK(ptr->reserved1);
759 TCHECK(ptr->phone_no);
760 printf(" PHONE_NO(%.64s)", ptr->phone_no);
761 TCHECK(ptr->subaddr);
762 pptp_subaddr_print(&ptr->subaddr[0]);
764 return;
766 trunc:
767 printf("%s", tstr);
770 static void
771 pptp_ocrp_print(const u_char *dat)
773 struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
775 TCHECK(ptr->call_id);
776 pptp_call_id_print(&ptr->call_id);
777 TCHECK(ptr->peer_call_id);
778 pptp_peer_call_id_print(&ptr->peer_call_id);
779 TCHECK(ptr->result_code);
780 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
781 TCHECK(ptr->err_code);
782 pptp_err_code_print(&ptr->err_code);
783 TCHECK(ptr->cause_code);
784 pptp_cause_code_print(&ptr->cause_code);
785 TCHECK(ptr->conn_speed);
786 pptp_conn_speed_print(&ptr->conn_speed);
787 TCHECK(ptr->recv_winsiz);
788 pptp_recv_winsiz_print(&ptr->recv_winsiz);
789 TCHECK(ptr->pkt_proc_delay);
790 pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
791 TCHECK(ptr->phy_chan_id);
792 pptp_phy_chan_id_print(&ptr->phy_chan_id);
794 return;
796 trunc:
797 printf("%s", tstr);
800 static void
801 pptp_icrq_print(const u_char *dat)
803 struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
805 TCHECK(ptr->call_id);
806 pptp_call_id_print(&ptr->call_id);
807 TCHECK(ptr->call_ser);
808 pptp_call_ser_print(&ptr->call_ser);
809 TCHECK(ptr->bearer_type);
810 pptp_bearer_type_print(&ptr->bearer_type);
811 TCHECK(ptr->phy_chan_id);
812 pptp_phy_chan_id_print(&ptr->phy_chan_id);
813 TCHECK(ptr->dialed_no_len);
814 printf(" DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len));
815 TCHECK(ptr->dialing_no_len);
816 printf(" DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len));
817 TCHECK(ptr->dialed_no);
818 printf(" DIALED_NO(%.64s)", ptr->dialed_no);
819 TCHECK(ptr->dialing_no);
820 printf(" DIALING_NO(%.64s)", ptr->dialing_no);
821 TCHECK(ptr->subaddr);
822 pptp_subaddr_print(&ptr->subaddr[0]);
824 return;
826 trunc:
827 printf("%s", tstr);
830 static void
831 pptp_icrp_print(const u_char *dat)
833 struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
835 TCHECK(ptr->call_id);
836 pptp_call_id_print(&ptr->call_id);
837 TCHECK(ptr->peer_call_id);
838 pptp_peer_call_id_print(&ptr->peer_call_id);
839 TCHECK(ptr->result_code);
840 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
841 TCHECK(ptr->err_code);
842 pptp_err_code_print(&ptr->err_code);
843 TCHECK(ptr->recv_winsiz);
844 pptp_recv_winsiz_print(&ptr->recv_winsiz);
845 TCHECK(ptr->pkt_proc_delay);
846 pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
847 TCHECK(ptr->reserved1);
849 return;
851 trunc:
852 printf("%s", tstr);
855 static void
856 pptp_iccn_print(const u_char *dat)
858 struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
860 TCHECK(ptr->peer_call_id);
861 pptp_peer_call_id_print(&ptr->peer_call_id);
862 TCHECK(ptr->reserved1);
863 TCHECK(ptr->conn_speed);
864 pptp_conn_speed_print(&ptr->conn_speed);
865 TCHECK(ptr->recv_winsiz);
866 pptp_recv_winsiz_print(&ptr->recv_winsiz);
867 TCHECK(ptr->pkt_proc_delay);
868 pptp_pkt_proc_delay_print(&ptr->pkt_proc_delay);
869 TCHECK(ptr->framing_type);
870 pptp_framing_type_print(&ptr->framing_type);
872 return;
874 trunc:
875 printf("%s", tstr);
878 static void
879 pptp_ccrq_print(const u_char *dat)
881 struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
883 TCHECK(ptr->call_id);
884 pptp_call_id_print(&ptr->call_id);
885 TCHECK(ptr->reserved1);
887 return;
889 trunc:
890 printf("%s", tstr);
893 static void
894 pptp_cdn_print(const u_char *dat)
896 struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
898 TCHECK(ptr->call_id);
899 pptp_call_id_print(&ptr->call_id);
900 TCHECK(ptr->result_code);
901 pptp_result_code_print(&ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
902 TCHECK(ptr->err_code);
903 pptp_err_code_print(&ptr->err_code);
904 TCHECK(ptr->cause_code);
905 pptp_cause_code_print(&ptr->cause_code);
906 TCHECK(ptr->reserved1);
907 TCHECK(ptr->call_stats);
908 printf(" CALL_STATS(%.128s)", ptr->call_stats);
910 return;
912 trunc:
913 printf("%s", tstr);
916 static void
917 pptp_wen_print(const u_char *dat)
919 struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
921 TCHECK(ptr->peer_call_id);
922 pptp_peer_call_id_print(&ptr->peer_call_id);
923 TCHECK(ptr->reserved1);
924 TCHECK(ptr->crc_err);
925 printf(" CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err));
926 TCHECK(ptr->framing_err);
927 printf(" FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err));
928 TCHECK(ptr->hardware_overrun);
929 printf(" HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun));
930 TCHECK(ptr->buffer_overrun);
931 printf(" BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun));
932 TCHECK(ptr->timeout_err);
933 printf(" TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err));
934 TCHECK(ptr->align_err);
935 printf(" ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err));
937 return;
939 trunc:
940 printf("%s", tstr);
943 static void
944 pptp_sli_print(const u_char *dat)
946 struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
948 TCHECK(ptr->peer_call_id);
949 pptp_peer_call_id_print(&ptr->peer_call_id);
950 TCHECK(ptr->reserved1);
951 TCHECK(ptr->send_accm);
952 printf(" SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm));
953 TCHECK(ptr->recv_accm);
954 printf(" RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm));
956 return;
958 trunc:
959 printf("%s", tstr);
962 void
963 pptp_print(const u_char *dat)
965 const struct pptp_hdr *hdr;
966 u_int32_t mc;
967 u_int16_t ctrl_msg_type;
969 printf(": pptp");
971 hdr = (struct pptp_hdr *)dat;
973 TCHECK(hdr->length);
974 if (vflag) {
975 printf(" Length=%u", EXTRACT_16BITS(&hdr->length));
977 TCHECK(hdr->msg_type);
978 if (vflag) {
979 switch(EXTRACT_16BITS(&hdr->msg_type)) {
980 case PPTP_MSG_TYPE_CTRL:
981 printf(" CTRL-MSG");
982 break;
983 case PPTP_MSG_TYPE_MGMT:
984 printf(" MGMT-MSG");
985 break;
986 default:
987 printf(" UNKNOWN-MSG-TYPE");
988 break;
992 TCHECK(hdr->magic_cookie);
993 mc = EXTRACT_32BITS(&hdr->magic_cookie);
994 if (mc != PPTP_MAGIC_COOKIE) {
995 printf(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
997 if (vflag || mc != PPTP_MAGIC_COOKIE) {
998 printf(" Magic-Cookie=%08x", mc);
1000 TCHECK(hdr->ctrl_msg_type);
1001 ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
1002 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
1003 printf(" CTRL_MSGTYPE=%s",
1004 pptp_message_type_string[ctrl_msg_type]);
1005 } else {
1006 printf(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
1008 TCHECK(hdr->reserved0);
1010 dat += 12;
1012 switch(ctrl_msg_type) {
1013 case PPTP_CTRL_MSG_TYPE_SCCRQ:
1014 pptp_sccrq_print(dat);
1015 break;
1016 case PPTP_CTRL_MSG_TYPE_SCCRP:
1017 pptp_sccrp_print(dat);
1018 break;
1019 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
1020 pptp_stopccrq_print(dat);
1021 break;
1022 case PPTP_CTRL_MSG_TYPE_StopCCRP:
1023 pptp_stopccrp_print(dat);
1024 break;
1025 case PPTP_CTRL_MSG_TYPE_ECHORQ:
1026 pptp_echorq_print(dat);
1027 break;
1028 case PPTP_CTRL_MSG_TYPE_ECHORP:
1029 pptp_echorp_print(dat);
1030 break;
1031 case PPTP_CTRL_MSG_TYPE_OCRQ:
1032 pptp_ocrq_print(dat);
1033 break;
1034 case PPTP_CTRL_MSG_TYPE_OCRP:
1035 pptp_ocrp_print(dat);
1036 break;
1037 case PPTP_CTRL_MSG_TYPE_ICRQ:
1038 pptp_icrq_print(dat);
1039 break;
1040 case PPTP_CTRL_MSG_TYPE_ICRP:
1041 pptp_icrp_print(dat);
1042 break;
1043 case PPTP_CTRL_MSG_TYPE_ICCN:
1044 pptp_iccn_print(dat);
1045 break;
1046 case PPTP_CTRL_MSG_TYPE_CCRQ:
1047 pptp_ccrq_print(dat);
1048 break;
1049 case PPTP_CTRL_MSG_TYPE_CDN:
1050 pptp_cdn_print(dat);
1051 break;
1052 case PPTP_CTRL_MSG_TYPE_WEN:
1053 pptp_wen_print(dat);
1054 break;
1055 case PPTP_CTRL_MSG_TYPE_SLI:
1056 pptp_sli_print(dat);
1057 break;
1058 default:
1059 /* do nothing */
1060 break;
1063 return;
1065 trunc:
1066 printf("%s", tstr);