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
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 /* \summary: Point-to-Point Tunnelling Protocol (PPTP) printer */
26 /* specification: RFC 2637 */
32 #include "netdissect-stdinc.h"
34 #include "netdissect.h"
37 static const char tstr
[] = " [|pptp]";
39 #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
40 #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
41 #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
43 #define PPTP_CTRL_MSG_TYPE_SCCRQ 1
44 #define PPTP_CTRL_MSG_TYPE_SCCRP 2
45 #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
46 #define PPTP_CTRL_MSG_TYPE_StopCCRP 4
47 #define PPTP_CTRL_MSG_TYPE_ECHORQ 5
48 #define PPTP_CTRL_MSG_TYPE_ECHORP 6
49 #define PPTP_CTRL_MSG_TYPE_OCRQ 7
50 #define PPTP_CTRL_MSG_TYPE_OCRP 8
51 #define PPTP_CTRL_MSG_TYPE_ICRQ 9
52 #define PPTP_CTRL_MSG_TYPE_ICRP 10
53 #define PPTP_CTRL_MSG_TYPE_ICCN 11
54 #define PPTP_CTRL_MSG_TYPE_CCRQ 12
55 #define PPTP_CTRL_MSG_TYPE_CDN 13
56 #define PPTP_CTRL_MSG_TYPE_WEN 14
57 #define PPTP_CTRL_MSG_TYPE_SLI 15
59 #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
60 #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
62 #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
63 #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
65 static const char *pptp_message_type_string
[] = {
66 "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
67 "SCCRQ", /* 1 Start-Control-Connection-Request */
68 "SCCRP", /* 2 Start-Control-Connection-Reply */
69 "StopCCRQ", /* 3 Stop-Control-Connection-Request */
70 "StopCCRP", /* 4 Stop-Control-Connection-Reply */
71 "ECHORQ", /* 5 Echo Request */
72 "ECHORP", /* 6 Echo Reply */
74 "OCRQ", /* 7 Outgoing-Call-Request */
75 "OCRP", /* 8 Outgoing-Call-Reply */
76 "ICRQ", /* 9 Incoming-Call-Request */
77 "ICRP", /* 10 Incoming-Call-Reply */
78 "ICCN", /* 11 Incoming-Call-Connected */
79 "CCRQ", /* 12 Call-Clear-Request */
80 "CDN", /* 13 Call-Disconnect-Notify */
82 "WEN", /* 14 WAN-Error-Notify */
84 "SLI" /* 15 Set-Link-Info */
85 #define PPTP_MAX_MSGTYPE_INDEX 16
88 /* common for all PPTP control messages */
92 nd_uint32_t magic_cookie
;
93 nd_uint16_t ctrl_msg_type
;
94 nd_uint16_t reserved0
;
97 struct pptp_msg_sccrq
{
98 nd_uint16_t proto_ver
;
99 nd_uint16_t reserved1
;
100 nd_uint32_t framing_cap
;
101 nd_uint32_t bearer_cap
;
102 nd_uint16_t max_channel
;
103 nd_uint16_t firm_rev
;
104 nd_byte hostname
[64];
108 struct pptp_msg_sccrp
{
109 nd_uint16_t proto_ver
;
110 nd_uint8_t result_code
;
112 nd_uint32_t framing_cap
;
113 nd_uint32_t bearer_cap
;
114 nd_uint16_t max_channel
;
115 nd_uint16_t firm_rev
;
116 nd_byte hostname
[64];
120 struct pptp_msg_stopccrq
{
122 nd_uint8_t reserved1
;
123 nd_uint16_t reserved2
;
126 struct pptp_msg_stopccrp
{
127 nd_uint8_t result_code
;
129 nd_uint16_t reserved1
;
132 struct pptp_msg_echorq
{
136 struct pptp_msg_echorp
{
138 nd_uint8_t result_code
;
140 nd_uint16_t reserved1
;
143 struct pptp_msg_ocrq
{
145 nd_uint16_t call_ser
;
148 nd_uint32_t bearer_type
;
149 nd_uint32_t framing_type
;
150 nd_uint16_t recv_winsiz
;
151 nd_uint16_t pkt_proc_delay
;
152 nd_uint16_t phone_no_len
;
153 nd_uint16_t reserved1
;
154 nd_byte phone_no
[64];
158 struct pptp_msg_ocrp
{
160 nd_uint16_t peer_call_id
;
161 nd_uint8_t result_code
;
163 nd_uint16_t cause_code
;
164 nd_uint32_t conn_speed
;
165 nd_uint16_t recv_winsiz
;
166 nd_uint16_t pkt_proc_delay
;
167 nd_uint32_t phy_chan_id
;
170 struct pptp_msg_icrq
{
172 nd_uint16_t call_ser
;
173 nd_uint32_t bearer_type
;
174 nd_uint32_t phy_chan_id
;
175 nd_uint16_t dialed_no_len
;
176 nd_uint16_t dialing_no_len
;
177 nd_byte dialed_no
[64]; /* DNIS */
178 nd_byte dialing_no
[64]; /* CLID */
182 struct pptp_msg_icrp
{
184 nd_uint16_t peer_call_id
;
185 nd_uint8_t result_code
;
187 nd_uint16_t recv_winsiz
;
188 nd_uint16_t pkt_proc_delay
;
189 nd_uint16_t reserved1
;
192 struct pptp_msg_iccn
{
193 nd_uint16_t peer_call_id
;
194 nd_uint16_t reserved1
;
195 nd_uint32_t conn_speed
;
196 nd_uint16_t recv_winsiz
;
197 nd_uint16_t pkt_proc_delay
;
198 nd_uint32_t framing_type
;
201 struct pptp_msg_ccrq
{
203 nd_uint16_t reserved1
;
206 struct pptp_msg_cdn
{
208 nd_uint8_t result_code
;
210 nd_uint16_t cause_code
;
211 nd_uint16_t reserved1
;
212 nd_byte call_stats
[128];
215 struct pptp_msg_wen
{
216 nd_uint16_t peer_call_id
;
217 nd_uint16_t reserved1
;
219 nd_uint32_t framing_err
;
220 nd_uint32_t hardware_overrun
;
221 nd_uint32_t buffer_overrun
;
222 nd_uint32_t timeout_err
;
223 nd_uint32_t align_err
;
226 struct pptp_msg_sli
{
227 nd_uint16_t peer_call_id
;
228 nd_uint16_t reserved1
;
229 nd_uint32_t send_accm
;
230 nd_uint32_t recv_accm
;
233 /* attributes that appear more than once in above messages:
237 --------------------------------------
238 2 uint32_t bearer_cap;
239 2 uint32_t bearer_type;
242 2 uint16_t cause_code;
243 2 uint32_t conn_speed;
246 2 uint32_t framing_cap;
247 2 uint32_t framing_type;
248 2 u_char hostname[64];
250 2 uint16_t max_channel;
251 5 uint16_t peer_call_id;
252 2 uint32_t phy_chan_id;
253 4 uint16_t pkt_proc_delay;
254 2 uint16_t proto_ver;
255 4 uint16_t recv_winsiz;
257 9 uint16_t reserved1;
258 6 uint8_t result_code;
259 2 u_char subaddr[64];
262 so I will prepare print out functions for these attributes (except for
266 #define PRINT_RESERVED_IF_NOT_ZERO_1(reserved) \
267 if (EXTRACT_U_1(reserved)) \
268 ND_PRINT(" [ERROR: reserved=%u must be zero]", \
269 EXTRACT_U_1(reserved));
271 #define PRINT_RESERVED_IF_NOT_ZERO_2(reserved) \
272 if (EXTRACT_BE_U_2(reserved)) \
273 ND_PRINT(" [ERROR: reserved=%u must be zero]", \
274 EXTRACT_BE_U_2(reserved));
276 /******************************************/
277 /* Attribute-specific print out functions */
278 /******************************************/
280 /* In these attribute-specific print-out functions, it't not necessary
281 to do ND_TCHECK because they are already checked in the caller of
285 pptp_bearer_cap_print(netdissect_options
*ndo
,
286 const nd_uint32_t
*bearer_cap
)
288 ND_PRINT(" BEARER_CAP(%s%s)",
289 EXTRACT_BE_U_4(*bearer_cap
) & PPTP_BEARER_CAP_DIGITAL_MASK
? "D" : "",
290 EXTRACT_BE_U_4(*bearer_cap
) & PPTP_BEARER_CAP_ANALOG_MASK
? "A" : "");
293 static const struct tok pptp_btype_str
[] = {
294 { 1, "A" }, /* Analog */
295 { 2, "D" }, /* Digital */
301 pptp_bearer_type_print(netdissect_options
*ndo
,
302 const nd_uint32_t
*bearer_type
)
304 ND_PRINT(" BEARER_TYPE(%s)",
305 tok2str(pptp_btype_str
, "?", EXTRACT_BE_U_4(*bearer_type
)));
309 pptp_call_id_print(netdissect_options
*ndo
,
310 const nd_uint16_t
*call_id
)
312 ND_PRINT(" CALL_ID(%u)", EXTRACT_BE_U_2(*call_id
));
316 pptp_call_ser_print(netdissect_options
*ndo
,
317 const nd_uint16_t
*call_ser
)
319 ND_PRINT(" CALL_SER_NUM(%u)", EXTRACT_BE_U_2(*call_ser
));
323 pptp_cause_code_print(netdissect_options
*ndo
,
324 const nd_uint16_t
*cause_code
)
326 ND_PRINT(" CAUSE_CODE(%u)", EXTRACT_BE_U_2(*cause_code
));
330 pptp_conn_speed_print(netdissect_options
*ndo
,
331 const nd_uint32_t
*conn_speed
)
333 ND_PRINT(" CONN_SPEED(%u)", EXTRACT_BE_U_4(*conn_speed
));
336 static const struct tok pptp_errcode_str
[] = {
338 { 1, "Not-Connected" },
341 { 4, "No-Resource" },
342 { 5, "Bad-Call-ID" },
348 pptp_err_code_print(netdissect_options
*ndo
,
349 const nd_uint8_t
*err_code
)
351 ND_PRINT(" ERR_CODE(%u", EXTRACT_U_1(*err_code
));
352 if (ndo
->ndo_vflag
) {
353 ND_PRINT(":%s", tok2str(pptp_errcode_str
, "?", EXTRACT_U_1(*err_code
)));
359 pptp_firm_rev_print(netdissect_options
*ndo
,
360 const nd_uint16_t
*firm_rev
)
362 ND_PRINT(" FIRM_REV(%u)", EXTRACT_BE_U_2(*firm_rev
));
366 pptp_framing_cap_print(netdissect_options
*ndo
,
367 const nd_uint32_t
*framing_cap
)
369 ND_PRINT(" FRAME_CAP(");
370 if (EXTRACT_BE_U_4(*framing_cap
) & PPTP_FRAMING_CAP_ASYNC_MASK
) {
371 ND_PRINT("A"); /* Async */
373 if (EXTRACT_BE_U_4(*framing_cap
) & PPTP_FRAMING_CAP_SYNC_MASK
) {
374 ND_PRINT("S"); /* Sync */
379 static const struct tok pptp_ftype_str
[] = {
380 { 1, "A" }, /* Async */
381 { 2, "S" }, /* Sync */
382 { 3, "E" }, /* Either */
387 pptp_framing_type_print(netdissect_options
*ndo
,
388 const nd_uint32_t
*framing_type
)
390 ND_PRINT(" FRAME_TYPE(%s)",
391 tok2str(pptp_ftype_str
, "?", EXTRACT_BE_U_4(*framing_type
)));
395 pptp_hostname_print(netdissect_options
*ndo
,
396 const u_char
*hostname
)
398 ND_PRINT(" HOSTNAME(%.64s)", hostname
);
402 pptp_id_print(netdissect_options
*ndo
,
403 const nd_uint32_t
*id
)
405 ND_PRINT(" ID(%u)", EXTRACT_BE_U_4(*id
));
409 pptp_max_channel_print(netdissect_options
*ndo
,
410 const nd_uint16_t
*max_channel
)
412 ND_PRINT(" MAX_CHAN(%u)", EXTRACT_BE_U_2(*max_channel
));
416 pptp_peer_call_id_print(netdissect_options
*ndo
,
417 const nd_uint16_t
*peer_call_id
)
419 ND_PRINT(" PEER_CALL_ID(%u)", EXTRACT_BE_U_2(*peer_call_id
));
423 pptp_phy_chan_id_print(netdissect_options
*ndo
,
424 const nd_uint32_t
*phy_chan_id
)
426 ND_PRINT(" PHY_CHAN_ID(%u)", EXTRACT_BE_U_4(*phy_chan_id
));
430 pptp_pkt_proc_delay_print(netdissect_options
*ndo
,
431 const nd_uint16_t
*pkt_proc_delay
)
433 ND_PRINT(" PROC_DELAY(%u)", EXTRACT_BE_U_2(*pkt_proc_delay
));
437 pptp_proto_ver_print(netdissect_options
*ndo
,
438 const nd_uint16_t
*proto_ver
)
440 ND_PRINT(" PROTO_VER(%u.%u)", /* Version.Revision */
441 EXTRACT_BE_U_2(*proto_ver
) >> 8,
442 EXTRACT_BE_U_2(*proto_ver
) & 0xff);
446 pptp_recv_winsiz_print(netdissect_options
*ndo
,
447 const nd_uint16_t
*recv_winsiz
)
449 ND_PRINT(" RECV_WIN(%u)", EXTRACT_BE_U_2(*recv_winsiz
));
452 static const struct tok pptp_scrrp_str
[] = {
453 { 1, "Successful channel establishment" },
454 { 2, "General error" },
455 { 3, "Command channel already exists" },
456 { 4, "Requester is not authorized to establish a command channel" },
457 { 5, "The protocol version of the requester is not supported" },
461 static const struct tok pptp_echorp_str
[] = {
463 { 2, "General Error" },
467 static const struct tok pptp_ocrp_str
[] = {
469 { 2, "General Error" },
472 { 5, "No Dial Tone" },
474 { 7, "Do Not Accept" },
478 static const struct tok pptp_icrp_str
[] = {
480 { 2, "General Error" },
481 { 3, "Do Not Accept" },
485 static const struct tok pptp_cdn_str
[] = {
486 { 1, "Lost Carrier" },
487 { 2, "General Error" },
488 { 3, "Admin Shutdown" },
494 pptp_result_code_print(netdissect_options
*ndo
,
495 const nd_uint8_t
*result_code
, int ctrl_msg_type
)
497 ND_PRINT(" RESULT_CODE(%u", EXTRACT_U_1(*result_code
));
498 if (ndo
->ndo_vflag
) {
499 const struct tok
*dict
=
500 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_SCCRP
? pptp_scrrp_str
:
501 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_StopCCRP
? pptp_echorp_str
:
502 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_ECHORP
? pptp_echorp_str
:
503 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_OCRP
? pptp_ocrp_str
:
504 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_ICRP
? pptp_icrp_str
:
505 ctrl_msg_type
== PPTP_CTRL_MSG_TYPE_CDN
? pptp_cdn_str
:
506 NULL
; /* assertion error */
508 ND_PRINT(":%s", tok2str(dict
, "?", EXTRACT_U_1(*result_code
)));
514 pptp_subaddr_print(netdissect_options
*ndo
,
515 const u_char
*subaddr
)
517 ND_PRINT(" SUB_ADDR(%.64s)", subaddr
);
521 pptp_vendor_print(netdissect_options
*ndo
,
522 const u_char
*vendor
)
524 ND_PRINT(" VENDOR(%.64s)", vendor
);
527 /************************************/
528 /* PPTP message print out functions */
529 /************************************/
531 pptp_sccrq_print(netdissect_options
*ndo
,
534 const struct pptp_msg_sccrq
*ptr
= (const struct pptp_msg_sccrq
*)dat
;
536 ND_TCHECK_2(ptr
->proto_ver
);
537 pptp_proto_ver_print(ndo
, &ptr
->proto_ver
);
538 ND_TCHECK_2(ptr
->reserved1
);
539 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
540 ND_TCHECK_4(ptr
->framing_cap
);
541 pptp_framing_cap_print(ndo
, &ptr
->framing_cap
);
542 ND_TCHECK_4(ptr
->bearer_cap
);
543 pptp_bearer_cap_print(ndo
, &ptr
->bearer_cap
);
544 ND_TCHECK_2(ptr
->max_channel
);
545 pptp_max_channel_print(ndo
, &ptr
->max_channel
);
546 ND_TCHECK_2(ptr
->firm_rev
);
547 pptp_firm_rev_print(ndo
, &ptr
->firm_rev
);
548 ND_TCHECK_SIZE(&ptr
->hostname
);
549 pptp_hostname_print(ndo
, &ptr
->hostname
[0]);
550 ND_TCHECK_SIZE(&ptr
->vendor
);
551 pptp_vendor_print(ndo
, &ptr
->vendor
[0]);
556 ND_PRINT("%s", tstr
);
560 pptp_sccrp_print(netdissect_options
*ndo
,
563 const struct pptp_msg_sccrp
*ptr
= (const struct pptp_msg_sccrp
*)dat
;
565 ND_TCHECK_2(ptr
->proto_ver
);
566 pptp_proto_ver_print(ndo
, &ptr
->proto_ver
);
567 ND_TCHECK_1(ptr
->result_code
);
568 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_SCCRP
);
569 ND_TCHECK_1(ptr
->err_code
);
570 pptp_err_code_print(ndo
, &ptr
->err_code
);
571 ND_TCHECK_4(ptr
->framing_cap
);
572 pptp_framing_cap_print(ndo
, &ptr
->framing_cap
);
573 ND_TCHECK_4(ptr
->bearer_cap
);
574 pptp_bearer_cap_print(ndo
, &ptr
->bearer_cap
);
575 ND_TCHECK_2(ptr
->max_channel
);
576 pptp_max_channel_print(ndo
, &ptr
->max_channel
);
577 ND_TCHECK_2(ptr
->firm_rev
);
578 pptp_firm_rev_print(ndo
, &ptr
->firm_rev
);
579 ND_TCHECK_SIZE(&ptr
->hostname
);
580 pptp_hostname_print(ndo
, &ptr
->hostname
[0]);
581 ND_TCHECK_SIZE(&ptr
->vendor
);
582 pptp_vendor_print(ndo
, &ptr
->vendor
[0]);
587 ND_PRINT("%s", tstr
);
591 pptp_stopccrq_print(netdissect_options
*ndo
,
594 const struct pptp_msg_stopccrq
*ptr
= (const struct pptp_msg_stopccrq
*)dat
;
596 ND_TCHECK_1(ptr
->reason
);
597 ND_PRINT(" REASON(%u", EXTRACT_U_1(ptr
->reason
));
598 if (ndo
->ndo_vflag
) {
599 switch (EXTRACT_U_1(ptr
->reason
)) {
604 ND_PRINT(":Stop-Protocol");
607 ND_PRINT(":Stop-Local-Shutdown");
615 ND_TCHECK_1(ptr
->reserved1
);
616 PRINT_RESERVED_IF_NOT_ZERO_1(ptr
->reserved1
);
617 ND_TCHECK_2(ptr
->reserved2
);
618 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved2
);
623 ND_PRINT("%s", tstr
);
627 pptp_stopccrp_print(netdissect_options
*ndo
,
630 const struct pptp_msg_stopccrp
*ptr
= (const struct pptp_msg_stopccrp
*)dat
;
632 ND_TCHECK_1(ptr
->result_code
);
633 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_StopCCRP
);
634 ND_TCHECK_1(ptr
->err_code
);
635 pptp_err_code_print(ndo
, &ptr
->err_code
);
636 ND_TCHECK_2(ptr
->reserved1
);
637 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
642 ND_PRINT("%s", tstr
);
646 pptp_echorq_print(netdissect_options
*ndo
,
649 const struct pptp_msg_echorq
*ptr
= (const struct pptp_msg_echorq
*)dat
;
651 ND_TCHECK_4(ptr
->id
);
652 pptp_id_print(ndo
, &ptr
->id
);
657 ND_PRINT("%s", tstr
);
661 pptp_echorp_print(netdissect_options
*ndo
,
664 const struct pptp_msg_echorp
*ptr
= (const struct pptp_msg_echorp
*)dat
;
666 ND_TCHECK_4(ptr
->id
);
667 pptp_id_print(ndo
, &ptr
->id
);
668 ND_TCHECK_1(ptr
->result_code
);
669 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_ECHORP
);
670 ND_TCHECK_1(ptr
->err_code
);
671 pptp_err_code_print(ndo
, &ptr
->err_code
);
672 ND_TCHECK_2(ptr
->reserved1
);
673 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
678 ND_PRINT("%s", tstr
);
682 pptp_ocrq_print(netdissect_options
*ndo
,
685 const struct pptp_msg_ocrq
*ptr
= (const struct pptp_msg_ocrq
*)dat
;
687 ND_TCHECK_2(ptr
->call_id
);
688 pptp_call_id_print(ndo
, &ptr
->call_id
);
689 ND_TCHECK_2(ptr
->call_ser
);
690 pptp_call_ser_print(ndo
, &ptr
->call_ser
);
691 ND_TCHECK_4(ptr
->min_bps
);
692 ND_PRINT(" MIN_BPS(%u)", EXTRACT_BE_U_4(ptr
->min_bps
));
693 ND_TCHECK_4(ptr
->max_bps
);
694 ND_PRINT(" MAX_BPS(%u)", EXTRACT_BE_U_4(ptr
->max_bps
));
695 ND_TCHECK_4(ptr
->bearer_type
);
696 pptp_bearer_type_print(ndo
, &ptr
->bearer_type
);
697 ND_TCHECK_4(ptr
->framing_type
);
698 pptp_framing_type_print(ndo
, &ptr
->framing_type
);
699 ND_TCHECK_2(ptr
->recv_winsiz
);
700 pptp_recv_winsiz_print(ndo
, &ptr
->recv_winsiz
);
701 ND_TCHECK_2(ptr
->pkt_proc_delay
);
702 pptp_pkt_proc_delay_print(ndo
, &ptr
->pkt_proc_delay
);
703 ND_TCHECK_2(ptr
->phone_no_len
);
704 ND_PRINT(" PHONE_NO_LEN(%u)", EXTRACT_BE_U_2(ptr
->phone_no_len
));
705 ND_TCHECK_2(ptr
->reserved1
);
706 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
707 ND_TCHECK_SIZE(&ptr
->phone_no
);
708 ND_PRINT(" PHONE_NO(%.64s)", ptr
->phone_no
);
709 ND_TCHECK_SIZE(&ptr
->subaddr
);
710 pptp_subaddr_print(ndo
, &ptr
->subaddr
[0]);
715 ND_PRINT("%s", tstr
);
719 pptp_ocrp_print(netdissect_options
*ndo
,
722 const struct pptp_msg_ocrp
*ptr
= (const struct pptp_msg_ocrp
*)dat
;
724 ND_TCHECK_2(ptr
->call_id
);
725 pptp_call_id_print(ndo
, &ptr
->call_id
);
726 ND_TCHECK_2(ptr
->peer_call_id
);
727 pptp_peer_call_id_print(ndo
, &ptr
->peer_call_id
);
728 ND_TCHECK_1(ptr
->result_code
);
729 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_OCRP
);
730 ND_TCHECK_1(ptr
->err_code
);
731 pptp_err_code_print(ndo
, &ptr
->err_code
);
732 ND_TCHECK_2(ptr
->cause_code
);
733 pptp_cause_code_print(ndo
, &ptr
->cause_code
);
734 ND_TCHECK_4(ptr
->conn_speed
);
735 pptp_conn_speed_print(ndo
, &ptr
->conn_speed
);
736 ND_TCHECK_2(ptr
->recv_winsiz
);
737 pptp_recv_winsiz_print(ndo
, &ptr
->recv_winsiz
);
738 ND_TCHECK_2(ptr
->pkt_proc_delay
);
739 pptp_pkt_proc_delay_print(ndo
, &ptr
->pkt_proc_delay
);
740 ND_TCHECK_4(ptr
->phy_chan_id
);
741 pptp_phy_chan_id_print(ndo
, &ptr
->phy_chan_id
);
746 ND_PRINT("%s", tstr
);
750 pptp_icrq_print(netdissect_options
*ndo
,
753 const struct pptp_msg_icrq
*ptr
= (const struct pptp_msg_icrq
*)dat
;
755 ND_TCHECK_2(ptr
->call_id
);
756 pptp_call_id_print(ndo
, &ptr
->call_id
);
757 ND_TCHECK_2(ptr
->call_ser
);
758 pptp_call_ser_print(ndo
, &ptr
->call_ser
);
759 ND_TCHECK_4(ptr
->bearer_type
);
760 pptp_bearer_type_print(ndo
, &ptr
->bearer_type
);
761 ND_TCHECK_4(ptr
->phy_chan_id
);
762 pptp_phy_chan_id_print(ndo
, &ptr
->phy_chan_id
);
763 ND_TCHECK_2(ptr
->dialed_no_len
);
764 ND_PRINT(" DIALED_NO_LEN(%u)", EXTRACT_BE_U_2(ptr
->dialed_no_len
));
765 ND_TCHECK_2(ptr
->dialing_no_len
);
766 ND_PRINT(" DIALING_NO_LEN(%u)", EXTRACT_BE_U_2(ptr
->dialing_no_len
));
767 ND_TCHECK_SIZE(&ptr
->dialed_no
);
768 ND_PRINT(" DIALED_NO(%.64s)", ptr
->dialed_no
);
769 ND_TCHECK_SIZE(&ptr
->dialing_no
);
770 ND_PRINT(" DIALING_NO(%.64s)", ptr
->dialing_no
);
771 ND_TCHECK_SIZE(&ptr
->subaddr
);
772 pptp_subaddr_print(ndo
, &ptr
->subaddr
[0]);
777 ND_PRINT("%s", tstr
);
781 pptp_icrp_print(netdissect_options
*ndo
,
784 const struct pptp_msg_icrp
*ptr
= (const struct pptp_msg_icrp
*)dat
;
786 ND_TCHECK_2(ptr
->call_id
);
787 pptp_call_id_print(ndo
, &ptr
->call_id
);
788 ND_TCHECK_2(ptr
->peer_call_id
);
789 pptp_peer_call_id_print(ndo
, &ptr
->peer_call_id
);
790 ND_TCHECK_1(ptr
->result_code
);
791 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_ICRP
);
792 ND_TCHECK_1(ptr
->err_code
);
793 pptp_err_code_print(ndo
, &ptr
->err_code
);
794 ND_TCHECK_2(ptr
->recv_winsiz
);
795 pptp_recv_winsiz_print(ndo
, &ptr
->recv_winsiz
);
796 ND_TCHECK_2(ptr
->pkt_proc_delay
);
797 pptp_pkt_proc_delay_print(ndo
, &ptr
->pkt_proc_delay
);
798 ND_TCHECK_2(ptr
->reserved1
);
799 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
804 ND_PRINT("%s", tstr
);
808 pptp_iccn_print(netdissect_options
*ndo
,
811 const struct pptp_msg_iccn
*ptr
= (const struct pptp_msg_iccn
*)dat
;
813 ND_TCHECK_2(ptr
->peer_call_id
);
814 pptp_peer_call_id_print(ndo
, &ptr
->peer_call_id
);
815 ND_TCHECK_2(ptr
->reserved1
);
816 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
817 ND_TCHECK_4(ptr
->conn_speed
);
818 pptp_conn_speed_print(ndo
, &ptr
->conn_speed
);
819 ND_TCHECK_2(ptr
->recv_winsiz
);
820 pptp_recv_winsiz_print(ndo
, &ptr
->recv_winsiz
);
821 ND_TCHECK_2(ptr
->pkt_proc_delay
);
822 pptp_pkt_proc_delay_print(ndo
, &ptr
->pkt_proc_delay
);
823 ND_TCHECK_4(ptr
->framing_type
);
824 pptp_framing_type_print(ndo
, &ptr
->framing_type
);
829 ND_PRINT("%s", tstr
);
833 pptp_ccrq_print(netdissect_options
*ndo
,
836 const struct pptp_msg_ccrq
*ptr
= (const struct pptp_msg_ccrq
*)dat
;
838 ND_TCHECK_2(ptr
->call_id
);
839 pptp_call_id_print(ndo
, &ptr
->call_id
);
840 ND_TCHECK_2(ptr
->reserved1
);
841 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
846 ND_PRINT("%s", tstr
);
850 pptp_cdn_print(netdissect_options
*ndo
,
853 const struct pptp_msg_cdn
*ptr
= (const struct pptp_msg_cdn
*)dat
;
855 ND_TCHECK_2(ptr
->call_id
);
856 pptp_call_id_print(ndo
, &ptr
->call_id
);
857 ND_TCHECK_1(ptr
->result_code
);
858 pptp_result_code_print(ndo
, &ptr
->result_code
, PPTP_CTRL_MSG_TYPE_CDN
);
859 ND_TCHECK_1(ptr
->err_code
);
860 pptp_err_code_print(ndo
, &ptr
->err_code
);
861 ND_TCHECK_2(ptr
->cause_code
);
862 pptp_cause_code_print(ndo
, &ptr
->cause_code
);
863 ND_TCHECK_2(ptr
->reserved1
);
864 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
865 ND_TCHECK_SIZE(&ptr
->call_stats
);
866 ND_PRINT(" CALL_STATS(%.128s)", ptr
->call_stats
);
871 ND_PRINT("%s", tstr
);
875 pptp_wen_print(netdissect_options
*ndo
,
878 const struct pptp_msg_wen
*ptr
= (const struct pptp_msg_wen
*)dat
;
880 ND_TCHECK_2(ptr
->peer_call_id
);
881 pptp_peer_call_id_print(ndo
, &ptr
->peer_call_id
);
882 ND_TCHECK_2(ptr
->reserved1
);
883 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
884 ND_TCHECK_4(ptr
->crc_err
);
885 ND_PRINT(" CRC_ERR(%u)", EXTRACT_BE_U_4(ptr
->crc_err
));
886 ND_TCHECK_4(ptr
->framing_err
);
887 ND_PRINT(" FRAMING_ERR(%u)", EXTRACT_BE_U_4(ptr
->framing_err
));
888 ND_TCHECK_4(ptr
->hardware_overrun
);
889 ND_PRINT(" HARDWARE_OVERRUN(%u)", EXTRACT_BE_U_4(ptr
->hardware_overrun
));
890 ND_TCHECK_4(ptr
->buffer_overrun
);
891 ND_PRINT(" BUFFER_OVERRUN(%u)", EXTRACT_BE_U_4(ptr
->buffer_overrun
));
892 ND_TCHECK_4(ptr
->timeout_err
);
893 ND_PRINT(" TIMEOUT_ERR(%u)", EXTRACT_BE_U_4(ptr
->timeout_err
));
894 ND_TCHECK_4(ptr
->align_err
);
895 ND_PRINT(" ALIGN_ERR(%u)", EXTRACT_BE_U_4(ptr
->align_err
));
900 ND_PRINT("%s", tstr
);
904 pptp_sli_print(netdissect_options
*ndo
,
907 const struct pptp_msg_sli
*ptr
= (const struct pptp_msg_sli
*)dat
;
909 ND_TCHECK_2(ptr
->peer_call_id
);
910 pptp_peer_call_id_print(ndo
, &ptr
->peer_call_id
);
911 ND_TCHECK_2(ptr
->reserved1
);
912 PRINT_RESERVED_IF_NOT_ZERO_2(ptr
->reserved1
);
913 ND_TCHECK_4(ptr
->send_accm
);
914 ND_PRINT(" SEND_ACCM(0x%08x)", EXTRACT_BE_U_4(ptr
->send_accm
));
915 ND_TCHECK_4(ptr
->recv_accm
);
916 ND_PRINT(" RECV_ACCM(0x%08x)", EXTRACT_BE_U_4(ptr
->recv_accm
));
921 ND_PRINT("%s", tstr
);
925 pptp_print(netdissect_options
*ndo
,
928 const struct pptp_hdr
*hdr
;
930 uint16_t ctrl_msg_type
;
932 ndo
->ndo_protocol
= "pptp";
935 hdr
= (const struct pptp_hdr
*)dat
;
937 ND_TCHECK_2(hdr
->length
);
938 if (ndo
->ndo_vflag
) {
939 ND_PRINT(" Length=%u", EXTRACT_BE_U_2(hdr
->length
));
941 ND_TCHECK_2(hdr
->msg_type
);
942 if (ndo
->ndo_vflag
) {
943 switch(EXTRACT_BE_U_2(hdr
->msg_type
)) {
944 case PPTP_MSG_TYPE_CTRL
:
945 ND_PRINT(" CTRL-MSG");
947 case PPTP_MSG_TYPE_MGMT
:
948 ND_PRINT(" MGMT-MSG");
951 ND_PRINT(" UNKNOWN-MSG-TYPE");
956 ND_TCHECK_4(hdr
->magic_cookie
);
957 mc
= EXTRACT_BE_U_4(hdr
->magic_cookie
);
958 if (mc
!= PPTP_MAGIC_COOKIE
) {
959 ND_PRINT(" UNEXPECTED Magic-Cookie!!(%08x)", mc
);
961 if (ndo
->ndo_vflag
|| mc
!= PPTP_MAGIC_COOKIE
) {
962 ND_PRINT(" Magic-Cookie=%08x", mc
);
964 ND_TCHECK_2(hdr
->ctrl_msg_type
);
965 ctrl_msg_type
= EXTRACT_BE_U_2(hdr
->ctrl_msg_type
);
966 if (ctrl_msg_type
< PPTP_MAX_MSGTYPE_INDEX
) {
967 ND_PRINT(" CTRL_MSGTYPE=%s",
968 pptp_message_type_string
[ctrl_msg_type
]);
970 ND_PRINT(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type
);
972 ND_TCHECK_2(hdr
->reserved0
);
973 PRINT_RESERVED_IF_NOT_ZERO_2(hdr
->reserved0
);
977 switch(ctrl_msg_type
) {
978 case PPTP_CTRL_MSG_TYPE_SCCRQ
:
979 pptp_sccrq_print(ndo
, dat
);
981 case PPTP_CTRL_MSG_TYPE_SCCRP
:
982 pptp_sccrp_print(ndo
, dat
);
984 case PPTP_CTRL_MSG_TYPE_StopCCRQ
:
985 pptp_stopccrq_print(ndo
, dat
);
987 case PPTP_CTRL_MSG_TYPE_StopCCRP
:
988 pptp_stopccrp_print(ndo
, dat
);
990 case PPTP_CTRL_MSG_TYPE_ECHORQ
:
991 pptp_echorq_print(ndo
, dat
);
993 case PPTP_CTRL_MSG_TYPE_ECHORP
:
994 pptp_echorp_print(ndo
, dat
);
996 case PPTP_CTRL_MSG_TYPE_OCRQ
:
997 pptp_ocrq_print(ndo
, dat
);
999 case PPTP_CTRL_MSG_TYPE_OCRP
:
1000 pptp_ocrp_print(ndo
, dat
);
1002 case PPTP_CTRL_MSG_TYPE_ICRQ
:
1003 pptp_icrq_print(ndo
, dat
);
1005 case PPTP_CTRL_MSG_TYPE_ICRP
:
1006 pptp_icrp_print(ndo
, dat
);
1008 case PPTP_CTRL_MSG_TYPE_ICCN
:
1009 pptp_iccn_print(ndo
, dat
);
1011 case PPTP_CTRL_MSG_TYPE_CCRQ
:
1012 pptp_ccrq_print(ndo
, dat
);
1014 case PPTP_CTRL_MSG_TYPE_CDN
:
1015 pptp_cdn_print(ndo
, dat
);
1017 case PPTP_CTRL_MSG_TYPE_WEN
:
1018 pptp_wen_print(ndo
, dat
);
1020 case PPTP_CTRL_MSG_TYPE_SLI
:
1021 pptp_sli_print(ndo
, dat
);
1031 ND_PRINT("%s", tstr
);