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