xref: /illumos-gate/usr/src/uts/common/inet/rts_impl.h (revision bd670b35a010421b6e1a5536c34453a827007c81)
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 2009 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
75 		rts_hdrincl : 1,	/* IP_HDRINCL option + RAW and IGMP */
76 
77 		: 0;
78 	rts_stack_t	*rts_rtss;
79 
80 	/* Written to only once at the time of opening the endpoint */
81 	conn_t		*rts_connp;
82 
83 	kmutex_t	rts_recv_mutex;	/* For recv flow control */
84 } rts_t;
85 
86 #define	RTS_WPUT_PENDING	0x1	/* Waiting for write-side to complete */
87 #define	RTS_WRW_PENDING		0x2	/* Routing socket write in progress */
88 
89 /*
90  * Object to represent database of options to search passed to
91  * {sock,tpi}optcom_req() interface routine to take care of option
92  * management and associated methods.
93  */
94 extern optdb_obj_t	rts_opt_obj;
95 extern uint_t		rts_max_optsize;
96 
97 extern void	rts_ddi_g_init(void);
98 extern void	rts_ddi_g_destroy(void);
99 
100 extern int	rts_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
101 extern int	rts_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
102 		    uint_t *, uchar_t *, void *, cred_t *);
103 extern int	rts_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name,
104 		    uchar_t *ptr);
105 
106 extern sock_lower_handle_t rts_create(int, int, int, sock_downcalls_t **,
107     uint_t *, int *, int, cred_t *);
108 
109 extern sock_downcalls_t sock_rts_downcalls;
110 
111 #endif	/* _KERNEL */
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _RTS_IMPL_H */
118