etc/protocols - sync with NetBSD-8
[minix.git] / external / bsd / tcpdump / dist / print-pptp.c
bloba496857ff37428a9162ecd91cf43a0fe4e518d35
1 /*
2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
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.
21 * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
24 #include <sys/cdefs.h>
25 #ifndef lint
26 __RCSID("$NetBSD: print-pptp.c,v 1.4 2014/11/20 03:05:03 christos Exp $");
27 #endif
29 #define NETDISSECT_REWORKED
30 #ifdef HAVE_CONFIG_H
31 #include "config.h"
32 #endif
34 #include <tcpdump-stdinc.h>
36 #include "interface.h"
37 #include "extract.h"
39 static const char tstr[] = " [|pptp]";
41 #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
42 #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
43 #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
45 #define PPTP_CTRL_MSG_TYPE_SCCRQ 1
46 #define PPTP_CTRL_MSG_TYPE_SCCRP 2
47 #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
48 #define PPTP_CTRL_MSG_TYPE_StopCCRP 4
49 #define PPTP_CTRL_MSG_TYPE_ECHORQ 5
50 #define PPTP_CTRL_MSG_TYPE_ECHORP 6
51 #define PPTP_CTRL_MSG_TYPE_OCRQ 7
52 #define PPTP_CTRL_MSG_TYPE_OCRP 8
53 #define PPTP_CTRL_MSG_TYPE_ICRQ 9
54 #define PPTP_CTRL_MSG_TYPE_ICRP 10
55 #define PPTP_CTRL_MSG_TYPE_ICCN 11
56 #define PPTP_CTRL_MSG_TYPE_CCRQ 12
57 #define PPTP_CTRL_MSG_TYPE_CDN 13
58 #define PPTP_CTRL_MSG_TYPE_WEN 14
59 #define PPTP_CTRL_MSG_TYPE_SLI 15
61 #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
62 #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
64 #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
65 #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
67 static const char *pptp_message_type_string[] = {
68 "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
69 "SCCRQ", /* 1 Start-Control-Connection-Request */
70 "SCCRP", /* 2 Start-Control-Connection-Reply */
71 "StopCCRQ", /* 3 Stop-Control-Connection-Request */
72 "StopCCRP", /* 4 Stop-Control-Connection-Reply */
73 "ECHORQ", /* 5 Echo Request */
74 "ECHORP", /* 6 Echo Reply */
76 "OCRQ", /* 7 Outgoing-Call-Request */
77 "OCRP", /* 8 Outgoing-Call-Reply */
78 "ICRQ", /* 9 Incoming-Call-Request */
79 "ICRP", /* 10 Incoming-Call-Reply */
80 "ICCN", /* 11 Incoming-Call-Connected */
81 "CCRQ", /* 12 Call-Clear-Request */
82 "CDN", /* 13 Call-Disconnect-Notify */
84 "WEN", /* 14 WAN-Error-Notify */
86 "SLI" /* 15 Set-Link-Info */
87 #define PPTP_MAX_MSGTYPE_INDEX 16
90 /* common for all PPTP control messages */
91 struct pptp_hdr {
92 uint16_t length;
93 uint16_t msg_type;
94 uint32_t magic_cookie;
95 uint16_t ctrl_msg_type;
96 uint16_t reserved0;
99 struct pptp_msg_sccrq {
100 uint16_t proto_ver;
101 uint16_t reserved1;
102 uint32_t framing_cap;
103 uint32_t bearer_cap;
104 uint16_t max_channel;
105 uint16_t firm_rev;
106 u_char hostname[64];
107 u_char vendor[64];
110 struct pptp_msg_sccrp {
111 uint16_t proto_ver;
112 uint8_t result_code;
113 uint8_t err_code;
114 uint32_t framing_cap;
115 uint32_t bearer_cap;
116 uint16_t max_channel;
117 uint16_t firm_rev;
118 u_char hostname[64];
119 u_char vendor[64];
122 struct pptp_msg_stopccrq {
123 uint8_t reason;
124 uint8_t reserved1;
125 uint16_t reserved2;
128 struct pptp_msg_stopccrp {
129 uint8_t result_code;
130 uint8_t err_code;
131 uint16_t reserved1;
134 struct pptp_msg_echorq {
135 uint32_t id;
138 struct pptp_msg_echorp {
139 uint32_t id;
140 uint8_t result_code;
141 uint8_t err_code;
142 uint16_t reserved1;
145 struct pptp_msg_ocrq {
146 uint16_t call_id;
147 uint16_t call_ser;
148 uint32_t min_bps;
149 uint32_t max_bps;
150 uint32_t bearer_type;
151 uint32_t framing_type;
152 uint16_t recv_winsiz;
153 uint16_t pkt_proc_delay;
154 uint16_t phone_no_len;
155 uint16_t reserved1;
156 u_char phone_no[64];
157 u_char subaddr[64];
160 struct pptp_msg_ocrp {
161 uint16_t call_id;
162 uint16_t peer_call_id;
163 uint8_t result_code;
164 uint8_t err_code;
165 uint16_t cause_code;
166 uint32_t conn_speed;
167 uint16_t recv_winsiz;
168 uint16_t pkt_proc_delay;
169 uint32_t phy_chan_id;
172 struct pptp_msg_icrq {
173 uint16_t call_id;
174 uint16_t call_ser;
175 uint32_t bearer_type;
176 uint32_t phy_chan_id;
177 uint16_t dialed_no_len;
178 uint16_t dialing_no_len;
179 u_char dialed_no[64]; /* DNIS */
180 u_char dialing_no[64]; /* CLID */
181 u_char subaddr[64];
184 struct pptp_msg_icrp {
185 uint16_t call_id;
186 uint16_t peer_call_id;
187 uint8_t result_code;
188 uint8_t err_code;
189 uint16_t recv_winsiz;
190 uint16_t pkt_proc_delay;
191 uint16_t reserved1;
194 struct pptp_msg_iccn {
195 uint16_t peer_call_id;
196 uint16_t reserved1;
197 uint32_t conn_speed;
198 uint16_t recv_winsiz;
199 uint16_t pkt_proc_delay;
200 uint32_t framing_type;
203 struct pptp_msg_ccrq {
204 uint16_t call_id;
205 uint16_t reserved1;
208 struct pptp_msg_cdn {
209 uint16_t call_id;
210 uint8_t result_code;
211 uint8_t err_code;
212 uint16_t cause_code;
213 uint16_t reserved1;
214 u_char call_stats[128];
217 struct pptp_msg_wen {
218 uint16_t peer_call_id;
219 uint16_t reserved1;
220 uint32_t crc_err;
221 uint32_t framing_err;
222 uint32_t hardware_overrun;
223 uint32_t buffer_overrun;
224 uint32_t timeout_err;
225 uint32_t align_err;
228 struct pptp_msg_sli {
229 uint16_t peer_call_id;
230 uint16_t reserved1;
231 uint32_t send_accm;
232 uint32_t recv_accm;
235 /* attributes that appear more than once in above messages:
237 Number of
238 occurence attributes
239 --------------------------------------
240 2 uint32_t bearer_cap;
241 2 uint32_t bearer_type;
242 6 uint16_t call_id;
243 2 uint16_t call_ser;
244 2 uint16_t cause_code;
245 2 uint32_t conn_speed;
246 6 uint8_t err_code;
247 2 uint16_t firm_rev;
248 2 uint32_t framing_cap;
249 2 uint32_t framing_type;
250 2 u_char hostname[64];
251 2 uint32_t id;
252 2 uint16_t max_channel;
253 5 uint16_t peer_call_id;
254 2 uint32_t phy_chan_id;
255 4 uint16_t pkt_proc_delay;
256 2 uint16_t proto_ver;
257 4 uint16_t recv_winsiz;
258 2 uint8_t reserved1;
259 9 uint16_t reserved1;
260 6 uint8_t result_code;
261 2 u_char subaddr[64];
262 2 u_char vendor[64];
264 so I will prepare print out functions for these attributes (except for
265 reserved*).
268 /******************************************/
269 /* Attribute-specific print out functions */
270 /******************************************/
272 /* In these attribute-specific print-out functions, it't not necessary
273 to do ND_TCHECK because they are already checked in the caller of
274 these functions. */
276 static void
277 pptp_bearer_cap_print(netdissect_options *ndo,
278 const uint32_t *bearer_cap)
280 ND_PRINT((ndo, " BEARER_CAP(%s%s)",
281 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
282 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
285 static const struct tok pptp_btype_str[] = {
286 { 1, "A" }, /* Analog */
287 { 2, "D" }, /* Digital */
288 { 3, "Any" },
289 { 0, NULL }
292 static void
293 pptp_bearer_type_print(netdissect_options *ndo,
294 const uint32_t *bearer_type)
296 ND_PRINT((ndo, " BEARER_TYPE(%s)",
297 tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
300 static void
301 pptp_call_id_print(netdissect_options *ndo,
302 const uint16_t *call_id)
304 ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
307 static void
308 pptp_call_ser_print(netdissect_options *ndo,
309 const uint16_t *call_ser)
311 ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
314 static void
315 pptp_cause_code_print(netdissect_options *ndo,
316 const uint16_t *cause_code)
318 ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
321 static void
322 pptp_conn_speed_print(netdissect_options *ndo,
323 const uint32_t *conn_speed)
325 ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
328 static const struct tok pptp_errcode_str[] = {
329 { 0, "None" },
330 { 1, "Not-Connected" },
331 { 2, "Bad-Format" },
332 { 3, "Bad-Value" },
333 { 4, "No-Resource" },
334 { 5, "Bad-Call-ID" },
335 { 6, "PAC-Error" },
336 { 0, NULL }
339 static void
340 pptp_err_code_print(netdissect_options *ndo,
341 const uint8_t *err_code)
343 ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
344 if (ndo->ndo_vflag) {
345 ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
347 ND_PRINT((ndo, ")"));
350 static void
351 pptp_firm_rev_print(netdissect_options *ndo,
352 const uint16_t *firm_rev)
354 ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
357 static void
358 pptp_framing_cap_print(netdissect_options *ndo,
359 const uint32_t *framing_cap)
361 ND_PRINT((ndo, " FRAME_CAP("));
362 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
363 ND_PRINT((ndo, "A")); /* Async */
365 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
366 ND_PRINT((ndo, "S")); /* Sync */
368 ND_PRINT((ndo, ")"));
371 static const struct tok pptp_ftype_str[] = {
372 { 1, "A" }, /* Async */
373 { 2, "S" }, /* Sync */
374 { 3, "E" }, /* Either */
375 { 0, NULL }
378 static void
379 pptp_framing_type_print(netdissect_options *ndo,
380 const uint32_t *framing_type)
382 ND_PRINT((ndo, " FRAME_TYPE(%s)",
383 tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
386 static void
387 pptp_hostname_print(netdissect_options *ndo,
388 const u_char *hostname)
390 ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
393 static void
394 pptp_id_print(netdissect_options *ndo,
395 const uint32_t *id)
397 ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
400 static void
401 pptp_max_channel_print(netdissect_options *ndo,
402 const uint16_t *max_channel)
404 ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
407 static void
408 pptp_peer_call_id_print(netdissect_options *ndo,
409 const uint16_t *peer_call_id)
411 ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
414 static void
415 pptp_phy_chan_id_print(netdissect_options *ndo,
416 const uint32_t *phy_chan_id)
418 ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
421 static void
422 pptp_pkt_proc_delay_print(netdissect_options *ndo,
423 const uint16_t *pkt_proc_delay)
425 ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
428 static void
429 pptp_proto_ver_print(netdissect_options *ndo,
430 const uint16_t *proto_ver)
432 ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
433 EXTRACT_16BITS(proto_ver) >> 8,
434 EXTRACT_16BITS(proto_ver) & 0xff));
437 static void
438 pptp_recv_winsiz_print(netdissect_options *ndo,
439 const uint16_t *recv_winsiz)
441 ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
444 static const struct tok pptp_scrrp_str[] = {
445 { 1, "Successful channel establishment" },
446 { 2, "General error" },
447 { 3, "Command channel already exists" },
448 { 4, "Requester is not authorized to establish a command channel" },
449 { 5, "The protocol version of the requester is not supported" },
450 { 0, NULL }
453 static const struct tok pptp_echorp_str[] = {
454 { 1, "OK" },
455 { 2, "General Error" },
456 { 0, NULL }
459 static const struct tok pptp_ocrp_str[] = {
460 { 1, "Connected" },
461 { 2, "General Error" },
462 { 3, "No Carrier" },
463 { 4, "Busy" },
464 { 5, "No Dial Tone" },
465 { 6, "Time-out" },
466 { 7, "Do Not Accept" },
467 { 0, NULL }
470 static const struct tok pptp_icrp_str[] = {
471 { 1, "Connect" },
472 { 2, "General Error" },
473 { 3, "Do Not Accept" },
474 { 0, NULL }
477 static const struct tok pptp_cdn_str[] = {
478 { 1, "Lost Carrier" },
479 { 2, "General Error" },
480 { 3, "Admin Shutdown" },
481 { 4, "Request" },
482 { 0, NULL }
485 static void
486 pptp_result_code_print(netdissect_options *ndo,
487 const uint8_t *result_code, int ctrl_msg_type)
489 ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
490 if (ndo->ndo_vflag) {
491 const struct tok *dict =
492 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
493 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
494 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
495 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
496 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
497 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
498 NULL; /* assertion error */
499 if (dict != NULL)
500 ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
502 ND_PRINT((ndo, ")"));
505 static void
506 pptp_subaddr_print(netdissect_options *ndo,
507 const u_char *subaddr)
509 ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
512 static void
513 pptp_vendor_print(netdissect_options *ndo,
514 const u_char *vendor)
516 ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
519 /************************************/
520 /* PPTP message print out functions */
521 /************************************/
522 static void
523 pptp_sccrq_print(netdissect_options *ndo,
524 const u_char *dat)
526 struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
528 ND_TCHECK(ptr->proto_ver);
529 pptp_proto_ver_print(ndo, &ptr->proto_ver);
530 ND_TCHECK(ptr->reserved1);
531 ND_TCHECK(ptr->framing_cap);
532 pptp_framing_cap_print(ndo, &ptr->framing_cap);
533 ND_TCHECK(ptr->bearer_cap);
534 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
535 ND_TCHECK(ptr->max_channel);
536 pptp_max_channel_print(ndo, &ptr->max_channel);
537 ND_TCHECK(ptr->firm_rev);
538 pptp_firm_rev_print(ndo, &ptr->firm_rev);
539 ND_TCHECK(ptr->hostname);
540 pptp_hostname_print(ndo, &ptr->hostname[0]);
541 ND_TCHECK(ptr->vendor);
542 pptp_vendor_print(ndo, &ptr->vendor[0]);
544 return;
546 trunc:
547 ND_PRINT((ndo, "%s", tstr));
550 static void
551 pptp_sccrp_print(netdissect_options *ndo,
552 const u_char *dat)
554 struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
556 ND_TCHECK(ptr->proto_ver);
557 pptp_proto_ver_print(ndo, &ptr->proto_ver);
558 ND_TCHECK(ptr->result_code);
559 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
560 ND_TCHECK(ptr->err_code);
561 pptp_err_code_print(ndo, &ptr->err_code);
562 ND_TCHECK(ptr->framing_cap);
563 pptp_framing_cap_print(ndo, &ptr->framing_cap);
564 ND_TCHECK(ptr->bearer_cap);
565 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
566 ND_TCHECK(ptr->max_channel);
567 pptp_max_channel_print(ndo, &ptr->max_channel);
568 ND_TCHECK(ptr->firm_rev);
569 pptp_firm_rev_print(ndo, &ptr->firm_rev);
570 ND_TCHECK(ptr->hostname);
571 pptp_hostname_print(ndo, &ptr->hostname[0]);
572 ND_TCHECK(ptr->vendor);
573 pptp_vendor_print(ndo, &ptr->vendor[0]);
575 return;
577 trunc:
578 ND_PRINT((ndo, "%s", tstr));
581 static void
582 pptp_stopccrq_print(netdissect_options *ndo,
583 const u_char *dat)
585 struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
587 ND_TCHECK(ptr->reason);
588 ND_PRINT((ndo, " REASON(%u", ptr->reason));
589 if (ndo->ndo_vflag) {
590 switch (ptr->reason) {
591 case 1:
592 ND_PRINT((ndo, ":None"));
593 break;
594 case 2:
595 ND_PRINT((ndo, ":Stop-Protocol"));
596 break;
597 case 3:
598 ND_PRINT((ndo, ":Stop-Local-Shutdown"));
599 break;
600 default:
601 ND_PRINT((ndo, ":?"));
602 break;
605 ND_PRINT((ndo, ")"));
606 ND_TCHECK(ptr->reserved1);
607 ND_TCHECK(ptr->reserved2);
609 return;
611 trunc:
612 ND_PRINT((ndo, "%s", tstr));
615 static void
616 pptp_stopccrp_print(netdissect_options *ndo,
617 const u_char *dat)
619 struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
621 ND_TCHECK(ptr->result_code);
622 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
623 ND_TCHECK(ptr->err_code);
624 pptp_err_code_print(ndo, &ptr->err_code);
625 ND_TCHECK(ptr->reserved1);
627 return;
629 trunc:
630 ND_PRINT((ndo, "%s", tstr));
633 static void
634 pptp_echorq_print(netdissect_options *ndo,
635 const u_char *dat)
637 struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
639 ND_TCHECK(ptr->id);
640 pptp_id_print(ndo, &ptr->id);
642 return;
644 trunc:
645 ND_PRINT((ndo, "%s", tstr));
648 static void
649 pptp_echorp_print(netdissect_options *ndo,
650 const u_char *dat)
652 struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
654 ND_TCHECK(ptr->id);
655 pptp_id_print(ndo, &ptr->id);
656 ND_TCHECK(ptr->result_code);
657 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
658 ND_TCHECK(ptr->err_code);
659 pptp_err_code_print(ndo, &ptr->err_code);
660 ND_TCHECK(ptr->reserved1);
662 return;
664 trunc:
665 ND_PRINT((ndo, "%s", tstr));
668 static void
669 pptp_ocrq_print(netdissect_options *ndo,
670 const u_char *dat)
672 struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
674 ND_TCHECK(ptr->call_id);
675 pptp_call_id_print(ndo, &ptr->call_id);
676 ND_TCHECK(ptr->call_ser);
677 pptp_call_ser_print(ndo, &ptr->call_ser);
678 ND_TCHECK(ptr->min_bps);
679 ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
680 ND_TCHECK(ptr->max_bps);
681 ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
682 ND_TCHECK(ptr->bearer_type);
683 pptp_bearer_type_print(ndo, &ptr->bearer_type);
684 ND_TCHECK(ptr->framing_type);
685 pptp_framing_type_print(ndo, &ptr->framing_type);
686 ND_TCHECK(ptr->recv_winsiz);
687 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
688 ND_TCHECK(ptr->pkt_proc_delay);
689 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
690 ND_TCHECK(ptr->phone_no_len);
691 ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
692 ND_TCHECK(ptr->reserved1);
693 ND_TCHECK(ptr->phone_no);
694 ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
695 ND_TCHECK(ptr->subaddr);
696 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
698 return;
700 trunc:
701 ND_PRINT((ndo, "%s", tstr));
704 static void
705 pptp_ocrp_print(netdissect_options *ndo,
706 const u_char *dat)
708 struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
710 ND_TCHECK(ptr->call_id);
711 pptp_call_id_print(ndo, &ptr->call_id);
712 ND_TCHECK(ptr->peer_call_id);
713 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
714 ND_TCHECK(ptr->result_code);
715 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
716 ND_TCHECK(ptr->err_code);
717 pptp_err_code_print(ndo, &ptr->err_code);
718 ND_TCHECK(ptr->cause_code);
719 pptp_cause_code_print(ndo, &ptr->cause_code);
720 ND_TCHECK(ptr->conn_speed);
721 pptp_conn_speed_print(ndo, &ptr->conn_speed);
722 ND_TCHECK(ptr->recv_winsiz);
723 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
724 ND_TCHECK(ptr->pkt_proc_delay);
725 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
726 ND_TCHECK(ptr->phy_chan_id);
727 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
729 return;
731 trunc:
732 ND_PRINT((ndo, "%s", tstr));
735 static void
736 pptp_icrq_print(netdissect_options *ndo,
737 const u_char *dat)
739 struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
741 ND_TCHECK(ptr->call_id);
742 pptp_call_id_print(ndo, &ptr->call_id);
743 ND_TCHECK(ptr->call_ser);
744 pptp_call_ser_print(ndo, &ptr->call_ser);
745 ND_TCHECK(ptr->bearer_type);
746 pptp_bearer_type_print(ndo, &ptr->bearer_type);
747 ND_TCHECK(ptr->phy_chan_id);
748 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
749 ND_TCHECK(ptr->dialed_no_len);
750 ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
751 ND_TCHECK(ptr->dialing_no_len);
752 ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
753 ND_TCHECK(ptr->dialed_no);
754 ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
755 ND_TCHECK(ptr->dialing_no);
756 ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
757 ND_TCHECK(ptr->subaddr);
758 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
760 return;
762 trunc:
763 ND_PRINT((ndo, "%s", tstr));
766 static void
767 pptp_icrp_print(netdissect_options *ndo,
768 const u_char *dat)
770 struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
772 ND_TCHECK(ptr->call_id);
773 pptp_call_id_print(ndo, &ptr->call_id);
774 ND_TCHECK(ptr->peer_call_id);
775 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
776 ND_TCHECK(ptr->result_code);
777 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
778 ND_TCHECK(ptr->err_code);
779 pptp_err_code_print(ndo, &ptr->err_code);
780 ND_TCHECK(ptr->recv_winsiz);
781 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
782 ND_TCHECK(ptr->pkt_proc_delay);
783 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
784 ND_TCHECK(ptr->reserved1);
786 return;
788 trunc:
789 ND_PRINT((ndo, "%s", tstr));
792 static void
793 pptp_iccn_print(netdissect_options *ndo,
794 const u_char *dat)
796 struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
798 ND_TCHECK(ptr->peer_call_id);
799 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
800 ND_TCHECK(ptr->reserved1);
801 ND_TCHECK(ptr->conn_speed);
802 pptp_conn_speed_print(ndo, &ptr->conn_speed);
803 ND_TCHECK(ptr->recv_winsiz);
804 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
805 ND_TCHECK(ptr->pkt_proc_delay);
806 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
807 ND_TCHECK(ptr->framing_type);
808 pptp_framing_type_print(ndo, &ptr->framing_type);
810 return;
812 trunc:
813 ND_PRINT((ndo, "%s", tstr));
816 static void
817 pptp_ccrq_print(netdissect_options *ndo,
818 const u_char *dat)
820 struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
822 ND_TCHECK(ptr->call_id);
823 pptp_call_id_print(ndo, &ptr->call_id);
824 ND_TCHECK(ptr->reserved1);
826 return;
828 trunc:
829 ND_PRINT((ndo, "%s", tstr));
832 static void
833 pptp_cdn_print(netdissect_options *ndo,
834 const u_char *dat)
836 struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
838 ND_TCHECK(ptr->call_id);
839 pptp_call_id_print(ndo, &ptr->call_id);
840 ND_TCHECK(ptr->result_code);
841 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
842 ND_TCHECK(ptr->err_code);
843 pptp_err_code_print(ndo, &ptr->err_code);
844 ND_TCHECK(ptr->cause_code);
845 pptp_cause_code_print(ndo, &ptr->cause_code);
846 ND_TCHECK(ptr->reserved1);
847 ND_TCHECK(ptr->call_stats);
848 ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
850 return;
852 trunc:
853 ND_PRINT((ndo, "%s", tstr));
856 static void
857 pptp_wen_print(netdissect_options *ndo,
858 const u_char *dat)
860 struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
862 ND_TCHECK(ptr->peer_call_id);
863 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
864 ND_TCHECK(ptr->reserved1);
865 ND_TCHECK(ptr->crc_err);
866 ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
867 ND_TCHECK(ptr->framing_err);
868 ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
869 ND_TCHECK(ptr->hardware_overrun);
870 ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
871 ND_TCHECK(ptr->buffer_overrun);
872 ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
873 ND_TCHECK(ptr->timeout_err);
874 ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
875 ND_TCHECK(ptr->align_err);
876 ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
878 return;
880 trunc:
881 ND_PRINT((ndo, "%s", tstr));
884 static void
885 pptp_sli_print(netdissect_options *ndo,
886 const u_char *dat)
888 struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
890 ND_TCHECK(ptr->peer_call_id);
891 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
892 ND_TCHECK(ptr->reserved1);
893 ND_TCHECK(ptr->send_accm);
894 ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
895 ND_TCHECK(ptr->recv_accm);
896 ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
898 return;
900 trunc:
901 ND_PRINT((ndo, "%s", tstr));
904 void
905 pptp_print(netdissect_options *ndo,
906 const u_char *dat)
908 const struct pptp_hdr *hdr;
909 uint32_t mc;
910 uint16_t ctrl_msg_type;
912 ND_PRINT((ndo, ": pptp"));
914 hdr = (struct pptp_hdr *)dat;
916 ND_TCHECK(hdr->length);
917 if (ndo->ndo_vflag) {
918 ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
920 ND_TCHECK(hdr->msg_type);
921 if (ndo->ndo_vflag) {
922 switch(EXTRACT_16BITS(&hdr->msg_type)) {
923 case PPTP_MSG_TYPE_CTRL:
924 ND_PRINT((ndo, " CTRL-MSG"));
925 break;
926 case PPTP_MSG_TYPE_MGMT:
927 ND_PRINT((ndo, " MGMT-MSG"));
928 break;
929 default:
930 ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
931 break;
935 ND_TCHECK(hdr->magic_cookie);
936 mc = EXTRACT_32BITS(&hdr->magic_cookie);
937 if (mc != PPTP_MAGIC_COOKIE) {
938 ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
940 if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
941 ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
943 ND_TCHECK(hdr->ctrl_msg_type);
944 ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
945 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
946 ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
947 pptp_message_type_string[ctrl_msg_type]));
948 } else {
949 ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
951 ND_TCHECK(hdr->reserved0);
953 dat += 12;
955 switch(ctrl_msg_type) {
956 case PPTP_CTRL_MSG_TYPE_SCCRQ:
957 pptp_sccrq_print(ndo, dat);
958 break;
959 case PPTP_CTRL_MSG_TYPE_SCCRP:
960 pptp_sccrp_print(ndo, dat);
961 break;
962 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
963 pptp_stopccrq_print(ndo, dat);
964 break;
965 case PPTP_CTRL_MSG_TYPE_StopCCRP:
966 pptp_stopccrp_print(ndo, dat);
967 break;
968 case PPTP_CTRL_MSG_TYPE_ECHORQ:
969 pptp_echorq_print(ndo, dat);
970 break;
971 case PPTP_CTRL_MSG_TYPE_ECHORP:
972 pptp_echorp_print(ndo, dat);
973 break;
974 case PPTP_CTRL_MSG_TYPE_OCRQ:
975 pptp_ocrq_print(ndo, dat);
976 break;
977 case PPTP_CTRL_MSG_TYPE_OCRP:
978 pptp_ocrp_print(ndo, dat);
979 break;
980 case PPTP_CTRL_MSG_TYPE_ICRQ:
981 pptp_icrq_print(ndo, dat);
982 break;
983 case PPTP_CTRL_MSG_TYPE_ICRP:
984 pptp_icrp_print(ndo, dat);
985 break;
986 case PPTP_CTRL_MSG_TYPE_ICCN:
987 pptp_iccn_print(ndo, dat);
988 break;
989 case PPTP_CTRL_MSG_TYPE_CCRQ:
990 pptp_ccrq_print(ndo, dat);
991 break;
992 case PPTP_CTRL_MSG_TYPE_CDN:
993 pptp_cdn_print(ndo, dat);
994 break;
995 case PPTP_CTRL_MSG_TYPE_WEN:
996 pptp_wen_print(ndo, dat);
997 break;
998 case PPTP_CTRL_MSG_TYPE_SLI:
999 pptp_sli_print(ndo, dat);
1000 break;
1001 default:
1002 /* do nothing */
1003 break;
1006 return;
1008 trunc:
1009 ND_PRINT((ndo, "%s", tstr));