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