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