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