xref: /illumos-gate/usr/src/uts/common/inet/rts_impl.h (revision 51f34d4b950abb3636d536e2250bdc05baba902e)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /* Copyright (c) 1990 Mentat Inc. */
26 
27 #ifndef	_RTS_IMPL_H
28 #define	_RTS_IMPL_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 #ifdef _KERNEL
35 
36 #include <sys/types.h>
37 #include <sys/netstack.h>
38 
39 #include <netinet/in.h>
40 #include <netinet/icmp6.h>
41 #include <netinet/ip6.h>
42 
43 #include <inet/common.h>
44 #include <inet/ip.h>
45 #include <inet/optcom.h>
46 
47 /* Named Dispatch Parameter Management Structure */
48 typedef struct rtsparam_s {
49 	uint_t	rts_param_min;
50 	uint_t	rts_param_max;
51 	uint_t	rts_param_value;
52 	char	*rts_param_name;
53 } rtsparam_t;
54 
55 /*
56  * RTS stack instances
57  */
58 struct rts_stack {
59 	netstack_t		*rtss_netstack;	/* Common netstack */
60 
61 	caddr_t			rtss_g_nd;
62 	rtsparam_t		*rtss_params;
63 
64 	ldi_ident_t		rtss_ldi_ident;
65 };
66 typedef struct rts_stack rts_stack_t;
67 
68 /* Internal routing socket stream control structure, one per open stream */
69 typedef	struct rts_s {
70 	krwlock_t	rts_rwlock;	/* Protects most of rts_t */
71 	uint_t	rts_state;		/* Provider interface state */
72 	uint_t	rts_error;		/* Routing socket error code */
73 	uint_t	rts_flag;		/* Pending I/O state */
74 	uint_t	rts_proto;		/* SO_PROTOTYPE "socket" option. */
75 	uint_t	rts_debug : 1,		/* SO_DEBUG "socket" option. */
76 		rts_dontroute : 1,	/* SO_DONTROUTE "socket" option. */
77 		rts_broadcast : 1,	/* SO_BROADCAST "socket" option. */
78 		rts_reuseaddr : 1,	/* SO_REUSEADDR "socket" option. */
79 		rts_useloopback : 1,	/* SO_USELOOPBACK "socket" option. */
80 		rts_multicast_loop : 1,	/* IP_MULTICAST_LOOP option */
81 		rts_hdrincl : 1,	/* IP_HDRINCL option + RAW and IGMP */
82 
83 		: 0;
84 	rts_stack_t	*rts_rtss;
85 
86 	/* Written to only once at the time of opening the endpoint */
87 	conn_t		*rts_connp;
88 
89 	/* Outbound flow control */
90 	size_t		rts_xmit_hiwat;
91 	size_t		rts_xmit_lowat;
92 
93 	/* Inbound flow control */
94 	size_t		rts_recv_hiwat;
95 	size_t		rts_recv_lowat;
96 
97 	kmutex_t	rts_send_mutex;
98 	kmutex_t	rts_recv_mutex;
99 	kcondvar_t	rts_send_cv;
100 	kcondvar_t	rts_io_cv;
101 } rts_t;
102 
103 #define	RTS_WPUT_PENDING	0x1	/* Waiting for write-side to complete */
104 #define	RTS_REQ_PENDING		0x1	/* For direct sockets */
105 #define	RTS_WRW_PENDING		0x2	/* Routing socket write in progress */
106 #define	RTS_REQ_INPROG		0x2	/* For direct sockets */
107 
108 /*
109  * Object to represent database of options to search passed to
110  * {sock,tpi}optcom_req() interface routine to take care of option
111  * management and associated methods.
112  * XXX. These and other externs should really move to a rts header.
113  */
114 extern optdb_obj_t	rts_opt_obj;
115 extern uint_t		rts_max_optsize;
116 
117 extern void	rts_ddi_g_init(void);
118 extern void	rts_ddi_g_destroy(void);
119 
120 extern int	rts_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
121 extern int	rts_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
122 		    uint_t *, uchar_t *, void *, cred_t *, mblk_t *);
123 extern int	rts_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name,
124 		    uchar_t *ptr);
125 
126 extern sock_lower_handle_t rts_create(int, int, int, sock_downcalls_t **,
127     uint_t *, int *, int, cred_t *);
128 
129 extern sock_downcalls_t sock_rts_downcalls;
130 
131 #endif	/* _KERNEL */
132 
133 #ifdef	__cplusplus
134 }
135 #endif
136 
137 #endif	/* _RTS_IMPL_H */
138