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