xref: /freebsd/contrib/tcpdump/print-udp.c (revision 641a6cfb86023499caafe26a4d821a0b885cf00b)
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 #ifndef lint
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 #endif
28 
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32 
33 #include <tcpdump-stdinc.h>
34 
35 #ifdef SEGSIZE
36 #undef SEGSIZE
37 #endif
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
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
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 *
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 
287 static int udp_cksum(register const struct ip *ip,
288 		     register const struct udphdr *up,
289 		     register u_int len)
290 {
291 	return (nextproto4_cksum(ip, (const u_int8_t *)(void *)up, len,
292 	    IPPROTO_UDP));
293 }
294 
295 #ifdef INET6
296 static int udp6_cksum(const struct ip6_hdr *ip6, const struct udphdr *up,
297 	u_int len)
298 {
299 	return (nextproto6_cksum(ip6, (const u_int8_t *)(void *)up, len,
300 	    IPPROTO_UDP));
301 }
302 #endif
303 
304 static void
305 udpipaddr_print(const struct ip *ip, int sport, int dport)
306 {
307 #ifdef INET6
308 	const struct ip6_hdr *ip6;
309 
310 	if (IP_V(ip) == 6)
311 		ip6 = (const struct ip6_hdr *)ip;
312 	else
313 		ip6 = NULL;
314 
315 	if (ip6) {
316 		if (ip6->ip6_nxt == IPPROTO_UDP) {
317 			if (sport == -1) {
318 				(void)printf("%s > %s: ",
319 					ip6addr_string(&ip6->ip6_src),
320 					ip6addr_string(&ip6->ip6_dst));
321 			} else {
322 				(void)printf("%s.%s > %s.%s: ",
323 					ip6addr_string(&ip6->ip6_src),
324 					udpport_string(sport),
325 					ip6addr_string(&ip6->ip6_dst),
326 					udpport_string(dport));
327 			}
328 		} else {
329 			if (sport != -1) {
330 				(void)printf("%s > %s: ",
331 					udpport_string(sport),
332 					udpport_string(dport));
333 			}
334 		}
335 	} else
336 #endif /*INET6*/
337 	{
338 		if (ip->ip_p == IPPROTO_UDP) {
339 			if (sport == -1) {
340 				(void)printf("%s > %s: ",
341 					ipaddr_string(&ip->ip_src),
342 					ipaddr_string(&ip->ip_dst));
343 			} else {
344 				(void)printf("%s.%s > %s.%s: ",
345 					ipaddr_string(&ip->ip_src),
346 					udpport_string(sport),
347 					ipaddr_string(&ip->ip_dst),
348 					udpport_string(dport));
349 			}
350 		} else {
351 			if (sport != -1) {
352 				(void)printf("%s > %s: ",
353 					udpport_string(sport),
354 					udpport_string(dport));
355 			}
356 		}
357 	}
358 }
359 
360 void
361 udp_print(register const u_char *bp, u_int length,
362 	  register const u_char *bp2, int fragmented)
363 {
364 	register const struct udphdr *up;
365 	register const struct ip *ip;
366 	register const u_char *cp;
367 	register const u_char *ep = bp + length;
368 	u_int16_t sport, dport, ulen;
369 #ifdef INET6
370 	register const struct ip6_hdr *ip6;
371 #endif
372 
373 	if (ep > snapend)
374 		ep = snapend;
375 	up = (struct udphdr *)bp;
376 	ip = (struct ip *)bp2;
377 #ifdef INET6
378 	if (IP_V(ip) == 6)
379 		ip6 = (struct ip6_hdr *)bp2;
380 	else
381 		ip6 = NULL;
382 #endif /*INET6*/
383 	cp = (u_char *)(up + 1);
384 	if (!TTEST(up->uh_dport)) {
385 		udpipaddr_print(ip, -1, -1);
386 		(void)printf("[|udp]");
387 		return;
388 	}
389 
390 	sport = EXTRACT_16BITS(&up->uh_sport);
391 	dport = EXTRACT_16BITS(&up->uh_dport);
392 
393 	if (length < sizeof(struct udphdr)) {
394 		udpipaddr_print(ip, sport, dport);
395 		(void)printf("truncated-udp %d", length);
396 		return;
397 	}
398 	length -= sizeof(struct udphdr);
399 
400 	if (cp > snapend) {
401 		udpipaddr_print(ip, sport, dport);
402 		(void)printf("[|udp]");
403 		return;
404 	}
405 
406 	ulen = EXTRACT_16BITS(&up->uh_ulen);
407 	if (ulen < 8) {
408 		udpipaddr_print(ip, sport, dport);
409 		(void)printf("truncated-udplength %d", ulen);
410 		return;
411 	}
412 	if (packettype) {
413 		register struct sunrpc_msg *rp;
414 		enum sunrpc_msg_type direction;
415 
416 		switch (packettype) {
417 
418 		case PT_VAT:
419 			udpipaddr_print(ip, sport, dport);
420 			vat_print((void *)(up + 1), up);
421 			break;
422 
423 		case PT_WB:
424 			udpipaddr_print(ip, sport, dport);
425 			wb_print((void *)(up + 1), length);
426 			break;
427 
428 		case PT_RPC:
429 			rp = (struct sunrpc_msg *)(up + 1);
430 			direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
431 			if (direction == SUNRPC_CALL)
432 				sunrpcrequest_print((u_char *)rp, length,
433 				    (u_char *)ip);
434 			else
435 				nfsreply_print((u_char *)rp, length,
436 				    (u_char *)ip);			/*XXX*/
437 			break;
438 
439 		case PT_RTP:
440 			udpipaddr_print(ip, sport, dport);
441 			rtp_print((void *)(up + 1), length, up);
442 			break;
443 
444 		case PT_RTCP:
445 			udpipaddr_print(ip, sport, dport);
446 			while (cp < ep)
447 				cp = rtcp_print(cp, ep);
448 			break;
449 
450 		case PT_SNMP:
451 			udpipaddr_print(ip, sport, dport);
452 			snmp_print((const u_char *)(up + 1), length);
453 			break;
454 
455 		case PT_CNFP:
456 			udpipaddr_print(ip, sport, dport);
457 			cnfp_print(cp, (const u_char *)ip);
458 			break;
459 
460 		case PT_TFTP:
461 			udpipaddr_print(ip, sport, dport);
462 			tftp_print(cp, length);
463 			break;
464 
465 		case PT_AODV:
466 			udpipaddr_print(ip, sport, dport);
467 			aodv_print((const u_char *)(up + 1), length,
468 #ifdef INET6
469 			    ip6 != NULL);
470 #else
471 			    0);
472 #endif
473 			break;
474 		}
475 		return;
476 	}
477 
478 	if (!qflag) {
479 		register struct sunrpc_msg *rp;
480 		enum sunrpc_msg_type direction;
481 
482 		rp = (struct sunrpc_msg *)(up + 1);
483 		if (TTEST(rp->rm_direction)) {
484 			direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
485 			if (dport == NFS_PORT && direction == SUNRPC_CALL) {
486 				nfsreq_print((u_char *)rp, length,
487 				    (u_char *)ip);
488 				return;
489 			}
490 			if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
491 				nfsreply_print((u_char *)rp, length,
492 				    (u_char *)ip);
493 				return;
494 			}
495 #ifdef notdef
496 			if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
497 				sunrpcrequest_print((u_char *)rp, length, (u_char *)ip);
498 				return;
499 			}
500 #endif
501 		}
502 		if (TTEST(((struct LAP *)cp)->type) &&
503 		    ((struct LAP *)cp)->type == lapDDP &&
504 		    (atalk_port(sport) || atalk_port(dport))) {
505 			if (vflag)
506 				fputs("kip ", stdout);
507 			llap_print(cp, length);
508 			return;
509 		}
510 	}
511 	udpipaddr_print(ip, sport, dport);
512 
513 	if (vflag && !Kflag && !fragmented) {
514                 /* Check the checksum, if possible. */
515                 u_int16_t sum, udp_sum;
516 
517 		/*
518 		 * XXX - do this even if vflag == 1?
519 		 * TCP does, and we do so for UDP-over-IPv6.
520 		 */
521 	        if (IP_V(ip) == 4 && (vflag > 1)) {
522 			udp_sum = EXTRACT_16BITS(&up->uh_sum);
523 			if (udp_sum == 0) {
524 				(void)printf("[no cksum] ");
525 			} else if (TTEST2(cp[0], length)) {
526 				sum = udp_cksum(ip, up, length + sizeof(struct udphdr));
527 
528 	                        if (sum != 0) {
529         	                        (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
530 					    udp_sum,
531 					    in_cksum_shouldbe(udp_sum, sum));
532 				} else
533 					(void)printf("[udp sum ok] ");
534 			}
535 		}
536 #ifdef INET6
537 		else if (IP_V(ip) == 6 && ip6->ip6_plen) {
538 			/* for IPv6, UDP checksum is mandatory */
539 			if (TTEST2(cp[0], length)) {
540 				sum = udp6_cksum(ip6, up, length + sizeof(struct udphdr));
541 				udp_sum = EXTRACT_16BITS(&up->uh_sum);
542 
543 	                        if (sum != 0) {
544         	                        (void)printf("[bad udp cksum 0x%04x -> 0x%04x!] ",
545 					    udp_sum,
546 					    in_cksum_shouldbe(udp_sum, sum));
547 				} else
548 					(void)printf("[udp sum ok] ");
549 			}
550 		}
551 #endif
552 	}
553 
554 	if (!qflag) {
555 #define ISPORT(p) (dport == (p) || sport == (p))
556 		if (ISPORT(NAMESERVER_PORT))
557 			ns_print((const u_char *)(up + 1), length, 0);
558 		else if (ISPORT(MULTICASTDNS_PORT))
559 			ns_print((const u_char *)(up + 1), length, 1);
560 		else if (ISPORT(TIMED_PORT))
561 			timed_print((const u_char *)(up + 1));
562 		else if (ISPORT(TFTP_PORT))
563 			tftp_print((const u_char *)(up + 1), length);
564 		else if (ISPORT(IPPORT_BOOTPC) || ISPORT(IPPORT_BOOTPS))
565 			bootp_print((const u_char *)(up + 1), length);
566 		else if (ISPORT(RIP_PORT))
567 			rip_print((const u_char *)(up + 1), length);
568 		else if (ISPORT(AODV_PORT))
569 			aodv_print((const u_char *)(up + 1), length,
570 #ifdef INET6
571 			    ip6 != NULL);
572 #else
573 			    0);
574 #endif
575 	        else if (ISPORT(ISAKMP_PORT))
576 			 isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
577   	        else if (ISPORT(ISAKMP_PORT_NATT))
578 			 isakmp_rfc3948_print(gndo, (const u_char *)(up + 1), length, bp2);
579 #if 1 /*???*/
580    	        else if (ISPORT(ISAKMP_PORT_USER1) || ISPORT(ISAKMP_PORT_USER2))
581 			isakmp_print(gndo, (const u_char *)(up + 1), length, bp2);
582 #endif
583 		else if (ISPORT(SNMP_PORT) || ISPORT(SNMPTRAP_PORT))
584 			snmp_print((const u_char *)(up + 1), length);
585 		else if (ISPORT(NTP_PORT))
586 			ntp_print((const u_char *)(up + 1), length);
587 		else if (ISPORT(KERBEROS_PORT) || ISPORT(KERBEROS_SEC_PORT))
588 			krb_print((const void *)(up + 1));
589 		else if (ISPORT(L2TP_PORT))
590 			l2tp_print((const u_char *)(up + 1), length);
591 #ifdef TCPDUMP_DO_SMB
592 		else if (ISPORT(NETBIOS_NS_PORT))
593 			nbt_udp137_print((const u_char *)(up + 1), length);
594 		else if (ISPORT(NETBIOS_DGRAM_PORT))
595 			nbt_udp138_print((const u_char *)(up + 1), length);
596 #endif
597 		else if (dport == 3456)
598 			vat_print((const void *)(up + 1), up);
599 		else if (ISPORT(ZEPHYR_SRV_PORT) || ISPORT(ZEPHYR_CLT_PORT))
600 			zephyr_print((const void *)(up + 1), length);
601 		/*
602 		 * Since there are 10 possible ports to check, I think
603 		 * a <> test would be more efficient
604 		 */
605 		else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
606 			 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
607 			rx_print((const void *)(up + 1), length, sport, dport,
608 				 (u_char *) ip);
609 #ifdef INET6
610 		else if (ISPORT(RIPNG_PORT))
611 			ripng_print((const u_char *)(up + 1), length);
612 		else if (ISPORT(DHCP6_SERV_PORT) || ISPORT(DHCP6_CLI_PORT))
613 			dhcp6_print((const u_char *)(up + 1), length);
614 		else if (ISPORT(BABEL_PORT) || ISPORT(BABEL_PORT_OLD))
615 			babel_print((const u_char *)(up + 1), length);
616 #endif /*INET6*/
617 		/*
618 		 * Kludge in test for whiteboard packets.
619 		 */
620 		else if (dport == 4567)
621 			wb_print((const void *)(up + 1), length);
622 		else if (ISPORT(CISCO_AUTORP_PORT))
623 			cisco_autorp_print((const void *)(up + 1), length);
624 		else if (ISPORT(RADIUS_PORT) ||
625 			 ISPORT(RADIUS_NEW_PORT) ||
626 			 ISPORT(RADIUS_ACCOUNTING_PORT) ||
627 			 ISPORT(RADIUS_NEW_ACCOUNTING_PORT) )
628 			radius_print((const u_char *)(up+1), length);
629 		else if (dport == HSRP_PORT)
630 			hsrp_print((const u_char *)(up + 1), length);
631 		else if (ISPORT(LWRES_PORT))
632 			lwres_print((const u_char *)(up + 1), length);
633 		else if (ISPORT(LDP_PORT))
634 			ldp_print((const u_char *)(up + 1), length);
635 		else if (ISPORT(OLSR_PORT))
636 			olsr_print((const u_char *)(up + 1), length,
637 #if INET6
638 					(IP_V(ip) == 6) ? 1 : 0);
639 #else
640 					0);
641 #endif
642 		else if (ISPORT(MPLS_LSP_PING_PORT))
643 			lspping_print((const u_char *)(up + 1), length);
644 		else if (dport == BFD_CONTROL_PORT ||
645 			 dport == BFD_ECHO_PORT )
646 			bfd_print((const u_char *)(up+1), length, dport);
647                 else if (ISPORT(LMP_PORT))
648 			lmp_print((const u_char *)(up + 1), length);
649 		else if (ISPORT(VQP_PORT))
650 			vqp_print((const u_char *)(up + 1), length);
651                 else if (ISPORT(SFLOW_PORT))
652                         sflow_print((const u_char *)(up + 1), length);
653 	        else if (dport == LWAPP_CONTROL_PORT)
654 			lwapp_control_print((const u_char *)(up + 1), length, 1);
655                 else if (sport == LWAPP_CONTROL_PORT)
656                         lwapp_control_print((const u_char *)(up + 1), length, 0);
657                 else if (ISPORT(LWAPP_DATA_PORT))
658                         lwapp_data_print((const u_char *)(up + 1), length);
659                 else if (ISPORT(SIP_PORT))
660 			sip_print((const u_char *)(up + 1), length);
661                 else if (ISPORT(SYSLOG_PORT))
662 			syslog_print((const u_char *)(up + 1), length);
663 		else
664 			(void)printf("UDP, length %u",
665 			    (u_int32_t)(ulen - sizeof(*up)));
666 #undef ISPORT
667 	} else
668 		(void)printf("UDP, length %u", (u_int32_t)(ulen - sizeof(*up)));
669 }
670 
671 
672 /*
673  * Local Variables:
674  * c-style: whitesmith
675  * c-basic-offset: 8
676  * End:
677  */
678 
679