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