xref: /illumos-gate/usr/src/uts/common/inet/ip/spdsock_opt_data.c (revision 4de2612967d06c4fdbf524a62556a1e8118a006f)
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 (c) 2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <sys/types.h>
30 #include <sys/stream.h>
31 #define	_SUN_TPI_VERSION 1
32 #include <sys/tihdr.h>
33 #include <sys/socket.h>
34 #include <sys/xti_xtiopt.h>
35 
36 #include <inet/common.h>
37 #include <netinet/ip6.h>
38 #include <inet/ip.h>
39 
40 #include <netinet/in.h>
41 #include <netinet/tcp.h>
42 #include <inet/optcom.h>
43 #include <inet/ipsec_impl.h>
44 #include <inet/spdsock.h>
45 
46 /*
47  * Table of all known options handled on a spdsock (PF_KEY) protocol stack.
48  *
49  * Note: This table contains options processed by both SPDSOCK and IP levels
50  *       and is the superset of options that can be performed on a SPDSOCK over
51  *	 IP stack.
52  */
53 
54 opdes_t spdsock_opt_arr[] = {
55 	{ SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_PASSNEXT,
56 	    (t_uscalar_t)sizeof (int), 0 },
57 	{ SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_PASSNEXT,
58 	    (t_uscalar_t)sizeof (int), 0 },
59 };
60 
61 /*
62  * Table of all supported levels
63  * Note: Some levels (e.g. XTI_GENERIC) may be valid but may not have
64  * any supported options so we need this info separately.
65  *
66  * This is needed only for topmost tpi providers.
67  */
68 optlevel_t	spdsock_valid_levels_arr[] = {
69 	SOL_SOCKET
70 };
71 
72 #define	SPDSOCK_VALID_LEVELS_CNT	A_CNT(spdsock_valid_levels_arr)
73 
74 #define	SPDSOCK_OPT_ARR_CNT		A_CNT(spdsock_opt_arr)
75 
76 uint_t spdsock_max_optsize; /* initialized in spdsock_ddi_init() */
77 
78 /*
79  * Intialize option database object for SPDSOCK
80  *
81  * This object represents database of options to search passed to
82  * {sock,tpi}optcom_req() interface routine to take care of option
83  * management and associated methods.
84  */
85 
86 optdb_obj_t spdsock_opt_obj = {
87 	NULL,			/* SPDSOCK default value function pointer */
88 	spdsock_opt_get,	/* SPDSOCK get function pointer */
89 	spdsock_opt_set,	/* SPDSOCK set function pointer */
90 	B_TRUE,			/* SPDSOCK is tpi provider */
91 	SPDSOCK_OPT_ARR_CNT,	/* SPDSOCK option database count of entries */
92 	spdsock_opt_arr,	/* SPDSOCK option database */
93 	SPDSOCK_VALID_LEVELS_CNT, /* SPDSOCK valid level count of entries */
94 	spdsock_valid_levels_arr  /* SPDSOCK valid level array */
95 };
96