17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5f4b3ec61Sdh  * Common Development and Distribution License (the "License").
6f4b3ec61Sdh  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21f4b3ec61Sdh 
227c478bd9Sstevel@tonic-gate /*
23*bd670b35SErik Nordmark  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24f4b3ec61Sdh  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/stream.h>
297c478bd9Sstevel@tonic-gate #define	_SUN_TPI_VERSION 1
307c478bd9Sstevel@tonic-gate #include <sys/tihdr.h>
317c478bd9Sstevel@tonic-gate #include <sys/socket.h>
327c478bd9Sstevel@tonic-gate #include <sys/xti_xtiopt.h>
337c478bd9Sstevel@tonic-gate 
34f4b3ec61Sdh #include <net/pfpolicy.h>
357c478bd9Sstevel@tonic-gate #include <inet/common.h>
367c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
377c478bd9Sstevel@tonic-gate #include <inet/ip.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #include <netinet/in.h>
407c478bd9Sstevel@tonic-gate #include <netinet/tcp.h>
417c478bd9Sstevel@tonic-gate #include <inet/optcom.h>
427c478bd9Sstevel@tonic-gate #include <inet/ipsec_impl.h>
437c478bd9Sstevel@tonic-gate #include <inet/spdsock.h>
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Table of all known options handled on a spdsock (PF_KEY) protocol stack.
477c478bd9Sstevel@tonic-gate  *
487c478bd9Sstevel@tonic-gate  * Note: This table contains options processed by both SPDSOCK and IP levels
497c478bd9Sstevel@tonic-gate  *       and is the superset of options that can be performed on a SPDSOCK over
507c478bd9Sstevel@tonic-gate  *	 IP stack.
517c478bd9Sstevel@tonic-gate  */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate opdes_t spdsock_opt_arr[] = {
54*bd670b35SErik Nordmark 	{ SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, 0,
557c478bd9Sstevel@tonic-gate 	    (t_uscalar_t)sizeof (int), 0 },
56*bd670b35SErik Nordmark 	{ SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, 0,
577c478bd9Sstevel@tonic-gate 	    (t_uscalar_t)sizeof (int), 0 },
587c478bd9Sstevel@tonic-gate };
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate /*
617c478bd9Sstevel@tonic-gate  * Table of all supported levels
627c478bd9Sstevel@tonic-gate  * Note: Some levels (e.g. XTI_GENERIC) may be valid but may not have
637c478bd9Sstevel@tonic-gate  * any supported options so we need this info separately.
647c478bd9Sstevel@tonic-gate  *
657c478bd9Sstevel@tonic-gate  * This is needed only for topmost tpi providers.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate optlevel_t	spdsock_valid_levels_arr[] = {
687c478bd9Sstevel@tonic-gate 	SOL_SOCKET
697c478bd9Sstevel@tonic-gate };
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate #define	SPDSOCK_VALID_LEVELS_CNT	A_CNT(spdsock_valid_levels_arr)
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate #define	SPDSOCK_OPT_ARR_CNT		A_CNT(spdsock_opt_arr)
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate uint_t spdsock_max_optsize; /* initialized in spdsock_ddi_init() */
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate /*
787c478bd9Sstevel@tonic-gate  * Intialize option database object for SPDSOCK
797c478bd9Sstevel@tonic-gate  *
807c478bd9Sstevel@tonic-gate  * This object represents database of options to search passed to
817c478bd9Sstevel@tonic-gate  * {sock,tpi}optcom_req() interface routine to take care of option
827c478bd9Sstevel@tonic-gate  * management and associated methods.
837c478bd9Sstevel@tonic-gate  */
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate optdb_obj_t spdsock_opt_obj = {
867c478bd9Sstevel@tonic-gate 	NULL,			/* SPDSOCK default value function pointer */
877c478bd9Sstevel@tonic-gate 	spdsock_opt_get,	/* SPDSOCK get function pointer */
887c478bd9Sstevel@tonic-gate 	spdsock_opt_set,	/* SPDSOCK set function pointer */
897c478bd9Sstevel@tonic-gate 	SPDSOCK_OPT_ARR_CNT,	/* SPDSOCK option database count of entries */
907c478bd9Sstevel@tonic-gate 	spdsock_opt_arr,	/* SPDSOCK option database */
917c478bd9Sstevel@tonic-gate 	SPDSOCK_VALID_LEVELS_CNT, /* SPDSOCK valid level count of entries */
927c478bd9Sstevel@tonic-gate 	spdsock_valid_levels_arr  /* SPDSOCK valid level array */
937c478bd9Sstevel@tonic-gate };
94