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