]> The Tcpdump Group git mirrors - tcpdump/blob - print-udp.c
Add more nd_print_trunc() calls
[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
46 struct rtcphdr {
47 nd_uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
48 nd_uint16_t rh_len; /* length of message (in words) */
49 nd_uint32_t rh_ssrc; /* synchronization src id */
50 };
51
52 typedef struct {
53 nd_uint32_t upper; /* more significant 32 bits */
54 nd_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 nd_uint32_t sr_ts; /* reference media timestamp */
63 nd_uint32_t sr_np; /* no. packets sent */
64 nd_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 nd_uint32_t rr_srcid; /* sender being reported */
73 nd_uint32_t rr_nl; /* no. packets lost */
74 nd_uint32_t rr_ls; /* extended last seq number received */
75 nd_uint32_t rr_dv; /* jitter (delay variance) */
76 nd_uint32_t rr_lsr; /* orig. ts from last rr from this src */
77 nd_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, u_int length)
97 {
98 /* vat/vt audio */
99 u_int ts;
100
101 ndo->ndo_protocol = "vat";
102 if (length < 2) {
103 ND_PRINT("udp/va/vat, length %u < 2", length);
104 return;
105 }
106 ND_TCHECK_2((const u_int *)hdr);
107 ts = EXTRACT_BE_U_2(hdr);
108 if ((ts & 0xf060) != 0) {
109 /* probably vt */
110 ND_PRINT("udp/vt %u %u / %u",
111 length,
112 ts & 0x3ff, ts >> 10);
113 } else {
114 /* probably vat */
115 uint32_t i0, i1;
116
117 if (length < 8) {
118 ND_PRINT("udp/vat, length %u < 8", length);
119 return;
120 }
121 ND_TCHECK_4(&((const u_int *)hdr)[0]);
122 i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]);
123 ND_TCHECK_4(&((const u_int *)hdr)[1]);
124 i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]);
125 ND_PRINT("udp/vat %u c%u %u%s",
126 length - 8,
127 i0 & 0xffff,
128 i1, i0 & 0x800000? "*" : "");
129 /* audio format */
130 if (i0 & 0x1f0000)
131 ND_PRINT(" f%u", (i0 >> 16) & 0x1f);
132 if (i0 & 0x3f000000)
133 ND_PRINT(" s%u", (i0 >> 24) & 0x3f);
134 }
135
136 trunc:
137 nd_print_trunc(ndo);
138 }
139
140 static void
141 rtp_print(netdissect_options *ndo, const void *hdr, u_int len)
142 {
143 /* rtp v1 or v2 */
144 const u_int *ip = (const u_int *)hdr;
145 u_int hasopt, hasext, contype, hasmarker, dlen;
146 uint32_t i0, i1;
147 const char * ptype;
148
149 ndo->ndo_protocol = "rtp";
150 if (len < 8) {
151 ND_PRINT("udp/rtp, length %u < 8", len);
152 return;
153 }
154 ND_TCHECK_4(&((const u_int *)hdr)[0]);
155 i0 = EXTRACT_BE_U_4(&((const u_int *)hdr)[0]);
156 ND_TCHECK_4(&((const u_int *)hdr)[1]);
157 i1 = EXTRACT_BE_U_4(&((const u_int *)hdr)[1]);
158 dlen = len - 8;
159 ip += 2;
160 len >>= 2;
161 len -= 2;
162 hasopt = 0;
163 hasext = 0;
164 if ((i0 >> 30) == 1) {
165 /* rtp v1 - draft-ietf-avt-rtp-04 */
166 hasopt = i0 & 0x800000;
167 contype = (i0 >> 16) & 0x3f;
168 hasmarker = i0 & 0x400000;
169 ptype = "rtpv1";
170 } else {
171 /* rtp v2 - RFC 3550 */
172 if (dlen < 4) {
173 ND_PRINT("udp/rtp, length %u < 12", dlen + 8);
174 return;
175 }
176 hasext = i0 & 0x10000000;
177 contype = (i0 >> 16) & 0x7f;
178 hasmarker = i0 & 0x800000;
179 dlen -= 4;
180 ptype = "rtp";
181 ip += 1;
182 len -= 1;
183 }
184 ND_PRINT("udp/%s %u c%u %s%s %u %u",
185 ptype,
186 dlen,
187 contype,
188 (hasopt || hasext)? "+" : "",
189 hasmarker? "*" : "",
190 i0 & 0xffff,
191 i1);
192 if (ndo->ndo_vflag) {
193 ND_TCHECK_4(&((const u_int *)hdr)[2]);
194 ND_PRINT(" %u", EXTRACT_BE_U_4(&((const u_int *)hdr)[2]));
195 if (hasopt) {
196 u_int i2, optlen;
197 do {
198 ND_TCHECK_4(ip);
199 i2 = EXTRACT_BE_U_4(ip);
200 optlen = (i2 >> 16) & 0xff;
201 if (optlen == 0 || optlen > len) {
202 ND_PRINT(" !opt");
203 return;
204 }
205 ip += optlen;
206 len -= optlen;
207 } while ((int)i2 >= 0);
208 }
209 if (hasext) {
210 u_int i2, extlen;
211 ND_TCHECK_4(ip);
212 i2 = EXTRACT_BE_U_4(ip);
213 extlen = (i2 & 0xffff) + 1;
214 if (extlen > len) {
215 ND_PRINT(" !ext");
216 return;
217 }
218 ip += extlen;
219 }
220 ND_TCHECK_4(ip);
221 if (contype == 0x1f) /*XXX H.261 */
222 ND_PRINT(" 0x%04x", EXTRACT_BE_U_4(ip) >> 16);
223 }
224
225 trunc:
226 nd_print_trunc(ndo);
227 }
228
229 static const u_char *
230 rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
231 {
232 /* rtp v2 control (rtcp) */
233 const struct rtcp_rr *rr = 0;
234 const struct rtcp_sr *sr;
235 const struct rtcphdr *rh = (const struct rtcphdr *)hdr;
236 u_int len;
237 uint16_t flags;
238 u_int cnt;
239 double ts, dts;
240
241 ndo->ndo_protocol = "rtcp";
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_trunc(ndo);
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 = ndo->ndo_snapend;
390 uint16_t sport, dport, ulen;
391 const struct ip6_hdr *ip6;
392
393 ndo->ndo_protocol = "udp";
394 up = (const struct udphdr *)bp;
395 ip = (const struct ip *)bp2;
396 if (IP_V(ip) == 6)
397 ip6 = (const struct ip6_hdr *)bp2;
398 else
399 ip6 = NULL;
400 if (!ND_TTEST_2(up->uh_dport)) {
401 udpipaddr_print(ndo, ip, -1, -1);
402 goto trunc;
403 }
404
405 sport = EXTRACT_BE_U_2(up->uh_sport);
406 dport = EXTRACT_BE_U_2(up->uh_dport);
407
408 if (length < sizeof(struct udphdr)) {
409 udpipaddr_print(ndo, ip, sport, dport);
410 ND_PRINT("truncated-udp %u", length);
411 return;
412 }
413 if (!ND_TTEST_2(up->uh_ulen)) {
414 udpipaddr_print(ndo, ip, sport, dport);
415 goto trunc;
416 }
417 ulen = EXTRACT_BE_U_2(up->uh_ulen);
418 if (ulen < sizeof(struct udphdr)) {
419 udpipaddr_print(ndo, ip, sport, dport);
420 ND_PRINT("truncated-udplength %u", ulen);
421 return;
422 }
423 ulen -= sizeof(struct udphdr);
424 length -= sizeof(struct udphdr);
425 if (ulen < length)
426 length = ulen;
427
428 cp = (const u_char *)(up + 1);
429 if (cp > ndo->ndo_snapend) {
430 udpipaddr_print(ndo, ip, sport, dport);
431 goto trunc;
432 }
433
434 if (ndo->ndo_packettype) {
435 const struct sunrpc_msg *rp;
436 enum sunrpc_msg_type direction;
437
438 switch (ndo->ndo_packettype) {
439
440 case PT_VAT:
441 udpipaddr_print(ndo, ip, sport, dport);
442 vat_print(ndo, (const void *)(up + 1), length);
443 break;
444
445 case PT_WB:
446 udpipaddr_print(ndo, ip, sport, dport);
447 wb_print(ndo, (const u_char *)(up + 1), length);
448 break;
449
450 case PT_RPC:
451 rp = (const struct sunrpc_msg *)(up + 1);
452 direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
453 if (direction == SUNRPC_CALL)
454 sunrpc_print(ndo, (const u_char *)rp, length,
455 (const u_char *)ip);
456 else
457 nfsreply_print(ndo, (const u_char *)rp, length,
458 (const u_char *)ip); /*XXX*/
459 break;
460
461 case PT_RTP:
462 udpipaddr_print(ndo, ip, sport, dport);
463 rtp_print(ndo, (const void *)(up + 1), length);
464 break;
465
466 case PT_RTCP:
467 udpipaddr_print(ndo, ip, sport, dport);
468 while (cp < ep)
469 cp = rtcp_print(ndo, cp, ep);
470 break;
471
472 case PT_SNMP:
473 udpipaddr_print(ndo, ip, sport, dport);
474 snmp_print(ndo, (const u_char *)(up + 1), length);
475 break;
476
477 case PT_CNFP:
478 udpipaddr_print(ndo, ip, sport, dport);
479 cnfp_print(ndo, cp);
480 break;
481
482 case PT_TFTP:
483 udpipaddr_print(ndo, ip, sport, dport);
484 tftp_print(ndo, cp, length);
485 break;
486
487 case PT_AODV:
488 udpipaddr_print(ndo, ip, sport, dport);
489 aodv_print(ndo, (const u_char *)(up + 1), length,
490 ip6 != NULL);
491 break;
492
493 case PT_RADIUS:
494 udpipaddr_print(ndo, ip, sport, dport);
495 radius_print(ndo, cp, length);
496 break;
497
498 case PT_VXLAN:
499 udpipaddr_print(ndo, ip, sport, dport);
500 vxlan_print(ndo, (const u_char *)(up + 1), length);
501 break;
502
503 case PT_PGM:
504 case PT_PGM_ZMTP1:
505 udpipaddr_print(ndo, ip, sport, dport);
506 pgm_print(ndo, cp, length, bp2);
507 break;
508 case PT_LMP:
509 udpipaddr_print(ndo, ip, sport, dport);
510 lmp_print(ndo, cp, length);
511 break;
512 }
513 return;
514 }
515
516 udpipaddr_print(ndo, ip, sport, dport);
517 if (!ndo->ndo_qflag) {
518 const struct sunrpc_msg *rp;
519 enum sunrpc_msg_type direction;
520
521 rp = (const struct sunrpc_msg *)(up + 1);
522 if (ND_TTEST_4(rp->rm_direction)) {
523 direction = (enum sunrpc_msg_type) EXTRACT_BE_U_4(rp->rm_direction);
524 if (dport == NFS_PORT && direction == SUNRPC_CALL) {
525 ND_PRINT("NFS request xid %u ",
526 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 ",
533 EXTRACT_BE_U_4(rp->rm_xid));
534 nfsreply_noaddr_print(ndo, (const u_char *)rp, length,
535 (const u_char *)ip);
536 return;
537 }
538 #ifdef notdef
539 if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
540 sunrpc_print((const u_char *)rp, length, (const u_char *)ip);
541 return;
542 }
543 #endif
544 }
545 }
546
547 if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
548 /* Check the checksum, if possible. */
549 uint16_t sum, udp_sum;
550
551 /*
552 * XXX - do this even if vflag == 1?
553 * TCP does, and we do so for UDP-over-IPv6.
554 */
555 if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
556 udp_sum = EXTRACT_BE_U_2(up->uh_sum);
557 if (udp_sum == 0) {
558 ND_PRINT("[no cksum] ");
559 } else if (ND_TTEST_LEN(cp, length)) {
560 sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
561
562 if (sum != 0) {
563 ND_PRINT("[bad udp cksum 0x%04x -> 0x%04x!] ",
564 udp_sum,
565 in_cksum_shouldbe(udp_sum, sum));
566 } else
567 ND_PRINT("[udp sum ok] ");
568 }
569 }
570 else if (IP_V(ip) == 6 && ip6->ip6_plen) {
571 /* for IPv6, UDP checksum is mandatory */
572 if (ND_TTEST_LEN(cp, length)) {
573 sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
574 udp_sum = EXTRACT_BE_U_2(up->uh_sum);
575
576 if (sum != 0) {
577 ND_PRINT("[bad udp cksum 0x%04x -> 0x%04x!] ",
578 udp_sum,
579 in_cksum_shouldbe(udp_sum, sum));
580 } else
581 ND_PRINT("[udp sum ok] ");
582 }
583 }
584 }
585
586 if (!ndo->ndo_qflag) {
587 if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
588 domain_print(ndo, (const u_char *)(up + 1), length, 0);
589 else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
590 domain_print(ndo, (const u_char *)(up + 1), length, 1);
591 else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
592 timed_print(ndo, (const u_char *)(up + 1));
593 else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
594 tftp_print(ndo, (const u_char *)(up + 1), length);
595 else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) || IS_SRC_OR_DST_PORT(BOOTPS_PORT))
596 bootp_print(ndo, (const u_char *)(up + 1), length);
597 else if (IS_SRC_OR_DST_PORT(RIP_PORT))
598 rip_print(ndo, (const u_char *)(up + 1), length);
599 else if (IS_SRC_OR_DST_PORT(AODV_PORT))
600 aodv_print(ndo, (const u_char *)(up + 1), length,
601 ip6 != NULL);
602 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
603 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
604 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
605 isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
606 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
607 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
608 else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
609 snmp_print(ndo, (const u_char *)(up + 1), length);
610 else if (IS_SRC_OR_DST_PORT(NTP_PORT))
611 ntp_print(ndo, (const u_char *)(up + 1), length);
612 else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
613 krb_print(ndo, (const void *)(up + 1));
614 else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
615 l2tp_print(ndo, (const u_char *)(up + 1), length);
616 #ifdef ENABLE_SMB
617 else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
618 nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
619 else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
620 nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
621 #endif
622 else if (dport == VAT_PORT)
623 vat_print(ndo, (const void *)(up + 1), length);
624 else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
625 zephyr_print(ndo, (const void *)(up + 1), length);
626 /*
627 * Since there are 10 possible ports to check, I think
628 * a <> test would be more efficient
629 */
630 else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
631 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
632 rx_print(ndo, (const void *)(up + 1), length, sport, dport,
633 (const u_char *) ip);
634 else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
635 ripng_print(ndo, (const u_char *)(up + 1), length);
636 else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) || IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
637 dhcp6_print(ndo, (const u_char *)(up + 1), length);
638 else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
639 ahcp_print(ndo, (const u_char *)(up + 1), length);
640 else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
641 babel_print(ndo, (const u_char *)(up + 1), length);
642 else if (IS_SRC_OR_DST_PORT(HNCP_PORT))
643 hncp_print(ndo, (const u_char *)(up + 1), length);
644 /*
645 * Kludge in test for whiteboard packets.
646 */
647 else if (dport == WB_PORT)
648 wb_print(ndo, (const u_char *)(up + 1), length);
649 else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
650 cisco_autorp_print(ndo, (const void *)(up + 1), length);
651 else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
652 IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
653 IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
654 IS_SRC_OR_DST_PORT(RADIUS_NEW_ACCOUNTING_PORT) ||
655 IS_SRC_OR_DST_PORT(RADIUS_CISCO_COA_PORT) ||
656 IS_SRC_OR_DST_PORT(RADIUS_COA_PORT) )
657 radius_print(ndo, (const u_char *)(up+1), length);
658 else if (dport == HSRP_PORT)
659 hsrp_print(ndo, (const u_char *)(up + 1), length);
660 else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
661 lwres_print(ndo, (const u_char *)(up + 1), length);
662 else if (IS_SRC_OR_DST_PORT(LDP_PORT))
663 ldp_print(ndo, (const u_char *)(up + 1), length);
664 else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
665 olsr_print(ndo, (const u_char *)(up + 1), length,
666 (IP_V(ip) == 6) ? 1 : 0);
667 else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
668 lspping_print(ndo, (const u_char *)(up + 1), length);
669 else if (dport == BFD_CONTROL_PORT ||
670 dport == BFD_ECHO_PORT )
671 bfd_print(ndo, (const u_char *)(up+1), length, dport);
672 else if (IS_SRC_OR_DST_PORT(LMP_PORT))
673 lmp_print(ndo, (const u_char *)(up + 1), length);
674 else if (IS_SRC_OR_DST_PORT(VQP_PORT))
675 vqp_print(ndo, (const u_char *)(up + 1), length);
676 else if (IS_SRC_OR_DST_PORT(SFLOW_PORT))
677 sflow_print(ndo, (const u_char *)(up + 1), length);
678 else if (dport == LWAPP_CONTROL_PORT)
679 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
680 else if (sport == LWAPP_CONTROL_PORT)
681 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
682 else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
683 lwapp_data_print(ndo, (const u_char *)(up + 1), length);
684 else if (IS_SRC_OR_DST_PORT(SIP_PORT))
685 sip_print(ndo, (const u_char *)(up + 1), length);
686 else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
687 syslog_print(ndo, (const u_char *)(up + 1), length);
688 else if (IS_SRC_OR_DST_PORT(OTV_PORT))
689 otv_print(ndo, (const u_char *)(up + 1), length);
690 else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
691 vxlan_print(ndo, (const u_char *)(up + 1), length);
692 else if (IS_SRC_OR_DST_PORT(GENEVE_PORT))
693 geneve_print(ndo, (const u_char *)(up + 1), length);
694 else if (IS_SRC_OR_DST_PORT(LISP_CONTROL_PORT))
695 lisp_print(ndo, (const u_char *)(up + 1), length);
696 else if (IS_SRC_OR_DST_PORT(VXLAN_GPE_PORT))
697 vxlan_gpe_print(ndo, (const u_char *)(up + 1), length);
698 else if (ND_TTEST_1(((const struct LAP *)cp)->type) &&
699 EXTRACT_U_1(((const struct LAP *)cp)->type) == lapDDP &&
700 (atalk_port(sport) || atalk_port(dport))) {
701 if (ndo->ndo_vflag)
702 ND_PRINT("kip ");
703 llap_print(ndo, cp, length);
704 } else {
705 if (ulen > length)
706 ND_PRINT("UDP, bad length %u > %u",
707 ulen, length);
708 else
709 ND_PRINT("UDP, length %u", ulen);
710 }
711 } else {
712 if (ulen > length)
713 ND_PRINT("UDP, bad length %u > %u",
714 ulen, length);
715 else
716 ND_PRINT("UDP, length %u", ulen);
717 }
718 return;
719
720 trunc:
721 nd_print_trunc(ndo);
722 }