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 1998-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 2 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 <netinet/ip_mroute.h> 43 #include <inet/optcom.h> 44 45 extern int rts_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name, 46 uchar_t *ptr); 47 extern int rts_opt_get(queue_t *q, t_scalar_t level, t_scalar_t name, 48 uchar_t *ptr); 49 extern int rts_opt_set(queue_t *q, uint_t optset_context, int level, 50 int name, uint_t inlen, uchar_t *invalp, uint_t *outlenp, 51 uchar_t *outvalp, void *thisdg_attrs, cred_t *cr, mblk_t *mblk); 52 53 /* 54 * Table of all known options handled on a RTS protocol stack. 55 * 56 * Note: This table contains options processed by both RTS and IP levels 57 * and is the superset of options that can be performed on a RTS over IP 58 * stack. 59 */ 60 opdes_t rts_opt_arr[] = { 61 62 { SO_DEBUG, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 63 { SO_DONTROUTE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 64 { SO_USELOOPBACK, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 65 0 }, 66 { SO_BROADCAST, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 67 { SO_REUSEADDR, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 68 { SO_TYPE, SOL_SOCKET, OA_R, OA_R, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 69 { SO_SNDBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 70 { SO_RCVBUF, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 71 { SO_PROTOTYPE, SOL_SOCKET, OA_RW, OA_RW, OP_NP, OP_PASSNEXT, sizeof (int), 0 }, 72 }; 73 74 /* 75 * Table of all supported levels 76 * Note: Some levels (e.g. XTI_GENERIC) may be valid but may not have 77 * any supported options so we need this info separately. 78 * 79 * This is needed only for topmost tpi providers and is used only by 80 * XTI interfaces. 81 */ 82 optlevel_t rts_valid_levels_arr[] = { 83 XTI_GENERIC, 84 SOL_SOCKET, 85 IPPROTO_IP, 86 IPPROTO_IPV6 87 }; 88 89 #define RTS_VALID_LEVELS_CNT A_CNT(rts_valid_levels_arr) 90 91 #define RTS_OPT_ARR_CNT A_CNT(rts_opt_arr) 92 93 uint_t rts_max_optsize; /* initialized in _init() */ 94 95 /* 96 * Intialize option database object for RTS 97 * 98 * This object represents database of options to search passed to 99 * {sock,tpi}optcom_req() interface routine to take care of option 100 * management and associated methods. 101 */ 102 103 optdb_obj_t rts_opt_obj = { 104 rts_opt_default, /* RTS default value function pointer */ 105 rts_opt_get, /* RTS get function pointer */ 106 rts_opt_set, /* RTS set function pointer */ 107 B_TRUE, /* RTS is tpi provider */ 108 RTS_OPT_ARR_CNT, /* RTS option database count of entries */ 109 rts_opt_arr, /* RTS option database */ 110 RTS_VALID_LEVELS_CNT, /* RTS valid level count of entries */ 111 rts_valid_levels_arr /* RTS valid level array */ 112 }; 113