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