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