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