1*05b00f60SXin Li /*
2*05b00f60SXin Li * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3*05b00f60SXin Li * The Regents of the University of California. All rights reserved.
4*05b00f60SXin Li *
5*05b00f60SXin Li * Redistribution and use in source and binary forms, with or without
6*05b00f60SXin Li * modification, are permitted provided that: (1) source code distributions
7*05b00f60SXin Li * retain the above copyright notice and this paragraph in its entirety, (2)
8*05b00f60SXin Li * distributions including binary code include the above copyright notice and
9*05b00f60SXin Li * this paragraph in its entirety in the documentation or other materials
10*05b00f60SXin Li * provided with the distribution, and (3) all advertising materials mentioning
11*05b00f60SXin Li * features or use of this software display the following acknowledgement:
12*05b00f60SXin Li * ``This product includes software developed by the University of California,
13*05b00f60SXin Li * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14*05b00f60SXin Li * the University nor the names of its contributors may be used to endorse
15*05b00f60SXin Li * or promote products derived from this software without specific prior
16*05b00f60SXin Li * written permission.
17*05b00f60SXin Li * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18*05b00f60SXin Li * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19*05b00f60SXin Li * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20*05b00f60SXin Li *
21*05b00f60SXin Li * PPTP support contributed by Motonori Shindo ([email protected])
22*05b00f60SXin Li */
23*05b00f60SXin Li
24*05b00f60SXin Li /* \summary: Point-to-Point Tunnelling Protocol (PPTP) printer */
25*05b00f60SXin Li
26*05b00f60SXin Li /* specification: RFC 2637 */
27*05b00f60SXin Li
28*05b00f60SXin Li #ifdef HAVE_CONFIG_H
29*05b00f60SXin Li #include <config.h>
30*05b00f60SXin Li #endif
31*05b00f60SXin Li
32*05b00f60SXin Li #include "netdissect-stdinc.h"
33*05b00f60SXin Li
34*05b00f60SXin Li #include "netdissect.h"
35*05b00f60SXin Li #include "extract.h"
36*05b00f60SXin Li
37*05b00f60SXin Li
38*05b00f60SXin Li #define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
39*05b00f60SXin Li #define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
40*05b00f60SXin Li #define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
41*05b00f60SXin Li
42*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_SCCRQ 1
43*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_SCCRP 2
44*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
45*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_StopCCRP 4
46*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_ECHORQ 5
47*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_ECHORP 6
48*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_OCRQ 7
49*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_OCRP 8
50*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_ICRQ 9
51*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_ICRP 10
52*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_ICCN 11
53*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_CCRQ 12
54*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_CDN 13
55*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_WEN 14
56*05b00f60SXin Li #define PPTP_CTRL_MSG_TYPE_SLI 15
57*05b00f60SXin Li
58*05b00f60SXin Li #define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Asynchronous */
59*05b00f60SXin Li #define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
60*05b00f60SXin Li
61*05b00f60SXin Li #define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
62*05b00f60SXin Li #define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
63*05b00f60SXin Li
64*05b00f60SXin Li static const char *pptp_message_type_string[] = {
65*05b00f60SXin Li "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
66*05b00f60SXin Li "SCCRQ", /* 1 Start-Control-Connection-Request */
67*05b00f60SXin Li "SCCRP", /* 2 Start-Control-Connection-Reply */
68*05b00f60SXin Li "StopCCRQ", /* 3 Stop-Control-Connection-Request */
69*05b00f60SXin Li "StopCCRP", /* 4 Stop-Control-Connection-Reply */
70*05b00f60SXin Li "ECHORQ", /* 5 Echo Request */
71*05b00f60SXin Li "ECHORP", /* 6 Echo Reply */
72*05b00f60SXin Li
73*05b00f60SXin Li "OCRQ", /* 7 Outgoing-Call-Request */
74*05b00f60SXin Li "OCRP", /* 8 Outgoing-Call-Reply */
75*05b00f60SXin Li "ICRQ", /* 9 Incoming-Call-Request */
76*05b00f60SXin Li "ICRP", /* 10 Incoming-Call-Reply */
77*05b00f60SXin Li "ICCN", /* 11 Incoming-Call-Connected */
78*05b00f60SXin Li "CCRQ", /* 12 Call-Clear-Request */
79*05b00f60SXin Li "CDN", /* 13 Call-Disconnect-Notify */
80*05b00f60SXin Li
81*05b00f60SXin Li "WEN", /* 14 WAN-Error-Notify */
82*05b00f60SXin Li
83*05b00f60SXin Li "SLI" /* 15 Set-Link-Info */
84*05b00f60SXin Li #define PPTP_MAX_MSGTYPE_INDEX 16
85*05b00f60SXin Li };
86*05b00f60SXin Li
87*05b00f60SXin Li /* common for all PPTP control messages */
88*05b00f60SXin Li struct pptp_hdr {
89*05b00f60SXin Li nd_uint16_t length;
90*05b00f60SXin Li nd_uint16_t msg_type;
91*05b00f60SXin Li nd_uint32_t magic_cookie;
92*05b00f60SXin Li nd_uint16_t ctrl_msg_type;
93*05b00f60SXin Li nd_uint16_t reserved0;
94*05b00f60SXin Li };
95*05b00f60SXin Li
96*05b00f60SXin Li struct pptp_msg_sccrq {
97*05b00f60SXin Li nd_uint16_t proto_ver;
98*05b00f60SXin Li nd_uint16_t reserved1;
99*05b00f60SXin Li nd_uint32_t framing_cap;
100*05b00f60SXin Li nd_uint32_t bearer_cap;
101*05b00f60SXin Li nd_uint16_t max_channel;
102*05b00f60SXin Li nd_uint16_t firm_rev;
103*05b00f60SXin Li nd_byte hostname[64];
104*05b00f60SXin Li nd_byte vendor[64];
105*05b00f60SXin Li };
106*05b00f60SXin Li
107*05b00f60SXin Li struct pptp_msg_sccrp {
108*05b00f60SXin Li nd_uint16_t proto_ver;
109*05b00f60SXin Li nd_uint8_t result_code;
110*05b00f60SXin Li nd_uint8_t err_code;
111*05b00f60SXin Li nd_uint32_t framing_cap;
112*05b00f60SXin Li nd_uint32_t bearer_cap;
113*05b00f60SXin Li nd_uint16_t max_channel;
114*05b00f60SXin Li nd_uint16_t firm_rev;
115*05b00f60SXin Li nd_byte hostname[64];
116*05b00f60SXin Li nd_byte vendor[64];
117*05b00f60SXin Li };
118*05b00f60SXin Li
119*05b00f60SXin Li struct pptp_msg_stopccrq {
120*05b00f60SXin Li nd_uint8_t reason;
121*05b00f60SXin Li nd_uint8_t reserved1;
122*05b00f60SXin Li nd_uint16_t reserved2;
123*05b00f60SXin Li };
124*05b00f60SXin Li
125*05b00f60SXin Li struct pptp_msg_stopccrp {
126*05b00f60SXin Li nd_uint8_t result_code;
127*05b00f60SXin Li nd_uint8_t err_code;
128*05b00f60SXin Li nd_uint16_t reserved1;
129*05b00f60SXin Li };
130*05b00f60SXin Li
131*05b00f60SXin Li struct pptp_msg_echorq {
132*05b00f60SXin Li nd_uint32_t id;
133*05b00f60SXin Li };
134*05b00f60SXin Li
135*05b00f60SXin Li struct pptp_msg_echorp {
136*05b00f60SXin Li nd_uint32_t id;
137*05b00f60SXin Li nd_uint8_t result_code;
138*05b00f60SXin Li nd_uint8_t err_code;
139*05b00f60SXin Li nd_uint16_t reserved1;
140*05b00f60SXin Li };
141*05b00f60SXin Li
142*05b00f60SXin Li struct pptp_msg_ocrq {
143*05b00f60SXin Li nd_uint16_t call_id;
144*05b00f60SXin Li nd_uint16_t call_ser;
145*05b00f60SXin Li nd_uint32_t min_bps;
146*05b00f60SXin Li nd_uint32_t max_bps;
147*05b00f60SXin Li nd_uint32_t bearer_type;
148*05b00f60SXin Li nd_uint32_t framing_type;
149*05b00f60SXin Li nd_uint16_t recv_winsiz;
150*05b00f60SXin Li nd_uint16_t pkt_proc_delay;
151*05b00f60SXin Li nd_uint16_t phone_no_len;
152*05b00f60SXin Li nd_uint16_t reserved1;
153*05b00f60SXin Li nd_byte phone_no[64];
154*05b00f60SXin Li nd_byte subaddr[64];
155*05b00f60SXin Li };
156*05b00f60SXin Li
157*05b00f60SXin Li struct pptp_msg_ocrp {
158*05b00f60SXin Li nd_uint16_t call_id;
159*05b00f60SXin Li nd_uint16_t peer_call_id;
160*05b00f60SXin Li nd_uint8_t result_code;
161*05b00f60SXin Li nd_uint8_t err_code;
162*05b00f60SXin Li nd_uint16_t cause_code;
163*05b00f60SXin Li nd_uint32_t conn_speed;
164*05b00f60SXin Li nd_uint16_t recv_winsiz;
165*05b00f60SXin Li nd_uint16_t pkt_proc_delay;
166*05b00f60SXin Li nd_uint32_t phy_chan_id;
167*05b00f60SXin Li };
168*05b00f60SXin Li
169*05b00f60SXin Li struct pptp_msg_icrq {
170*05b00f60SXin Li nd_uint16_t call_id;
171*05b00f60SXin Li nd_uint16_t call_ser;
172*05b00f60SXin Li nd_uint32_t bearer_type;
173*05b00f60SXin Li nd_uint32_t phy_chan_id;
174*05b00f60SXin Li nd_uint16_t dialed_no_len;
175*05b00f60SXin Li nd_uint16_t dialing_no_len;
176*05b00f60SXin Li nd_byte dialed_no[64]; /* DNIS */
177*05b00f60SXin Li nd_byte dialing_no[64]; /* CLID */
178*05b00f60SXin Li nd_byte subaddr[64];
179*05b00f60SXin Li };
180*05b00f60SXin Li
181*05b00f60SXin Li struct pptp_msg_icrp {
182*05b00f60SXin Li nd_uint16_t call_id;
183*05b00f60SXin Li nd_uint16_t peer_call_id;
184*05b00f60SXin Li nd_uint8_t result_code;
185*05b00f60SXin Li nd_uint8_t err_code;
186*05b00f60SXin Li nd_uint16_t recv_winsiz;
187*05b00f60SXin Li nd_uint16_t pkt_proc_delay;
188*05b00f60SXin Li nd_uint16_t reserved1;
189*05b00f60SXin Li };
190*05b00f60SXin Li
191*05b00f60SXin Li struct pptp_msg_iccn {
192*05b00f60SXin Li nd_uint16_t peer_call_id;
193*05b00f60SXin Li nd_uint16_t reserved1;
194*05b00f60SXin Li nd_uint32_t conn_speed;
195*05b00f60SXin Li nd_uint16_t recv_winsiz;
196*05b00f60SXin Li nd_uint16_t pkt_proc_delay;
197*05b00f60SXin Li nd_uint32_t framing_type;
198*05b00f60SXin Li };
199*05b00f60SXin Li
200*05b00f60SXin Li struct pptp_msg_ccrq {
201*05b00f60SXin Li nd_uint16_t call_id;
202*05b00f60SXin Li nd_uint16_t reserved1;
203*05b00f60SXin Li };
204*05b00f60SXin Li
205*05b00f60SXin Li struct pptp_msg_cdn {
206*05b00f60SXin Li nd_uint16_t call_id;
207*05b00f60SXin Li nd_uint8_t result_code;
208*05b00f60SXin Li nd_uint8_t err_code;
209*05b00f60SXin Li nd_uint16_t cause_code;
210*05b00f60SXin Li nd_uint16_t reserved1;
211*05b00f60SXin Li nd_byte call_stats[128];
212*05b00f60SXin Li };
213*05b00f60SXin Li
214*05b00f60SXin Li struct pptp_msg_wen {
215*05b00f60SXin Li nd_uint16_t peer_call_id;
216*05b00f60SXin Li nd_uint16_t reserved1;
217*05b00f60SXin Li nd_uint32_t crc_err;
218*05b00f60SXin Li nd_uint32_t framing_err;
219*05b00f60SXin Li nd_uint32_t hardware_overrun;
220*05b00f60SXin Li nd_uint32_t buffer_overrun;
221*05b00f60SXin Li nd_uint32_t timeout_err;
222*05b00f60SXin Li nd_uint32_t align_err;
223*05b00f60SXin Li };
224*05b00f60SXin Li
225*05b00f60SXin Li struct pptp_msg_sli {
226*05b00f60SXin Li nd_uint16_t peer_call_id;
227*05b00f60SXin Li nd_uint16_t reserved1;
228*05b00f60SXin Li nd_uint32_t send_accm;
229*05b00f60SXin Li nd_uint32_t recv_accm;
230*05b00f60SXin Li };
231*05b00f60SXin Li
232*05b00f60SXin Li /* attributes that appear more than once in above messages:
233*05b00f60SXin Li
234*05b00f60SXin Li Number of
235*05b00f60SXin Li occurrence attributes
236*05b00f60SXin Li --------------------------------------
237*05b00f60SXin Li 2 uint32_t bearer_cap;
238*05b00f60SXin Li 2 uint32_t bearer_type;
239*05b00f60SXin Li 6 uint16_t call_id;
240*05b00f60SXin Li 2 uint16_t call_ser;
241*05b00f60SXin Li 2 uint16_t cause_code;
242*05b00f60SXin Li 2 uint32_t conn_speed;
243*05b00f60SXin Li 6 uint8_t err_code;
244*05b00f60SXin Li 2 uint16_t firm_rev;
245*05b00f60SXin Li 2 uint32_t framing_cap;
246*05b00f60SXin Li 2 uint32_t framing_type;
247*05b00f60SXin Li 2 u_char hostname[64];
248*05b00f60SXin Li 2 uint32_t id;
249*05b00f60SXin Li 2 uint16_t max_channel;
250*05b00f60SXin Li 5 uint16_t peer_call_id;
251*05b00f60SXin Li 2 uint32_t phy_chan_id;
252*05b00f60SXin Li 4 uint16_t pkt_proc_delay;
253*05b00f60SXin Li 2 uint16_t proto_ver;
254*05b00f60SXin Li 4 uint16_t recv_winsiz;
255*05b00f60SXin Li 2 uint8_t reserved1;
256*05b00f60SXin Li 9 uint16_t reserved1;
257*05b00f60SXin Li 6 uint8_t result_code;
258*05b00f60SXin Li 2 u_char subaddr[64];
259*05b00f60SXin Li 2 u_char vendor[64];
260*05b00f60SXin Li
261*05b00f60SXin Li so I will prepare print out functions for these attributes (except for
262*05b00f60SXin Li reserved*).
263*05b00f60SXin Li */
264*05b00f60SXin Li
265*05b00f60SXin Li #define PRINT_RESERVED_IF_NOT_ZERO_1(reserved) \
266*05b00f60SXin Li if (GET_U_1(reserved)) \
267*05b00f60SXin Li ND_PRINT(" [ERROR: reserved=%u must be zero]", \
268*05b00f60SXin Li GET_U_1(reserved));
269*05b00f60SXin Li
270*05b00f60SXin Li #define PRINT_RESERVED_IF_NOT_ZERO_2(reserved) \
271*05b00f60SXin Li if (GET_BE_U_2(reserved)) \
272*05b00f60SXin Li ND_PRINT(" [ERROR: reserved=%u must be zero]", \
273*05b00f60SXin Li GET_BE_U_2(reserved));
274*05b00f60SXin Li
275*05b00f60SXin Li /******************************************/
276*05b00f60SXin Li /* Attribute-specific print out functions */
277*05b00f60SXin Li /******************************************/
278*05b00f60SXin Li
279*05b00f60SXin Li static void
pptp_bearer_cap_print(netdissect_options * ndo,const nd_uint32_t bearer_cap)280*05b00f60SXin Li pptp_bearer_cap_print(netdissect_options *ndo,
281*05b00f60SXin Li const nd_uint32_t bearer_cap)
282*05b00f60SXin Li {
283*05b00f60SXin Li ND_PRINT(" BEARER_CAP(%s%s)",
284*05b00f60SXin Li GET_BE_U_4(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
285*05b00f60SXin Li GET_BE_U_4(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : "");
286*05b00f60SXin Li }
287*05b00f60SXin Li
288*05b00f60SXin Li static const struct tok pptp_btype_str[] = {
289*05b00f60SXin Li { 1, "A" }, /* Analog */
290*05b00f60SXin Li { 2, "D" }, /* Digital */
291*05b00f60SXin Li { 3, "Any" },
292*05b00f60SXin Li { 0, NULL }
293*05b00f60SXin Li };
294*05b00f60SXin Li
295*05b00f60SXin Li static void
pptp_bearer_type_print(netdissect_options * ndo,const nd_uint32_t bearer_type)296*05b00f60SXin Li pptp_bearer_type_print(netdissect_options *ndo,
297*05b00f60SXin Li const nd_uint32_t bearer_type)
298*05b00f60SXin Li {
299*05b00f60SXin Li ND_PRINT(" BEARER_TYPE(%s)",
300*05b00f60SXin Li tok2str(pptp_btype_str, "?", GET_BE_U_4(bearer_type)));
301*05b00f60SXin Li }
302*05b00f60SXin Li
303*05b00f60SXin Li static void
pptp_call_id_print(netdissect_options * ndo,const nd_uint16_t call_id)304*05b00f60SXin Li pptp_call_id_print(netdissect_options *ndo,
305*05b00f60SXin Li const nd_uint16_t call_id)
306*05b00f60SXin Li {
307*05b00f60SXin Li ND_PRINT(" CALL_ID(%u)", GET_BE_U_2(call_id));
308*05b00f60SXin Li }
309*05b00f60SXin Li
310*05b00f60SXin Li static void
pptp_call_ser_print(netdissect_options * ndo,const nd_uint16_t call_ser)311*05b00f60SXin Li pptp_call_ser_print(netdissect_options *ndo,
312*05b00f60SXin Li const nd_uint16_t call_ser)
313*05b00f60SXin Li {
314*05b00f60SXin Li ND_PRINT(" CALL_SER_NUM(%u)", GET_BE_U_2(call_ser));
315*05b00f60SXin Li }
316*05b00f60SXin Li
317*05b00f60SXin Li static void
pptp_cause_code_print(netdissect_options * ndo,const nd_uint16_t cause_code)318*05b00f60SXin Li pptp_cause_code_print(netdissect_options *ndo,
319*05b00f60SXin Li const nd_uint16_t cause_code)
320*05b00f60SXin Li {
321*05b00f60SXin Li ND_PRINT(" CAUSE_CODE(%u)", GET_BE_U_2(cause_code));
322*05b00f60SXin Li }
323*05b00f60SXin Li
324*05b00f60SXin Li static void
pptp_conn_speed_print(netdissect_options * ndo,const nd_uint32_t conn_speed)325*05b00f60SXin Li pptp_conn_speed_print(netdissect_options *ndo,
326*05b00f60SXin Li const nd_uint32_t conn_speed)
327*05b00f60SXin Li {
328*05b00f60SXin Li ND_PRINT(" CONN_SPEED(%u)", GET_BE_U_4(conn_speed));
329*05b00f60SXin Li }
330*05b00f60SXin Li
331*05b00f60SXin Li static const struct tok pptp_errcode_str[] = {
332*05b00f60SXin Li { 0, "None" },
333*05b00f60SXin Li { 1, "Not-Connected" },
334*05b00f60SXin Li { 2, "Bad-Format" },
335*05b00f60SXin Li { 3, "Bad-Value" },
336*05b00f60SXin Li { 4, "No-Resource" },
337*05b00f60SXin Li { 5, "Bad-Call-ID" },
338*05b00f60SXin Li { 6, "PAC-Error" },
339*05b00f60SXin Li { 0, NULL }
340*05b00f60SXin Li };
341*05b00f60SXin Li
342*05b00f60SXin Li static void
pptp_err_code_print(netdissect_options * ndo,const nd_uint8_t err_code)343*05b00f60SXin Li pptp_err_code_print(netdissect_options *ndo,
344*05b00f60SXin Li const nd_uint8_t err_code)
345*05b00f60SXin Li {
346*05b00f60SXin Li ND_PRINT(" ERR_CODE(%u", GET_U_1(err_code));
347*05b00f60SXin Li if (ndo->ndo_vflag) {
348*05b00f60SXin Li ND_PRINT(":%s",
349*05b00f60SXin Li tok2str(pptp_errcode_str, "?", GET_U_1(err_code)));
350*05b00f60SXin Li }
351*05b00f60SXin Li ND_PRINT(")");
352*05b00f60SXin Li }
353*05b00f60SXin Li
354*05b00f60SXin Li static void
pptp_firm_rev_print(netdissect_options * ndo,const nd_uint16_t firm_rev)355*05b00f60SXin Li pptp_firm_rev_print(netdissect_options *ndo,
356*05b00f60SXin Li const nd_uint16_t firm_rev)
357*05b00f60SXin Li {
358*05b00f60SXin Li ND_PRINT(" FIRM_REV(%u)", GET_BE_U_2(firm_rev));
359*05b00f60SXin Li }
360*05b00f60SXin Li
361*05b00f60SXin Li static void
pptp_framing_cap_print(netdissect_options * ndo,const nd_uint32_t framing_cap)362*05b00f60SXin Li pptp_framing_cap_print(netdissect_options *ndo,
363*05b00f60SXin Li const nd_uint32_t framing_cap)
364*05b00f60SXin Li {
365*05b00f60SXin Li ND_PRINT(" FRAME_CAP(");
366*05b00f60SXin Li if (GET_BE_U_4(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
367*05b00f60SXin Li ND_PRINT("A"); /* Async */
368*05b00f60SXin Li }
369*05b00f60SXin Li if (GET_BE_U_4(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
370*05b00f60SXin Li ND_PRINT("S"); /* Sync */
371*05b00f60SXin Li }
372*05b00f60SXin Li ND_PRINT(")");
373*05b00f60SXin Li }
374*05b00f60SXin Li
375*05b00f60SXin Li static const struct tok pptp_ftype_str[] = {
376*05b00f60SXin Li { 1, "A" }, /* Async */
377*05b00f60SXin Li { 2, "S" }, /* Sync */
378*05b00f60SXin Li { 3, "E" }, /* Either */
379*05b00f60SXin Li { 0, NULL }
380*05b00f60SXin Li };
381*05b00f60SXin Li
382*05b00f60SXin Li static void
pptp_framing_type_print(netdissect_options * ndo,const nd_uint32_t framing_type)383*05b00f60SXin Li pptp_framing_type_print(netdissect_options *ndo,
384*05b00f60SXin Li const nd_uint32_t framing_type)
385*05b00f60SXin Li {
386*05b00f60SXin Li ND_PRINT(" FRAME_TYPE(%s)",
387*05b00f60SXin Li tok2str(pptp_ftype_str, "?", GET_BE_U_4(framing_type)));
388*05b00f60SXin Li }
389*05b00f60SXin Li
390*05b00f60SXin Li static void
pptp_hostname_print(netdissect_options * ndo,const u_char * hostname)391*05b00f60SXin Li pptp_hostname_print(netdissect_options *ndo,
392*05b00f60SXin Li const u_char *hostname)
393*05b00f60SXin Li {
394*05b00f60SXin Li ND_PRINT(" HOSTNAME(");
395*05b00f60SXin Li nd_printjnp(ndo, hostname, 64);
396*05b00f60SXin Li ND_PRINT(")");
397*05b00f60SXin Li }
398*05b00f60SXin Li
399*05b00f60SXin Li static void
pptp_id_print(netdissect_options * ndo,const nd_uint32_t id)400*05b00f60SXin Li pptp_id_print(netdissect_options *ndo,
401*05b00f60SXin Li const nd_uint32_t id)
402*05b00f60SXin Li {
403*05b00f60SXin Li ND_PRINT(" ID(%u)", GET_BE_U_4(id));
404*05b00f60SXin Li }
405*05b00f60SXin Li
406*05b00f60SXin Li static void
pptp_max_channel_print(netdissect_options * ndo,const nd_uint16_t max_channel)407*05b00f60SXin Li pptp_max_channel_print(netdissect_options *ndo,
408*05b00f60SXin Li const nd_uint16_t max_channel)
409*05b00f60SXin Li {
410*05b00f60SXin Li ND_PRINT(" MAX_CHAN(%u)", GET_BE_U_2(max_channel));
411*05b00f60SXin Li }
412*05b00f60SXin Li
413*05b00f60SXin Li static void
pptp_peer_call_id_print(netdissect_options * ndo,const nd_uint16_t peer_call_id)414*05b00f60SXin Li pptp_peer_call_id_print(netdissect_options *ndo,
415*05b00f60SXin Li const nd_uint16_t peer_call_id)
416*05b00f60SXin Li {
417*05b00f60SXin Li ND_PRINT(" PEER_CALL_ID(%u)", GET_BE_U_2(peer_call_id));
418*05b00f60SXin Li }
419*05b00f60SXin Li
420*05b00f60SXin Li static void
pptp_phy_chan_id_print(netdissect_options * ndo,const nd_uint32_t phy_chan_id)421*05b00f60SXin Li pptp_phy_chan_id_print(netdissect_options *ndo,
422*05b00f60SXin Li const nd_uint32_t phy_chan_id)
423*05b00f60SXin Li {
424*05b00f60SXin Li ND_PRINT(" PHY_CHAN_ID(%u)", GET_BE_U_4(phy_chan_id));
425*05b00f60SXin Li }
426*05b00f60SXin Li
427*05b00f60SXin Li static void
pptp_pkt_proc_delay_print(netdissect_options * ndo,const nd_uint16_t pkt_proc_delay)428*05b00f60SXin Li pptp_pkt_proc_delay_print(netdissect_options *ndo,
429*05b00f60SXin Li const nd_uint16_t pkt_proc_delay)
430*05b00f60SXin Li {
431*05b00f60SXin Li ND_PRINT(" PROC_DELAY(%u)", GET_BE_U_2(pkt_proc_delay));
432*05b00f60SXin Li }
433*05b00f60SXin Li
434*05b00f60SXin Li static void
pptp_proto_ver_print(netdissect_options * ndo,const nd_uint16_t proto_ver)435*05b00f60SXin Li pptp_proto_ver_print(netdissect_options *ndo,
436*05b00f60SXin Li const nd_uint16_t proto_ver)
437*05b00f60SXin Li {
438*05b00f60SXin Li ND_PRINT(" PROTO_VER(%u.%u)", /* Version.Revision */
439*05b00f60SXin Li GET_BE_U_2(proto_ver) >> 8,
440*05b00f60SXin Li GET_BE_U_2(proto_ver) & 0xff);
441*05b00f60SXin Li }
442*05b00f60SXin Li
443*05b00f60SXin Li static void
pptp_recv_winsiz_print(netdissect_options * ndo,const nd_uint16_t recv_winsiz)444*05b00f60SXin Li pptp_recv_winsiz_print(netdissect_options *ndo,
445*05b00f60SXin Li const nd_uint16_t recv_winsiz)
446*05b00f60SXin Li {
447*05b00f60SXin Li ND_PRINT(" RECV_WIN(%u)", GET_BE_U_2(recv_winsiz));
448*05b00f60SXin Li }
449*05b00f60SXin Li
450*05b00f60SXin Li static const struct tok pptp_scrrp_str[] = {
451*05b00f60SXin Li { 1, "Successful channel establishment" },
452*05b00f60SXin Li { 2, "General error" },
453*05b00f60SXin Li { 3, "Command channel already exists" },
454*05b00f60SXin Li { 4, "Requester is not authorized to establish a command channel" },
455*05b00f60SXin Li { 5, "The protocol version of the requester is not supported" },
456*05b00f60SXin Li { 0, NULL }
457*05b00f60SXin Li };
458*05b00f60SXin Li
459*05b00f60SXin Li static const struct tok pptp_echorp_str[] = {
460*05b00f60SXin Li { 1, "OK" },
461*05b00f60SXin Li { 2, "General Error" },
462*05b00f60SXin Li { 0, NULL }
463*05b00f60SXin Li };
464*05b00f60SXin Li
465*05b00f60SXin Li static const struct tok pptp_ocrp_str[] = {
466*05b00f60SXin Li { 1, "Connected" },
467*05b00f60SXin Li { 2, "General Error" },
468*05b00f60SXin Li { 3, "No Carrier" },
469*05b00f60SXin Li { 4, "Busy" },
470*05b00f60SXin Li { 5, "No Dial Tone" },
471*05b00f60SXin Li { 6, "Time-out" },
472*05b00f60SXin Li { 7, "Do Not Accept" },
473*05b00f60SXin Li { 0, NULL }
474*05b00f60SXin Li };
475*05b00f60SXin Li
476*05b00f60SXin Li static const struct tok pptp_icrp_str[] = {
477*05b00f60SXin Li { 1, "Connect" },
478*05b00f60SXin Li { 2, "General Error" },
479*05b00f60SXin Li { 3, "Do Not Accept" },
480*05b00f60SXin Li { 0, NULL }
481*05b00f60SXin Li };
482*05b00f60SXin Li
483*05b00f60SXin Li static const struct tok pptp_cdn_str[] = {
484*05b00f60SXin Li { 1, "Lost Carrier" },
485*05b00f60SXin Li { 2, "General Error" },
486*05b00f60SXin Li { 3, "Admin Shutdown" },
487*05b00f60SXin Li { 4, "Request" },
488*05b00f60SXin Li { 0, NULL }
489*05b00f60SXin Li };
490*05b00f60SXin Li
491*05b00f60SXin Li static void
pptp_result_code_print(netdissect_options * ndo,const nd_uint8_t result_code,int ctrl_msg_type)492*05b00f60SXin Li pptp_result_code_print(netdissect_options *ndo,
493*05b00f60SXin Li const nd_uint8_t result_code, int ctrl_msg_type)
494*05b00f60SXin Li {
495*05b00f60SXin Li ND_PRINT(" RESULT_CODE(%u", GET_U_1(result_code));
496*05b00f60SXin Li if (ndo->ndo_vflag) {
497*05b00f60SXin Li const struct tok *dict =
498*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
499*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
500*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
501*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
502*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
503*05b00f60SXin Li ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
504*05b00f60SXin Li NULL; /* assertion error */
505*05b00f60SXin Li if (dict != NULL)
506*05b00f60SXin Li ND_PRINT(":%s",
507*05b00f60SXin Li tok2str(dict, "?", GET_U_1(result_code)));
508*05b00f60SXin Li }
509*05b00f60SXin Li ND_PRINT(")");
510*05b00f60SXin Li }
511*05b00f60SXin Li
512*05b00f60SXin Li static void
pptp_subaddr_print(netdissect_options * ndo,const u_char * subaddr)513*05b00f60SXin Li pptp_subaddr_print(netdissect_options *ndo,
514*05b00f60SXin Li const u_char *subaddr)
515*05b00f60SXin Li {
516*05b00f60SXin Li ND_PRINT(" SUB_ADDR(");
517*05b00f60SXin Li nd_printjnp(ndo, subaddr, 64);
518*05b00f60SXin Li ND_PRINT(")");
519*05b00f60SXin Li }
520*05b00f60SXin Li
521*05b00f60SXin Li static void
pptp_vendor_print(netdissect_options * ndo,const u_char * vendor)522*05b00f60SXin Li pptp_vendor_print(netdissect_options *ndo,
523*05b00f60SXin Li const u_char *vendor)
524*05b00f60SXin Li {
525*05b00f60SXin Li ND_PRINT(" VENDOR(");
526*05b00f60SXin Li nd_printjnp(ndo, vendor, 64);
527*05b00f60SXin Li ND_PRINT(")");
528*05b00f60SXin Li }
529*05b00f60SXin Li
530*05b00f60SXin Li /************************************/
531*05b00f60SXin Li /* PPTP message print out functions */
532*05b00f60SXin Li /************************************/
533*05b00f60SXin Li static void
pptp_sccrq_print(netdissect_options * ndo,const u_char * dat)534*05b00f60SXin Li pptp_sccrq_print(netdissect_options *ndo,
535*05b00f60SXin Li const u_char *dat)
536*05b00f60SXin Li {
537*05b00f60SXin Li const struct pptp_msg_sccrq *ptr = (const struct pptp_msg_sccrq *)dat;
538*05b00f60SXin Li
539*05b00f60SXin Li pptp_proto_ver_print(ndo, ptr->proto_ver);
540*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
541*05b00f60SXin Li pptp_framing_cap_print(ndo, ptr->framing_cap);
542*05b00f60SXin Li pptp_bearer_cap_print(ndo, ptr->bearer_cap);
543*05b00f60SXin Li pptp_max_channel_print(ndo, ptr->max_channel);
544*05b00f60SXin Li pptp_firm_rev_print(ndo, ptr->firm_rev);
545*05b00f60SXin Li pptp_hostname_print(ndo, ptr->hostname);
546*05b00f60SXin Li pptp_vendor_print(ndo, ptr->vendor);
547*05b00f60SXin Li }
548*05b00f60SXin Li
549*05b00f60SXin Li static void
pptp_sccrp_print(netdissect_options * ndo,const u_char * dat)550*05b00f60SXin Li pptp_sccrp_print(netdissect_options *ndo,
551*05b00f60SXin Li const u_char *dat)
552*05b00f60SXin Li {
553*05b00f60SXin Li const struct pptp_msg_sccrp *ptr = (const struct pptp_msg_sccrp *)dat;
554*05b00f60SXin Li
555*05b00f60SXin Li pptp_proto_ver_print(ndo, ptr->proto_ver);
556*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
557*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
558*05b00f60SXin Li pptp_framing_cap_print(ndo, ptr->framing_cap);
559*05b00f60SXin Li pptp_bearer_cap_print(ndo, ptr->bearer_cap);
560*05b00f60SXin Li pptp_max_channel_print(ndo, ptr->max_channel);
561*05b00f60SXin Li pptp_firm_rev_print(ndo, ptr->firm_rev);
562*05b00f60SXin Li pptp_hostname_print(ndo, ptr->hostname);
563*05b00f60SXin Li pptp_vendor_print(ndo, ptr->vendor);
564*05b00f60SXin Li }
565*05b00f60SXin Li
566*05b00f60SXin Li static void
pptp_stopccrq_print(netdissect_options * ndo,const u_char * dat)567*05b00f60SXin Li pptp_stopccrq_print(netdissect_options *ndo,
568*05b00f60SXin Li const u_char *dat)
569*05b00f60SXin Li {
570*05b00f60SXin Li const struct pptp_msg_stopccrq *ptr = (const struct pptp_msg_stopccrq *)dat;
571*05b00f60SXin Li
572*05b00f60SXin Li ND_PRINT(" REASON(%u", GET_U_1(ptr->reason));
573*05b00f60SXin Li if (ndo->ndo_vflag) {
574*05b00f60SXin Li switch (GET_U_1(ptr->reason)) {
575*05b00f60SXin Li case 1:
576*05b00f60SXin Li ND_PRINT(":None");
577*05b00f60SXin Li break;
578*05b00f60SXin Li case 2:
579*05b00f60SXin Li ND_PRINT(":Stop-Protocol");
580*05b00f60SXin Li break;
581*05b00f60SXin Li case 3:
582*05b00f60SXin Li ND_PRINT(":Stop-Local-Shutdown");
583*05b00f60SXin Li break;
584*05b00f60SXin Li default:
585*05b00f60SXin Li ND_PRINT(":?");
586*05b00f60SXin Li break;
587*05b00f60SXin Li }
588*05b00f60SXin Li }
589*05b00f60SXin Li ND_PRINT(")");
590*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_1(ptr->reserved1);
591*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved2);
592*05b00f60SXin Li }
593*05b00f60SXin Li
594*05b00f60SXin Li static void
pptp_stopccrp_print(netdissect_options * ndo,const u_char * dat)595*05b00f60SXin Li pptp_stopccrp_print(netdissect_options *ndo,
596*05b00f60SXin Li const u_char *dat)
597*05b00f60SXin Li {
598*05b00f60SXin Li const struct pptp_msg_stopccrp *ptr = (const struct pptp_msg_stopccrp *)dat;
599*05b00f60SXin Li
600*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
601*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
602*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
603*05b00f60SXin Li }
604*05b00f60SXin Li
605*05b00f60SXin Li static void
pptp_echorq_print(netdissect_options * ndo,const u_char * dat)606*05b00f60SXin Li pptp_echorq_print(netdissect_options *ndo,
607*05b00f60SXin Li const u_char *dat)
608*05b00f60SXin Li {
609*05b00f60SXin Li const struct pptp_msg_echorq *ptr = (const struct pptp_msg_echorq *)dat;
610*05b00f60SXin Li
611*05b00f60SXin Li pptp_id_print(ndo, ptr->id);
612*05b00f60SXin Li }
613*05b00f60SXin Li
614*05b00f60SXin Li static void
pptp_echorp_print(netdissect_options * ndo,const u_char * dat)615*05b00f60SXin Li pptp_echorp_print(netdissect_options *ndo,
616*05b00f60SXin Li const u_char *dat)
617*05b00f60SXin Li {
618*05b00f60SXin Li const struct pptp_msg_echorp *ptr = (const struct pptp_msg_echorp *)dat;
619*05b00f60SXin Li
620*05b00f60SXin Li pptp_id_print(ndo, ptr->id);
621*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
622*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
623*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
624*05b00f60SXin Li }
625*05b00f60SXin Li
626*05b00f60SXin Li static void
pptp_ocrq_print(netdissect_options * ndo,const u_char * dat)627*05b00f60SXin Li pptp_ocrq_print(netdissect_options *ndo,
628*05b00f60SXin Li const u_char *dat)
629*05b00f60SXin Li {
630*05b00f60SXin Li const struct pptp_msg_ocrq *ptr = (const struct pptp_msg_ocrq *)dat;
631*05b00f60SXin Li
632*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
633*05b00f60SXin Li pptp_call_ser_print(ndo, ptr->call_ser);
634*05b00f60SXin Li ND_PRINT(" MIN_BPS(%u)", GET_BE_U_4(ptr->min_bps));
635*05b00f60SXin Li ND_PRINT(" MAX_BPS(%u)", GET_BE_U_4(ptr->max_bps));
636*05b00f60SXin Li pptp_bearer_type_print(ndo, ptr->bearer_type);
637*05b00f60SXin Li pptp_framing_type_print(ndo, ptr->framing_type);
638*05b00f60SXin Li pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
639*05b00f60SXin Li pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
640*05b00f60SXin Li ND_PRINT(" PHONE_NO_LEN(%u)", GET_BE_U_2(ptr->phone_no_len));
641*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
642*05b00f60SXin Li ND_PRINT(" PHONE_NO(");
643*05b00f60SXin Li nd_printjnp(ndo, ptr->phone_no,
644*05b00f60SXin Li ND_MIN(64, GET_BE_U_2(ptr->phone_no_len)));
645*05b00f60SXin Li ND_PRINT(")");
646*05b00f60SXin Li pptp_subaddr_print(ndo, ptr->subaddr);
647*05b00f60SXin Li }
648*05b00f60SXin Li
649*05b00f60SXin Li static void
pptp_ocrp_print(netdissect_options * ndo,const u_char * dat)650*05b00f60SXin Li pptp_ocrp_print(netdissect_options *ndo,
651*05b00f60SXin Li const u_char *dat)
652*05b00f60SXin Li {
653*05b00f60SXin Li const struct pptp_msg_ocrp *ptr = (const struct pptp_msg_ocrp *)dat;
654*05b00f60SXin Li
655*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
656*05b00f60SXin Li pptp_peer_call_id_print(ndo, ptr->peer_call_id);
657*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
658*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
659*05b00f60SXin Li pptp_cause_code_print(ndo, ptr->cause_code);
660*05b00f60SXin Li pptp_conn_speed_print(ndo, ptr->conn_speed);
661*05b00f60SXin Li pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
662*05b00f60SXin Li pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
663*05b00f60SXin Li pptp_phy_chan_id_print(ndo, ptr->phy_chan_id);
664*05b00f60SXin Li }
665*05b00f60SXin Li
666*05b00f60SXin Li static void
pptp_icrq_print(netdissect_options * ndo,const u_char * dat)667*05b00f60SXin Li pptp_icrq_print(netdissect_options *ndo,
668*05b00f60SXin Li const u_char *dat)
669*05b00f60SXin Li {
670*05b00f60SXin Li const struct pptp_msg_icrq *ptr = (const struct pptp_msg_icrq *)dat;
671*05b00f60SXin Li
672*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
673*05b00f60SXin Li pptp_call_ser_print(ndo, ptr->call_ser);
674*05b00f60SXin Li pptp_bearer_type_print(ndo, ptr->bearer_type);
675*05b00f60SXin Li pptp_phy_chan_id_print(ndo, ptr->phy_chan_id);
676*05b00f60SXin Li ND_PRINT(" DIALED_NO_LEN(%u)", GET_BE_U_2(ptr->dialed_no_len));
677*05b00f60SXin Li ND_PRINT(" DIALING_NO_LEN(%u)", GET_BE_U_2(ptr->dialing_no_len));
678*05b00f60SXin Li ND_PRINT(" DIALED_NO(");
679*05b00f60SXin Li nd_printjnp(ndo, ptr->dialed_no,
680*05b00f60SXin Li ND_MIN(64, GET_BE_U_2(ptr->dialed_no_len)));
681*05b00f60SXin Li ND_PRINT(")");
682*05b00f60SXin Li ND_PRINT(" DIALING_NO(");
683*05b00f60SXin Li nd_printjnp(ndo, ptr->dialing_no,
684*05b00f60SXin Li ND_MIN(64, GET_BE_U_2(ptr->dialing_no_len)));
685*05b00f60SXin Li ND_PRINT(")");
686*05b00f60SXin Li pptp_subaddr_print(ndo, ptr->subaddr);
687*05b00f60SXin Li }
688*05b00f60SXin Li
689*05b00f60SXin Li static void
pptp_icrp_print(netdissect_options * ndo,const u_char * dat)690*05b00f60SXin Li pptp_icrp_print(netdissect_options *ndo,
691*05b00f60SXin Li const u_char *dat)
692*05b00f60SXin Li {
693*05b00f60SXin Li const struct pptp_msg_icrp *ptr = (const struct pptp_msg_icrp *)dat;
694*05b00f60SXin Li
695*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
696*05b00f60SXin Li pptp_peer_call_id_print(ndo, ptr->peer_call_id);
697*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
698*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
699*05b00f60SXin Li pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
700*05b00f60SXin Li pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
701*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
702*05b00f60SXin Li }
703*05b00f60SXin Li
704*05b00f60SXin Li static void
pptp_iccn_print(netdissect_options * ndo,const u_char * dat)705*05b00f60SXin Li pptp_iccn_print(netdissect_options *ndo,
706*05b00f60SXin Li const u_char *dat)
707*05b00f60SXin Li {
708*05b00f60SXin Li const struct pptp_msg_iccn *ptr = (const struct pptp_msg_iccn *)dat;
709*05b00f60SXin Li
710*05b00f60SXin Li pptp_peer_call_id_print(ndo, ptr->peer_call_id);
711*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
712*05b00f60SXin Li pptp_conn_speed_print(ndo, ptr->conn_speed);
713*05b00f60SXin Li pptp_recv_winsiz_print(ndo, ptr->recv_winsiz);
714*05b00f60SXin Li pptp_pkt_proc_delay_print(ndo, ptr->pkt_proc_delay);
715*05b00f60SXin Li pptp_framing_type_print(ndo, ptr->framing_type);
716*05b00f60SXin Li }
717*05b00f60SXin Li
718*05b00f60SXin Li static void
pptp_ccrq_print(netdissect_options * ndo,const u_char * dat)719*05b00f60SXin Li pptp_ccrq_print(netdissect_options *ndo,
720*05b00f60SXin Li const u_char *dat)
721*05b00f60SXin Li {
722*05b00f60SXin Li const struct pptp_msg_ccrq *ptr = (const struct pptp_msg_ccrq *)dat;
723*05b00f60SXin Li
724*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
725*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
726*05b00f60SXin Li }
727*05b00f60SXin Li
728*05b00f60SXin Li static void
pptp_cdn_print(netdissect_options * ndo,const u_char * dat)729*05b00f60SXin Li pptp_cdn_print(netdissect_options *ndo,
730*05b00f60SXin Li const u_char *dat)
731*05b00f60SXin Li {
732*05b00f60SXin Li const struct pptp_msg_cdn *ptr = (const struct pptp_msg_cdn *)dat;
733*05b00f60SXin Li
734*05b00f60SXin Li pptp_call_id_print(ndo, ptr->call_id);
735*05b00f60SXin Li pptp_result_code_print(ndo, ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
736*05b00f60SXin Li pptp_err_code_print(ndo, ptr->err_code);
737*05b00f60SXin Li pptp_cause_code_print(ndo, ptr->cause_code);
738*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
739*05b00f60SXin Li ND_PRINT(" CALL_STATS(");
740*05b00f60SXin Li nd_printjnp(ndo, ptr->call_stats, 128);
741*05b00f60SXin Li ND_PRINT(")");
742*05b00f60SXin Li }
743*05b00f60SXin Li
744*05b00f60SXin Li static void
pptp_wen_print(netdissect_options * ndo,const u_char * dat)745*05b00f60SXin Li pptp_wen_print(netdissect_options *ndo,
746*05b00f60SXin Li const u_char *dat)
747*05b00f60SXin Li {
748*05b00f60SXin Li const struct pptp_msg_wen *ptr = (const struct pptp_msg_wen *)dat;
749*05b00f60SXin Li
750*05b00f60SXin Li pptp_peer_call_id_print(ndo, ptr->peer_call_id);
751*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
752*05b00f60SXin Li ND_PRINT(" CRC_ERR(%u)", GET_BE_U_4(ptr->crc_err));
753*05b00f60SXin Li ND_PRINT(" FRAMING_ERR(%u)", GET_BE_U_4(ptr->framing_err));
754*05b00f60SXin Li ND_PRINT(" HARDWARE_OVERRUN(%u)", GET_BE_U_4(ptr->hardware_overrun));
755*05b00f60SXin Li ND_PRINT(" BUFFER_OVERRUN(%u)", GET_BE_U_4(ptr->buffer_overrun));
756*05b00f60SXin Li ND_PRINT(" TIMEOUT_ERR(%u)", GET_BE_U_4(ptr->timeout_err));
757*05b00f60SXin Li ND_PRINT(" ALIGN_ERR(%u)", GET_BE_U_4(ptr->align_err));
758*05b00f60SXin Li }
759*05b00f60SXin Li
760*05b00f60SXin Li static void
pptp_sli_print(netdissect_options * ndo,const u_char * dat)761*05b00f60SXin Li pptp_sli_print(netdissect_options *ndo,
762*05b00f60SXin Li const u_char *dat)
763*05b00f60SXin Li {
764*05b00f60SXin Li const struct pptp_msg_sli *ptr = (const struct pptp_msg_sli *)dat;
765*05b00f60SXin Li
766*05b00f60SXin Li pptp_peer_call_id_print(ndo, ptr->peer_call_id);
767*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
768*05b00f60SXin Li ND_PRINT(" SEND_ACCM(0x%08x)", GET_BE_U_4(ptr->send_accm));
769*05b00f60SXin Li ND_PRINT(" RECV_ACCM(0x%08x)", GET_BE_U_4(ptr->recv_accm));
770*05b00f60SXin Li }
771*05b00f60SXin Li
772*05b00f60SXin Li void
pptp_print(netdissect_options * ndo,const u_char * dat)773*05b00f60SXin Li pptp_print(netdissect_options *ndo,
774*05b00f60SXin Li const u_char *dat)
775*05b00f60SXin Li {
776*05b00f60SXin Li const struct pptp_hdr *hdr;
777*05b00f60SXin Li uint32_t mc;
778*05b00f60SXin Li uint16_t ctrl_msg_type;
779*05b00f60SXin Li
780*05b00f60SXin Li ndo->ndo_protocol = "pptp";
781*05b00f60SXin Li ND_PRINT(": ");
782*05b00f60SXin Li nd_print_protocol(ndo);
783*05b00f60SXin Li
784*05b00f60SXin Li hdr = (const struct pptp_hdr *)dat;
785*05b00f60SXin Li
786*05b00f60SXin Li if (ndo->ndo_vflag) {
787*05b00f60SXin Li ND_PRINT(" Length=%u", GET_BE_U_2(hdr->length));
788*05b00f60SXin Li }
789*05b00f60SXin Li if (ndo->ndo_vflag) {
790*05b00f60SXin Li switch(GET_BE_U_2(hdr->msg_type)) {
791*05b00f60SXin Li case PPTP_MSG_TYPE_CTRL:
792*05b00f60SXin Li ND_PRINT(" CTRL-MSG");
793*05b00f60SXin Li break;
794*05b00f60SXin Li case PPTP_MSG_TYPE_MGMT:
795*05b00f60SXin Li ND_PRINT(" MGMT-MSG");
796*05b00f60SXin Li break;
797*05b00f60SXin Li default:
798*05b00f60SXin Li ND_PRINT(" UNKNOWN-MSG-TYPE");
799*05b00f60SXin Li break;
800*05b00f60SXin Li }
801*05b00f60SXin Li }
802*05b00f60SXin Li
803*05b00f60SXin Li mc = GET_BE_U_4(hdr->magic_cookie);
804*05b00f60SXin Li if (mc != PPTP_MAGIC_COOKIE) {
805*05b00f60SXin Li ND_PRINT(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
806*05b00f60SXin Li }
807*05b00f60SXin Li if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
808*05b00f60SXin Li ND_PRINT(" Magic-Cookie=%08x", mc);
809*05b00f60SXin Li }
810*05b00f60SXin Li ctrl_msg_type = GET_BE_U_2(hdr->ctrl_msg_type);
811*05b00f60SXin Li if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
812*05b00f60SXin Li ND_PRINT(" CTRL_MSGTYPE=%s",
813*05b00f60SXin Li pptp_message_type_string[ctrl_msg_type]);
814*05b00f60SXin Li } else {
815*05b00f60SXin Li ND_PRINT(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
816*05b00f60SXin Li }
817*05b00f60SXin Li PRINT_RESERVED_IF_NOT_ZERO_2(hdr->reserved0);
818*05b00f60SXin Li
819*05b00f60SXin Li dat += 12;
820*05b00f60SXin Li
821*05b00f60SXin Li switch(ctrl_msg_type) {
822*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_SCCRQ:
823*05b00f60SXin Li pptp_sccrq_print(ndo, dat);
824*05b00f60SXin Li break;
825*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_SCCRP:
826*05b00f60SXin Li pptp_sccrp_print(ndo, dat);
827*05b00f60SXin Li break;
828*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_StopCCRQ:
829*05b00f60SXin Li pptp_stopccrq_print(ndo, dat);
830*05b00f60SXin Li break;
831*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_StopCCRP:
832*05b00f60SXin Li pptp_stopccrp_print(ndo, dat);
833*05b00f60SXin Li break;
834*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_ECHORQ:
835*05b00f60SXin Li pptp_echorq_print(ndo, dat);
836*05b00f60SXin Li break;
837*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_ECHORP:
838*05b00f60SXin Li pptp_echorp_print(ndo, dat);
839*05b00f60SXin Li break;
840*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_OCRQ:
841*05b00f60SXin Li pptp_ocrq_print(ndo, dat);
842*05b00f60SXin Li break;
843*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_OCRP:
844*05b00f60SXin Li pptp_ocrp_print(ndo, dat);
845*05b00f60SXin Li break;
846*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_ICRQ:
847*05b00f60SXin Li pptp_icrq_print(ndo, dat);
848*05b00f60SXin Li break;
849*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_ICRP:
850*05b00f60SXin Li pptp_icrp_print(ndo, dat);
851*05b00f60SXin Li break;
852*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_ICCN:
853*05b00f60SXin Li pptp_iccn_print(ndo, dat);
854*05b00f60SXin Li break;
855*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_CCRQ:
856*05b00f60SXin Li pptp_ccrq_print(ndo, dat);
857*05b00f60SXin Li break;
858*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_CDN:
859*05b00f60SXin Li pptp_cdn_print(ndo, dat);
860*05b00f60SXin Li break;
861*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_WEN:
862*05b00f60SXin Li pptp_wen_print(ndo, dat);
863*05b00f60SXin Li break;
864*05b00f60SXin Li case PPTP_CTRL_MSG_TYPE_SLI:
865*05b00f60SXin Li pptp_sli_print(ndo, dat);
866*05b00f60SXin Li break;
867*05b00f60SXin Li default:
868*05b00f60SXin Li /* do nothing */
869*05b00f60SXin Li break;
870*05b00f60SXin Li }
871*05b00f60SXin Li }
872