xref: /netbsd-src/external/bsd/tcpdump/dist/print-udp.c (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
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 				sunrpcrequest_print(ndo, (u_char *)rp, length,
428 				    (u_char *)ip);
429 			else
430 				nfsreply_print(ndo, (u_char *)rp, length,
431 				    (u_char *)ip);			/*XXX*/
432 			break;
433 
434 		case PT_RTP:
435 			udpipaddr_print(ndo, ip, sport, dport);
436 			rtp_print(ndo, (void *)(up + 1), length, up);
437 			break;
438 
439 		case PT_RTCP:
440 			udpipaddr_print(ndo, ip, sport, dport);
441 			while (cp < ep)
442 				cp = rtcp_print(ndo, cp, ep);
443 			break;
444 
445 		case PT_SNMP:
446 			udpipaddr_print(ndo, ip, sport, dport);
447 			snmp_print(ndo, (const u_char *)(up + 1), length);
448 			break;
449 
450 		case PT_CNFP:
451 			udpipaddr_print(ndo, ip, sport, dport);
452 			cnfp_print(ndo, cp);
453 			break;
454 
455 		case PT_TFTP:
456 			udpipaddr_print(ndo, ip, sport, dport);
457 			tftp_print(ndo, cp, length);
458 			break;
459 
460 		case PT_AODV:
461 			udpipaddr_print(ndo, ip, sport, dport);
462 			aodv_print(ndo, (const u_char *)(up + 1), length,
463 #ifdef INET6
464 			    ip6 != NULL);
465 #else
466 			    0);
467 #endif
468 			break;
469 
470 		case PT_RADIUS:
471 			udpipaddr_print(ndo, ip, sport, dport);
472 			radius_print(ndo, cp, length);
473 			break;
474 
475 		case PT_VXLAN:
476 			udpipaddr_print(ndo, ip, sport, dport);
477 			vxlan_print(ndo, (const u_char *)(up + 1), length);
478 			break;
479 
480 		case PT_PGM:
481 		case PT_PGM_ZMTP1:
482 			udpipaddr_print(ndo, ip, sport, dport);
483 			pgm_print(ndo, cp, length, bp2);
484 			break;
485 		case PT_LMP:
486 			udpipaddr_print(ndo, ip, sport, dport);
487 			lmp_print(ndo, cp, length);
488 			break;
489 		}
490 		return;
491 	}
492 
493 	udpipaddr_print(ndo, ip, sport, dport);
494 	if (!ndo->ndo_qflag) {
495 		register struct sunrpc_msg *rp;
496 		enum sunrpc_msg_type direction;
497 
498 		rp = (struct sunrpc_msg *)(up + 1);
499 		if (ND_TTEST(rp->rm_direction)) {
500 			direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
501 			if (dport == NFS_PORT && direction == SUNRPC_CALL) {
502 				ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
503 				nfsreq_print_noaddr(ndo, (u_char *)rp, length,
504 				    (u_char *)ip);
505 				return;
506 			}
507 			if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
508 				ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
509 				nfsreply_print_noaddr(ndo, (u_char *)rp, length,
510 				    (u_char *)ip);
511 				return;
512 			}
513 #ifdef notdef
514 			if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
515 				sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
516 				return;
517 			}
518 #endif
519 		}
520 		if (ND_TTEST(((struct LAP *)cp)->type) &&
521 		    ((struct LAP *)cp)->type == lapDDP &&
522 		    (atalk_port(sport) || atalk_port(dport))) {
523 			if (ndo->ndo_vflag)
524 				ND_PRINT((ndo, "kip "));
525 			llap_print(ndo, cp, length);
526 			return;
527 		}
528 	}
529 
530 	if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
531                 /* Check the checksum, if possible. */
532                 uint16_t sum, udp_sum;
533 
534 		/*
535 		 * XXX - do this even if vflag == 1?
536 		 * TCP does, and we do so for UDP-over-IPv6.
537 		 */
538 	        if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
539 			udp_sum = EXTRACT_16BITS(&up->uh_sum);
540 			if (udp_sum == 0) {
541 				ND_PRINT((ndo, "[no cksum] "));
542 			} else if (ND_TTEST2(cp[0], length)) {
543 				sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
544 
545 	                        if (sum != 0) {
546 					ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
547 					    udp_sum,
548 					    in_cksum_shouldbe(udp_sum, sum)));
549 				} else
550 					ND_PRINT((ndo, "[udp sum ok] "));
551 			}
552 		}
553 #ifdef INET6
554 		else if (IP_V(ip) == 6 && ip6->ip6_plen) {
555 			/* for IPv6, UDP checksum is mandatory */
556 			if (ND_TTEST2(cp[0], length)) {
557 				sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
558 				udp_sum = EXTRACT_16BITS(&up->uh_sum);
559 
560 	                        if (sum != 0) {
561 					ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
562 					    udp_sum,
563 					    in_cksum_shouldbe(udp_sum, sum)));
564 				} else
565 					ND_PRINT((ndo, "[udp sum ok] "));
566 			}
567 		}
568 #endif
569 	}
570 
571 	if (!ndo->ndo_qflag) {
572 #define ISPORT(p) (dport == (p) || sport == (p))
573 		if (ISPORT(NAMESERVER_PORT))
574 			ns_print(ndo, (const u_char *)(up + 1), length, 0);
575 		else if (ISPORT(MULTICASTDNS_PORT))
576 			ns_print(ndo, (const u_char *)(up + 1), length, 1);
577 		else if (ISPORT(TIMED_PORT))
578 			timed_print(ndo, (const u_char *)(up + 1));
579 		else if (ISPORT(TFTP_PORT))
580 			tftp_print(ndo, (const u_char *)(up + 1), length);
581 		else if (ISPORT(BOOTPC_PORT) || ISPORT(BOOTPS_PORT))
582 			bootp_print(ndo, (const u_char *)(up + 1), length);
583 		else if (ISPORT(RIP_PORT))
584 			rip_print(ndo, (const u_char *)(up + 1), length);
585 		else if (ISPORT(AODV_PORT))
586 			aodv_print(ndo, (const u_char *)(up + 1), length,
587 #ifdef INET6
588 			    ip6 != NULL);
589 #else
590 			    0);
591 #endif
592 	        else if (ISPORT(ISAKMP_PORT))
593 			 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
594   	        else if (ISPORT(ISAKMP_PORT_NATT))
595 			 isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
596 #if 1 /*???*/
597    	        else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
598 			isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
599 #endif
600 		else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
601 			snmp_print(ndo, (const u_char *)(up + 1), length);
602 		else if (ISPORT(NTP_PORT))
603 			ntp_print(ndo, (const u_char *)(up + 1), length);
604 		else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
605 			krb_print(ndo, (const void *)(up + 1));
606 		else if (ISPORT(L2TP_PORT))
607 			l2tp_print(ndo, (const u_char *)(up + 1), length);
608 #ifdef TCPDUMP_DO_SMB
609 		else if (ISPORT(NETBIOS_NS_PORT))
610 			nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
611 		else if (ISPORT(NETBIOS_DGRAM_PORT))
612 			nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
613 #endif
614 		else if (dport == VAT_PORT)
615 			vat_print(ndo, (const void *)(up + 1), up);
616 		else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
617 			zephyr_print(ndo, (const void *)(up + 1), length);
618 		/*
619 		 * Since there are 10 possible ports to check, I think
620 		 * a <> test would be more efficient
621 		 */
622 		else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
623 			 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
624 			rx_print(ndo, (const void *)(up + 1), length, sport, dport,
625 				 (u_char *) ip);
626 #ifdef INET6
627 		else if (ISPORT(RIPNG_PORT))
628 			ripng_print(ndo, (const u_char *)(up + 1), length);
629 		else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
630 			dhcp6_print(ndo, (const u_char *)(up + 1), length);
631 		else if (ISPORT(AHCP_PORT))
632 			ahcp_print(ndo, (const u_char *)(up + 1), length);
633 		else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
634 			babel_print(ndo, (const u_char *)(up + 1), length);
635 #endif /*INET6*/
636 		/*
637 		 * Kludge in test for whiteboard packets.
638 		 */
639 		else if (dport == WB_PORT)
640 			wb_print(ndo, (const void *)(up + 1), length);
641 		else if (ISPORT(CISCO_AUTORP_PORT))
642 			cisco_autorp_print(ndo, (const void *)(up + 1), length);
643 		else if (ISPORT(RADIUS_PORT) ||
644 			 ISPORT(RADIUS_NEW_PORT) ||
645 			 ISPORT(RADIUS_ACCOUNTING_PORT) ||
646 			 ISPORT(RADIUS_NEW_ACCOUNTING_PORT) ||
647 			 ISPORT(RADIUS_COA_PORT) )
648 			radius_print(ndo, (const u_char *)(up+1), length);
649 		else if (dport == HSRP_PORT)
650 			hsrp_print(ndo, (const u_char *)(up + 1), length);
651 		else if (ISPORT(LWRES_PORT))
652 			lwres_print(ndo, (const u_char *)(up + 1), length);
653 		else if (ISPORT(LDP_PORT))
654 			ldp_print(ndo, (const u_char *)(up + 1), length);
655 		else if (ISPORT(OLSR_PORT))
656 			olsr_print(ndo, (const u_char *)(up + 1), length,
657 #if INET6
658 					(IP_V(ip) == 6) ? 1 : 0);
659 #else
660 					0);
661 #endif
662 		else if (ISPORT(MPLS_LSP_PING_PORT))
663 			lspping_print(ndo, (const u_char *)(up + 1), length);
664 		else if (dport == BFD_CONTROL_PORT ||
665 			 dport == BFD_ECHO_PORT )
666 			bfd_print(ndo, (const u_char *)(up+1), length, dport);
667                 else if (ISPORT(LMP_PORT))
668 			lmp_print(ndo, (const u_char *)(up + 1), length);
669 		else if (ISPORT(VQP_PORT))
670 			vqp_print(ndo, (const u_char *)(up + 1), length);
671                 else if (ISPORT(SFLOW_PORT))
672                         sflow_print(ndo, (const u_char *)(up + 1), length);
673 	        else if (dport == LWAPP_CONTROL_PORT)
674 			lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
675                 else if (sport == LWAPP_CONTROL_PORT)
676                         lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
677                 else if (ISPORT(LWAPP_DATA_PORT))
678                         lwapp_data_print(ndo, (const u_char *)(up + 1), length);
679                 else if (ISPORT(SIP_PORT))
680 			sip_print(ndo, (const u_char *)(up + 1), length);
681                 else if (ISPORT(SYSLOG_PORT))
682 			syslog_print(ndo, (const u_char *)(up + 1), length);
683                 else if (ISPORT(OTV_PORT))
684 			otv_print(ndo, (const u_char *)(up + 1), length);
685                 else if (ISPORT(VXLAN_PORT))
686 			vxlan_print(ndo, (const u_char *)(up + 1), length);
687                 else if (ISPORT(GENEVE_PORT))
688 			geneve_print(ndo, (const u_char *)(up + 1), length);
689 		else {
690 			if (ulen > length)
691 				ND_PRINT((ndo, "UDP, bad length %u > %u",
692 				    ulen, length));
693 			else
694 				ND_PRINT((ndo, "UDP, length %u", ulen));
695 		}
696 #undef ISPORT
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 }
705 
706 
707 /*
708  * Local Variables:
709  * c-style: whitesmith
710  * c-basic-offset: 8
711  * End:
712  */
713 
714