blob: c77868d46256e0f9bf3327f4a4fbb918e1f6c026 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
2 * Copyright (c) 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and
9 * this paragraph in its entirety in the documentation or other materials
10 * provided with the distribution, and (3) all advertising materials mentioning
11 * features or use of this software display the following acknowledgement:
12 * ``This product includes software developed by the University of California,
13 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
14 * the University nor the names of its contributors may be used to endorse
15 * or promote products derived from this software without specific prior
16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 * PPTP support contributed by Motonori Shindo (mshindo@mshindo.net)
22 */
23
Elliott Hughes892a68b2015-10-19 14:43:53 -070024#define NETDISSECT_REWORKED
The Android Open Source Project2949f582009-03-03 19:30:46 -080025#ifdef HAVE_CONFIG_H
26#include "config.h"
27#endif
28
29#include <tcpdump-stdinc.h>
30
The Android Open Source Project2949f582009-03-03 19:30:46 -080031#include "interface.h"
32#include "extract.h"
33
Elliott Hughes892a68b2015-10-19 14:43:53 -070034static const char tstr[] = " [|pptp]";
The Android Open Source Project2949f582009-03-03 19:30:46 -080035
36#define PPTP_MSG_TYPE_CTRL 1 /* Control Message */
37#define PPTP_MSG_TYPE_MGMT 2 /* Management Message (currently not used */
38#define PPTP_MAGIC_COOKIE 0x1a2b3c4d /* for sanity check */
39
40#define PPTP_CTRL_MSG_TYPE_SCCRQ 1
41#define PPTP_CTRL_MSG_TYPE_SCCRP 2
42#define PPTP_CTRL_MSG_TYPE_StopCCRQ 3
43#define PPTP_CTRL_MSG_TYPE_StopCCRP 4
44#define PPTP_CTRL_MSG_TYPE_ECHORQ 5
45#define PPTP_CTRL_MSG_TYPE_ECHORP 6
46#define PPTP_CTRL_MSG_TYPE_OCRQ 7
47#define PPTP_CTRL_MSG_TYPE_OCRP 8
48#define PPTP_CTRL_MSG_TYPE_ICRQ 9
49#define PPTP_CTRL_MSG_TYPE_ICRP 10
50#define PPTP_CTRL_MSG_TYPE_ICCN 11
51#define PPTP_CTRL_MSG_TYPE_CCRQ 12
52#define PPTP_CTRL_MSG_TYPE_CDN 13
53#define PPTP_CTRL_MSG_TYPE_WEN 14
54#define PPTP_CTRL_MSG_TYPE_SLI 15
55
56#define PPTP_FRAMING_CAP_ASYNC_MASK 0x00000001 /* Aynchronous */
57#define PPTP_FRAMING_CAP_SYNC_MASK 0x00000002 /* Synchronous */
58
59#define PPTP_BEARER_CAP_ANALOG_MASK 0x00000001 /* Analog */
60#define PPTP_BEARER_CAP_DIGITAL_MASK 0x00000002 /* Digital */
61
62static const char *pptp_message_type_string[] = {
63 "NOT_DEFINED", /* 0 Not defined in the RFC2637 */
64 "SCCRQ", /* 1 Start-Control-Connection-Request */
65 "SCCRP", /* 2 Start-Control-Connection-Reply */
66 "StopCCRQ", /* 3 Stop-Control-Connection-Request */
67 "StopCCRP", /* 4 Stop-Control-Connection-Reply */
68 "ECHORQ", /* 5 Echo Request */
69 "ECHORP", /* 6 Echo Reply */
70
71 "OCRQ", /* 7 Outgoing-Call-Request */
72 "OCRP", /* 8 Outgoing-Call-Reply */
73 "ICRQ", /* 9 Incoming-Call-Request */
74 "ICRP", /* 10 Incoming-Call-Reply */
75 "ICCN", /* 11 Incoming-Call-Connected */
76 "CCRQ", /* 12 Call-Clear-Request */
77 "CDN", /* 13 Call-Disconnect-Notify */
78
79 "WEN", /* 14 WAN-Error-Notify */
80
81 "SLI" /* 15 Set-Link-Info */
82#define PPTP_MAX_MSGTYPE_INDEX 16
83};
84
85/* common for all PPTP control messages */
86struct pptp_hdr {
Elliott Hughes892a68b2015-10-19 14:43:53 -070087 uint16_t length;
88 uint16_t msg_type;
89 uint32_t magic_cookie;
90 uint16_t ctrl_msg_type;
91 uint16_t reserved0;
The Android Open Source Project2949f582009-03-03 19:30:46 -080092};
93
94struct pptp_msg_sccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -070095 uint16_t proto_ver;
96 uint16_t reserved1;
97 uint32_t framing_cap;
98 uint32_t bearer_cap;
99 uint16_t max_channel;
100 uint16_t firm_rev;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800101 u_char hostname[64];
102 u_char vendor[64];
103};
104
105struct pptp_msg_sccrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700106 uint16_t proto_ver;
107 uint8_t result_code;
108 uint8_t err_code;
109 uint32_t framing_cap;
110 uint32_t bearer_cap;
111 uint16_t max_channel;
112 uint16_t firm_rev;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800113 u_char hostname[64];
114 u_char vendor[64];
115};
116
117struct pptp_msg_stopccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700118 uint8_t reason;
119 uint8_t reserved1;
120 uint16_t reserved2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800121};
122
123struct pptp_msg_stopccrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700124 uint8_t result_code;
125 uint8_t err_code;
126 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800127};
128
129struct pptp_msg_echorq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700130 uint32_t id;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800131};
132
133struct pptp_msg_echorp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700134 uint32_t id;
135 uint8_t result_code;
136 uint8_t err_code;
137 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800138};
139
140struct pptp_msg_ocrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700141 uint16_t call_id;
142 uint16_t call_ser;
143 uint32_t min_bps;
144 uint32_t max_bps;
145 uint32_t bearer_type;
146 uint32_t framing_type;
147 uint16_t recv_winsiz;
148 uint16_t pkt_proc_delay;
149 uint16_t phone_no_len;
150 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800151 u_char phone_no[64];
152 u_char subaddr[64];
153};
154
155struct pptp_msg_ocrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700156 uint16_t call_id;
157 uint16_t peer_call_id;
158 uint8_t result_code;
159 uint8_t err_code;
160 uint16_t cause_code;
161 uint32_t conn_speed;
162 uint16_t recv_winsiz;
163 uint16_t pkt_proc_delay;
164 uint32_t phy_chan_id;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800165};
166
167struct pptp_msg_icrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700168 uint16_t call_id;
169 uint16_t call_ser;
170 uint32_t bearer_type;
171 uint32_t phy_chan_id;
172 uint16_t dialed_no_len;
173 uint16_t dialing_no_len;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800174 u_char dialed_no[64]; /* DNIS */
175 u_char dialing_no[64]; /* CLID */
176 u_char subaddr[64];
177};
178
179struct pptp_msg_icrp {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700180 uint16_t call_id;
181 uint16_t peer_call_id;
182 uint8_t result_code;
183 uint8_t err_code;
184 uint16_t recv_winsiz;
185 uint16_t pkt_proc_delay;
186 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800187};
188
189struct pptp_msg_iccn {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700190 uint16_t peer_call_id;
191 uint16_t reserved1;
192 uint32_t conn_speed;
193 uint16_t recv_winsiz;
194 uint16_t pkt_proc_delay;
195 uint32_t framing_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800196};
197
198struct pptp_msg_ccrq {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700199 uint16_t call_id;
200 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800201};
202
203struct pptp_msg_cdn {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700204 uint16_t call_id;
205 uint8_t result_code;
206 uint8_t err_code;
207 uint16_t cause_code;
208 uint16_t reserved1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800209 u_char call_stats[128];
210};
211
212struct pptp_msg_wen {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700213 uint16_t peer_call_id;
214 uint16_t reserved1;
215 uint32_t crc_err;
216 uint32_t framing_err;
217 uint32_t hardware_overrun;
218 uint32_t buffer_overrun;
219 uint32_t timeout_err;
220 uint32_t align_err;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800221};
222
223struct pptp_msg_sli {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700224 uint16_t peer_call_id;
225 uint16_t reserved1;
226 uint32_t send_accm;
227 uint32_t recv_accm;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800228};
229
230/* attributes that appear more than once in above messages:
231
232 Number of
233 occurence attributes
234 --------------------------------------
Elliott Hughes892a68b2015-10-19 14:43:53 -0700235 2 uint32_t bearer_cap;
236 2 uint32_t bearer_type;
237 6 uint16_t call_id;
238 2 uint16_t call_ser;
239 2 uint16_t cause_code;
240 2 uint32_t conn_speed;
241 6 uint8_t err_code;
242 2 uint16_t firm_rev;
243 2 uint32_t framing_cap;
244 2 uint32_t framing_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800245 2 u_char hostname[64];
Elliott Hughes892a68b2015-10-19 14:43:53 -0700246 2 uint32_t id;
247 2 uint16_t max_channel;
248 5 uint16_t peer_call_id;
249 2 uint32_t phy_chan_id;
250 4 uint16_t pkt_proc_delay;
251 2 uint16_t proto_ver;
252 4 uint16_t recv_winsiz;
253 2 uint8_t reserved1;
254 9 uint16_t reserved1;
255 6 uint8_t result_code;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800256 2 u_char subaddr[64];
257 2 u_char vendor[64];
258
259 so I will prepare print out functions for these attributes (except for
260 reserved*).
261*/
262
263/******************************************/
264/* Attribute-specific print out functions */
265/******************************************/
266
267/* In these attribute-specific print-out functions, it't not necessary
Elliott Hughes892a68b2015-10-19 14:43:53 -0700268 to do ND_TCHECK because they are already checked in the caller of
The Android Open Source Project2949f582009-03-03 19:30:46 -0800269 these functions. */
270
271static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700272pptp_bearer_cap_print(netdissect_options *ndo,
273 const uint32_t *bearer_cap)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800274{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700275 ND_PRINT((ndo, " BEARER_CAP(%s%s)",
276 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
277 EXTRACT_32BITS(bearer_cap) & PPTP_BEARER_CAP_ANALOG_MASK ? "A" : ""));
278}
279
280static const struct tok pptp_btype_str[] = {
281 { 1, "A" }, /* Analog */
282 { 2, "D" }, /* Digital */
283 { 3, "Any" },
284 { 0, NULL }
285};
286
287static void
288pptp_bearer_type_print(netdissect_options *ndo,
289 const uint32_t *bearer_type)
290{
291 ND_PRINT((ndo, " BEARER_TYPE(%s)",
292 tok2str(pptp_btype_str, "?", EXTRACT_32BITS(bearer_type))));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800293}
294
295static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700296pptp_call_id_print(netdissect_options *ndo,
297 const uint16_t *call_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800298{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700299 ND_PRINT((ndo, " CALL_ID(%u)", EXTRACT_16BITS(call_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800300}
301
302static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700303pptp_call_ser_print(netdissect_options *ndo,
304 const uint16_t *call_ser)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800305{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700306 ND_PRINT((ndo, " CALL_SER_NUM(%u)", EXTRACT_16BITS(call_ser)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800307}
308
309static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700310pptp_cause_code_print(netdissect_options *ndo,
311 const uint16_t *cause_code)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800312{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700313 ND_PRINT((ndo, " CAUSE_CODE(%u)", EXTRACT_16BITS(cause_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800314}
315
316static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700317pptp_conn_speed_print(netdissect_options *ndo,
318 const uint32_t *conn_speed)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800319{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700320 ND_PRINT((ndo, " CONN_SPEED(%u)", EXTRACT_32BITS(conn_speed)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800321}
322
Elliott Hughes892a68b2015-10-19 14:43:53 -0700323static const struct tok pptp_errcode_str[] = {
324 { 0, "None" },
325 { 1, "Not-Connected" },
326 { 2, "Bad-Format" },
327 { 3, "Bad-Value" },
328 { 4, "No-Resource" },
329 { 5, "Bad-Call-ID" },
330 { 6, "PAC-Error" },
331 { 0, NULL }
332};
The Android Open Source Project2949f582009-03-03 19:30:46 -0800333
334static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700335pptp_err_code_print(netdissect_options *ndo,
336 const uint8_t *err_code)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800337{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700338 ND_PRINT((ndo, " ERR_CODE(%u", *err_code));
339 if (ndo->ndo_vflag) {
340 ND_PRINT((ndo, ":%s", tok2str(pptp_errcode_str, "?", *err_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800341 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700342 ND_PRINT((ndo, ")"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800343}
344
345static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700346pptp_firm_rev_print(netdissect_options *ndo,
347 const uint16_t *firm_rev)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800348{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700349 ND_PRINT((ndo, " FIRM_REV(%u)", EXTRACT_16BITS(firm_rev)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800350}
351
352static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700353pptp_framing_cap_print(netdissect_options *ndo,
354 const uint32_t *framing_cap)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800355{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700356 ND_PRINT((ndo, " FRAME_CAP("));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800357 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700358 ND_PRINT((ndo, "A")); /* Async */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800359 }
360 if (EXTRACT_32BITS(framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700361 ND_PRINT((ndo, "S")); /* Sync */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800362 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700363 ND_PRINT((ndo, ")"));
364}
365
366static const struct tok pptp_ftype_str[] = {
367 { 1, "A" }, /* Async */
368 { 2, "S" }, /* Sync */
369 { 3, "E" }, /* Either */
370 { 0, NULL }
371};
372
373static void
374pptp_framing_type_print(netdissect_options *ndo,
375 const uint32_t *framing_type)
376{
377 ND_PRINT((ndo, " FRAME_TYPE(%s)",
378 tok2str(pptp_ftype_str, "?", EXTRACT_32BITS(framing_type))));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800379}
380
381static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700382pptp_hostname_print(netdissect_options *ndo,
383 const u_char *hostname)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800384{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700385 ND_PRINT((ndo, " HOSTNAME(%.64s)", hostname));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800386}
387
388static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700389pptp_id_print(netdissect_options *ndo,
390 const uint32_t *id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800391{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700392 ND_PRINT((ndo, " ID(%u)", EXTRACT_32BITS(id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800393}
394
395static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700396pptp_max_channel_print(netdissect_options *ndo,
397 const uint16_t *max_channel)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800398{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700399 ND_PRINT((ndo, " MAX_CHAN(%u)", EXTRACT_16BITS(max_channel)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800400}
401
402static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700403pptp_peer_call_id_print(netdissect_options *ndo,
404 const uint16_t *peer_call_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800405{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700406 ND_PRINT((ndo, " PEER_CALL_ID(%u)", EXTRACT_16BITS(peer_call_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800407}
408
409static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700410pptp_phy_chan_id_print(netdissect_options *ndo,
411 const uint32_t *phy_chan_id)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800412{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700413 ND_PRINT((ndo, " PHY_CHAN_ID(%u)", EXTRACT_32BITS(phy_chan_id)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800414}
415
416static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700417pptp_pkt_proc_delay_print(netdissect_options *ndo,
418 const uint16_t *pkt_proc_delay)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800419{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700420 ND_PRINT((ndo, " PROC_DELAY(%u)", EXTRACT_16BITS(pkt_proc_delay)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800421}
422
423static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700424pptp_proto_ver_print(netdissect_options *ndo,
425 const uint16_t *proto_ver)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800426{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700427 ND_PRINT((ndo, " PROTO_VER(%u.%u)", /* Version.Revision */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800428 EXTRACT_16BITS(proto_ver) >> 8,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700429 EXTRACT_16BITS(proto_ver) & 0xff));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800430}
431
432static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700433pptp_recv_winsiz_print(netdissect_options *ndo,
434 const uint16_t *recv_winsiz)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800435{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700436 ND_PRINT((ndo, " RECV_WIN(%u)", EXTRACT_16BITS(recv_winsiz)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800437}
438
Elliott Hughes892a68b2015-10-19 14:43:53 -0700439static const struct tok pptp_scrrp_str[] = {
440 { 1, "Successful channel establishment" },
441 { 2, "General error" },
442 { 3, "Command channel already exists" },
443 { 4, "Requester is not authorized to establish a command channel" },
444 { 5, "The protocol version of the requester is not supported" },
445 { 0, NULL }
446};
447
448static const struct tok pptp_echorp_str[] = {
449 { 1, "OK" },
450 { 2, "General Error" },
451 { 0, NULL }
452};
453
454static const struct tok pptp_ocrp_str[] = {
455 { 1, "Connected" },
456 { 2, "General Error" },
457 { 3, "No Carrier" },
458 { 4, "Busy" },
459 { 5, "No Dial Tone" },
460 { 6, "Time-out" },
461 { 7, "Do Not Accept" },
462 { 0, NULL }
463};
464
465static const struct tok pptp_icrp_str[] = {
466 { 1, "Connect" },
467 { 2, "General Error" },
468 { 3, "Do Not Accept" },
469 { 0, NULL }
470};
471
472static const struct tok pptp_cdn_str[] = {
473 { 1, "Lost Carrier" },
474 { 2, "General Error" },
475 { 3, "Admin Shutdown" },
476 { 4, "Request" },
477 { 0, NULL }
478};
479
The Android Open Source Project2949f582009-03-03 19:30:46 -0800480static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700481pptp_result_code_print(netdissect_options *ndo,
482 const uint8_t *result_code, int ctrl_msg_type)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800483{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700484 ND_PRINT((ndo, " RESULT_CODE(%u", *result_code));
485 if (ndo->ndo_vflag) {
486 const struct tok *dict =
487 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
488 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
489 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
490 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
491 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
492 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
493 NULL; /* assertion error */
494 if (dict != NULL)
495 ND_PRINT((ndo, ":%s", tok2str(dict, "?", *result_code)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800496 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700497 ND_PRINT((ndo, ")"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800498}
499
500static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700501pptp_subaddr_print(netdissect_options *ndo,
502 const u_char *subaddr)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800503{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700504 ND_PRINT((ndo, " SUB_ADDR(%.64s)", subaddr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800505}
506
507static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700508pptp_vendor_print(netdissect_options *ndo,
509 const u_char *vendor)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800510{
Elliott Hughes892a68b2015-10-19 14:43:53 -0700511 ND_PRINT((ndo, " VENDOR(%.64s)", vendor));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800512}
513
514/************************************/
515/* PPTP message print out functions */
516/************************************/
517static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700518pptp_sccrq_print(netdissect_options *ndo,
519 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800520{
521 struct pptp_msg_sccrq *ptr = (struct pptp_msg_sccrq *)dat;
522
Elliott Hughes892a68b2015-10-19 14:43:53 -0700523 ND_TCHECK(ptr->proto_ver);
524 pptp_proto_ver_print(ndo, &ptr->proto_ver);
525 ND_TCHECK(ptr->reserved1);
526 ND_TCHECK(ptr->framing_cap);
527 pptp_framing_cap_print(ndo, &ptr->framing_cap);
528 ND_TCHECK(ptr->bearer_cap);
529 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
530 ND_TCHECK(ptr->max_channel);
531 pptp_max_channel_print(ndo, &ptr->max_channel);
532 ND_TCHECK(ptr->firm_rev);
533 pptp_firm_rev_print(ndo, &ptr->firm_rev);
534 ND_TCHECK(ptr->hostname);
535 pptp_hostname_print(ndo, &ptr->hostname[0]);
536 ND_TCHECK(ptr->vendor);
537 pptp_vendor_print(ndo, &ptr->vendor[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800538
539 return;
540
541trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700542 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800543}
544
545static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700546pptp_sccrp_print(netdissect_options *ndo,
547 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800548{
549 struct pptp_msg_sccrp *ptr = (struct pptp_msg_sccrp *)dat;
550
Elliott Hughes892a68b2015-10-19 14:43:53 -0700551 ND_TCHECK(ptr->proto_ver);
552 pptp_proto_ver_print(ndo, &ptr->proto_ver);
553 ND_TCHECK(ptr->result_code);
554 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
555 ND_TCHECK(ptr->err_code);
556 pptp_err_code_print(ndo, &ptr->err_code);
557 ND_TCHECK(ptr->framing_cap);
558 pptp_framing_cap_print(ndo, &ptr->framing_cap);
559 ND_TCHECK(ptr->bearer_cap);
560 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
561 ND_TCHECK(ptr->max_channel);
562 pptp_max_channel_print(ndo, &ptr->max_channel);
563 ND_TCHECK(ptr->firm_rev);
564 pptp_firm_rev_print(ndo, &ptr->firm_rev);
565 ND_TCHECK(ptr->hostname);
566 pptp_hostname_print(ndo, &ptr->hostname[0]);
567 ND_TCHECK(ptr->vendor);
568 pptp_vendor_print(ndo, &ptr->vendor[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800569
570 return;
571
572trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700573 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800574}
575
576static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700577pptp_stopccrq_print(netdissect_options *ndo,
578 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800579{
580 struct pptp_msg_stopccrq *ptr = (struct pptp_msg_stopccrq *)dat;
581
Elliott Hughes892a68b2015-10-19 14:43:53 -0700582 ND_TCHECK(ptr->reason);
583 ND_PRINT((ndo, " REASON(%u", ptr->reason));
584 if (ndo->ndo_vflag) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800585 switch (ptr->reason) {
586 case 1:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700587 ND_PRINT((ndo, ":None"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800588 break;
589 case 2:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700590 ND_PRINT((ndo, ":Stop-Protocol"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800591 break;
592 case 3:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700593 ND_PRINT((ndo, ":Stop-Local-Shutdown"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800594 break;
595 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700596 ND_PRINT((ndo, ":?"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800597 break;
598 }
599 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700600 ND_PRINT((ndo, ")"));
601 ND_TCHECK(ptr->reserved1);
602 ND_TCHECK(ptr->reserved2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800603
604 return;
605
606trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700607 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800608}
609
610static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700611pptp_stopccrp_print(netdissect_options *ndo,
612 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800613{
614 struct pptp_msg_stopccrp *ptr = (struct pptp_msg_stopccrp *)dat;
615
Elliott Hughes892a68b2015-10-19 14:43:53 -0700616 ND_TCHECK(ptr->result_code);
617 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
618 ND_TCHECK(ptr->err_code);
619 pptp_err_code_print(ndo, &ptr->err_code);
620 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800621
622 return;
623
624trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700625 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800626}
627
628static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700629pptp_echorq_print(netdissect_options *ndo,
630 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800631{
632 struct pptp_msg_echorq *ptr = (struct pptp_msg_echorq *)dat;
633
Elliott Hughes892a68b2015-10-19 14:43:53 -0700634 ND_TCHECK(ptr->id);
635 pptp_id_print(ndo, &ptr->id);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800636
637 return;
638
639trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700640 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800641}
642
643static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700644pptp_echorp_print(netdissect_options *ndo,
645 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800646{
647 struct pptp_msg_echorp *ptr = (struct pptp_msg_echorp *)dat;
648
Elliott Hughes892a68b2015-10-19 14:43:53 -0700649 ND_TCHECK(ptr->id);
650 pptp_id_print(ndo, &ptr->id);
651 ND_TCHECK(ptr->result_code);
652 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
653 ND_TCHECK(ptr->err_code);
654 pptp_err_code_print(ndo, &ptr->err_code);
655 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800656
657 return;
658
659trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700660 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800661}
662
663static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700664pptp_ocrq_print(netdissect_options *ndo,
665 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800666{
667 struct pptp_msg_ocrq *ptr = (struct pptp_msg_ocrq *)dat;
668
Elliott Hughes892a68b2015-10-19 14:43:53 -0700669 ND_TCHECK(ptr->call_id);
670 pptp_call_id_print(ndo, &ptr->call_id);
671 ND_TCHECK(ptr->call_ser);
672 pptp_call_ser_print(ndo, &ptr->call_ser);
673 ND_TCHECK(ptr->min_bps);
674 ND_PRINT((ndo, " MIN_BPS(%u)", EXTRACT_32BITS(&ptr->min_bps)));
675 ND_TCHECK(ptr->max_bps);
676 ND_PRINT((ndo, " MAX_BPS(%u)", EXTRACT_32BITS(&ptr->max_bps)));
677 ND_TCHECK(ptr->bearer_type);
678 pptp_bearer_type_print(ndo, &ptr->bearer_type);
679 ND_TCHECK(ptr->framing_type);
680 pptp_framing_type_print(ndo, &ptr->framing_type);
681 ND_TCHECK(ptr->recv_winsiz);
682 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
683 ND_TCHECK(ptr->pkt_proc_delay);
684 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
685 ND_TCHECK(ptr->phone_no_len);
686 ND_PRINT((ndo, " PHONE_NO_LEN(%u)", EXTRACT_16BITS(&ptr->phone_no_len)));
687 ND_TCHECK(ptr->reserved1);
688 ND_TCHECK(ptr->phone_no);
689 ND_PRINT((ndo, " PHONE_NO(%.64s)", ptr->phone_no));
690 ND_TCHECK(ptr->subaddr);
691 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800692
693 return;
694
695trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700696 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800697}
698
699static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700700pptp_ocrp_print(netdissect_options *ndo,
701 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800702{
703 struct pptp_msg_ocrp *ptr = (struct pptp_msg_ocrp *)dat;
704
Elliott Hughes892a68b2015-10-19 14:43:53 -0700705 ND_TCHECK(ptr->call_id);
706 pptp_call_id_print(ndo, &ptr->call_id);
707 ND_TCHECK(ptr->peer_call_id);
708 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
709 ND_TCHECK(ptr->result_code);
710 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
711 ND_TCHECK(ptr->err_code);
712 pptp_err_code_print(ndo, &ptr->err_code);
713 ND_TCHECK(ptr->cause_code);
714 pptp_cause_code_print(ndo, &ptr->cause_code);
715 ND_TCHECK(ptr->conn_speed);
716 pptp_conn_speed_print(ndo, &ptr->conn_speed);
717 ND_TCHECK(ptr->recv_winsiz);
718 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
719 ND_TCHECK(ptr->pkt_proc_delay);
720 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
721 ND_TCHECK(ptr->phy_chan_id);
722 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800723
724 return;
725
726trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700727 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800728}
729
730static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700731pptp_icrq_print(netdissect_options *ndo,
732 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800733{
734 struct pptp_msg_icrq *ptr = (struct pptp_msg_icrq *)dat;
735
Elliott Hughes892a68b2015-10-19 14:43:53 -0700736 ND_TCHECK(ptr->call_id);
737 pptp_call_id_print(ndo, &ptr->call_id);
738 ND_TCHECK(ptr->call_ser);
739 pptp_call_ser_print(ndo, &ptr->call_ser);
740 ND_TCHECK(ptr->bearer_type);
741 pptp_bearer_type_print(ndo, &ptr->bearer_type);
742 ND_TCHECK(ptr->phy_chan_id);
743 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
744 ND_TCHECK(ptr->dialed_no_len);
745 ND_PRINT((ndo, " DIALED_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialed_no_len)));
746 ND_TCHECK(ptr->dialing_no_len);
747 ND_PRINT((ndo, " DIALING_NO_LEN(%u)", EXTRACT_16BITS(&ptr->dialing_no_len)));
748 ND_TCHECK(ptr->dialed_no);
749 ND_PRINT((ndo, " DIALED_NO(%.64s)", ptr->dialed_no));
750 ND_TCHECK(ptr->dialing_no);
751 ND_PRINT((ndo, " DIALING_NO(%.64s)", ptr->dialing_no));
752 ND_TCHECK(ptr->subaddr);
753 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800754
755 return;
756
757trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700758 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800759}
760
761static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700762pptp_icrp_print(netdissect_options *ndo,
763 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800764{
765 struct pptp_msg_icrp *ptr = (struct pptp_msg_icrp *)dat;
766
Elliott Hughes892a68b2015-10-19 14:43:53 -0700767 ND_TCHECK(ptr->call_id);
768 pptp_call_id_print(ndo, &ptr->call_id);
769 ND_TCHECK(ptr->peer_call_id);
770 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
771 ND_TCHECK(ptr->result_code);
772 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
773 ND_TCHECK(ptr->err_code);
774 pptp_err_code_print(ndo, &ptr->err_code);
775 ND_TCHECK(ptr->recv_winsiz);
776 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
777 ND_TCHECK(ptr->pkt_proc_delay);
778 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
779 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800780
781 return;
782
783trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700784 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800785}
786
787static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700788pptp_iccn_print(netdissect_options *ndo,
789 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800790{
791 struct pptp_msg_iccn *ptr = (struct pptp_msg_iccn *)dat;
792
Elliott Hughes892a68b2015-10-19 14:43:53 -0700793 ND_TCHECK(ptr->peer_call_id);
794 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
795 ND_TCHECK(ptr->reserved1);
796 ND_TCHECK(ptr->conn_speed);
797 pptp_conn_speed_print(ndo, &ptr->conn_speed);
798 ND_TCHECK(ptr->recv_winsiz);
799 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
800 ND_TCHECK(ptr->pkt_proc_delay);
801 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
802 ND_TCHECK(ptr->framing_type);
803 pptp_framing_type_print(ndo, &ptr->framing_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800804
805 return;
806
807trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700808 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800809}
810
811static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700812pptp_ccrq_print(netdissect_options *ndo,
813 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800814{
815 struct pptp_msg_ccrq *ptr = (struct pptp_msg_ccrq *)dat;
816
Elliott Hughes892a68b2015-10-19 14:43:53 -0700817 ND_TCHECK(ptr->call_id);
818 pptp_call_id_print(ndo, &ptr->call_id);
819 ND_TCHECK(ptr->reserved1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800820
821 return;
822
823trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700824 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800825}
826
827static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700828pptp_cdn_print(netdissect_options *ndo,
829 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800830{
831 struct pptp_msg_cdn *ptr = (struct pptp_msg_cdn *)dat;
832
Elliott Hughes892a68b2015-10-19 14:43:53 -0700833 ND_TCHECK(ptr->call_id);
834 pptp_call_id_print(ndo, &ptr->call_id);
835 ND_TCHECK(ptr->result_code);
836 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
837 ND_TCHECK(ptr->err_code);
838 pptp_err_code_print(ndo, &ptr->err_code);
839 ND_TCHECK(ptr->cause_code);
840 pptp_cause_code_print(ndo, &ptr->cause_code);
841 ND_TCHECK(ptr->reserved1);
842 ND_TCHECK(ptr->call_stats);
843 ND_PRINT((ndo, " CALL_STATS(%.128s)", ptr->call_stats));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800844
845 return;
846
847trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700848 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800849}
850
851static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700852pptp_wen_print(netdissect_options *ndo,
853 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800854{
855 struct pptp_msg_wen *ptr = (struct pptp_msg_wen *)dat;
856
Elliott Hughes892a68b2015-10-19 14:43:53 -0700857 ND_TCHECK(ptr->peer_call_id);
858 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
859 ND_TCHECK(ptr->reserved1);
860 ND_TCHECK(ptr->crc_err);
861 ND_PRINT((ndo, " CRC_ERR(%u)", EXTRACT_32BITS(&ptr->crc_err)));
862 ND_TCHECK(ptr->framing_err);
863 ND_PRINT((ndo, " FRAMING_ERR(%u)", EXTRACT_32BITS(&ptr->framing_err)));
864 ND_TCHECK(ptr->hardware_overrun);
865 ND_PRINT((ndo, " HARDWARE_OVERRUN(%u)", EXTRACT_32BITS(&ptr->hardware_overrun)));
866 ND_TCHECK(ptr->buffer_overrun);
867 ND_PRINT((ndo, " BUFFER_OVERRUN(%u)", EXTRACT_32BITS(&ptr->buffer_overrun)));
868 ND_TCHECK(ptr->timeout_err);
869 ND_PRINT((ndo, " TIMEOUT_ERR(%u)", EXTRACT_32BITS(&ptr->timeout_err)));
870 ND_TCHECK(ptr->align_err);
871 ND_PRINT((ndo, " ALIGN_ERR(%u)", EXTRACT_32BITS(&ptr->align_err)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800872
873 return;
874
875trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700876 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800877}
878
879static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700880pptp_sli_print(netdissect_options *ndo,
881 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800882{
883 struct pptp_msg_sli *ptr = (struct pptp_msg_sli *)dat;
884
Elliott Hughes892a68b2015-10-19 14:43:53 -0700885 ND_TCHECK(ptr->peer_call_id);
886 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
887 ND_TCHECK(ptr->reserved1);
888 ND_TCHECK(ptr->send_accm);
889 ND_PRINT((ndo, " SEND_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->send_accm)));
890 ND_TCHECK(ptr->recv_accm);
891 ND_PRINT((ndo, " RECV_ACCM(0x%08x)", EXTRACT_32BITS(&ptr->recv_accm)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800892
893 return;
894
895trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700896 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800897}
898
899void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700900pptp_print(netdissect_options *ndo,
901 const u_char *dat)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800902{
903 const struct pptp_hdr *hdr;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700904 uint32_t mc;
905 uint16_t ctrl_msg_type;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800906
Elliott Hughes892a68b2015-10-19 14:43:53 -0700907 ND_PRINT((ndo, ": pptp"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800908
909 hdr = (struct pptp_hdr *)dat;
910
Elliott Hughes892a68b2015-10-19 14:43:53 -0700911 ND_TCHECK(hdr->length);
912 if (ndo->ndo_vflag) {
913 ND_PRINT((ndo, " Length=%u", EXTRACT_16BITS(&hdr->length)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800914 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700915 ND_TCHECK(hdr->msg_type);
916 if (ndo->ndo_vflag) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800917 switch(EXTRACT_16BITS(&hdr->msg_type)) {
918 case PPTP_MSG_TYPE_CTRL:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700919 ND_PRINT((ndo, " CTRL-MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800920 break;
921 case PPTP_MSG_TYPE_MGMT:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700922 ND_PRINT((ndo, " MGMT-MSG"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800923 break;
924 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700925 ND_PRINT((ndo, " UNKNOWN-MSG-TYPE"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800926 break;
927 }
928 }
929
Elliott Hughes892a68b2015-10-19 14:43:53 -0700930 ND_TCHECK(hdr->magic_cookie);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800931 mc = EXTRACT_32BITS(&hdr->magic_cookie);
932 if (mc != PPTP_MAGIC_COOKIE) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700933 ND_PRINT((ndo, " UNEXPECTED Magic-Cookie!!(%08x)", mc));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800934 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700935 if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
936 ND_PRINT((ndo, " Magic-Cookie=%08x", mc));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800937 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700938 ND_TCHECK(hdr->ctrl_msg_type);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800939 ctrl_msg_type = EXTRACT_16BITS(&hdr->ctrl_msg_type);
940 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700941 ND_PRINT((ndo, " CTRL_MSGTYPE=%s",
942 pptp_message_type_string[ctrl_msg_type]));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800943 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700944 ND_PRINT((ndo, " UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800945 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700946 ND_TCHECK(hdr->reserved0);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800947
948 dat += 12;
949
950 switch(ctrl_msg_type) {
951 case PPTP_CTRL_MSG_TYPE_SCCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700952 pptp_sccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800953 break;
954 case PPTP_CTRL_MSG_TYPE_SCCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700955 pptp_sccrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800956 break;
957 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700958 pptp_stopccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800959 break;
960 case PPTP_CTRL_MSG_TYPE_StopCCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700961 pptp_stopccrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800962 break;
963 case PPTP_CTRL_MSG_TYPE_ECHORQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700964 pptp_echorq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800965 break;
966 case PPTP_CTRL_MSG_TYPE_ECHORP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700967 pptp_echorp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800968 break;
969 case PPTP_CTRL_MSG_TYPE_OCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700970 pptp_ocrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800971 break;
972 case PPTP_CTRL_MSG_TYPE_OCRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700973 pptp_ocrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800974 break;
975 case PPTP_CTRL_MSG_TYPE_ICRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700976 pptp_icrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800977 break;
978 case PPTP_CTRL_MSG_TYPE_ICRP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700979 pptp_icrp_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800980 break;
981 case PPTP_CTRL_MSG_TYPE_ICCN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700982 pptp_iccn_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800983 break;
984 case PPTP_CTRL_MSG_TYPE_CCRQ:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700985 pptp_ccrq_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800986 break;
987 case PPTP_CTRL_MSG_TYPE_CDN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700988 pptp_cdn_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800989 break;
990 case PPTP_CTRL_MSG_TYPE_WEN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700991 pptp_wen_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800992 break;
993 case PPTP_CTRL_MSG_TYPE_SLI:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700994 pptp_sli_print(ndo, dat);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800995 break;
996 default:
997 /* do nothing */
998 break;
999 }
1000
1001 return;
1002
1003trunc:
Elliott Hughes892a68b2015-10-19 14:43:53 -07001004 ND_PRINT((ndo, "%s", tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -08001005}