1 /* 2 * Copyright (c) 1988, 1989, 1990, 1991, 1992, 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 22 #include <sys/cdefs.h> 23 #ifndef lint 24 __RCSID("$NetBSD: print-udp.c,v 1.6 2015/03/31 21:59:35 christos Exp $"); 25 #endif 26 27 #define NETDISSECT_REWORKED 28 #ifdef HAVE_CONFIG_H 29 #include "config.h" 30 #endif 31 32 #include <tcpdump-stdinc.h> 33 34 #include "interface.h" 35 #include "addrtoname.h" 36 #include "extract.h" 37 #include "appletalk.h" 38 39 #include "udp.h" 40 41 #include "ip.h" 42 #ifdef INET6 43 #include "ip6.h" 44 #endif 45 #include "ipproto.h" 46 #include "rpc_auth.h" 47 #include "rpc_msg.h" 48 49 #include "nameser.h" 50 #include "nfs.h" 51 52 struct rtcphdr { 53 uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */ 54 uint16_t rh_len; /* length of message (in words) */ 55 uint32_t rh_ssrc; /* synchronization src id */ 56 }; 57 58 typedef struct { 59 uint32_t upper; /* more significant 32 bits */ 60 uint32_t lower; /* less significant 32 bits */ 61 } ntp64; 62 63 /* 64 * Sender report. 65 */ 66 struct rtcp_sr { 67 ntp64 sr_ntp; /* 64-bit ntp timestamp */ 68 uint32_t sr_ts; /* reference media timestamp */ 69 uint32_t sr_np; /* no. packets sent */ 70 uint32_t sr_nb; /* no. bytes sent */ 71 }; 72 73 /* 74 * Receiver report. 75 * Time stamps are middle 32-bits of ntp timestamp. 76 */ 77 struct rtcp_rr { 78 uint32_t rr_srcid; /* sender being reported */ 79 uint32_t rr_nl; /* no. packets lost */ 80 uint32_t rr_ls; /* extended last seq number received */ 81 uint32_t rr_dv; /* jitter (delay variance) */ 82 uint32_t rr_lsr; /* orig. ts from last rr from this src */ 83 uint32_t rr_dlsr; /* time from recpt of last rr to xmit time */ 84 }; 85 86 /*XXX*/ 87 #define RTCP_PT_SR 200 88 #define RTCP_PT_RR 201 89 #define RTCP_PT_SDES 202 90 #define RTCP_SDES_CNAME 1 91 #define RTCP_SDES_NAME 2 92 #define RTCP_SDES_EMAIL 3 93 #define RTCP_SDES_PHONE 4 94 #define RTCP_SDES_LOC 5 95 #define RTCP_SDES_TOOL 6 96 #define RTCP_SDES_NOTE 7 97 #define RTCP_SDES_PRIV 8 98 #define RTCP_PT_BYE 203 99 #define RTCP_PT_APP 204 100 101 static void 102 vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up) 103 { 104 /* vat/vt audio */ 105 u_int ts = *(uint16_t *)hdr; 106 if ((ts & 0xf060) != 0) { 107 /* probably vt */ 108 ND_PRINT((ndo, "udp/vt %u %d / %d", 109 (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)), 110 ts & 0x3ff, ts >> 10)); 111 } else { 112 /* probably vat */ 113 uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]); 114 uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]); 115 ND_PRINT((ndo, "udp/vat %u c%d %u%s", 116 (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8), 117 i0 & 0xffff, 118 i1, i0 & 0x800000? "*" : "")); 119 /* audio format */ 120 if (i0 & 0x1f0000) 121 ND_PRINT((ndo, " f%d", (i0 >> 16) & 0x1f)); 122 if (i0 & 0x3f000000) 123 ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f)); 124 } 125 } 126 127 static void 128 rtp_print(netdissect_options *ndo, const void *hdr, u_int len, 129 register const struct udphdr *up) 130 { 131 /* rtp v1 or v2 */ 132 u_int *ip = (u_int *)hdr; 133 u_int hasopt, hasext, contype, hasmarker; 134 uint32_t i0 = EXTRACT_32BITS(&((u_int *)hdr)[0]); 135 uint32_t i1 = EXTRACT_32BITS(&((u_int *)hdr)[1]); 136 u_int dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8; 137 const char * ptype; 138 139 ip += 2; 140 len >>= 2; 141 len -= 2; 142 hasopt = 0; 143 hasext = 0; 144 if ((i0 >> 30) == 1) { 145 /* rtp v1 */ 146 hasopt = i0 & 0x800000; 147 contype = (i0 >> 16) & 0x3f; 148 hasmarker = i0 & 0x400000; 149 ptype = "rtpv1"; 150 } else { 151 /* rtp v2 */ 152 hasext = i0 & 0x10000000; 153 contype = (i0 >> 16) & 0x7f; 154 hasmarker = i0 & 0x800000; 155 dlen -= 4; 156 ptype = "rtp"; 157 ip += 1; 158 len -= 1; 159 } 160 ND_PRINT((ndo, "udp/%s %d c%d %s%s %d %u", 161 ptype, 162 dlen, 163 contype, 164 (hasopt || hasext)? "+" : "", 165 hasmarker? "*" : "", 166 i0 & 0xffff, 167 i1)); 168 if (ndo->ndo_vflag) { 169 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((u_int *)hdr)[2]))); 170 if (hasopt) { 171 u_int i2, optlen; 172 do { 173 i2 = ip[0]; 174 optlen = (i2 >> 16) & 0xff; 175 if (optlen == 0 || optlen > len) { 176 ND_PRINT((ndo, " !opt")); 177 return; 178 } 179 ip += optlen; 180 len -= optlen; 181 } while ((int)i2 >= 0); 182 } 183 if (hasext) { 184 u_int i2, extlen; 185 i2 = ip[0]; 186 extlen = (i2 & 0xffff) + 1; 187 if (extlen > len) { 188 ND_PRINT((ndo, " !ext")); 189 return; 190 } 191 ip += extlen; 192 } 193 if (contype == 0x1f) /*XXX H.261 */ 194 ND_PRINT((ndo, " 0x%04x", ip[0] >> 16)); 195 } 196 } 197 198 static const u_char * 199 rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep) 200 { 201 /* rtp v2 control (rtcp) */ 202 struct rtcp_rr *rr = 0; 203 struct rtcp_sr *sr; 204 struct rtcphdr *rh = (struct rtcphdr *)hdr; 205 u_int len; 206 uint16_t flags; 207 int cnt; 208 double ts, dts; 209 if ((u_char *)(rh + 1) > ep) { 210 ND_PRINT((ndo, " [|rtcp]")); 211 return (ep); 212 } 213 len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4; 214 flags = EXTRACT_16BITS(&rh->rh_flags); 215 cnt = (flags >> 8) & 0x1f; 216 switch (flags & 0xff) { 217 case RTCP_PT_SR: 218 sr = (struct rtcp_sr *)(rh + 1); 219 ND_PRINT((ndo, " sr")); 220 if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh)) 221 ND_PRINT((ndo, " [%d]", len)); 222 if (ndo->ndo_vflag) 223 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc))); 224 if ((u_char *)(sr + 1) > ep) { 225 ND_PRINT((ndo, " [|rtcp]")); 226 return (ep); 227 } 228 ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) + 229 ((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) / 230 4294967296.0); 231 ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts), 232 EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb))); 233 rr = (struct rtcp_rr *)(sr + 1); 234 break; 235 case RTCP_PT_RR: 236 ND_PRINT((ndo, " rr")); 237 if (len != cnt * sizeof(*rr) + sizeof(*rh)) 238 ND_PRINT((ndo, " [%d]", len)); 239 rr = (struct rtcp_rr *)(rh + 1); 240 if (ndo->ndo_vflag) 241 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc))); 242 break; 243 case RTCP_PT_SDES: 244 ND_PRINT((ndo, " sdes %d", len)); 245 if (ndo->ndo_vflag) 246 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc))); 247 cnt = 0; 248 break; 249 case RTCP_PT_BYE: 250 ND_PRINT((ndo, " bye %d", len)); 251 if (ndo->ndo_vflag) 252 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc))); 253 cnt = 0; 254 break; 255 default: 256 ND_PRINT((ndo, " type-0x%x %d", flags & 0xff, len)); 257 cnt = 0; 258 break; 259 } 260 if (cnt > 1) 261 ND_PRINT((ndo, " c%d", cnt)); 262 while (--cnt >= 0) { 263 if ((u_char *)(rr + 1) > ep) { 264 ND_PRINT((ndo, " [|rtcp]")); 265 return (ep); 266 } 267 if (ndo->ndo_vflag) 268 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rr->rr_srcid))); 269 ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.; 270 dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.; 271 ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f", 272 EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff, 273 EXTRACT_32BITS(&rr->rr_ls), 274 EXTRACT_32BITS(&rr->rr_dv), ts, dts)); 275 } 276 return (hdr + len); 277 } 278 279 static int udp_cksum(netdissect_options *ndo, register const struct ip *ip, 280 register const struct udphdr *up, 281 register u_int len) 282 { 283 return nextproto4_cksum(ndo, ip, (const uint8_t *)(void *)up, len, len, 284 IPPROTO_UDP); 285 } 286 287 #ifdef INET6 288 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up, 289 u_int len) 290 { 291 return nextproto6_cksum(ip6, (const uint8_t *)(void *)up, len, len, 292 IPPROTO_UDP); 293 } 294 #endif 295 296 static void 297 udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport) 298 { 299 #ifdef INET6 300 const struct ip6_hdr *ip6; 301 302 if (IP_V(ip) == 6) 303 ip6 = (const struct ip6_hdr *)ip; 304 else 305 ip6 = NULL; 306 307 if (ip6) { 308 if (ip6->ip6_nxt == IPPROTO_UDP) { 309 if (sport == -1) { 310 ND_PRINT((ndo, "%s > %s: ", 311 ip6addr_string(ndo, &ip6->ip6_src), 312 ip6addr_string(ndo, &ip6->ip6_dst))); 313 } else { 314 ND_PRINT((ndo, "%s.%s > %s.%s: ", 315 ip6addr_string(ndo, &ip6->ip6_src), 316 udpport_string(sport), 317 ip6addr_string(ndo, &ip6->ip6_dst), 318 udpport_string(dport))); 319 } 320 } else { 321 if (sport != -1) { 322 ND_PRINT((ndo, "%s > %s: ", 323 udpport_string(sport), 324 udpport_string(dport))); 325 } 326 } 327 } else 328 #endif /*INET6*/ 329 { 330 if (ip->ip_p == IPPROTO_UDP) { 331 if (sport == -1) { 332 ND_PRINT((ndo, "%s > %s: ", 333 ipaddr_string(ndo, &ip->ip_src), 334 ipaddr_string(ndo, &ip->ip_dst))); 335 } else { 336 ND_PRINT((ndo, "%s.%s > %s.%s: ", 337 ipaddr_string(ndo, &ip->ip_src), 338 udpport_string(sport), 339 ipaddr_string(ndo, &ip->ip_dst), 340 udpport_string(dport))); 341 } 342 } else { 343 if (sport != -1) { 344 ND_PRINT((ndo, "%s > %s: ", 345 udpport_string(sport), 346 udpport_string(dport))); 347 } 348 } 349 } 350 } 351 352 void 353 udp_print(netdissect_options *ndo, register const u_char *bp, u_int length, 354 register const u_char *bp2, int fragmented) 355 { 356 register const struct udphdr *up; 357 register const struct ip *ip; 358 register const u_char *cp; 359 register const u_char *ep = bp + length; 360 uint16_t sport, dport, ulen; 361 #ifdef INET6 362 register const struct ip6_hdr *ip6; 363 #endif 364 365 if (ep > ndo->ndo_snapend) 366 ep = ndo->ndo_snapend; 367 up = (struct udphdr *)bp; 368 ip = (struct ip *)bp2; 369 #ifdef INET6 370 if (IP_V(ip) == 6) 371 ip6 = (struct ip6_hdr *)bp2; 372 else 373 ip6 = NULL; 374 #endif /*INET6*/ 375 if (!ND_TTEST(up->uh_dport)) { 376 udpipaddr_print(ndo, ip, -1, -1); 377 ND_PRINT((ndo, "[|udp]")); 378 return; 379 } 380 381 sport = EXTRACT_16BITS(&up->uh_sport); 382 dport = EXTRACT_16BITS(&up->uh_dport); 383 384 if (length < sizeof(struct udphdr)) { 385 udpipaddr_print(ndo, ip, sport, dport); 386 ND_PRINT((ndo, "truncated-udp %d", length)); 387 return; 388 } 389 ulen = EXTRACT_16BITS(&up->uh_ulen); 390 if (ulen < sizeof(struct udphdr)) { 391 udpipaddr_print(ndo, ip, sport, dport); 392 ND_PRINT((ndo, "truncated-udplength %d", ulen)); 393 return; 394 } 395 ulen -= sizeof(struct udphdr); 396 length -= sizeof(struct udphdr); 397 if (ulen < length) 398 length = ulen; 399 400 cp = (u_char *)(up + 1); 401 if (cp > ndo->ndo_snapend) { 402 udpipaddr_print(ndo, ip, sport, dport); 403 ND_PRINT((ndo, "[|udp]")); 404 return; 405 } 406 407 if (ndo->ndo_packettype) { 408 register struct sunrpc_msg *rp; 409 enum sunrpc_msg_type direction; 410 411 switch (ndo->ndo_packettype) { 412 413 case PT_VAT: 414 udpipaddr_print(ndo, ip, sport, dport); 415 vat_print(ndo, (void *)(up + 1), up); 416 break; 417 418 case PT_WB: 419 udpipaddr_print(ndo, ip, sport, dport); 420 wb_print(ndo, (void *)(up + 1), length); 421 break; 422 423 case PT_RPC: 424 rp = (struct sunrpc_msg *)(up + 1); 425 direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction); 426 if (direction == SUNRPC_CALL) 427 #ifndef __minix 428 sunrpcrequest_print(ndo, (u_char *)rp, length, 429 (u_char *)ip); 430 #else /* __minix */ 431 /* 432 * FIXME: remove this exception once rpc has 433 * been imported! 434 */ 435 /*nothing*/; 436 #endif /* __minix */ 437 else 438 nfsreply_print(ndo, (u_char *)rp, length, 439 (u_char *)ip); /*XXX*/ 440 break; 441 442 case PT_RTP: 443 udpipaddr_print(ndo, ip, sport, dport); 444 rtp_print(ndo, (void *)(up + 1), length, up); 445 break; 446 447 case PT_RTCP: 448 udpipaddr_print(ndo, ip, sport, dport); 449 while (cp < ep) 450 cp = rtcp_print(ndo, cp, ep); 451 break; 452 453 case PT_SNMP: 454 udpipaddr_print(ndo, ip, sport, dport); 455 snmp_print(ndo, (const u_char *)(up + 1), length); 456 break; 457 458 case PT_CNFP: 459 udpipaddr_print(ndo, ip, sport, dport); 460 cnfp_print(ndo, cp); 461 break; 462 463 case PT_TFTP: 464 udpipaddr_print(ndo, ip, sport, dport); 465 tftp_print(ndo, cp, length); 466 break; 467 468 case PT_AODV: 469 udpipaddr_print(ndo, ip, sport, dport); 470 aodv_print(ndo, (const u_char *)(up + 1), length, 471 #ifdef INET6 472 ip6 != NULL); 473 #else 474 0); 475 #endif 476 break; 477 478 case PT_RADIUS: 479 udpipaddr_print(ndo, ip, sport, dport); 480 radius_print(ndo, cp, length); 481 break; 482 483 case PT_VXLAN: 484 udpipaddr_print(ndo, ip, sport, dport); 485 vxlan_print(ndo, (const u_char *)(up + 1), length); 486 break; 487 488 case PT_PGM: 489 case PT_PGM_ZMTP1: 490 udpipaddr_print(ndo, ip, sport, dport); 491 pgm_print(ndo, cp, length, bp2); 492 break; 493 case PT_LMP: 494 udpipaddr_print(ndo, ip, sport, dport); 495 lmp_print(ndo, cp, length); 496 break; 497 } 498 return; 499 } 500 501 udpipaddr_print(ndo, ip, sport, dport); 502 if (!ndo->ndo_qflag) { 503 register struct sunrpc_msg *rp; 504 enum sunrpc_msg_type direction; 505 506 rp = (struct sunrpc_msg *)(up + 1); 507 if (ND_TTEST(rp->rm_direction)) { 508 direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction); 509 if (dport == NFS_PORT && direction == SUNRPC_CALL) { 510 ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid))); 511 nfsreq_print_noaddr(ndo, (u_char *)rp, length, 512 (u_char *)ip); 513 return; 514 } 515 if (sport == NFS_PORT && direction == SUNRPC_REPLY) { 516 ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid))); 517 nfsreply_print_noaddr(ndo, (u_char *)rp, length, 518 (u_char *)ip); 519 return; 520 } 521 #ifdef notdef 522 if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) { 523 sunrpcrequest_print((u_char *)rp, length, (u_char *)ip); 524 return; 525 } 526 #endif 527 } 528 if (ND_TTEST(((struct LAP *)cp)->type) && 529 ((struct LAP *)cp)->type == lapDDP && 530 (atalk_port(sport) || atalk_port(dport))) { 531 if (ndo->ndo_vflag) 532 ND_PRINT((ndo, "kip ")); 533 llap_print(ndo, cp, length); 534 return; 535 } 536 } 537 538 if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) { 539 /* Check the checksum, if possible. */ 540 uint16_t sum, udp_sum; 541 542 /* 543 * XXX - do this even if vflag == 1? 544 * TCP does, and we do so for UDP-over-IPv6. 545 */ 546 if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) { 547 udp_sum = EXTRACT_16BITS(&up->uh_sum); 548 if (udp_sum == 0) { 549 ND_PRINT((ndo, "[no cksum] ")); 550 } else if (ND_TTEST2(cp[0], length)) { 551 sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr)); 552 553 if (sum != 0) { 554 ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ", 555 udp_sum, 556 in_cksum_shouldbe(udp_sum, sum))); 557 } else 558 ND_PRINT((ndo, "[udp sum ok] ")); 559 } 560 } 561 #ifdef INET6 562 else if (IP_V(ip) == 6 && ip6->ip6_plen) { 563 /* for IPv6, UDP checksum is mandatory */ 564 if (ND_TTEST2(cp[0], length)) { 565 sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr)); 566 udp_sum = EXTRACT_16BITS(&up->uh_sum); 567 568 if (sum != 0) { 569 ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ", 570 udp_sum, 571 in_cksum_shouldbe(udp_sum, sum))); 572 } else 573 ND_PRINT((ndo, "[udp sum ok] ")); 574 } 575 } 576 #endif 577 } 578 579 if (!ndo->ndo_qflag) { 580 #define ISPORT(p) (dport == (p) || sport == (p)) 581 if (ISPORT(NAMESERVER_PORT)) 582 ns_print(ndo, (const u_char *)(up + 1), length, 0); 583 else if (ISPORT(MULTICASTDNS_PORT)) 584 ns_print(ndo, (const u_char *)(up + 1), length, 1); 585 else if (ISPORT(TIMED_PORT)) 586 timed_print(ndo, (const u_char *)(up + 1)); 587 else if (ISPORT(TFTP_PORT)) 588 tftp_print(ndo, (const u_char *)(up + 1), length); 589 else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT)) 590 bootp_print(ndo, (const u_char *)(up + 1), length); 591 else if (ISPORT(RIP_PORT)) 592 rip_print(ndo, (const u_char *)(up + 1), length); 593 else if (ISPORT(AODV_PORT)) 594 aodv_print(ndo, (const u_char *)(up + 1), length, 595 #ifdef INET6 596 ip6 != NULL); 597 #else 598 0); 599 #endif 600 else if (ISPORT(ISAKMP_PORT)) 601 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2); 602 else if (ISPORT(ISAKMP_PORT_NATT)) 603 isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2); 604 #if 1 /*???*/ 605 else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2)) 606 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2); 607 #endif 608 else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT)) 609 snmp_print(ndo, (const u_char *)(up + 1), length); 610 else if (ISPORT(NTP_PORT)) 611 ntp_print(ndo, (const u_char *)(up + 1), length); 612 else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT)) 613 krb_print(ndo, (const void *)(up + 1)); 614 else if (ISPORT(L2TP_PORT)) 615 l2tp_print(ndo, (const u_char *)(up + 1), length); 616 #ifdef TCPDUMP_DO_SMB 617 else if (ISPORT(NETBIOS_NS_PORT)) 618 nbt_udp137_print(ndo, (const u_char *)(up + 1), length); 619 else if (ISPORT(NETBIOS_DGRAM_PORT)) 620 nbt_udp138_print(ndo, (const u_char *)(up + 1), length); 621 #endif 622 else if (dport == VAT_PORT) 623 vat_print(ndo, (const void *)(up + 1), up); 624 else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT)) 625 zephyr_print(ndo, (const void *)(up + 1), length); 626 /* 627 * Since there are 10 possible ports to check, I think 628 * a <> test would be more efficient 629 */ 630 else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) || 631 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH)) 632 rx_print(ndo, (const void *)(up + 1), length, sport, dport, 633 (u_char *) ip); 634 #ifdef INET6 635 else if (ISPORT(RIPNG_PORT)) 636 ripng_print(ndo, (const u_char *)(up + 1), length); 637 else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT)) 638 dhcp6_print(ndo, (const u_char *)(up + 1), length); 639 else if (ISPORT(AHCP_PORT)) 640 ahcp_print(ndo, (const u_char *)(up + 1), length); 641 else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD)) 642 babel_print(ndo, (const u_char *)(up + 1), length); 643 #endif /*INET6*/ 644 /* 645 * Kludge in test for whiteboard packets. 646 */ 647 else if (dport == WB_PORT) 648 wb_print(ndo, (const void *)(up + 1), length); 649 else if (ISPORT(CISCO_AUTORP_PORT)) 650 cisco_autorp_print(ndo, (const void *)(up + 1), length); 651 else if (ISPORT(RADIUS_PORT) || 652 ISPORT(RADIUS_NEW_PORT) || 653 ISPORT(RADIUS_ACCOUNTING_PORT) || 654 ISPORT(RADIUS_NEW_ACCOUNTING_PORT) || 655 ISPORT(RADIUS_COA_PORT) ) 656 radius_print(ndo, (const u_char *)(up+1), length); 657 else if (dport == HSRP_PORT) 658 hsrp_print(ndo, (const u_char *)(up + 1), length); 659 else if (ISPORT(LWRES_PORT)) 660 lwres_print(ndo, (const u_char *)(up + 1), length); 661 else if (ISPORT(LDP_PORT)) 662 ldp_print(ndo, (const u_char *)(up + 1), length); 663 else if (ISPORT(OLSR_PORT)) 664 olsr_print(ndo, (const u_char *)(up + 1), length, 665 #if INET6 666 (IP_V(ip) == 6) ? 1 : 0); 667 #else 668 0); 669 #endif 670 else if (ISPORT(MPLS_LSP_PING_PORT)) 671 lspping_print(ndo, (const u_char *)(up + 1), length); 672 else if (dport == BFD_CONTROL_PORT || 673 dport == BFD_ECHO_PORT ) 674 bfd_print(ndo, (const u_char *)(up+1), length, dport); 675 else if (ISPORT(LMP_PORT)) 676 lmp_print(ndo, (const u_char *)(up + 1), length); 677 else if (ISPORT(VQP_PORT)) 678 vqp_print(ndo, (const u_char *)(up + 1), length); 679 else if (ISPORT(SFLOW_PORT)) 680 sflow_print(ndo, (const u_char *)(up + 1), length); 681 else if (dport == LWAPP_CONTROL_PORT) 682 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1); 683 else if (sport == LWAPP_CONTROL_PORT) 684 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0); 685 else if (ISPORT(LWAPP_DATA_PORT)) 686 lwapp_data_print(ndo, (const u_char *)(up + 1), length); 687 else if (ISPORT(SIP_PORT)) 688 sip_print(ndo, (const u_char *)(up + 1), length); 689 else if (ISPORT(SYSLOG_PORT)) 690 syslog_print(ndo, (const u_char *)(up + 1), length); 691 else if (ISPORT(OTV_PORT)) 692 otv_print(ndo, (const u_char *)(up + 1), length); 693 else if (ISPORT(VXLAN_PORT)) 694 vxlan_print(ndo, (const u_char *)(up + 1), length); 695 else if (ISPORT(GENEVE_PORT)) 696 geneve_print(ndo, (const u_char *)(up + 1), length); 697 else { 698 if (ulen > length) 699 ND_PRINT((ndo, "UDP, bad length %u > %u", 700 ulen, length)); 701 else 702 ND_PRINT((ndo, "UDP, length %u", ulen)); 703 } 704 #undef ISPORT 705 } else { 706 if (ulen > length) 707 ND_PRINT((ndo, "UDP, bad length %u > %u", 708 ulen, length)); 709 else 710 ND_PRINT((ndo, "UDP, length %u", ulen)); 711 } 712 } 713 714 715 /* 716 * Local Variables: 717 * c-style: whitesmith 718 * c-basic-offset: 8 719 * End: 720 */ 721 722