]> The Tcpdump Group git mirrors - tcpdump/blob - print-pptp.c
remove redundant ND_TCHECK, let GET_ routines handle checks
[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 (GET_U_1(reserved)) \
267 ND_PRINT(" [ERROR: reserved=%u must be zero]", \
268 GET_U_1(reserved));
269
270 #define PRINT_RESERVED_IF_NOT_ZERO_2(reserved) \
271 if (GET_BE_U_2(reserved)) \
272 ND_PRINT(" [ERROR: reserved=%u must be zero]", \
273 GET_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 GET_BE_U_4(*bearer_cap) & PPTP_BEARER_CAP_DIGITAL_MASK ? "D" : "",
289 GET_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, "?", GET_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)", GET_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)", GET_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)", GET_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)", GET_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", GET_U_1(*err_code));
351 if (ndo->ndo_vflag) {
352 ND_PRINT(":%s",
353 tok2str(pptp_errcode_str, "?", GET_U_1(*err_code)));
354 }
355 ND_PRINT(")");
356 }
357
358 static void
359 pptp_firm_rev_print(netdissect_options *ndo,
360 const nd_uint16_t *firm_rev)
361 {
362 ND_PRINT(" FIRM_REV(%u)", GET_BE_U_2(*firm_rev));
363 }
364
365 static void
366 pptp_framing_cap_print(netdissect_options *ndo,
367 const nd_uint32_t *framing_cap)
368 {
369 ND_PRINT(" FRAME_CAP(");
370 if (GET_BE_U_4(*framing_cap) & PPTP_FRAMING_CAP_ASYNC_MASK) {
371 ND_PRINT("A"); /* Async */
372 }
373 if (GET_BE_U_4(*framing_cap) & PPTP_FRAMING_CAP_SYNC_MASK) {
374 ND_PRINT("S"); /* Sync */
375 }
376 ND_PRINT(")");
377 }
378
379 static const struct tok pptp_ftype_str[] = {
380 { 1, "A" }, /* Async */
381 { 2, "S" }, /* Sync */
382 { 3, "E" }, /* Either */
383 { 0, NULL }
384 };
385
386 static void
387 pptp_framing_type_print(netdissect_options *ndo,
388 const nd_uint32_t *framing_type)
389 {
390 ND_PRINT(" FRAME_TYPE(%s)",
391 tok2str(pptp_ftype_str, "?", GET_BE_U_4(*framing_type)));
392 }
393
394 static void
395 pptp_hostname_print(netdissect_options *ndo,
396 const u_char *hostname)
397 {
398 ND_PRINT(" HOSTNAME(%.64s)", hostname);
399 }
400
401 static void
402 pptp_id_print(netdissect_options *ndo,
403 const nd_uint32_t *id)
404 {
405 ND_PRINT(" ID(%u)", GET_BE_U_4(*id));
406 }
407
408 static void
409 pptp_max_channel_print(netdissect_options *ndo,
410 const nd_uint16_t *max_channel)
411 {
412 ND_PRINT(" MAX_CHAN(%u)", GET_BE_U_2(*max_channel));
413 }
414
415 static void
416 pptp_peer_call_id_print(netdissect_options *ndo,
417 const nd_uint16_t *peer_call_id)
418 {
419 ND_PRINT(" PEER_CALL_ID(%u)", GET_BE_U_2(*peer_call_id));
420 }
421
422 static void
423 pptp_phy_chan_id_print(netdissect_options *ndo,
424 const nd_uint32_t *phy_chan_id)
425 {
426 ND_PRINT(" PHY_CHAN_ID(%u)", GET_BE_U_4(*phy_chan_id));
427 }
428
429 static void
430 pptp_pkt_proc_delay_print(netdissect_options *ndo,
431 const nd_uint16_t *pkt_proc_delay)
432 {
433 ND_PRINT(" PROC_DELAY(%u)", GET_BE_U_2(*pkt_proc_delay));
434 }
435
436 static void
437 pptp_proto_ver_print(netdissect_options *ndo,
438 const nd_uint16_t *proto_ver)
439 {
440 ND_PRINT(" PROTO_VER(%u.%u)", /* Version.Revision */
441 GET_BE_U_2(*proto_ver) >> 8,
442 GET_BE_U_2(*proto_ver) & 0xff);
443 }
444
445 static void
446 pptp_recv_winsiz_print(netdissect_options *ndo,
447 const nd_uint16_t *recv_winsiz)
448 {
449 ND_PRINT(" RECV_WIN(%u)", GET_BE_U_2(*recv_winsiz));
450 }
451
452 static const struct tok pptp_scrrp_str[] = {
453 { 1, "Successful channel establishment" },
454 { 2, "General error" },
455 { 3, "Command channel already exists" },
456 { 4, "Requester is not authorized to establish a command channel" },
457 { 5, "The protocol version of the requester is not supported" },
458 { 0, NULL }
459 };
460
461 static const struct tok pptp_echorp_str[] = {
462 { 1, "OK" },
463 { 2, "General Error" },
464 { 0, NULL }
465 };
466
467 static const struct tok pptp_ocrp_str[] = {
468 { 1, "Connected" },
469 { 2, "General Error" },
470 { 3, "No Carrier" },
471 { 4, "Busy" },
472 { 5, "No Dial Tone" },
473 { 6, "Time-out" },
474 { 7, "Do Not Accept" },
475 { 0, NULL }
476 };
477
478 static const struct tok pptp_icrp_str[] = {
479 { 1, "Connect" },
480 { 2, "General Error" },
481 { 3, "Do Not Accept" },
482 { 0, NULL }
483 };
484
485 static const struct tok pptp_cdn_str[] = {
486 { 1, "Lost Carrier" },
487 { 2, "General Error" },
488 { 3, "Admin Shutdown" },
489 { 4, "Request" },
490 { 0, NULL }
491 };
492
493 static void
494 pptp_result_code_print(netdissect_options *ndo,
495 const nd_uint8_t *result_code, int ctrl_msg_type)
496 {
497 ND_PRINT(" RESULT_CODE(%u", GET_U_1(*result_code));
498 if (ndo->ndo_vflag) {
499 const struct tok *dict =
500 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_SCCRP ? pptp_scrrp_str :
501 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_StopCCRP ? pptp_echorp_str :
502 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ECHORP ? pptp_echorp_str :
503 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_OCRP ? pptp_ocrp_str :
504 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_ICRP ? pptp_icrp_str :
505 ctrl_msg_type == PPTP_CTRL_MSG_TYPE_CDN ? pptp_cdn_str :
506 NULL; /* assertion error */
507 if (dict != NULL)
508 ND_PRINT(":%s",
509 tok2str(dict, "?", GET_U_1(*result_code)));
510 }
511 ND_PRINT(")");
512 }
513
514 static void
515 pptp_subaddr_print(netdissect_options *ndo,
516 const u_char *subaddr)
517 {
518 ND_PRINT(" SUB_ADDR(%.64s)", subaddr);
519 }
520
521 static void
522 pptp_vendor_print(netdissect_options *ndo,
523 const u_char *vendor)
524 {
525 ND_PRINT(" VENDOR(%.64s)", vendor);
526 }
527
528 /************************************/
529 /* PPTP message print out functions */
530 /************************************/
531 static void
532 pptp_sccrq_print(netdissect_options *ndo,
533 const u_char *dat)
534 {
535 const struct pptp_msg_sccrq *ptr = (const struct pptp_msg_sccrq *)dat;
536
537 ND_TCHECK_2(ptr->proto_ver);
538 pptp_proto_ver_print(ndo, &ptr->proto_ver);
539 ND_TCHECK_2(ptr->reserved1);
540 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
541 ND_TCHECK_4(ptr->framing_cap);
542 pptp_framing_cap_print(ndo, &ptr->framing_cap);
543 ND_TCHECK_4(ptr->bearer_cap);
544 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
545 ND_TCHECK_2(ptr->max_channel);
546 pptp_max_channel_print(ndo, &ptr->max_channel);
547 ND_TCHECK_2(ptr->firm_rev);
548 pptp_firm_rev_print(ndo, &ptr->firm_rev);
549 ND_TCHECK_SIZE(&ptr->hostname);
550 pptp_hostname_print(ndo, &ptr->hostname[0]);
551 ND_TCHECK_SIZE(&ptr->vendor);
552 pptp_vendor_print(ndo, &ptr->vendor[0]);
553
554 return;
555
556 trunc:
557 nd_print_trunc(ndo);
558 }
559
560 static void
561 pptp_sccrp_print(netdissect_options *ndo,
562 const u_char *dat)
563 {
564 const struct pptp_msg_sccrp *ptr = (const struct pptp_msg_sccrp *)dat;
565
566 ND_TCHECK_2(ptr->proto_ver);
567 pptp_proto_ver_print(ndo, &ptr->proto_ver);
568 ND_TCHECK_1(ptr->result_code);
569 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_SCCRP);
570 ND_TCHECK_1(ptr->err_code);
571 pptp_err_code_print(ndo, &ptr->err_code);
572 ND_TCHECK_4(ptr->framing_cap);
573 pptp_framing_cap_print(ndo, &ptr->framing_cap);
574 ND_TCHECK_4(ptr->bearer_cap);
575 pptp_bearer_cap_print(ndo, &ptr->bearer_cap);
576 ND_TCHECK_2(ptr->max_channel);
577 pptp_max_channel_print(ndo, &ptr->max_channel);
578 ND_TCHECK_2(ptr->firm_rev);
579 pptp_firm_rev_print(ndo, &ptr->firm_rev);
580 ND_TCHECK_SIZE(&ptr->hostname);
581 pptp_hostname_print(ndo, &ptr->hostname[0]);
582 ND_TCHECK_SIZE(&ptr->vendor);
583 pptp_vendor_print(ndo, &ptr->vendor[0]);
584
585 return;
586
587 trunc:
588 nd_print_trunc(ndo);
589 }
590
591 static void
592 pptp_stopccrq_print(netdissect_options *ndo,
593 const u_char *dat)
594 {
595 const struct pptp_msg_stopccrq *ptr = (const struct pptp_msg_stopccrq *)dat;
596
597 ND_PRINT(" REASON(%u", GET_U_1(ptr->reason));
598 if (ndo->ndo_vflag) {
599 switch (GET_U_1(ptr->reason)) {
600 case 1:
601 ND_PRINT(":None");
602 break;
603 case 2:
604 ND_PRINT(":Stop-Protocol");
605 break;
606 case 3:
607 ND_PRINT(":Stop-Local-Shutdown");
608 break;
609 default:
610 ND_PRINT(":?");
611 break;
612 }
613 }
614 ND_PRINT(")");
615 ND_TCHECK_1(ptr->reserved1);
616 PRINT_RESERVED_IF_NOT_ZERO_1(ptr->reserved1);
617 ND_TCHECK_2(ptr->reserved2);
618 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved2);
619
620 return;
621
622 trunc:
623 nd_print_trunc(ndo);
624 }
625
626 static void
627 pptp_stopccrp_print(netdissect_options *ndo,
628 const u_char *dat)
629 {
630 const struct pptp_msg_stopccrp *ptr = (const struct pptp_msg_stopccrp *)dat;
631
632 ND_TCHECK_1(ptr->result_code);
633 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_StopCCRP);
634 ND_TCHECK_1(ptr->err_code);
635 pptp_err_code_print(ndo, &ptr->err_code);
636 ND_TCHECK_2(ptr->reserved1);
637 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
638
639 return;
640
641 trunc:
642 nd_print_trunc(ndo);
643 }
644
645 static void
646 pptp_echorq_print(netdissect_options *ndo,
647 const u_char *dat)
648 {
649 const struct pptp_msg_echorq *ptr = (const struct pptp_msg_echorq *)dat;
650
651 ND_TCHECK_4(ptr->id);
652 pptp_id_print(ndo, &ptr->id);
653
654 return;
655
656 trunc:
657 nd_print_trunc(ndo);
658 }
659
660 static void
661 pptp_echorp_print(netdissect_options *ndo,
662 const u_char *dat)
663 {
664 const struct pptp_msg_echorp *ptr = (const struct pptp_msg_echorp *)dat;
665
666 ND_TCHECK_4(ptr->id);
667 pptp_id_print(ndo, &ptr->id);
668 ND_TCHECK_1(ptr->result_code);
669 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ECHORP);
670 ND_TCHECK_1(ptr->err_code);
671 pptp_err_code_print(ndo, &ptr->err_code);
672 ND_TCHECK_2(ptr->reserved1);
673 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
674
675 return;
676
677 trunc:
678 nd_print_trunc(ndo);
679 }
680
681 static void
682 pptp_ocrq_print(netdissect_options *ndo,
683 const u_char *dat)
684 {
685 const struct pptp_msg_ocrq *ptr = (const struct pptp_msg_ocrq *)dat;
686
687 ND_TCHECK_2(ptr->call_id);
688 pptp_call_id_print(ndo, &ptr->call_id);
689 ND_TCHECK_2(ptr->call_ser);
690 pptp_call_ser_print(ndo, &ptr->call_ser);
691 ND_PRINT(" MIN_BPS(%u)", GET_BE_U_4(ptr->min_bps));
692 ND_PRINT(" MAX_BPS(%u)", GET_BE_U_4(ptr->max_bps));
693 ND_TCHECK_4(ptr->bearer_type);
694 pptp_bearer_type_print(ndo, &ptr->bearer_type);
695 ND_TCHECK_4(ptr->framing_type);
696 pptp_framing_type_print(ndo, &ptr->framing_type);
697 ND_TCHECK_2(ptr->recv_winsiz);
698 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
699 ND_TCHECK_2(ptr->pkt_proc_delay);
700 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
701 ND_PRINT(" PHONE_NO_LEN(%u)", GET_BE_U_2(ptr->phone_no_len));
702 ND_TCHECK_2(ptr->reserved1);
703 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
704 ND_TCHECK_SIZE(&ptr->phone_no);
705 ND_PRINT(" PHONE_NO(%.64s)", ptr->phone_no);
706 ND_TCHECK_SIZE(&ptr->subaddr);
707 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
708
709 return;
710
711 trunc:
712 nd_print_trunc(ndo);
713 }
714
715 static void
716 pptp_ocrp_print(netdissect_options *ndo,
717 const u_char *dat)
718 {
719 const struct pptp_msg_ocrp *ptr = (const struct pptp_msg_ocrp *)dat;
720
721 ND_TCHECK_2(ptr->call_id);
722 pptp_call_id_print(ndo, &ptr->call_id);
723 ND_TCHECK_2(ptr->peer_call_id);
724 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
725 ND_TCHECK_1(ptr->result_code);
726 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_OCRP);
727 ND_TCHECK_1(ptr->err_code);
728 pptp_err_code_print(ndo, &ptr->err_code);
729 ND_TCHECK_2(ptr->cause_code);
730 pptp_cause_code_print(ndo, &ptr->cause_code);
731 ND_TCHECK_4(ptr->conn_speed);
732 pptp_conn_speed_print(ndo, &ptr->conn_speed);
733 ND_TCHECK_2(ptr->recv_winsiz);
734 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
735 ND_TCHECK_2(ptr->pkt_proc_delay);
736 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
737 ND_TCHECK_4(ptr->phy_chan_id);
738 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
739
740 return;
741
742 trunc:
743 nd_print_trunc(ndo);
744 }
745
746 static void
747 pptp_icrq_print(netdissect_options *ndo,
748 const u_char *dat)
749 {
750 const struct pptp_msg_icrq *ptr = (const struct pptp_msg_icrq *)dat;
751
752 ND_TCHECK_2(ptr->call_id);
753 pptp_call_id_print(ndo, &ptr->call_id);
754 ND_TCHECK_2(ptr->call_ser);
755 pptp_call_ser_print(ndo, &ptr->call_ser);
756 ND_TCHECK_4(ptr->bearer_type);
757 pptp_bearer_type_print(ndo, &ptr->bearer_type);
758 ND_TCHECK_4(ptr->phy_chan_id);
759 pptp_phy_chan_id_print(ndo, &ptr->phy_chan_id);
760 ND_PRINT(" DIALED_NO_LEN(%u)", GET_BE_U_2(ptr->dialed_no_len));
761 ND_PRINT(" DIALING_NO_LEN(%u)", GET_BE_U_2(ptr->dialing_no_len));
762 ND_TCHECK_SIZE(&ptr->dialed_no);
763 ND_PRINT(" DIALED_NO(%.64s)", ptr->dialed_no);
764 ND_TCHECK_SIZE(&ptr->dialing_no);
765 ND_PRINT(" DIALING_NO(%.64s)", ptr->dialing_no);
766 ND_TCHECK_SIZE(&ptr->subaddr);
767 pptp_subaddr_print(ndo, &ptr->subaddr[0]);
768
769 return;
770
771 trunc:
772 nd_print_trunc(ndo);
773 }
774
775 static void
776 pptp_icrp_print(netdissect_options *ndo,
777 const u_char *dat)
778 {
779 const struct pptp_msg_icrp *ptr = (const struct pptp_msg_icrp *)dat;
780
781 ND_TCHECK_2(ptr->call_id);
782 pptp_call_id_print(ndo, &ptr->call_id);
783 ND_TCHECK_2(ptr->peer_call_id);
784 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
785 ND_TCHECK_1(ptr->result_code);
786 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_ICRP);
787 ND_TCHECK_1(ptr->err_code);
788 pptp_err_code_print(ndo, &ptr->err_code);
789 ND_TCHECK_2(ptr->recv_winsiz);
790 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
791 ND_TCHECK_2(ptr->pkt_proc_delay);
792 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
793 ND_TCHECK_2(ptr->reserved1);
794 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
795
796 return;
797
798 trunc:
799 nd_print_trunc(ndo);
800 }
801
802 static void
803 pptp_iccn_print(netdissect_options *ndo,
804 const u_char *dat)
805 {
806 const struct pptp_msg_iccn *ptr = (const struct pptp_msg_iccn *)dat;
807
808 ND_TCHECK_2(ptr->peer_call_id);
809 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
810 ND_TCHECK_2(ptr->reserved1);
811 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
812 ND_TCHECK_4(ptr->conn_speed);
813 pptp_conn_speed_print(ndo, &ptr->conn_speed);
814 ND_TCHECK_2(ptr->recv_winsiz);
815 pptp_recv_winsiz_print(ndo, &ptr->recv_winsiz);
816 ND_TCHECK_2(ptr->pkt_proc_delay);
817 pptp_pkt_proc_delay_print(ndo, &ptr->pkt_proc_delay);
818 ND_TCHECK_4(ptr->framing_type);
819 pptp_framing_type_print(ndo, &ptr->framing_type);
820
821 return;
822
823 trunc:
824 nd_print_trunc(ndo);
825 }
826
827 static void
828 pptp_ccrq_print(netdissect_options *ndo,
829 const u_char *dat)
830 {
831 const struct pptp_msg_ccrq *ptr = (const struct pptp_msg_ccrq *)dat;
832
833 ND_TCHECK_2(ptr->call_id);
834 pptp_call_id_print(ndo, &ptr->call_id);
835 ND_TCHECK_2(ptr->reserved1);
836 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
837
838 return;
839
840 trunc:
841 nd_print_trunc(ndo);
842 }
843
844 static void
845 pptp_cdn_print(netdissect_options *ndo,
846 const u_char *dat)
847 {
848 const struct pptp_msg_cdn *ptr = (const struct pptp_msg_cdn *)dat;
849
850 ND_TCHECK_2(ptr->call_id);
851 pptp_call_id_print(ndo, &ptr->call_id);
852 ND_TCHECK_1(ptr->result_code);
853 pptp_result_code_print(ndo, &ptr->result_code, PPTP_CTRL_MSG_TYPE_CDN);
854 ND_TCHECK_1(ptr->err_code);
855 pptp_err_code_print(ndo, &ptr->err_code);
856 ND_TCHECK_2(ptr->cause_code);
857 pptp_cause_code_print(ndo, &ptr->cause_code);
858 ND_TCHECK_2(ptr->reserved1);
859 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
860 ND_TCHECK_SIZE(&ptr->call_stats);
861 ND_PRINT(" CALL_STATS(%.128s)", ptr->call_stats);
862
863 return;
864
865 trunc:
866 nd_print_trunc(ndo);
867 }
868
869 static void
870 pptp_wen_print(netdissect_options *ndo,
871 const u_char *dat)
872 {
873 const struct pptp_msg_wen *ptr = (const struct pptp_msg_wen *)dat;
874
875 ND_TCHECK_2(ptr->peer_call_id);
876 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
877 ND_TCHECK_2(ptr->reserved1);
878 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
879 ND_PRINT(" CRC_ERR(%u)", GET_BE_U_4(ptr->crc_err));
880 ND_PRINT(" FRAMING_ERR(%u)", GET_BE_U_4(ptr->framing_err));
881 ND_PRINT(" HARDWARE_OVERRUN(%u)", GET_BE_U_4(ptr->hardware_overrun));
882 ND_PRINT(" BUFFER_OVERRUN(%u)", GET_BE_U_4(ptr->buffer_overrun));
883 ND_PRINT(" TIMEOUT_ERR(%u)", GET_BE_U_4(ptr->timeout_err));
884 ND_PRINT(" ALIGN_ERR(%u)", GET_BE_U_4(ptr->align_err));
885
886 return;
887
888 trunc:
889 nd_print_trunc(ndo);
890 }
891
892 static void
893 pptp_sli_print(netdissect_options *ndo,
894 const u_char *dat)
895 {
896 const struct pptp_msg_sli *ptr = (const struct pptp_msg_sli *)dat;
897
898 ND_TCHECK_2(ptr->peer_call_id);
899 pptp_peer_call_id_print(ndo, &ptr->peer_call_id);
900 ND_TCHECK_2(ptr->reserved1);
901 PRINT_RESERVED_IF_NOT_ZERO_2(ptr->reserved1);
902 ND_PRINT(" SEND_ACCM(0x%08x)", GET_BE_U_4(ptr->send_accm));
903 ND_PRINT(" RECV_ACCM(0x%08x)", GET_BE_U_4(ptr->recv_accm));
904
905 return;
906
907 trunc:
908 nd_print_trunc(ndo);
909 }
910
911 void
912 pptp_print(netdissect_options *ndo,
913 const u_char *dat)
914 {
915 const struct pptp_hdr *hdr;
916 uint32_t mc;
917 uint16_t ctrl_msg_type;
918
919 ndo->ndo_protocol = "pptp";
920 ND_PRINT(": pptp");
921
922 hdr = (const struct pptp_hdr *)dat;
923
924 if (ndo->ndo_vflag) {
925 ND_PRINT(" Length=%u", GET_BE_U_2(hdr->length));
926 }
927 if (ndo->ndo_vflag) {
928 switch(GET_BE_U_2(hdr->msg_type)) {
929 case PPTP_MSG_TYPE_CTRL:
930 ND_PRINT(" CTRL-MSG");
931 break;
932 case PPTP_MSG_TYPE_MGMT:
933 ND_PRINT(" MGMT-MSG");
934 break;
935 default:
936 ND_PRINT(" UNKNOWN-MSG-TYPE");
937 break;
938 }
939 }
940
941 mc = GET_BE_U_4(hdr->magic_cookie);
942 if (mc != PPTP_MAGIC_COOKIE) {
943 ND_PRINT(" UNEXPECTED Magic-Cookie!!(%08x)", mc);
944 }
945 if (ndo->ndo_vflag || mc != PPTP_MAGIC_COOKIE) {
946 ND_PRINT(" Magic-Cookie=%08x", mc);
947 }
948 ctrl_msg_type = GET_BE_U_2(hdr->ctrl_msg_type);
949 if (ctrl_msg_type < PPTP_MAX_MSGTYPE_INDEX) {
950 ND_PRINT(" CTRL_MSGTYPE=%s",
951 pptp_message_type_string[ctrl_msg_type]);
952 } else {
953 ND_PRINT(" UNKNOWN_CTRL_MSGTYPE(%u)", ctrl_msg_type);
954 }
955 ND_TCHECK_2(hdr->reserved0);
956 PRINT_RESERVED_IF_NOT_ZERO_2(hdr->reserved0);
957
958 dat += 12;
959
960 switch(ctrl_msg_type) {
961 case PPTP_CTRL_MSG_TYPE_SCCRQ:
962 pptp_sccrq_print(ndo, dat);
963 break;
964 case PPTP_CTRL_MSG_TYPE_SCCRP:
965 pptp_sccrp_print(ndo, dat);
966 break;
967 case PPTP_CTRL_MSG_TYPE_StopCCRQ:
968 pptp_stopccrq_print(ndo, dat);
969 break;
970 case PPTP_CTRL_MSG_TYPE_StopCCRP:
971 pptp_stopccrp_print(ndo, dat);
972 break;
973 case PPTP_CTRL_MSG_TYPE_ECHORQ:
974 pptp_echorq_print(ndo, dat);
975 break;
976 case PPTP_CTRL_MSG_TYPE_ECHORP:
977 pptp_echorp_print(ndo, dat);
978 break;
979 case PPTP_CTRL_MSG_TYPE_OCRQ:
980 pptp_ocrq_print(ndo, dat);
981 break;
982 case PPTP_CTRL_MSG_TYPE_OCRP:
983 pptp_ocrp_print(ndo, dat);
984 break;
985 case PPTP_CTRL_MSG_TYPE_ICRQ:
986 pptp_icrq_print(ndo, dat);
987 break;
988 case PPTP_CTRL_MSG_TYPE_ICRP:
989 pptp_icrp_print(ndo, dat);
990 break;
991 case PPTP_CTRL_MSG_TYPE_ICCN:
992 pptp_iccn_print(ndo, dat);
993 break;
994 case PPTP_CTRL_MSG_TYPE_CCRQ:
995 pptp_ccrq_print(ndo, dat);
996 break;
997 case PPTP_CTRL_MSG_TYPE_CDN:
998 pptp_cdn_print(ndo, dat);
999 break;
1000 case PPTP_CTRL_MSG_TYPE_WEN:
1001 pptp_wen_print(ndo, dat);
1002 break;
1003 case PPTP_CTRL_MSG_TYPE_SLI:
1004 pptp_sli_print(ndo, dat);
1005 break;
1006 default:
1007 /* do nothing */
1008 break;
1009 }
1010
1011 return;
1012
1013 trunc:
1014 nd_print_trunc(ndo);
1015 }