xref: /titanic_51/usr/src/uts/common/inet/udp_impl.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_UDP_IMPL_H
28 #define	_UDP_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #ifdef _KERNEL
37 
38 #include <sys/int_types.h>
39 
40 #include <netinet/in.h>
41 #include <netinet/ip6.h>
42 
43 #include <inet/common.h>
44 #include <inet/ip.h>
45 
46 /* Internal udp control structure, one per open stream */
47 typedef	struct udp_s {
48 	uint32_t 	udp_state;	/* TPI state */
49 	in_port_t 	udp_port;	/* Port bound to this stream */
50 	in_port_t 	udp_dstport;	/* Connected port */
51 	in6_addr_t 	udp_v6src;	/* Source address of this stream */
52 	in6_addr_t 	udp_bound_v6src; /* Explicitly bound address */
53 	in6_addr_t 	udp_v6dst;	/* Connected destination */
54 	uint32_t	udp_flowinfo;	/* Connected flow id and tclass */
55 	uint32_t 	udp_max_hdr_len; /* For write offset in stream head */
56 	sa_family_t	udp_family;	/* Family from socket() call */
57 	/*
58 	 * IP format that packets transmitted from this struct should use.
59 	 * Value can be IP4_VERSION or IPV6_VERSION.
60 	 */
61 	ushort_t	udp_ipversion;
62 	uint32_t 	udp_ip_snd_options_len; /* Len of IPv4 options */
63 	uchar_t		*udp_ip_snd_options;    /* Ptr to IPv4 options */
64 	uint32_t 	udp_ip_rcv_options_len; /* Len of IPv4 options recvd */
65 	uchar_t		*udp_ip_rcv_options;    /* Ptr to IPv4 options recvd */
66 	cred_t		*udp_credp;		/* Credentials at open */
67 	uchar_t		udp_multicast_ttl;	/* IP*_MULTICAST_TTL/HOPS */
68 	ipaddr_t 	udp_multicast_if_addr;  /* IP_MULTICAST_IF option */
69 	uint_t		udp_multicast_if_index;	/* IPV6_MULTICAST_IF option */
70 	int		udp_bound_if;		/* IP*_BOUND_IF option */
71 	int		udp_xmit_if;		/* IP_XMIT_IF option */
72 	uint32_t
73 		udp_debug : 1,		/* SO_DEBUG "socket" option. */
74 		udp_dontroute : 1,	/* SO_DONTROUTE "socket" option. */
75 		udp_broadcast : 1,	/* SO_BROADCAST "socket" option. */
76 		udp_useloopback : 1,	/* SO_USELOOPBACK "socket" option */
77 
78 		udp_reuseaddr : 1,	/* SO_REUSEADDR "socket" option. */
79 		udp_multicast_loop : 1,	/* IP_MULTICAST_LOOP option */
80 		udp_dgram_errind : 1,	/* SO_DGRAM_ERRIND option */
81 		udp_recvdstaddr : 1,	/* IP_RECVDSTADDR option */
82 
83 		udp_recvopts : 1,	/* IP_RECVOPTS option */
84 		udp_discon_pending : 1,	/* T_DISCON_REQ in progress */
85 		udp_unspec_source : 1,	/* IP*_UNSPEC_SRC option */
86 		udp_ipv6_recvpktinfo : 1,	/* IPV6_RECVPKTINFO option  */
87 
88 		udp_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
89 		udp_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
90 		udp_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
91 		udp_ipv6_recvrthdr : 1,		/* IPV6_RECVRTHDR option */
92 
93 		udp_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS */
94 		udp_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU */
95 		udp_anon_priv_bind : 1,
96 		udp_exclbind : 1,	/* ``exclusive'' binding */
97 
98 		udp_recvif : 1,		/* IP_RECVIF option */
99 		udp_recvslla : 1,	/* IP_RECVSLLA option */
100 		udp_recvttl : 1,	/* IP_RECVTTL option */
101 		udp_recvucred : 1,	/* IP_RECVUCRED option */
102 
103 		udp_old_ipv6_recvdstopts : 1,	/* old form of IPV6_DSTOPTS */
104 		udp_ipv6_recvrthdrdstopts : 1,	/* IPV6_RECVRTHDRDSTOPTS */
105 
106 		udp_rcvhdr : 1,		/* UDP_RCVHDR option */
107 		udp_pad_to_bit_31 : 7;
108 
109 	uint8_t		udp_type_of_service;	/* IP_TOS option */
110 	uint8_t		udp_ttl;		/* TTL or hoplimit */
111 
112 	ip6_pkt_t	udp_sticky_ipp;		/* Sticky options */
113 	uint8_t		*udp_sticky_hdrs;	/* Prebuilt IPv6 hdrs */
114 	uint_t		udp_sticky_hdrs_len;	/* Incl. ip6h and any ip6i */
115 	struct udp_s	*udp_bind_hash; /* Bind hash chain */
116 	struct udp_s	**udp_ptpbhn; /* Pointer to previous bind hash next. */
117 	zoneid_t	udp_zoneid;	/* ID of owning zone */
118 } udp_t;
119 
120 /* UDP Protocol header */
121 /* UDP Protocol header aligned */
122 typedef	struct udpahdr_s {
123 	in_port_t	uha_src_port;		/* Source port */
124 	in_port_t	uha_dst_port;		/* Destination port */
125 	uint16_t	uha_length;		/* UDP length */
126 	uint16_t	uha_checksum;		/* UDP checksum */
127 } udpha_t;
128 #define	UDPH_SIZE	8
129 
130 #endif	/*  _KERNEL */
131 
132 #ifdef	__cplusplus
133 }
134 #endif
135 
136 #endif	/* _UDP_IMPL_H */
137