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