Home | History | Annotate | Download | only in ip
      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 1996-1998,2001-2003 Sun Microsystems, Inc.  All rights reserved.
     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 <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/keysock.h>
     44 
     45 /*
     46  * Table of all known options handled on a keysock (PF_KEY) protocol stack.
     47  *
     48  * Note: This table contains options processed by both KEYSOCK and IP levels
     49  *       and is the superset of options that can be performed on a KEYSOCK over
     50  *	 IP stack.
     51  */
     52 
     53 opdes_t keysock_opt_arr[] = {
     54 	{ SO_USELOOPBACK, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT,
     55 	    (t_uscalar_t)sizeof (int), 0 },
     56 	{ SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT,
     57 	    (t_uscalar_t)sizeof (int), 0 },
     58 	{ SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT,
     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  */
     69 optlevel_t	keysock_valid_levels_arr[] = {
     70 	SOL_SOCKET
     71 };
     72 
     73 #define	KEYSOCK_VALID_LEVELS_CNT	A_CNT(keysock_valid_levels_arr)
     74 
     75 #define	KEYSOCK_OPT_ARR_CNT		A_CNT(keysock_opt_arr)
     76 
     77 uint_t keysock_max_optsize; /* initialized in keysock_ddi_init() */
     78 
     79 /*
     80  * Intialize option database object for KEYSOCK
     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 
     87 optdb_obj_t keysock_opt_obj = {
     88 	NULL,			/* KEYSOCK default value function pointer */
     89 	keysock_opt_get,	/* KEYSOCK get function pointer */
     90 	keysock_opt_set,	/* KEYSOCK set function pointer */
     91 	B_TRUE,			/* KEYSOCK is tpi provider */
     92 	KEYSOCK_OPT_ARR_CNT,	/* KEYSOCK option database count of entries */
     93 	keysock_opt_arr,	/* KEYSOCK option database */
     94 	KEYSOCK_VALID_LEVELS_CNT, /* KEYSOCK valid level count of entries */
     95 	keysock_valid_levels_arr  /* KEYSOCK valid level array */
     96 };
     97