xref: /illumos-gate/usr/src/uts/common/inet/ip/rts_opt_data.c (revision e11c3f44f531fdff80941ce57c065d2ae861cefc)
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 
26 #include <sys/types.h>
27 #include <sys/stream.h>
28 #define	_SUN_TPI_VERSION 2
29 #include <sys/tihdr.h>
30 #include <sys/socket.h>
31 #include <sys/xti_xtiopt.h>
32 
33 #include <inet/common.h>
34 #include <netinet/ip6.h>
35 #include <inet/ip.h>
36 
37 #include <netinet/in.h>
38 #include <netinet/tcp.h>
39 #include <netinet/ip_mroute.h>
40 #include <inet/optcom.h>
41 #include <inet/rts_impl.h>
42 
43 /*
44  * Table of all known options handled on a RTS protocol stack.
45  *
46  * Note: This table contains options processed by both RTS and IP levels
47  *       and is the superset of options that can be performed on a RTS over IP
48  *       stack.
49  */
50 opdes_t	rts_opt_arr[] = {
51 
52 { SO_DEBUG,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
53 { SO_DONTROUTE,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
54 { SO_USELOOPBACK, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int),
55 	0 },
56 { SO_BROADCAST,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
57 { SO_REUSEADDR,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
58 { SO_TYPE,	SOL_SOCKET, OA_R, OA_R, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
59 { SO_SNDBUF,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
60 { SO_RCVBUF,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
61 { SO_PROTOTYPE,	SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
62 { SO_DOMAIN,	SOL_SOCKET, OA_R, OA_R, OP_NP, OP_PASSNEXT, sizeof (int), 0 },
63 { RT_AWARE,	SOL_ROUTE, OA_RW, OA_RW, OP_NP, 0, sizeof (int), 0 },
64 };
65 
66 /*
67  * Table of all supported levels
68  * Note: Some levels (e.g. XTI_GENERIC) may be valid but may not have
69  * any supported options so we need this info separately.
70  *
71  * This is needed only for topmost tpi providers and is used only by
72  * XTI interfaces.
73  */
74 optlevel_t	rts_valid_levels_arr[] = {
75 	XTI_GENERIC,
76 	SOL_SOCKET,
77 	IPPROTO_IP,
78 	IPPROTO_IPV6
79 };
80 
81 #define	RTS_VALID_LEVELS_CNT	A_CNT(rts_valid_levels_arr)
82 
83 #define	RTS_OPT_ARR_CNT		A_CNT(rts_opt_arr)
84 
85 uint_t rts_max_optsize; /* initialized in _init() */
86 
87 /*
88  * Intialize option database object for RTS
89  *
90  * This object represents 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 
95 optdb_obj_t rts_opt_obj = {
96 	rts_opt_default,	/* RTS default value function pointer */
97 	rts_tpi_opt_get,		/* RTS get function pointer */
98 	rts_tpi_opt_set,		/* RTS set function pointer */
99 	B_TRUE,			/* RTS is tpi provider */
100 	RTS_OPT_ARR_CNT,	/* RTS option database count of entries */
101 	rts_opt_arr,		/* RTS option database */
102 	RTS_VALID_LEVELS_CNT,	/* RTS valid level count of entries */
103 	rts_valid_levels_arr	/* RTS valid level array */
104 };
105