1a90e161bSBill Fenner /*
2a90e161bSBill Fenner * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3a90e161bSBill Fenner * The Regents of the University of California. All rights reserved.
4a90e161bSBill Fenner *
5a90e161bSBill Fenner * Redistribution and use in source and binary forms, with or without
6a90e161bSBill Fenner * modification, are permitted provided that: (1) source code distributions
7a90e161bSBill Fenner * retain the above copyright notice and this paragraph in its entirety, (2)
8a90e161bSBill Fenner * distributions including binary code include the above copyright notice and
9a90e161bSBill Fenner * this paragraph in its entirety in the documentation or other materials
10a90e161bSBill Fenner * provided with the distribution, and (3) all advertising materials mentioning
11a90e161bSBill Fenner * features or use of this software display the following acknowledgement:
12a90e161bSBill Fenner * ``This product includes software developed by the University of California,
13a90e161bSBill Fenner * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14a90e161bSBill Fenner * the University nor the names of its contributors may be used to endorse
15a90e161bSBill Fenner * or promote products derived from this software without specific prior
16a90e161bSBill Fenner * written permission.
17a90e161bSBill Fenner * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18a90e161bSBill Fenner * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19a90e161bSBill Fenner * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20a90e161bSBill Fenner *
21a90e161bSBill Fenner * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
22a90e161bSBill Fenner */
23a90e161bSBill Fenner
243340d773SGleb Smirnoff /* \summary: Point-to-Point Tunnelling Protocol (PPTP) printer */
253340d773SGleb Smirnoff
26*ee67461eSJoseph Mingrone /* specification: RFC 2637 */
27*ee67461eSJoseph Mingrone
28*ee67461eSJoseph Mingrone #include <config.h>
29a90e161bSBill Fenner
30*ee67461eSJoseph Mingrone #include "netdissect-stdinc.h"
315b0fe478SBruce M Simpson
323340d773SGleb Smirnoff #include "netdissect.h"
335b0fe478SBruce M Simpson #include "extract.h"
34a90e161bSBill Fenner
35a90e161bSBill Fenner
36a90e161bSBill Fenner #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
37a90e161bSBill Fenner #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
38a90e161bSBill Fenner #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
39a90e161bSBill Fenner
40a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SCCRQ 1
41a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SCCRP 2
42a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
43a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_StopCCRP 4
44a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ECHORQ 5
45a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ECHORP 6
46a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_OCRQ 7
47a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_OCRP 8
48a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICRQ 9
49a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICRP 10
50a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_ICCN 11
51a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_CCRQ 12
52a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_CDN 13
53a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_WEN 14
54a90e161bSBill Fenner #define PPTP_CTRL_MSG_TYPE_SLI 15
55a90e161bSBill Fenner
56*ee67461eSJoseph Mingrone #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Asynchronous */
57a90e161bSBill Fenner #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
58a90e161bSBill Fenner
59a90e161bSBill Fenner #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
60a90e161bSBill Fenner #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
61a90e161bSBill Fenner
625b0fe478SBruce M Simpson static const char *pptp_message_type_string[] = {
63a90e161bSBill Fenner "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
64a90e161bSBill Fenner "SCCRQ", /* 1 Start-Control-Connection-Request */
65a90e161bSBill Fenner "SCCRP", /* 2 Start-Control-Connection-Reply */
66a90e161bSBill Fenner "StopCCRQ", /* 3 Stop-Control-Connection-Request */
67a90e161bSBill Fenner "StopCCRP", /* 4 Stop-Control-Connection-Reply */
68a90e161bSBill Fenner "ECHORQ", /* 5 Echo Request */
69a90e161bSBill Fenner "ECHORP", /* 6 Echo Reply */
70a90e161bSBill Fenner
71a90e161bSBill Fenner "OCRQ", /* 7 Outgoing-Call-Request */
72a90e161bSBill Fenner "OCRP", /* 8 Outgoing-Call-Reply */
73a90e161bSBill Fenner "ICRQ", /* 9 Incoming-Call-Request */
74a90e161bSBill Fenner "ICRP", /* 10 Incoming-Call-Reply */
75a90e161bSBill Fenner "ICCN", /* 11 Incoming-Call-Connected */
76a90e161bSBill Fenner "CCRQ", /* 12 Call-Clear-Request */
77a90e161bSBill Fenner "CDN", /* 13 Call-Disconnect-Notify */
78a90e161bSBill Fenner
79a90e161bSBill Fenner "WEN", /* 14 WAN-Error-Notify */
80a90e161bSBill Fenner
81a90e161bSBill Fenner "SLI" /* 15 Set-Link-Info */
82a90e161bSBill Fenner #define PPTP_MAX_MSGTYPE_INDEX 16
83a90e161bSBill Fenner };
84a90e161bSBill Fenner
85a90e161bSBill Fenner /* common for all PPTP control messages */
86a90e161bSBill Fenner struct pptp_hdr {
87*ee67461eSJoseph Mingrone nd_uint16_t length;
88*ee67461eSJoseph Mingrone nd_uint16_t msg_type;
89*ee67461eSJoseph Mingrone nd_uint32_t magic_cookie;
90*ee67461eSJoseph Mingrone nd_uint16_t ctrl_msg_type;
91*ee67461eSJoseph Mingrone nd_uint16_t reserved0;
92a90e161bSBill Fenner };
93a90e161bSBill Fenner
94a90e161bSBill Fenner struct pptp_msg_sccrq {
95*ee67461eSJoseph Mingrone nd_uint16_t proto_ver;
96*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
97*ee67461eSJoseph Mingrone nd_uint32_t framing_cap;
98*ee67461eSJoseph Mingrone nd_uint32_t bearer_cap;
99*ee67461eSJoseph Mingrone nd_uint16_t max_channel;
100*ee67461eSJoseph Mingrone nd_uint16_t firm_rev;
101*ee67461eSJoseph Mingrone nd_byte hostname[64];
102*ee67461eSJoseph Mingrone nd_byte vendor[64];
103a90e161bSBill Fenner };
104a90e161bSBill Fenner
105a90e161bSBill Fenner struct pptp_msg_sccrp {
106*ee67461eSJoseph Mingrone nd_uint16_t proto_ver;
107*ee67461eSJoseph Mingrone nd_uint8_t result_code;
108*ee67461eSJoseph Mingrone nd_uint8_t err_code;
109*ee67461eSJoseph Mingrone nd_uint32_t framing_cap;
110*ee67461eSJoseph Mingrone nd_uint32_t bearer_cap;
111*ee67461eSJoseph Mingrone nd_uint16_t max_channel;
112*ee67461eSJoseph Mingrone nd_uint16_t firm_rev;
113*ee67461eSJoseph Mingrone nd_byte hostname[64];
114*ee67461eSJoseph Mingrone nd_byte vendor[64];
115a90e161bSBill Fenner };
116a90e161bSBill Fenner
117a90e161bSBill Fenner struct pptp_msg_stopccrq {
118*ee67461eSJoseph Mingrone nd_uint8_t reason;
119*ee67461eSJoseph Mingrone nd_uint8_t reserved1;
120*ee67461eSJoseph Mingrone nd_uint16_t reserved2;
121a90e161bSBill Fenner };
122a90e161bSBill Fenner
123a90e161bSBill Fenner struct pptp_msg_stopccrp {
124*ee67461eSJoseph Mingrone nd_uint8_t result_code;
125*ee67461eSJoseph Mingrone nd_uint8_t err_code;
126*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
127a90e161bSBill Fenner };
128a90e161bSBill Fenner
129a90e161bSBill Fenner struct pptp_msg_echorq {
130*ee67461eSJoseph Mingrone nd_uint32_t id;
131a90e161bSBill Fenner };
132a90e161bSBill Fenner
133a90e161bSBill Fenner struct pptp_msg_echorp {
134*ee67461eSJoseph Mingrone nd_uint32_t id;
135*ee67461eSJoseph Mingrone nd_uint8_t result_code;
136*ee67461eSJoseph Mingrone nd_uint8_t err_code;
137*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
138a90e161bSBill Fenner };
139a90e161bSBill Fenner
140a90e161bSBill Fenner struct pptp_msg_ocrq {
141*ee67461eSJoseph Mingrone nd_uint16_t call_id;
142*ee67461eSJoseph Mingrone nd_uint16_t call_ser;
143*ee67461eSJoseph Mingrone nd_uint32_t min_bps;
144*ee67461eSJoseph Mingrone nd_uint32_t max_bps;
145*ee67461eSJoseph Mingrone nd_uint32_t bearer_type;
146*ee67461eSJoseph Mingrone nd_uint32_t framing_type;
147*ee67461eSJoseph Mingrone nd_uint16_t recv_winsiz;
148*ee67461eSJoseph Mingrone nd_uint16_t pkt_proc_delay;
149*ee67461eSJoseph Mingrone nd_uint16_t phone_no_len;
150*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
151*ee67461eSJoseph Mingrone nd_byte phone_no[64];
152*ee67461eSJoseph Mingrone nd_byte subaddr[64];
153a90e161bSBill Fenner };
154a90e161bSBill Fenner
155a90e161bSBill Fenner struct pptp_msg_ocrp {
156*ee67461eSJoseph Mingrone nd_uint16_t call_id;
157*ee67461eSJoseph Mingrone nd_uint16_t peer_call_id;
158*ee67461eSJoseph Mingrone nd_uint8_t result_code;
159*ee67461eSJoseph Mingrone nd_uint8_t err_code;
160*ee67461eSJoseph Mingrone nd_uint16_t cause_code;
161*ee67461eSJoseph Mingrone nd_uint32_t conn_speed;
162*ee67461eSJoseph Mingrone nd_uint16_t recv_winsiz;
163*ee67461eSJoseph Mingrone nd_uint16_t pkt_proc_delay;
164*ee67461eSJoseph Mingrone nd_uint32_t phy_chan_id;
165a90e161bSBill Fenner };
166a90e161bSBill Fenner
167a90e161bSBill Fenner struct pptp_msg_icrq {
168*ee67461eSJoseph Mingrone nd_uint16_t call_id;
169*ee67461eSJoseph Mingrone nd_uint16_t call_ser;
170*ee67461eSJoseph Mingrone nd_uint32_t bearer_type;
171*ee67461eSJoseph Mingrone nd_uint32_t phy_chan_id;
172*ee67461eSJoseph Mingrone nd_uint16_t dialed_no_len;
173*ee67461eSJoseph Mingrone nd_uint16_t dialing_no_len;
174*ee67461eSJoseph Mingrone nd_byte dialed_no[64]; /* DNIS */
175*ee67461eSJoseph Mingrone nd_byte dialing_no[64]; /* CLID */
176*ee67461eSJoseph Mingrone nd_byte subaddr[64];
177a90e161bSBill Fenner };
178a90e161bSBill Fenner
179a90e161bSBill Fenner struct pptp_msg_icrp {
180*ee67461eSJoseph Mingrone nd_uint16_t call_id;
181*ee67461eSJoseph Mingrone nd_uint16_t peer_call_id;
182*ee67461eSJoseph Mingrone nd_uint8_t result_code;
183*ee67461eSJoseph Mingrone nd_uint8_t err_code;
184*ee67461eSJoseph Mingrone nd_uint16_t recv_winsiz;
185*ee67461eSJoseph Mingrone nd_uint16_t pkt_proc_delay;
186*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
187a90e161bSBill Fenner };
188a90e161bSBill Fenner
189a90e161bSBill Fenner struct pptp_msg_iccn {
190*ee67461eSJoseph Mingrone nd_uint16_t peer_call_id;
191*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
192*ee67461eSJoseph Mingrone nd_uint32_t conn_speed;
193*ee67461eSJoseph Mingrone nd_uint16_t recv_winsiz;
194*ee67461eSJoseph Mingrone nd_uint16_t pkt_proc_delay;
195*ee67461eSJoseph Mingrone nd_uint32_t framing_type;
196a90e161bSBill Fenner };
197a90e161bSBill Fenner
198a90e161bSBill Fenner struct pptp_msg_ccrq {
199*ee67461eSJoseph Mingrone nd_uint16_t call_id;
200*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
201a90e161bSBill Fenner };
202a90e161bSBill Fenner
203a90e161bSBill Fenner struct pptp_msg_cdn {
204*ee67461eSJoseph Mingrone nd_uint16_t call_id;
205*ee67461eSJoseph Mingrone nd_uint8_t result_code;
206*ee67461eSJoseph Mingrone nd_uint8_t err_code;
207*ee67461eSJoseph Mingrone nd_uint16_t cause_code;
208*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
209*ee67461eSJoseph Mingrone nd_byte call_stats[128];
210a90e161bSBill Fenner };
211a90e161bSBill Fenner
212a90e161bSBill Fenner struct pptp_msg_wen {
213*ee67461eSJoseph Mingrone nd_uint16_t peer_call_id;
214*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
215*ee67461eSJoseph Mingrone nd_uint32_t crc_err;
216*ee67461eSJoseph Mingrone nd_uint32_t framing_err;
217*ee67461eSJoseph Mingrone nd_uint32_t hardware_overrun;
218*ee67461eSJoseph Mingrone nd_uint32_t buffer_overrun;
219*ee67461eSJoseph Mingrone nd_uint32_t timeout_err;
220*ee67461eSJoseph Mingrone nd_uint32_t align_err;
221a90e161bSBill Fenner };
222a90e161bSBill Fenner
223a90e161bSBill Fenner struct pptp_msg_sli {
224*ee67461eSJoseph Mingrone nd_uint16_t peer_call_id;
225*ee67461eSJoseph Mingrone nd_uint16_t reserved1;
226*ee67461eSJoseph Mingrone nd_uint32_t send_accm;
227*ee67461eSJoseph Mingrone nd_uint32_t recv_accm;
228a90e161bSBill Fenner };
229a90e161bSBill Fenner
230a90e161bSBill Fenner /* attributes that appear more than once in above messages:
231a90e161bSBill Fenner
232a90e161bSBill Fenner Number of
233*ee67461eSJoseph Mingrone occurrence attributes
234a90e161bSBill Fenner --------------------------------------
2353c602fabSXin LI 2 uint32_t bearer_cap;
2363c602fabSXin LI 2 uint32_t bearer_type;
2373c602fabSXin LI 6 uint16_t call_id;
2383c602fabSXin LI 2 uint16_t call_ser;
2393c602fabSXin LI 2 uint16_t cause_code;
2403c602fabSXin LI 2 uint32_t conn_speed;
2413c602fabSXin LI 6 uint8_t err_code;
2423c602fabSXin LI 2 uint16_t firm_rev;
2433c602fabSXin LI 2 uint32_t framing_cap;
2443c602fabSXin LI 2 uint32_t framing_type;
245a90e161bSBill Fenner 2 u_char hostname[64];
2463c602fabSXin LI 2 uint32_t id;
2473c602fabSXin LI 2 uint16_t max_channel;
2483c602fabSXin LI 5 uint16_t peer_call_id;
2493c602fabSXin LI 2 uint32_t phy_chan_id;
2503c602fabSXin LI 4 uint16_t pkt_proc_delay;
2513c602fabSXin LI 2 uint16_t proto_ver;
2523c602fabSXin LI 4 uint16_t recv_winsiz;
2533c602fabSXin LI 2 uint8_t reserved1;
2543c602fabSXin LI 9 uint16_t reserved1;
2553c602fabSXin LI 6 uint8_t result_code;
256a90e161bSBill Fenner 2 u_char subaddr[64];
257a90e161bSBill Fenner 2 u_char vendor[64];
258a90e161bSBill Fenner
259a90e161bSBill Fenner so I will prepare print out functions for these attributes (except for
260a90e161bSBill Fenner reserved*).
261a90e161bSBill Fenner */
262a90e161bSBill Fenner
263*ee67461eSJoseph Mingrone #define PRINT_RESERVED_IF_NOT_ZERO_1(reserved) \
264*ee67461eSJoseph Mingrone if (GET_U_1(reserved)) \
265*ee67461eSJoseph Mingrone ND_PRINT(" [ERROR: reserved=%u must be zero]", \
266*ee67461eSJoseph Mingrone GET_U_1(reserved));
267*ee67461eSJoseph Mingrone
268*ee67461eSJoseph Mingrone #define PRINT_RESERVED_IF_NOT_ZERO_2(reserved) \
269*ee67461eSJoseph Mingrone if (GET_BE_U_2(reserved)) \
270*ee67461eSJoseph Mingrone ND_PRINT(" [ERROR: reserved=%u must be zero]", \
271*ee67461eSJoseph Mingrone GET_BE_U_2(reserved));
272*ee67461eSJoseph Mingrone
273a90e161bSBill Fenner /******************************************/
274a90e161bSBill Fenner /* Attribute-specific print out functions */
275a90e161bSBill Fenner /******************************************/
276a90e161bSBill Fenner
277a90e161bSBill Fenner static void
pptp_bearer_cap_print(netdissect_options * ndo,const nd_uint32_t bearer_cap)2783c602fabSXin LI pptp_bearer_cap_print(netdissect_options *ndo,
279*ee67461eSJoseph Mingrone const nd_uint32_t bearer_cap)
280a90e161bSBill Fenner {
281*ee67461eSJoseph Mingrone ND_PRINT(" BEARER_CAP(%s%s)",
282*ee67461eSJoseph Mingrone GET_BE_U_4(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
283*ee67461eSJoseph Mingrone GET_BE_U_4(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : "");
284a90e161bSBill Fenner }
2853c602fabSXin LI
2863c602fabSXin LI static const struct tok pptp_btype_str[] = {
2873c602fabSXin LI { 1, "A" }, /* Analog */
2883c602fabSXin LI { 2, "D" }, /* Digital */
2893c602fabSXin LI { 3, "Any" },
2903c602fabSXin LI { 0, NULL }
2913c602fabSXin LI };
2923c602fabSXin LI
2933c602fabSXin LI static void
pptp_bearer_type_print(netdissect_options * ndo,const nd_uint32_t bearer_type)2943c602fabSXin LI pptp_bearer_type_print(netdissect_options *ndo,
295*ee67461eSJoseph Mingrone const nd_uint32_t bearer_type)
2963c602fabSXin LI {
297*ee67461eSJoseph Mingrone ND_PRINT(" BEARER_TYPE(%s)",
298*ee67461eSJoseph Mingrone tok2str(pptp_btype_str, "?", GET_BE_U_4(bearer_type)));
299a90e161bSBill Fenner }
300a90e161bSBill Fenner
301a90e161bSBill Fenner static void
pptp_call_id_print(netdissect_options * ndo,const nd_uint16_t call_id)3023c602fabSXin LI pptp_call_id_print(netdissect_options *ndo,
303*ee67461eSJoseph Mingrone const nd_uint16_t call_id)
304a90e161bSBill Fenner {
305*ee67461eSJoseph Mingrone ND_PRINT(" CALL_ID(%u)", GET_BE_U_2(call_id));
306a90e161bSBill Fenner }
307a90e161bSBill Fenner
308a90e161bSBill Fenner static void
pptp_call_ser_print(netdissect_options * ndo,const nd_uint16_t call_ser)3093c602fabSXin LI pptp_call_ser_print(netdissect_options *ndo,
310*ee67461eSJoseph Mingrone const nd_uint16_t call_ser)
311a90e161bSBill Fenner {
312*ee67461eSJoseph Mingrone ND_PRINT(" CALL_SER_NUM(%u)", GET_BE_U_2(call_ser));
313a90e161bSBill Fenner }
314a90e161bSBill Fenner
315a90e161bSBill Fenner static void
pptp_cause_code_print(netdissect_options * ndo,const nd_uint16_t cause_code)3163c602fabSXin LI pptp_cause_code_print(netdissect_options *ndo,
317*ee67461eSJoseph Mingrone const nd_uint16_t cause_code)
318a90e161bSBill Fenner {
319*ee67461eSJoseph Mingrone ND_PRINT(" CAUSE_CODE(%u)", GET_BE_U_2(cause_code));
320a90e161bSBill Fenner }
321a90e161bSBill Fenner
322a90e161bSBill Fenner static void
pptp_conn_speed_print(netdissect_options * ndo,const nd_uint32_t conn_speed)3233c602fabSXin LI pptp_conn_speed_print(netdissect_options *ndo,
324*ee67461eSJoseph Mingrone const nd_uint32_t conn_speed)
325a90e161bSBill Fenner {
326*ee67461eSJoseph Mingrone ND_PRINT(" CONN_SPEED(%u)", GET_BE_U_4(conn_speed));
3273c602fabSXin LI }
3283c602fabSXin LI
3293c602fabSXin LI static const struct tok pptp_errcode_str[] = {
3303c602fabSXin LI { 0, "None" },
3313c602fabSXin LI { 1, "Not-Connected" },
3323c602fabSXin LI { 2, "Bad-Format" },
3333c602fabSXin LI { 3, "Bad-Value" },
3343c602fabSXin LI { 4, "No-Resource" },
3353c602fabSXin LI { 5, "Bad-Call-ID" },
3363c602fabSXin LI { 6, "PAC-Error" },
3373c602fabSXin LI { 0, NULL }
3383c602fabSXin LI };
3393c602fabSXin LI
3403c602fabSXin LI static void
pptp_err_code_print(netdissect_options * ndo,const nd_uint8_t err_code)3413c602fabSXin LI pptp_err_code_print(netdissect_options *ndo,
342*ee67461eSJoseph Mingrone const nd_uint8_t err_code)
3433c602fabSXin LI {
344*ee67461eSJoseph Mingrone ND_PRINT(" ERR_CODE(%u", GET_U_1(err_code));
3453c602fabSXin LI if (ndo->ndo_vflag) {
346*ee67461eSJoseph Mingrone ND_PRINT(":%s",
347*ee67461eSJoseph Mingrone tok2str(pptp_errcode_str, "?", GET_U_1(err_code)));
3483c602fabSXin LI }
349*ee67461eSJoseph Mingrone ND_PRINT(")");
350a90e161bSBill Fenner }
351a90e161bSBill Fenner
352a90e161bSBill Fenner static void
pptp_firm_rev_print(netdissect_options * ndo,const nd_uint16_t firm_rev)3533c602fabSXin LI pptp_firm_rev_print(netdissect_options *ndo,
354*ee67461eSJoseph Mingrone const nd_uint16_t firm_rev)
355a90e161bSBill Fenner {
356*ee67461eSJoseph Mingrone ND_PRINT(" FIRM_REV(%u)", GET_BE_U_2(firm_rev));
357a90e161bSBill Fenner }
358a90e161bSBill Fenner
359a90e161bSBill Fenner static void
pptp_framing_cap_print(netdissect_options * ndo,const nd_uint32_t framing_cap)3603c602fabSXin LI pptp_framing_cap_print(netdissect_options *ndo,
361*ee67461eSJoseph Mingrone const nd_uint32_t framing_cap)
362a90e161bSBill Fenner {
363*ee67461eSJoseph Mingrone ND_PRINT(" FRAME_CAP(");
364*ee67461eSJoseph Mingrone if (GET_BE_U_4(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
365*ee67461eSJoseph Mingrone ND_PRINT("A"); /* Async */
366a90e161bSBill Fenner }
367*ee67461eSJoseph Mingrone if (GET_BE_U_4(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
368*ee67461eSJoseph Mingrone ND_PRINT("S"); /* Sync */
369a90e161bSBill Fenner }
370*ee67461eSJoseph Mingrone ND_PRINT(")");
3713c602fabSXin LI }
3723c602fabSXin LI
3733c602fabSXin LI static const struct tok pptp_ftype_str[] = {
3743c602fabSXin LI { 1, "A" }, /* Async */
3753c602fabSXin LI { 2, "S" }, /* Sync */
3763c602fabSXin LI { 3, "E" }, /* Either */
3773c602fabSXin LI { 0, NULL }
3783c602fabSXin LI };
3793c602fabSXin LI
3803c602fabSXin LI static void
pptp_framing_type_print(netdissect_options * ndo,const nd_uint32_t framing_type)3813c602fabSXin LI pptp_framing_type_print(netdissect_options *ndo,
382*ee67461eSJoseph Mingrone const nd_uint32_t framing_type)
3833c602fabSXin LI {
384*ee67461eSJoseph Mingrone ND_PRINT(" FRAME_TYPE(%s)",
385*ee67461eSJoseph Mingrone tok2str(pptp_ftype_str, "?", GET_BE_U_4(framing_type)));
386a90e161bSBill Fenner }
387a90e161bSBill Fenner
388a90e161bSBill Fenner static void
pptp_hostname_print(netdissect_options * ndo,const u_char * hostname)3893c602fabSXin LI pptp_hostname_print(netdissect_options *ndo,
3903c602fabSXin LI const u_char *hostname)
391a90e161bSBill Fenner {
392*ee67461eSJoseph Mingrone ND_PRINT(" HOSTNAME(");
393*ee67461eSJoseph Mingrone nd_printjnp(ndo, hostname, 64);
394*ee67461eSJoseph Mingrone ND_PRINT(")");
395a90e161bSBill Fenner }
396a90e161bSBill Fenner
397a90e161bSBill Fenner static void
pptp_id_print(netdissect_options * ndo,const nd_uint32_t id)3983c602fabSXin LI pptp_id_print(netdissect_options *ndo,
399*ee67461eSJoseph Mingrone const nd_uint32_t id)
400a90e161bSBill Fenner {
401*ee67461eSJoseph Mingrone ND_PRINT(" ID(%u)", GET_BE_U_4(id));
402a90e161bSBill Fenner }
403a90e161bSBill Fenner
404a90e161bSBill Fenner static void
pptp_max_channel_print(netdissect_options * ndo,const nd_uint16_t max_channel)4053c602fabSXin LI pptp_max_channel_print(netdissect_options *ndo,
406*ee67461eSJoseph Mingrone const nd_uint16_t max_channel)
407a90e161bSBill Fenner {
408*ee67461eSJoseph Mingrone ND_PRINT(" MAX_CHAN(%u)", GET_BE_U_2(max_channel));
409a90e161bSBill Fenner }
410a90e161bSBill Fenner
411a90e161bSBill Fenner static void
pptp_peer_call_id_print(netdissect_options * ndo,const nd_uint16_t peer_call_id)4123c602fabSXin LI pptp_peer_call_id_print(netdissect_options *ndo,
413*ee67461eSJoseph Mingrone const nd_uint16_t peer_call_id)
414a90e161bSBill Fenner {
415*ee67461eSJoseph Mingrone ND_PRINT(" PEER_CALL_ID(%u)", GET_BE_U_2(peer_call_id));
416a90e161bSBill Fenner }
417a90e161bSBill Fenner
418a90e161bSBill Fenner static void
pptp_phy_chan_id_print(netdissect_options * ndo,const nd_uint32_t phy_chan_id)4193c602fabSXin LI pptp_phy_chan_id_print(netdissect_options *ndo,
420*ee67461eSJoseph Mingrone const nd_uint32_t phy_chan_id)
421a90e161bSBill Fenner {
422*ee67461eSJoseph Mingrone ND_PRINT(" PHY_CHAN_ID(%u)", GET_BE_U_4(phy_chan_id));
423a90e161bSBill Fenner }
424a90e161bSBill Fenner
425a90e161bSBill Fenner static void
pptp_pkt_proc_delay_print(netdissect_options * ndo,const nd_uint16_t pkt_proc_delay)4263c602fabSXin LI pptp_pkt_proc_delay_print(netdissect_options *ndo,
427*ee67461eSJoseph Mingrone const nd_uint16_t pkt_proc_delay)
428a90e161bSBill Fenner {
429*ee67461eSJoseph Mingrone ND_PRINT(" PROC_DELAY(%u)", GET_BE_U_2(pkt_proc_delay));
430a90e161bSBill Fenner }
431a90e161bSBill Fenner
432a90e161bSBill Fenner static void
pptp_proto_ver_print(netdissect_options * ndo,const nd_uint16_t proto_ver)4333c602fabSXin LI pptp_proto_ver_print(netdissect_options *ndo,
434*ee67461eSJoseph Mingrone const nd_uint16_t proto_ver)
435a90e161bSBill Fenner {
436*ee67461eSJoseph Mingrone ND_PRINT(" PROTO_VER(%u.%u)", /* Version.Revision */
437*ee67461eSJoseph Mingrone GET_BE_U_2(proto_ver) >> 8,
438*ee67461eSJoseph Mingrone GET_BE_U_2(proto_ver) & 0xff);
439a90e161bSBill Fenner }
440a90e161bSBill Fenner
441a90e161bSBill Fenner static void
pptp_recv_winsiz_print(netdissect_options * ndo,const nd_uint16_t recv_winsiz)4423c602fabSXin LI pptp_recv_winsiz_print(netdissect_options *ndo,
443*ee67461eSJoseph Mingrone const nd_uint16_t recv_winsiz)
444a90e161bSBill Fenner {
445*ee67461eSJoseph Mingrone ND_PRINT(" RECV_WIN(%u)", GET_BE_U_2(recv_winsiz));
4463c602fabSXin LI }
4473c602fabSXin LI
4483c602fabSXin LI static const struct tok pptp_scrrp_str[] = {
4493c602fabSXin LI { 1, "Successful channel establishment" },
4503c602fabSXin LI { 2, "General error" },
4513c602fabSXin LI { 3, "Command channel already exists" },
4523c602fabSXin LI { 4, "Requester is not authorized to establish a command channel" },
4533c602fabSXin LI { 5, "The protocol version of the requester is not supported" },
4543c602fabSXin LI { 0, NULL }
4553c602fabSXin LI };
4563c602fabSXin LI
4573c602fabSXin LI static const struct tok pptp_echorp_str[] = {
4583c602fabSXin LI { 1, "OK" },
4593c602fabSXin LI { 2, "General Error" },
4603c602fabSXin LI { 0, NULL }
4613c602fabSXin LI };
4623c602fabSXin LI
4633c602fabSXin LI static const struct tok pptp_ocrp_str[] = {
4643c602fabSXin LI { 1, "Connected" },
4653c602fabSXin LI { 2, "General Error" },
4663c602fabSXin LI { 3, "No Carrier" },
4673c602fabSXin LI { 4, "Busy" },
4683c602fabSXin LI { 5, "No Dial Tone" },
4693c602fabSXin LI { 6, "Time-out" },
4703c602fabSXin LI { 7, "Do Not Accept" },
4713c602fabSXin LI { 0, NULL }
4723c602fabSXin LI };
4733c602fabSXin LI
4743c602fabSXin LI static const struct tok pptp_icrp_str[] = {
4753c602fabSXin LI { 1, "Connect" },
4763c602fabSXin LI { 2, "General Error" },
4773c602fabSXin LI { 3, "Do Not Accept" },
4783c602fabSXin LI { 0, NULL }
4793c602fabSXin LI };
4803c602fabSXin LI
4813c602fabSXin LI static const struct tok pptp_cdn_str[] = {
4823c602fabSXin LI { 1, "Lost Carrier" },
4833c602fabSXin LI { 2, "General Error" },
4843c602fabSXin LI { 3, "Admin Shutdown" },
4853c602fabSXin LI { 4, "Request" },
4863c602fabSXin LI { 0, NULL }
4873c602fabSXin LI };
4883c602fabSXin LI
4893c602fabSXin LI static void
pptp_result_code_print(netdissect_options * ndo,const nd_uint8_t result_code,int ctrl_msg_type)4903c602fabSXin LI pptp_result_code_print(netdissect_options *ndo,
491*ee67461eSJoseph Mingrone const nd_uint8_t result_code, int ctrl_msg_type)
4923c602fabSXin LI {
493*ee67461eSJoseph Mingrone ND_PRINT(" RESULT_CODE(%u", GET_U_1(result_code));
4943c602fabSXin LI if (ndo->ndo_vflag) {
4953c602fabSXin LI const struct tok *dict =
4963c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
4973c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
4983c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
4993c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
5003c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
5013c602fabSXin LI ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
5023c602fabSXin LI NULL; /* assertion error */
5033c602fabSXin LI if (dict != NULL)
504*ee67461eSJoseph Mingrone ND_PRINT(":%s",
505*ee67461eSJoseph Mingrone tok2str(dict, "?", GET_U_1(result_code)));
5063c602fabSXin LI }
507*ee67461eSJoseph Mingrone ND_PRINT(")");
508a90e161bSBill Fenner }
509a90e161bSBill Fenner
510a90e161bSBill Fenner static void
pptp_subaddr_print(netdissect_options * ndo,const u_char * subaddr)5113c602fabSXin LI pptp_subaddr_print(netdissect_options *ndo,
5123c602fabSXin LI const u_char *subaddr)
513a90e161bSBill Fenner {
514*ee67461eSJoseph Mingrone ND_PRINT(" SUB_ADDR(");
515*ee67461eSJoseph Mingrone nd_printjnp(ndo, subaddr, 64);
516*ee67461eSJoseph Mingrone ND_PRINT(")");
517a90e161bSBill Fenner }
518a90e161bSBill Fenner
519a90e161bSBill Fenner static void
pptp_vendor_print(netdissect_options * ndo,const u_char * vendor)5203c602fabSXin LI pptp_vendor_print(netdissect_options *ndo,
5213c602fabSXin LI const u_char *vendor)
522a90e161bSBill Fenner {
523*ee67461eSJoseph Mingrone ND_PRINT(" VENDOR(");
524*ee67461eSJoseph Mingrone nd_printjnp(ndo, vendor, 64);
525*ee67461eSJoseph Mingrone ND_PRINT(")");
526a90e161bSBill Fenner }
527a90e161bSBill Fenner
528a90e161bSBill Fenner /************************************/
529a90e161bSBill Fenner /* PPTP message print out functions */
530a90e161bSBill Fenner /************************************/
531a90e161bSBill Fenner static void
pptp_sccrq_print(netdissect_options * ndo,const u_char * dat)5323c602fabSXin LI pptp_sccrq_print(netdissect_options *ndo,
5333c602fabSXin LI const u_char *dat)
534a90e161bSBill Fenner {
5353340d773SGleb Smirnoff const struct pptp_msg_sccrq *ptr = (const struct pptp_msg_sccrq *)dat;
536a90e161bSBill Fenner
537*ee67461eSJoseph Mingrone pptp_proto_ver_print(ndo, ptr->proto_ver);
538*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
539*ee67461eSJoseph Mingrone pptp_framing_cap_print(ndo, ptr->framing_cap);
540*ee67461eSJoseph Mingrone pptp_bearer_cap_print(ndo, ptr->bearer_cap);
541*ee67461eSJoseph Mingrone pptp_max_channel_print(ndo, ptr->max_channel);
542*ee67461eSJoseph Mingrone pptp_firm_rev_print(ndo, ptr->firm_rev);
543*ee67461eSJoseph Mingrone pptp_hostname_print(ndo, ptr->hostname);
544*ee67461eSJoseph Mingrone pptp_vendor_print(ndo, ptr->vendor);
545a90e161bSBill Fenner }
546a90e161bSBill Fenner
547a90e161bSBill Fenner static void
pptp_sccrp_print(netdissect_options * ndo,const u_char * dat)5483c602fabSXin LI pptp_sccrp_print(netdissect_options *ndo,
5493c602fabSXin LI const u_char *dat)
550a90e161bSBill Fenner {
5513340d773SGleb Smirnoff const struct pptp_msg_sccrp *ptr = (const struct pptp_msg_sccrp *)dat;
552a90e161bSBill Fenner
553*ee67461eSJoseph Mingrone pptp_proto_ver_print(ndo, ptr->proto_ver);
554*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
555*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
556*ee67461eSJoseph Mingrone pptp_framing_cap_print(ndo, ptr->framing_cap);
557*ee67461eSJoseph Mingrone pptp_bearer_cap_print(ndo, ptr->bearer_cap);
558*ee67461eSJoseph Mingrone pptp_max_channel_print(ndo, ptr->max_channel);
559*ee67461eSJoseph Mingrone pptp_firm_rev_print(ndo, ptr->firm_rev);
560*ee67461eSJoseph Mingrone pptp_hostname_print(ndo, ptr->hostname);
561*ee67461eSJoseph Mingrone pptp_vendor_print(ndo, ptr->vendor);
562a90e161bSBill Fenner }
563a90e161bSBill Fenner
564a90e161bSBill Fenner static void
pptp_stopccrq_print(netdissect_options * ndo,const u_char * dat)5653c602fabSXin LI pptp_stopccrq_print(netdissect_options *ndo,
5663c602fabSXin LI const u_char *dat)
567a90e161bSBill Fenner {
5683340d773SGleb Smirnoff const struct pptp_msg_stopccrq *ptr = (const struct pptp_msg_stopccrq *)dat;
569a90e161bSBill Fenner
570*ee67461eSJoseph Mingrone ND_PRINT(" REASON(%u", GET_U_1(ptr->reason));
5713c602fabSXin LI if (ndo->ndo_vflag) {
572*ee67461eSJoseph Mingrone switch (GET_U_1(ptr->reason)) {
573a90e161bSBill Fenner case 1:
574*ee67461eSJoseph Mingrone ND_PRINT(":None");
575a90e161bSBill Fenner break;
576a90e161bSBill Fenner case 2:
577*ee67461eSJoseph Mingrone ND_PRINT(":Stop-Protocol");
578a90e161bSBill Fenner break;
579a90e161bSBill Fenner case 3:
580*ee67461eSJoseph Mingrone ND_PRINT(":Stop-Local-Shutdown");
581a90e161bSBill Fenner break;
582a90e161bSBill Fenner default:
583*ee67461eSJoseph Mingrone ND_PRINT(":?");
584a90e161bSBill Fenner break;
585a90e161bSBill Fenner }
586a90e161bSBill Fenner }
587*ee67461eSJoseph Mingrone ND_PRINT(")");
588*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_1(ptr->reserved1);
589*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved2);
590a90e161bSBill Fenner }
591a90e161bSBill Fenner
592a90e161bSBill Fenner static void
pptp_stopccrp_print(netdissect_options * ndo,const u_char * dat)5933c602fabSXin LI pptp_stopccrp_print(netdissect_options *ndo,
5943c602fabSXin LI const u_char *dat)
595a90e161bSBill Fenner {
5963340d773SGleb Smirnoff const struct pptp_msg_stopccrp *ptr = (const struct pptp_msg_stopccrp *)dat;
597a90e161bSBill Fenner
598*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
599*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
600*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
601a90e161bSBill Fenner }
602a90e161bSBill Fenner
603a90e161bSBill Fenner static void
pptp_echorq_print(netdissect_options * ndo,const u_char * dat)6043c602fabSXin LI pptp_echorq_print(netdissect_options *ndo,
6053c602fabSXin LI const u_char *dat)
606a90e161bSBill Fenner {
6073340d773SGleb Smirnoff const struct pptp_msg_echorq *ptr = (const struct pptp_msg_echorq *)dat;
608a90e161bSBill Fenner
609*ee67461eSJoseph Mingrone pptp_id_print(ndo, ptr->id);
610a90e161bSBill Fenner }
611a90e161bSBill Fenner
612a90e161bSBill Fenner static void
pptp_echorp_print(netdissect_options * ndo,const u_char * dat)6133c602fabSXin LI pptp_echorp_print(netdissect_options *ndo,
6143c602fabSXin LI const u_char *dat)
615a90e161bSBill Fenner {
6163340d773SGleb Smirnoff const struct pptp_msg_echorp *ptr = (const struct pptp_msg_echorp *)dat;
617a90e161bSBill Fenner
618*ee67461eSJoseph Mingrone pptp_id_print(ndo, ptr->id);
619*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
620*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
621*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
622a90e161bSBill Fenner }
623a90e161bSBill Fenner
624a90e161bSBill Fenner static void
pptp_ocrq_print(netdissect_options * ndo,const u_char * dat)6253c602fabSXin LI pptp_ocrq_print(netdissect_options *ndo,
6263c602fabSXin LI const u_char *dat)
627a90e161bSBill Fenner {
6283340d773SGleb Smirnoff const struct pptp_msg_ocrq *ptr = (const struct pptp_msg_ocrq *)dat;
629a90e161bSBill Fenner
630*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
631*ee67461eSJoseph Mingrone pptp_call_ser_print(ndo, ptr->call_ser);
632*ee67461eSJoseph Mingrone ND_PRINT(" MIN_BPS(%u)", GET_BE_U_4(ptr->min_bps));
633*ee67461eSJoseph Mingrone ND_PRINT(" MAX_BPS(%u)", GET_BE_U_4(ptr->max_bps));
634*ee67461eSJoseph Mingrone pptp_bearer_type_print(ndo, ptr->bearer_type);
635*ee67461eSJoseph Mingrone pptp_framing_type_print(ndo, ptr->framing_type);
636*ee67461eSJoseph Mingrone pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
637*ee67461eSJoseph Mingrone pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
638*ee67461eSJoseph Mingrone ND_PRINT(" PHONE_NO_LEN(%u)", GET_BE_U_2(ptr->phone_no_len));
639*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
640*ee67461eSJoseph Mingrone ND_PRINT(" PHONE_NO(");
641*ee67461eSJoseph Mingrone nd_printjnp(ndo, ptr->phone_no,
642*ee67461eSJoseph Mingrone ND_MIN(64, GET_BE_U_2(ptr->phone_no_len)));
643*ee67461eSJoseph Mingrone ND_PRINT(")");
644*ee67461eSJoseph Mingrone pptp_subaddr_print(ndo, ptr->subaddr);
645a90e161bSBill Fenner }
646a90e161bSBill Fenner
647a90e161bSBill Fenner static void
pptp_ocrp_print(netdissect_options * ndo,const u_char * dat)6483c602fabSXin LI pptp_ocrp_print(netdissect_options *ndo,
6493c602fabSXin LI const u_char *dat)
650a90e161bSBill Fenner {
6513340d773SGleb Smirnoff const struct pptp_msg_ocrp *ptr = (const struct pptp_msg_ocrp *)dat;
652a90e161bSBill Fenner
653*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
654*ee67461eSJoseph Mingrone pptp_peer_call_id_print(ndo, ptr->peer_call_id);
655*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
656*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
657*ee67461eSJoseph Mingrone pptp_cause_code_print(ndo, ptr->cause_code);
658*ee67461eSJoseph Mingrone pptp_conn_speed_print(ndo, ptr->conn_speed);
659*ee67461eSJoseph Mingrone pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
660*ee67461eSJoseph Mingrone pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
661*ee67461eSJoseph Mingrone pptp_phy_chan_id_print(ndo, ptr->phy_chan_id);
662a90e161bSBill Fenner }
663a90e161bSBill Fenner
664a90e161bSBill Fenner static void
pptp_icrq_print(netdissect_options * ndo,const u_char * dat)6653c602fabSXin LI pptp_icrq_print(netdissect_options *ndo,
6663c602fabSXin LI const u_char *dat)
667a90e161bSBill Fenner {
6683340d773SGleb Smirnoff const struct pptp_msg_icrq *ptr = (const struct pptp_msg_icrq *)dat;
669a90e161bSBill Fenner
670*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
671*ee67461eSJoseph Mingrone pptp_call_ser_print(ndo, ptr->call_ser);
672*ee67461eSJoseph Mingrone pptp_bearer_type_print(ndo, ptr->bearer_type);
673*ee67461eSJoseph Mingrone pptp_phy_chan_id_print(ndo, ptr->phy_chan_id);
674*ee67461eSJoseph Mingrone ND_PRINT(" DIALED_NO_LEN(%u)", GET_BE_U_2(ptr->dialed_no_len));
675*ee67461eSJoseph Mingrone ND_PRINT(" DIALING_NO_LEN(%u)", GET_BE_U_2(ptr->dialing_no_len));
676*ee67461eSJoseph Mingrone ND_PRINT(" DIALED_NO(");
677*ee67461eSJoseph Mingrone nd_printjnp(ndo, ptr->dialed_no,
678*ee67461eSJoseph Mingrone ND_MIN(64, GET_BE_U_2(ptr->dialed_no_len)));
679*ee67461eSJoseph Mingrone ND_PRINT(")");
680*ee67461eSJoseph Mingrone ND_PRINT(" DIALING_NO(");
681*ee67461eSJoseph Mingrone nd_printjnp(ndo, ptr->dialing_no,
682*ee67461eSJoseph Mingrone ND_MIN(64, GET_BE_U_2(ptr->dialing_no_len)));
683*ee67461eSJoseph Mingrone ND_PRINT(")");
684*ee67461eSJoseph Mingrone pptp_subaddr_print(ndo, ptr->subaddr);
685a90e161bSBill Fenner }
686a90e161bSBill Fenner
687a90e161bSBill Fenner static void
pptp_icrp_print(netdissect_options * ndo,const u_char * dat)6883c602fabSXin LI pptp_icrp_print(netdissect_options *ndo,
6893c602fabSXin LI const u_char *dat)
690a90e161bSBill Fenner {
6913340d773SGleb Smirnoff const struct pptp_msg_icrp *ptr = (const struct pptp_msg_icrp *)dat;
692a90e161bSBill Fenner
693*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
694*ee67461eSJoseph Mingrone pptp_peer_call_id_print(ndo, ptr->peer_call_id);
695*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
696*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
697*ee67461eSJoseph Mingrone pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
698*ee67461eSJoseph Mingrone pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
699*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
700a90e161bSBill Fenner }
701a90e161bSBill Fenner
702a90e161bSBill Fenner static void
pptp_iccn_print(netdissect_options * ndo,const u_char * dat)7033c602fabSXin LI pptp_iccn_print(netdissect_options *ndo,
7043c602fabSXin LI const u_char *dat)
705a90e161bSBill Fenner {
7063340d773SGleb Smirnoff const struct pptp_msg_iccn *ptr = (const struct pptp_msg_iccn *)dat;
707a90e161bSBill Fenner
708*ee67461eSJoseph Mingrone pptp_peer_call_id_print(ndo, ptr->peer_call_id);
709*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
710*ee67461eSJoseph Mingrone pptp_conn_speed_print(ndo, ptr->conn_speed);
711*ee67461eSJoseph Mingrone pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
712*ee67461eSJoseph Mingrone pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
713*ee67461eSJoseph Mingrone pptp_framing_type_print(ndo, ptr->framing_type);
714a90e161bSBill Fenner }
715a90e161bSBill Fenner
716a90e161bSBill Fenner static void
pptp_ccrq_print(netdissect_options * ndo,const u_char * dat)7173c602fabSXin LI pptp_ccrq_print(netdissect_options *ndo,
7183c602fabSXin LI const u_char *dat)
719a90e161bSBill Fenner {
7203340d773SGleb Smirnoff const struct pptp_msg_ccrq *ptr = (const struct pptp_msg_ccrq *)dat;
721a90e161bSBill Fenner
722*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
723*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
724a90e161bSBill Fenner }
725a90e161bSBill Fenner
726a90e161bSBill Fenner static void
pptp_cdn_print(netdissect_options * ndo,const u_char * dat)7273c602fabSXin LI pptp_cdn_print(netdissect_options *ndo,
7283c602fabSXin LI const u_char *dat)
729a90e161bSBill Fenner {
7303340d773SGleb Smirnoff const struct pptp_msg_cdn *ptr = (const struct pptp_msg_cdn *)dat;
731a90e161bSBill Fenner
732*ee67461eSJoseph Mingrone pptp_call_id_print(ndo, ptr->call_id);
733*ee67461eSJoseph Mingrone pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
734*ee67461eSJoseph Mingrone pptp_err_code_print(ndo, ptr->err_code);
735*ee67461eSJoseph Mingrone pptp_cause_code_print(ndo, ptr->cause_code);
736*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
737*ee67461eSJoseph Mingrone ND_PRINT(" CALL_STATS(");
738*ee67461eSJoseph Mingrone nd_printjnp(ndo, ptr->call_stats, 128);
739*ee67461eSJoseph Mingrone ND_PRINT(")");
740a90e161bSBill Fenner }
741a90e161bSBill Fenner
742a90e161bSBill Fenner static void
pptp_wen_print(netdissect_options * ndo,const u_char * dat)7433c602fabSXin LI pptp_wen_print(netdissect_options *ndo,
7443c602fabSXin LI const u_char *dat)
745a90e161bSBill Fenner {
7463340d773SGleb Smirnoff const struct pptp_msg_wen *ptr = (const struct pptp_msg_wen *)dat;
747a90e161bSBill Fenner
748*ee67461eSJoseph Mingrone pptp_peer_call_id_print(ndo, ptr->peer_call_id);
749*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
750*ee67461eSJoseph Mingrone ND_PRINT(" CRC_ERR(%u)", GET_BE_U_4(ptr->crc_err));
751*ee67461eSJoseph Mingrone ND_PRINT(" FRAMING_ERR(%u)", GET_BE_U_4(ptr->framing_err));
752*ee67461eSJoseph Mingrone ND_PRINT(" HARDWARE_OVERRUN(%u)", GET_BE_U_4(ptr->hardware_overrun));
753*ee67461eSJoseph Mingrone ND_PRINT(" BUFFER_OVERRUN(%u)", GET_BE_U_4(ptr->buffer_overrun));
754*ee67461eSJoseph Mingrone ND_PRINT(" TIMEOUT_ERR(%u)", GET_BE_U_4(ptr->timeout_err));
755*ee67461eSJoseph Mingrone ND_PRINT(" ALIGN_ERR(%u)", GET_BE_U_4(ptr->align_err));
756a90e161bSBill Fenner }
757a90e161bSBill Fenner
758a90e161bSBill Fenner static void
pptp_sli_print(netdissect_options * ndo,const u_char * dat)7593c602fabSXin LI pptp_sli_print(netdissect_options *ndo,
7603c602fabSXin LI const u_char *dat)
761a90e161bSBill Fenner {
7623340d773SGleb Smirnoff const struct pptp_msg_sli *ptr = (const struct pptp_msg_sli *)dat;
763a90e161bSBill Fenner
764*ee67461eSJoseph Mingrone pptp_peer_call_id_print(ndo, ptr->peer_call_id);
765*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
766*ee67461eSJoseph Mingrone ND_PRINT(" SEND_ACCM(0x%08x)", GET_BE_U_4(ptr->send_accm));
767*ee67461eSJoseph Mingrone ND_PRINT(" RECV_ACCM(0x%08x)", GET_BE_U_4(ptr->recv_accm));
768a90e161bSBill Fenner }
769a90e161bSBill Fenner
770a90e161bSBill Fenner void
pptp_print(netdissect_options * ndo,const u_char * dat)7713c602fabSXin LI pptp_print(netdissect_options *ndo,
7723c602fabSXin LI const u_char *dat)
773a90e161bSBill Fenner {
774a90e161bSBill Fenner const struct pptp_hdr *hdr;
7753c602fabSXin LI uint32_t mc;
7763c602fabSXin LI uint16_t ctrl_msg_type;
777a90e161bSBill Fenner
778*ee67461eSJoseph Mingrone ndo->ndo_protocol = "pptp";
779*ee67461eSJoseph Mingrone ND_PRINT(": ");
780*ee67461eSJoseph Mingrone nd_print_protocol(ndo);
781a90e161bSBill Fenner
7823340d773SGleb Smirnoff hdr = (const struct pptp_hdr *)dat;
783a90e161bSBill Fenner
7843c602fabSXin LI if (ndo->ndo_vflag) {
785*ee67461eSJoseph Mingrone ND_PRINT(" Length=%u", GET_BE_U_2(hdr->length));
786a90e161bSBill Fenner }
7873c602fabSXin LI if (ndo->ndo_vflag) {
788*ee67461eSJoseph Mingrone switch(GET_BE_U_2(hdr->msg_type)) {
789a90e161bSBill Fenner case PPTP_MSG_TYPE_CTRL:
790*ee67461eSJoseph Mingrone ND_PRINT(" CTRL-MSG");
791a90e161bSBill Fenner break;
792a90e161bSBill Fenner case PPTP_MSG_TYPE_MGMT:
793*ee67461eSJoseph Mingrone ND_PRINT(" MGMT-MSG");
794a90e161bSBill Fenner break;
795a90e161bSBill Fenner default:
796*ee67461eSJoseph Mingrone ND_PRINT(" UNKNOWN-MSG-TYPE");
797a90e161bSBill Fenner break;
798a90e161bSBill Fenner }
799a90e161bSBill Fenner }
800a90e161bSBill Fenner
801*ee67461eSJoseph Mingrone mc = GET_BE_U_4(hdr->magic_cookie);
802a90e161bSBill Fenner if (mc != PPTP_MAGIC_COOKIE) {
803*ee67461eSJoseph Mingrone ND_PRINT(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
804a90e161bSBill Fenner }
8053c602fabSXin LI if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
806*ee67461eSJoseph Mingrone ND_PRINT(" Magic-Cookie=%08x", mc);
807a90e161bSBill Fenner }
808*ee67461eSJoseph Mingrone ctrl_msg_type = GET_BE_U_2(hdr->ctrl_msg_type);
809a90e161bSBill Fenner if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
810*ee67461eSJoseph Mingrone ND_PRINT(" CTRL_MSGTYPE=%s",
811*ee67461eSJoseph Mingrone pptp_message_type_string[ctrl_msg_type]);
812a90e161bSBill Fenner } else {
813*ee67461eSJoseph Mingrone ND_PRINT(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
814a90e161bSBill Fenner }
815*ee67461eSJoseph Mingrone PRINT_RESERVED_IF_NOT_ZERO_2(hdr->reserved0);
816a90e161bSBill Fenner
817a90e161bSBill Fenner dat += 12;
818a90e161bSBill Fenner
819a90e161bSBill Fenner switch(ctrl_msg_type) {
820a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SCCRQ:
8213c602fabSXin LI pptp_sccrq_print(ndo, dat);
822a90e161bSBill Fenner break;
823a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SCCRP:
8243c602fabSXin LI pptp_sccrp_print(ndo, dat);
825a90e161bSBill Fenner break;
826a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_StopCCRQ:
8273c602fabSXin LI pptp_stopccrq_print(ndo, dat);
828a90e161bSBill Fenner break;
829a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_StopCCRP:
8303c602fabSXin LI pptp_stopccrp_print(ndo, dat);
831a90e161bSBill Fenner break;
832a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ECHORQ:
8333c602fabSXin LI pptp_echorq_print(ndo, dat);
834a90e161bSBill Fenner break;
835a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ECHORP:
8363c602fabSXin LI pptp_echorp_print(ndo, dat);
837a90e161bSBill Fenner break;
838a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_OCRQ:
8393c602fabSXin LI pptp_ocrq_print(ndo, dat);
840a90e161bSBill Fenner break;
841a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_OCRP:
8423c602fabSXin LI pptp_ocrp_print(ndo, dat);
843a90e161bSBill Fenner break;
844a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICRQ:
8453c602fabSXin LI pptp_icrq_print(ndo, dat);
846a90e161bSBill Fenner break;
847a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICRP:
8483c602fabSXin LI pptp_icrp_print(ndo, dat);
849a90e161bSBill Fenner break;
850a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_ICCN:
8513c602fabSXin LI pptp_iccn_print(ndo, dat);
852a90e161bSBill Fenner break;
853a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_CCRQ:
8543c602fabSXin LI pptp_ccrq_print(ndo, dat);
855a90e161bSBill Fenner break;
856a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_CDN:
8573c602fabSXin LI pptp_cdn_print(ndo, dat);
858a90e161bSBill Fenner break;
859a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_WEN:
8603c602fabSXin LI pptp_wen_print(ndo, dat);
861a90e161bSBill Fenner break;
862a90e161bSBill Fenner case PPTP_CTRL_MSG_TYPE_SLI:
8633c602fabSXin LI pptp_sli_print(ndo, dat);
864a90e161bSBill Fenner break;
865a90e161bSBill Fenner default:
866a90e161bSBill Fenner /* do nothing */
867a90e161bSBill Fenner break;
868a90e161bSBill Fenner }
869a90e161bSBill Fenner }
870