blob: 5a74ff2fc69c706d43002f6d770955c63c59ea95 [file] [log] [blame]
The Android Open Source Project2949f582009-03-03 19:30:46 -08001/*
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
Elliott Hughese2e3bd12017-05-15 10:59:29 -070022/* \summary: UDP printer */
23
The Android Open Source Project2949f582009-03-03 19:30:46 -080024#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
Elliott Hughese2e3bd12017-05-15 10:59:29 -070028#include <netdissect-stdinc.h>
The Android Open Source Project2949f582009-03-03 19:30:46 -080029
Elliott Hughese2e3bd12017-05-15 10:59:29 -070030#include "netdissect.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080031#include "addrtoname.h"
32#include "extract.h"
33#include "appletalk.h"
34
35#include "udp.h"
36
37#include "ip.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080038#include "ip6.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080039#include "ipproto.h"
40#include "rpc_auth.h"
41#include "rpc_msg.h"
42
The Android Open Source Project2949f582009-03-03 19:30:46 -080043#include "nfs.h"
The Android Open Source Project2949f582009-03-03 19:30:46 -080044
Elliott Hughese2e3bd12017-05-15 10:59:29 -070045static const char vat_tstr[] = " [|vat]";
46static const char rtp_tstr[] = " [|rtp]";
47static const char rtcp_tstr[] = " [|rtcp]";
48static const char udp_tstr[] = " [|udp]";
49
The Android Open Source Project2949f582009-03-03 19:30:46 -080050struct rtcphdr {
Elliott Hughes892a68b2015-10-19 14:43:53 -070051 uint16_t rh_flags; /* T:2 P:1 CNT:5 PT:8 */
52 uint16_t rh_len; /* length of message (in words) */
53 uint32_t rh_ssrc; /* synchronization src id */
The Android Open Source Project2949f582009-03-03 19:30:46 -080054};
55
56typedef struct {
Elliott Hughes892a68b2015-10-19 14:43:53 -070057 uint32_t upper; /* more significant 32 bits */
58 uint32_t lower; /* less significant 32 bits */
The Android Open Source Project2949f582009-03-03 19:30:46 -080059} ntp64;
60
61/*
62 * Sender report.
63 */
64struct rtcp_sr {
65 ntp64 sr_ntp; /* 64-bit ntp timestamp */
Elliott Hughes892a68b2015-10-19 14:43:53 -070066 uint32_t sr_ts; /* reference media timestamp */
67 uint32_t sr_np; /* no. packets sent */
68 uint32_t sr_nb; /* no. bytes sent */
The Android Open Source Project2949f582009-03-03 19:30:46 -080069};
70
71/*
72 * Receiver report.
73 * Time stamps are middle 32-bits of ntp timestamp.
74 */
75struct rtcp_rr {
Elliott Hughes892a68b2015-10-19 14:43:53 -070076 uint32_t rr_srcid; /* sender being reported */
77 uint32_t rr_nl; /* no. packets lost */
78 uint32_t rr_ls; /* extended last seq number received */
79 uint32_t rr_dv; /* jitter (delay variance) */
80 uint32_t rr_lsr; /* orig. ts from last rr from this src */
81 uint32_t rr_dlsr; /* time from recpt of last rr to xmit time */
The Android Open Source Project2949f582009-03-03 19:30:46 -080082};
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
99static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700100vat_print(netdissect_options *ndo, const void *hdr, register const struct udphdr *up)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800101{
102 /* vat/vt audio */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700103 u_int ts;
104
105 ND_TCHECK_16BITS((const u_int *)hdr);
106 ts = EXTRACT_16BITS(hdr);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800107 if ((ts & 0xf060) != 0) {
108 /* probably vt */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700109 ND_TCHECK_16BITS(&up->uh_ulen);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700110 ND_PRINT((ndo, "udp/vt %u %d / %d",
111 (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up)),
112 ts & 0x3ff, ts >> 10));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800113 } else {
114 /* probably vat */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700115 uint32_t i0, i1;
116
117 ND_TCHECK_32BITS(&((const u_int *)hdr)[0]);
118 i0 = EXTRACT_32BITS(&((const u_int *)hdr)[0]);
119 ND_TCHECK_32BITS(&((const u_int *)hdr)[1]);
120 i1 = EXTRACT_32BITS(&((const u_int *)hdr)[1]);
121 ND_TCHECK_16BITS(&up->uh_ulen);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700122 ND_PRINT((ndo, "udp/vat %u c%d %u%s",
123 (uint32_t)(EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8),
The Android Open Source Project2949f582009-03-03 19:30:46 -0800124 i0 & 0xffff,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700125 i1, i0 & 0x800000? "*" : ""));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800126 /* audio format */
127 if (i0 & 0x1f0000)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700128 ND_PRINT((ndo, " f%d", (i0 >> 16) & 0x1f));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800129 if (i0 & 0x3f000000)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700130 ND_PRINT((ndo, " s%d", (i0 >> 24) & 0x3f));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800131 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700132
133trunc:
134 ND_PRINT((ndo, "%s", vat_tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800135}
136
137static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700138rtp_print(netdissect_options *ndo, const void *hdr, u_int len,
139 register const struct udphdr *up)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800140{
141 /* rtp v1 or v2 */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700142 const u_int *ip = (const u_int *)hdr;
143 u_int hasopt, hasext, contype, hasmarker, dlen;
144 uint32_t i0, i1;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800145 const char * ptype;
146
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700147 ND_TCHECK_32BITS(&((const u_int *)hdr)[0]);
148 i0 = EXTRACT_32BITS(&((const u_int *)hdr)[0]);
149 ND_TCHECK_32BITS(&((const u_int *)hdr)[1]);
150 i1 = EXTRACT_32BITS(&((const u_int *)hdr)[1]);
151 ND_TCHECK_16BITS(&up->uh_ulen);
152 dlen = EXTRACT_16BITS(&up->uh_ulen) - sizeof(*up) - 8;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800153 ip += 2;
154 len >>= 2;
155 len -= 2;
156 hasopt = 0;
157 hasext = 0;
158 if ((i0 >> 30) == 1) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700159 /* rtp v1 - draft-ietf-avt-rtp-04 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800160 hasopt = i0 & 0x800000;
161 contype = (i0 >> 16) & 0x3f;
162 hasmarker = i0 & 0x400000;
163 ptype = "rtpv1";
164 } else {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700165 /* rtp v2 - RFC 3550 */
The Android Open Source Project2949f582009-03-03 19:30:46 -0800166 hasext = i0 & 0x10000000;
167 contype = (i0 >> 16) & 0x7f;
168 hasmarker = i0 & 0x800000;
169 dlen -= 4;
170 ptype = "rtp";
171 ip += 1;
172 len -= 1;
173 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700174 ND_PRINT((ndo, "udp/%s %d c%d %s%s %d %u",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800175 ptype,
176 dlen,
177 contype,
178 (hasopt || hasext)? "+" : "",
179 hasmarker? "*" : "",
180 i0 & 0xffff,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700181 i1));
182 if (ndo->ndo_vflag) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700183 ND_TCHECK_32BITS(&((const u_int *)hdr)[2]);
184 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&((const u_int *)hdr)[2])));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800185 if (hasopt) {
186 u_int i2, optlen;
187 do {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700188 ND_TCHECK_32BITS(ip);
189 i2 = EXTRACT_32BITS(ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800190 optlen = (i2 >> 16) & 0xff;
191 if (optlen == 0 || optlen > len) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700192 ND_PRINT((ndo, " !opt"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800193 return;
194 }
195 ip += optlen;
196 len -= optlen;
197 } while ((int)i2 >= 0);
198 }
199 if (hasext) {
200 u_int i2, extlen;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700201 ND_TCHECK_32BITS(ip);
202 i2 = EXTRACT_32BITS(ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800203 extlen = (i2 & 0xffff) + 1;
204 if (extlen > len) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700205 ND_PRINT((ndo, " !ext"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800206 return;
207 }
208 ip += extlen;
209 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700210 ND_TCHECK_32BITS(ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800211 if (contype == 0x1f) /*XXX H.261 */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700212 ND_PRINT((ndo, " 0x%04x", EXTRACT_32BITS(ip) >> 16));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800213 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700214
215trunc:
216 ND_PRINT((ndo, "%s", rtp_tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800217}
218
219static const u_char *
Elliott Hughes892a68b2015-10-19 14:43:53 -0700220rtcp_print(netdissect_options *ndo, const u_char *hdr, const u_char *ep)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800221{
222 /* rtp v2 control (rtcp) */
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700223 const struct rtcp_rr *rr = 0;
224 const struct rtcp_sr *sr;
225 const struct rtcphdr *rh = (const struct rtcphdr *)hdr;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800226 u_int len;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700227 uint16_t flags;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800228 int cnt;
229 double ts, dts;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700230 if ((const u_char *)(rh + 1) > ep)
231 goto trunc;
232 ND_TCHECK(*rh);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800233 len = (EXTRACT_16BITS(&rh->rh_len) + 1) * 4;
234 flags = EXTRACT_16BITS(&rh->rh_flags);
235 cnt = (flags >> 8) & 0x1f;
236 switch (flags & 0xff) {
237 case RTCP_PT_SR:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700238 sr = (const struct rtcp_sr *)(rh + 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700239 ND_PRINT((ndo, " sr"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800240 if (len != cnt * sizeof(*rr) + sizeof(*sr) + sizeof(*rh))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700241 ND_PRINT((ndo, " [%d]", len));
242 if (ndo->ndo_vflag)
243 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700244 if ((const u_char *)(sr + 1) > ep)
245 goto trunc;
246 ND_TCHECK(*sr);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800247 ts = (double)(EXTRACT_32BITS(&sr->sr_ntp.upper)) +
248 ((double)(EXTRACT_32BITS(&sr->sr_ntp.lower)) /
249 4294967296.0);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700250 ND_PRINT((ndo, " @%.2f %u %up %ub", ts, EXTRACT_32BITS(&sr->sr_ts),
251 EXTRACT_32BITS(&sr->sr_np), EXTRACT_32BITS(&sr->sr_nb)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700252 rr = (const struct rtcp_rr *)(sr + 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800253 break;
254 case RTCP_PT_RR:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700255 ND_PRINT((ndo, " rr"));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800256 if (len != cnt * sizeof(*rr) + sizeof(*rh))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700257 ND_PRINT((ndo, " [%d]", len));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700258 rr = (const struct rtcp_rr *)(rh + 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700259 if (ndo->ndo_vflag)
260 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800261 break;
262 case RTCP_PT_SDES:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700263 ND_PRINT((ndo, " sdes %d", len));
264 if (ndo->ndo_vflag)
265 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800266 cnt = 0;
267 break;
268 case RTCP_PT_BYE:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700269 ND_PRINT((ndo, " bye %d", len));
270 if (ndo->ndo_vflag)
271 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rh->rh_ssrc)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800272 cnt = 0;
273 break;
274 default:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700275 ND_PRINT((ndo, " type-0x%x %d", flags & 0xff, len));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800276 cnt = 0;
277 break;
278 }
279 if (cnt > 1)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700280 ND_PRINT((ndo, " c%d", cnt));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800281 while (--cnt >= 0) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700282 if ((const u_char *)(rr + 1) > ep)
283 goto trunc;
284 ND_TCHECK(*rr);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700285 if (ndo->ndo_vflag)
286 ND_PRINT((ndo, " %u", EXTRACT_32BITS(&rr->rr_srcid)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800287 ts = (double)(EXTRACT_32BITS(&rr->rr_lsr)) / 65536.;
288 dts = (double)(EXTRACT_32BITS(&rr->rr_dlsr)) / 65536.;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700289 ND_PRINT((ndo, " %ul %us %uj @%.2f+%.2f",
The Android Open Source Project2949f582009-03-03 19:30:46 -0800290 EXTRACT_32BITS(&rr->rr_nl) & 0x00ffffff,
291 EXTRACT_32BITS(&rr->rr_ls),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700292 EXTRACT_32BITS(&rr->rr_dv), ts, dts));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800293 }
294 return (hdr + len);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700295
296trunc:
297 ND_PRINT((ndo, "%s", rtcp_tstr));
298 return ep;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800299}
300
Elliott Hughes892a68b2015-10-19 14:43:53 -0700301static int udp_cksum(netdissect_options *ndo, register const struct ip *ip,
The Android Open Source Project2949f582009-03-03 19:30:46 -0800302 register const struct udphdr *up,
303 register u_int len)
304{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700305 return nextproto4_cksum(ndo, ip, (const uint8_t *)(const void *)up, len, len,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700306 IPPROTO_UDP);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800307}
308
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700309static int udp6_cksum(netdissect_options *ndo, const struct ip6_hdr *ip6,
310 const struct udphdr *up, u_int len)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800311{
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700312 return nextproto6_cksum(ndo, ip6, (const uint8_t *)(const void *)up, len, len,
313 IPPROTO_UDP);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800314}
The Android Open Source Project2949f582009-03-03 19:30:46 -0800315
316static void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700317udpipaddr_print(netdissect_options *ndo, const struct ip *ip, int sport, int dport)
The Android Open Source Project2949f582009-03-03 19:30:46 -0800318{
The Android Open Source Project2949f582009-03-03 19:30:46 -0800319 const struct ip6_hdr *ip6;
320
321 if (IP_V(ip) == 6)
322 ip6 = (const struct ip6_hdr *)ip;
323 else
324 ip6 = NULL;
325
326 if (ip6) {
327 if (ip6->ip6_nxt == IPPROTO_UDP) {
328 if (sport == -1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700329 ND_PRINT((ndo, "%s > %s: ",
330 ip6addr_string(ndo, &ip6->ip6_src),
331 ip6addr_string(ndo, &ip6->ip6_dst)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800332 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700333 ND_PRINT((ndo, "%s.%s > %s.%s: ",
334 ip6addr_string(ndo, &ip6->ip6_src),
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700335 udpport_string(ndo, sport),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700336 ip6addr_string(ndo, &ip6->ip6_dst),
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700337 udpport_string(ndo, dport)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800338 }
339 } else {
340 if (sport != -1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700341 ND_PRINT((ndo, "%s > %s: ",
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700342 udpport_string(ndo, sport),
343 udpport_string(ndo, dport)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800344 }
345 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700346 } else {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800347 if (ip->ip_p == IPPROTO_UDP) {
348 if (sport == -1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700349 ND_PRINT((ndo, "%s > %s: ",
350 ipaddr_string(ndo, &ip->ip_src),
351 ipaddr_string(ndo, &ip->ip_dst)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800352 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700353 ND_PRINT((ndo, "%s.%s > %s.%s: ",
354 ipaddr_string(ndo, &ip->ip_src),
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700355 udpport_string(ndo, sport),
Elliott Hughes892a68b2015-10-19 14:43:53 -0700356 ipaddr_string(ndo, &ip->ip_dst),
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700357 udpport_string(ndo, dport)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800358 }
359 } else {
360 if (sport != -1) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700361 ND_PRINT((ndo, "%s > %s: ",
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700362 udpport_string(ndo, sport),
363 udpport_string(ndo, dport)));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800364 }
365 }
366 }
367}
368
369void
Elliott Hughes892a68b2015-10-19 14:43:53 -0700370udp_print(netdissect_options *ndo, register const u_char *bp, u_int length,
The Android Open Source Project2949f582009-03-03 19:30:46 -0800371 register const u_char *bp2, int fragmented)
372{
373 register const struct udphdr *up;
374 register const struct ip *ip;
375 register const u_char *cp;
376 register const u_char *ep = bp + length;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700377 uint16_t sport, dport, ulen;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800378 register const struct ip6_hdr *ip6;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800379
Elliott Hughes892a68b2015-10-19 14:43:53 -0700380 if (ep > ndo->ndo_snapend)
381 ep = ndo->ndo_snapend;
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700382 up = (const struct udphdr *)bp;
383 ip = (const struct ip *)bp2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800384 if (IP_V(ip) == 6)
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700385 ip6 = (const struct ip6_hdr *)bp2;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800386 else
387 ip6 = NULL;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700388 if (!ND_TTEST(up->uh_dport)) {
389 udpipaddr_print(ndo, ip, -1, -1);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700390 goto trunc;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800391 }
392
393 sport = EXTRACT_16BITS(&up->uh_sport);
394 dport = EXTRACT_16BITS(&up->uh_dport);
395
396 if (length < sizeof(struct udphdr)) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700397 udpipaddr_print(ndo, ip, sport, dport);
398 ND_PRINT((ndo, "truncated-udp %d", length));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800399 return;
400 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700401 if (!ND_TTEST(up->uh_ulen)) {
402 udpipaddr_print(ndo, ip, sport, dport);
403 goto trunc;
404 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800405 ulen = EXTRACT_16BITS(&up->uh_ulen);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700406 if (ulen < sizeof(struct udphdr)) {
407 udpipaddr_print(ndo, ip, sport, dport);
408 ND_PRINT((ndo, "truncated-udplength %d", ulen));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800409 return;
410 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700411 ulen -= sizeof(struct udphdr);
412 length -= sizeof(struct udphdr);
413 if (ulen < length)
414 length = ulen;
415
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700416 cp = (const u_char *)(up + 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700417 if (cp > ndo->ndo_snapend) {
418 udpipaddr_print(ndo, ip, sport, dport);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700419 goto trunc;
Elliott Hughes892a68b2015-10-19 14:43:53 -0700420 }
421
422 if (ndo->ndo_packettype) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700423 register const struct sunrpc_msg *rp;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800424 enum sunrpc_msg_type direction;
425
Elliott Hughes892a68b2015-10-19 14:43:53 -0700426 switch (ndo->ndo_packettype) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800427
428 case PT_VAT:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700429 udpipaddr_print(ndo, ip, sport, dport);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700430 vat_print(ndo, (const void *)(up + 1), up);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800431 break;
432
433 case PT_WB:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700434 udpipaddr_print(ndo, ip, sport, dport);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700435 wb_print(ndo, (const void *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800436 break;
437
438 case PT_RPC:
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700439 rp = (const struct sunrpc_msg *)(up + 1);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800440 direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
441 if (direction == SUNRPC_CALL)
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700442 sunrpcrequest_print(ndo, (const u_char *)rp, length,
443 (const u_char *)ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800444 else
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700445 nfsreply_print(ndo, (const u_char *)rp, length,
446 (const u_char *)ip); /*XXX*/
The Android Open Source Project2949f582009-03-03 19:30:46 -0800447 break;
448
449 case PT_RTP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700450 udpipaddr_print(ndo, ip, sport, dport);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700451 rtp_print(ndo, (const void *)(up + 1), length, up);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800452 break;
453
454 case PT_RTCP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700455 udpipaddr_print(ndo, ip, sport, dport);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800456 while (cp < ep)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700457 cp = rtcp_print(ndo, cp, ep);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800458 break;
459
460 case PT_SNMP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700461 udpipaddr_print(ndo, ip, sport, dport);
462 snmp_print(ndo, (const u_char *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800463 break;
464
465 case PT_CNFP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700466 udpipaddr_print(ndo, ip, sport, dport);
467 cnfp_print(ndo, cp);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800468 break;
469
470 case PT_TFTP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700471 udpipaddr_print(ndo, ip, sport, dport);
472 tftp_print(ndo, cp, length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800473 break;
474
475 case PT_AODV:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700476 udpipaddr_print(ndo, ip, sport, dport);
477 aodv_print(ndo, (const u_char *)(up + 1), length,
The Android Open Source Project2949f582009-03-03 19:30:46 -0800478 ip6 != NULL);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800479 break;
JP Abgrall53f17a92014-02-12 14:02:41 -0800480
481 case PT_RADIUS:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700482 udpipaddr_print(ndo, ip, sport, dport);
483 radius_print(ndo, cp, length);
JP Abgrall53f17a92014-02-12 14:02:41 -0800484 break;
485
486 case PT_VXLAN:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700487 udpipaddr_print(ndo, ip, sport, dport);
488 vxlan_print(ndo, (const u_char *)(up + 1), length);
JP Abgrall53f17a92014-02-12 14:02:41 -0800489 break;
490
491 case PT_PGM:
492 case PT_PGM_ZMTP1:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700493 udpipaddr_print(ndo, ip, sport, dport);
494 pgm_print(ndo, cp, length, bp2);
JP Abgrall53f17a92014-02-12 14:02:41 -0800495 break;
496 case PT_LMP:
Elliott Hughes892a68b2015-10-19 14:43:53 -0700497 udpipaddr_print(ndo, ip, sport, dport);
498 lmp_print(ndo, cp, length);
JP Abgrall53f17a92014-02-12 14:02:41 -0800499 break;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800500 }
501 return;
502 }
503
Elliott Hughes892a68b2015-10-19 14:43:53 -0700504 udpipaddr_print(ndo, ip, sport, dport);
505 if (!ndo->ndo_qflag) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700506 register const struct sunrpc_msg *rp;
The Android Open Source Project2949f582009-03-03 19:30:46 -0800507 enum sunrpc_msg_type direction;
508
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700509 rp = (const struct sunrpc_msg *)(up + 1);
Elliott Hughes892a68b2015-10-19 14:43:53 -0700510 if (ND_TTEST(rp->rm_direction)) {
The Android Open Source Project2949f582009-03-03 19:30:46 -0800511 direction = (enum sunrpc_msg_type)EXTRACT_32BITS(&rp->rm_direction);
512 if (dport == NFS_PORT && direction == SUNRPC_CALL) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700513 ND_PRINT((ndo, "NFS request xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700514 nfsreq_print_noaddr(ndo, (const u_char *)rp, length,
515 (const u_char *)ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800516 return;
517 }
518 if (sport == NFS_PORT && direction == SUNRPC_REPLY) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700519 ND_PRINT((ndo, "NFS reply xid %u ", EXTRACT_32BITS(&rp->rm_xid)));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700520 nfsreply_print_noaddr(ndo, (const u_char *)rp, length,
521 (const u_char *)ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800522 return;
523 }
524#ifdef notdef
525 if (dport == SUNRPC_PORT && direction == SUNRPC_CALL) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700526 sunrpcrequest_print((const u_char *)rp, length, (const u_char *)ip);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800527 return;
528 }
529#endif
530 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800531 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800532
Elliott Hughes892a68b2015-10-19 14:43:53 -0700533 if (ndo->ndo_vflag && !ndo->ndo_Kflag && !fragmented) {
JP Abgrall53f17a92014-02-12 14:02:41 -0800534 /* Check the checksum, if possible. */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700535 uint16_t sum, udp_sum;
JP Abgrall53f17a92014-02-12 14:02:41 -0800536
537 /*
538 * XXX - do this even if vflag == 1?
539 * TCP does, and we do so for UDP-over-IPv6.
540 */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700541 if (IP_V(ip) == 4 && (ndo->ndo_vflag > 1)) {
JP Abgrall53f17a92014-02-12 14:02:41 -0800542 udp_sum = EXTRACT_16BITS(&up->uh_sum);
543 if (udp_sum == 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700544 ND_PRINT((ndo, "[no cksum] "));
545 } else if (ND_TTEST2(cp[0], length)) {
546 sum = udp_cksum(ndo, ip, up, length + sizeof(struct udphdr));
JP Abgrall53f17a92014-02-12 14:02:41 -0800547
548 if (sum != 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700549 ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
JP Abgrall53f17a92014-02-12 14:02:41 -0800550 udp_sum,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700551 in_cksum_shouldbe(udp_sum, sum)));
JP Abgrall53f17a92014-02-12 14:02:41 -0800552 } else
Elliott Hughes892a68b2015-10-19 14:43:53 -0700553 ND_PRINT((ndo, "[udp sum ok] "));
JP Abgrall53f17a92014-02-12 14:02:41 -0800554 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800555 }
JP Abgrall53f17a92014-02-12 14:02:41 -0800556 else if (IP_V(ip) == 6 && ip6->ip6_plen) {
557 /* for IPv6, UDP checksum is mandatory */
Elliott Hughes892a68b2015-10-19 14:43:53 -0700558 if (ND_TTEST2(cp[0], length)) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700559 sum = udp6_cksum(ndo, ip6, up, length + sizeof(struct udphdr));
JP Abgrall53f17a92014-02-12 14:02:41 -0800560 udp_sum = EXTRACT_16BITS(&up->uh_sum);
561
562 if (sum != 0) {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700563 ND_PRINT((ndo, "[bad udp cksum 0x%04x -> 0x%04x!] ",
JP Abgrall53f17a92014-02-12 14:02:41 -0800564 udp_sum,
Elliott Hughes892a68b2015-10-19 14:43:53 -0700565 in_cksum_shouldbe(udp_sum, sum)));
JP Abgrall53f17a92014-02-12 14:02:41 -0800566 } else
Elliott Hughes892a68b2015-10-19 14:43:53 -0700567 ND_PRINT((ndo, "[udp sum ok] "));
JP Abgrall53f17a92014-02-12 14:02:41 -0800568 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800569 }
JP Abgrall53f17a92014-02-12 14:02:41 -0800570 }
The Android Open Source Project2949f582009-03-03 19:30:46 -0800571
Elliott Hughes892a68b2015-10-19 14:43:53 -0700572 if (!ndo->ndo_qflag) {
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700573 if (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700574 ns_print(ndo, (const u_char *)(up + 1), length, 0);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700575 else if (IS_SRC_OR_DST_PORT(MULTICASTDNS_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700576 ns_print(ndo, (const u_char *)(up + 1), length, 1);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700577 else if (IS_SRC_OR_DST_PORT(TIMED_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700578 timed_print(ndo, (const u_char *)(up + 1));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700579 else if (IS_SRC_OR_DST_PORT(TFTP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700580 tftp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700581 else if (IS_SRC_OR_DST_PORT(BOOTPC_PORT) || IS_SRC_OR_DST_PORT(BOOTPS_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700582 bootp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700583 else if (IS_SRC_OR_DST_PORT(RIP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700584 rip_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700585 else if (IS_SRC_OR_DST_PORT(AODV_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700586 aodv_print(ndo, (const u_char *)(up + 1), length,
The Android Open Source Project2949f582009-03-03 19:30:46 -0800587 ip6 != NULL);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700588 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700589 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700590 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_NATT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700591 isakmp_rfc3948_print(ndo, (const u_char *)(up + 1), length, bp2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800592#if 1 /*???*/
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700593 else if (IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER1) || IS_SRC_OR_DST_PORT(ISAKMP_PORT_USER2))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700594 isakmp_print(ndo, (const u_char *)(up + 1), length, bp2);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800595#endif
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700596 else if (IS_SRC_OR_DST_PORT(SNMP_PORT) || IS_SRC_OR_DST_PORT(SNMPTRAP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700597 snmp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700598 else if (IS_SRC_OR_DST_PORT(NTP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700599 ntp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700600 else if (IS_SRC_OR_DST_PORT(KERBEROS_PORT) || IS_SRC_OR_DST_PORT(KERBEROS_SEC_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700601 krb_print(ndo, (const void *)(up + 1));
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700602 else if (IS_SRC_OR_DST_PORT(L2TP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700603 l2tp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700604#ifdef ENABLE_SMB
605 else if (IS_SRC_OR_DST_PORT(NETBIOS_NS_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700606 nbt_udp137_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700607 else if (IS_SRC_OR_DST_PORT(NETBIOS_DGRAM_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700608 nbt_udp138_print(ndo, (const u_char *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800609#endif
JP Abgrall53f17a92014-02-12 14:02:41 -0800610 else if (dport == VAT_PORT)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700611 vat_print(ndo, (const void *)(up + 1), up);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700612 else if (IS_SRC_OR_DST_PORT(ZEPHYR_SRV_PORT) || IS_SRC_OR_DST_PORT(ZEPHYR_CLT_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700613 zephyr_print(ndo, (const void *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800614 /*
615 * Since there are 10 possible ports to check, I think
616 * a <> test would be more efficient
617 */
618 else if ((sport >= RX_PORT_LOW && sport <= RX_PORT_HIGH) ||
619 (dport >= RX_PORT_LOW && dport <= RX_PORT_HIGH))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700620 rx_print(ndo, (const void *)(up + 1), length, sport, dport,
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700621 (const u_char *) ip);
622 else if (IS_SRC_OR_DST_PORT(RIPNG_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700623 ripng_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700624 else if (IS_SRC_OR_DST_PORT(DHCP6_SERV_PORT) || IS_SRC_OR_DST_PORT(DHCP6_CLI_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700625 dhcp6_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700626 else if (IS_SRC_OR_DST_PORT(AHCP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700627 ahcp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700628 else if (IS_SRC_OR_DST_PORT(BABEL_PORT) || IS_SRC_OR_DST_PORT(BABEL_PORT_OLD))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700629 babel_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700630 else if (IS_SRC_OR_DST_PORT(HNCP_PORT))
631 hncp_print(ndo, (const u_char *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800632 /*
633 * Kludge in test for whiteboard packets.
634 */
JP Abgrall53f17a92014-02-12 14:02:41 -0800635 else if (dport == WB_PORT)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700636 wb_print(ndo, (const void *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700637 else if (IS_SRC_OR_DST_PORT(CISCO_AUTORP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700638 cisco_autorp_print(ndo, (const void *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700639 else if (IS_SRC_OR_DST_PORT(RADIUS_PORT) ||
640 IS_SRC_OR_DST_PORT(RADIUS_NEW_PORT) ||
641 IS_SRC_OR_DST_PORT(RADIUS_ACCOUNTING_PORT) ||
642 IS_SRC_OR_DST_PORT(RADIUS_NEW_ACCOUNTING_PORT) ||
643 IS_SRC_OR_DST_PORT(RADIUS_CISCO_COA_PORT) ||
644 IS_SRC_OR_DST_PORT(RADIUS_COA_PORT) )
Elliott Hughes892a68b2015-10-19 14:43:53 -0700645 radius_print(ndo, (const u_char *)(up+1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800646 else if (dport == HSRP_PORT)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700647 hsrp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700648 else if (IS_SRC_OR_DST_PORT(LWRES_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700649 lwres_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700650 else if (IS_SRC_OR_DST_PORT(LDP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700651 ldp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700652 else if (IS_SRC_OR_DST_PORT(OLSR_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700653 olsr_print(ndo, (const u_char *)(up + 1), length,
JP Abgrall53f17a92014-02-12 14:02:41 -0800654 (IP_V(ip) == 6) ? 1 : 0);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700655 else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700656 lspping_print(ndo, (const u_char *)(up + 1), length);
The Android Open Source Project2949f582009-03-03 19:30:46 -0800657 else if (dport == BFD_CONTROL_PORT ||
658 dport == BFD_ECHO_PORT )
Elliott Hughes892a68b2015-10-19 14:43:53 -0700659 bfd_print(ndo, (const u_char *)(up+1), length, dport);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700660 else if (IS_SRC_OR_DST_PORT(LMP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700661 lmp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700662 else if (IS_SRC_OR_DST_PORT(VQP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700663 vqp_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700664 else if (IS_SRC_OR_DST_PORT(SFLOW_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700665 sflow_print(ndo, (const u_char *)(up + 1), length);
JP Abgrall53f17a92014-02-12 14:02:41 -0800666 else if (dport == LWAPP_CONTROL_PORT)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700667 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 1);
JP Abgrall53f17a92014-02-12 14:02:41 -0800668 else if (sport == LWAPP_CONTROL_PORT)
Elliott Hughes892a68b2015-10-19 14:43:53 -0700669 lwapp_control_print(ndo, (const u_char *)(up + 1), length, 0);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700670 else if (IS_SRC_OR_DST_PORT(LWAPP_DATA_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700671 lwapp_data_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700672 else if (IS_SRC_OR_DST_PORT(SIP_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700673 sip_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700674 else if (IS_SRC_OR_DST_PORT(SYSLOG_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700675 syslog_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700676 else if (IS_SRC_OR_DST_PORT(OTV_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700677 otv_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700678 else if (IS_SRC_OR_DST_PORT(VXLAN_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700679 vxlan_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700680 else if (IS_SRC_OR_DST_PORT(GENEVE_PORT))
Elliott Hughes892a68b2015-10-19 14:43:53 -0700681 geneve_print(ndo, (const u_char *)(up + 1), length);
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700682 else if (IS_SRC_OR_DST_PORT(LISP_CONTROL_PORT))
683 lisp_print(ndo, (const u_char *)(up + 1), length);
684 else if (IS_SRC_OR_DST_PORT(VXLAN_GPE_PORT))
685 vxlan_gpe_print(ndo, (const u_char *)(up + 1), length);
686 else if (ND_TTEST(((const struct LAP *)cp)->type) &&
687 ((const struct LAP *)cp)->type == lapDDP &&
688 (atalk_port(sport) || atalk_port(dport))) {
689 if (ndo->ndo_vflag)
690 ND_PRINT((ndo, "kip "));
691 llap_print(ndo, cp, length);
692 } else {
Elliott Hughes892a68b2015-10-19 14:43:53 -0700693 if (ulen > length)
694 ND_PRINT((ndo, "UDP, bad length %u > %u",
695 ulen, length));
696 else
697 ND_PRINT((ndo, "UDP, length %u", ulen));
698 }
Elliott Hughes892a68b2015-10-19 14:43:53 -0700699 } else {
700 if (ulen > length)
701 ND_PRINT((ndo, "UDP, bad length %u > %u",
702 ulen, length));
703 else
704 ND_PRINT((ndo, "UDP, length %u", ulen));
705 }
Elliott Hughese2e3bd12017-05-15 10:59:29 -0700706 return;
707
708trunc:
709 ND_PRINT((ndo, "%s", udp_tstr));
The Android Open Source Project2949f582009-03-03 19:30:46 -0800710}
711
712
713/*
714 * Local Variables:
715 * c-style: whitesmith
716 * c-basic-offset: 8
717 * End:
718 */