4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <sys/types.h>
37 #include <sys/socket.h>
38 #include <sys/sockio.h>
40 #include <netinet/in_systm.h>
41 #include <netinet/in.h>
42 #include <netinet/ip.h>
43 #include <netinet/if_ether.h>
44 #include <netinet/udp.h>
47 extern char *dlc_header
;
50 interpret_udp(int flags
, struct udphdr
*udp
, int iplen
, int fraglen
)
58 if (fraglen
< sizeof (struct udphdr
))
59 return (fraglen
); /* incomplete header */
61 data
= (char *)udp
+ sizeof (struct udphdr
);
62 udplen
= ntohs((ushort_t
)udp
->uh_ulen
) - sizeof (struct udphdr
);
63 fraglen
-= sizeof (struct udphdr
);
68 (void) sprintf(get_sum_line(),
69 "UDP D=%d S=%d LEN=%d",
72 ntohs((ushort_t
)udp
->uh_ulen
));
75 sunrpc
= !reservedport(IPPROTO_UDP
, ntohs(udp
->uh_dport
)) &&
76 !reservedport(IPPROTO_UDP
, ntohs(udp
->uh_sport
)) &&
77 valid_rpc(data
, udplen
);
79 if (flags
& F_DTAIL
) {
80 show_header("UDP: ", "UDP Header", udplen
);
82 (void) sprintf(get_line((char *)(uintptr_t)udp
->uh_sport
-
83 dlc_header
, 1), "Source port = %d", ntohs(udp
->uh_sport
));
88 pname
= getportname(IPPROTO_UDP
, ntohs(udp
->uh_dport
));
92 (void) sprintf(buff
, "(%s)", pname
);
96 (void) sprintf(get_line((char *)(uintptr_t)udp
->uh_dport
-
97 dlc_header
, 1), "Destination port = %d %s",
98 ntohs(udp
->uh_dport
), pname
);
99 (void) sprintf(get_line((char *)(uintptr_t)udp
->uh_ulen
-
100 dlc_header
, 1), "Length = %d %s",
101 ntohs((ushort_t
)udp
->uh_ulen
),
103 "(Not all data contained in this fragment)"
105 (void) sprintf(get_line((char *)(uintptr_t)udp
->uh_sum
-
106 dlc_header
, 1), "Checksum = %04X %s",
108 udp
->uh_sum
== 0 ? "(no checksum)" : "");
113 /* go to the next protocol layer */
115 if (!interpret_reserved(flags
, IPPROTO_UDP
,
116 ntohs(udp
->uh_sport
),
117 ntohs(udp
->uh_dport
),
119 if (fraglen
> 0 && sunrpc
)
120 interpret_rpc(flags
, data
, fraglen
, IPPROTO_UDP
);