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