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