1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate #include <sys/types.h> 30*0Sstevel@tonic-gate #include <sys/stream.h> 31*0Sstevel@tonic-gate #include <sys/strsubr.h> 32*0Sstevel@tonic-gate #include <sys/stropts.h> 33*0Sstevel@tonic-gate #include <sys/strsun.h> 34*0Sstevel@tonic-gate #include <sys/strlog.h> 35*0Sstevel@tonic-gate #define _SUN_TPI_VERSION 2 36*0Sstevel@tonic-gate #include <sys/tihdr.h> 37*0Sstevel@tonic-gate #include <sys/timod.h> 38*0Sstevel@tonic-gate #include <sys/ddi.h> 39*0Sstevel@tonic-gate #include <sys/sunddi.h> 40*0Sstevel@tonic-gate #include <sys/cmn_err.h> 41*0Sstevel@tonic-gate #include <sys/proc.h> 42*0Sstevel@tonic-gate #include <sys/suntpi.h> 43*0Sstevel@tonic-gate #include <sys/policy.h> 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #include <sys/socket.h> 46*0Sstevel@tonic-gate #include <netinet/in.h> 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate #include <inet/common.h> 49*0Sstevel@tonic-gate #include <netinet/ip6.h> 50*0Sstevel@tonic-gate #include <inet/ip.h> 51*0Sstevel@tonic-gate #include <inet/mi.h> 52*0Sstevel@tonic-gate #include <inet/nd.h> 53*0Sstevel@tonic-gate #include <inet/optcom.h> 54*0Sstevel@tonic-gate #include <netinet/ip_mroute.h> 55*0Sstevel@tonic-gate #include <sys/isa_defs.h> 56*0Sstevel@tonic-gate #include <net/route.h> 57*0Sstevel@tonic-gate 58*0Sstevel@tonic-gate /* 59*0Sstevel@tonic-gate * This is a transport provider for routing sockets. Downstream messages are 60*0Sstevel@tonic-gate * wrapped with a IP_IOCTL header, and ip_wput_ioctl calls the appropriate entry 61*0Sstevel@tonic-gate * in the ip_ioctl_ftbl callout table to pass the routing socket data into IP. 62*0Sstevel@tonic-gate * Upstream messages are generated for listeners of the routing socket as well 63*0Sstevel@tonic-gate * as the message sender (unless they have turned off their end using 64*0Sstevel@tonic-gate * SO_USELOOPBACK or shutdown(3n)). Upstream messages may also be generated 65*0Sstevel@tonic-gate * asynchronously when: 66*0Sstevel@tonic-gate * 67*0Sstevel@tonic-gate * Interfaces are brought up or down. 68*0Sstevel@tonic-gate * Addresses are assigned to interfaces. 69*0Sstevel@tonic-gate * ICMP redirects are processed and a IRE_HOST_REDIRECT is installed. 70*0Sstevel@tonic-gate * No route is found while sending a packet. 71*0Sstevel@tonic-gate * When TCP requests IP to remove an IRE_CACHE of a troubled destination. 72*0Sstevel@tonic-gate * 73*0Sstevel@tonic-gate * Since all we do is reformat the messages between routing socket and 74*0Sstevel@tonic-gate * ioctl forms, no synchronization is necessary in this module; all 75*0Sstevel@tonic-gate * the dirty work is done down in ip. 76*0Sstevel@tonic-gate */ 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate /* 79*0Sstevel@tonic-gate * Object to represent database of options to search passed to 80*0Sstevel@tonic-gate * {sock,tpi}optcom_req() interface routine to take care of option 81*0Sstevel@tonic-gate * management and associated methods. 82*0Sstevel@tonic-gate * XXX. These and other externs should really move to a rts header. 83*0Sstevel@tonic-gate */ 84*0Sstevel@tonic-gate extern optdb_obj_t rts_opt_obj; 85*0Sstevel@tonic-gate extern uint_t rts_max_optsize; 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate /* Internal routing socket stream control structure, one per open stream */ 88*0Sstevel@tonic-gate typedef struct rts_s { 89*0Sstevel@tonic-gate cred_t *rts_credp; /* Opener's credentials */ 90*0Sstevel@tonic-gate uint_t rts_state; /* Provider interface state */ 91*0Sstevel@tonic-gate uint_t rts_error; /* Routing socket error code */ 92*0Sstevel@tonic-gate uint_t rts_flag; /* Pending I/O state */ 93*0Sstevel@tonic-gate uint_t rts_proto; /* SO_PROTOTYPE "socket" option. */ 94*0Sstevel@tonic-gate uint_t rts_debug : 1, /* SO_DEBUG "socket" option. */ 95*0Sstevel@tonic-gate rts_dontroute : 1, /* SO_DONTROUTE "socket" option. */ 96*0Sstevel@tonic-gate rts_broadcast : 1, /* SO_BROADCAST "socket" option. */ 97*0Sstevel@tonic-gate rts_reuseaddr : 1, /* SO_REUSEADDR "socket" option. */ 98*0Sstevel@tonic-gate rts_useloopback : 1, /* SO_USELOOPBACK "socket" option. */ 99*0Sstevel@tonic-gate rts_multicast_loop : 1, /* IP_MULTICAST_LOOP option */ 100*0Sstevel@tonic-gate rts_hdrincl : 1, /* IP_HDRINCL option + RAW and IGMP */ 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate : 0; 103*0Sstevel@tonic-gate } rts_t; 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate #define RTS_WPUT_PENDING 0x1 /* Waiting for write-side to complete */ 106*0Sstevel@tonic-gate #define RTS_WRW_PENDING 0x2 /* Routing socket write in progress */ 107*0Sstevel@tonic-gate #define RTS_OPEN_PENDING 0x4 /* Routing socket open in progress */ 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate /* Default structure copied into T_INFO_ACK messages */ 110*0Sstevel@tonic-gate static struct T_info_ack rts_g_t_info_ack = { 111*0Sstevel@tonic-gate T_INFO_ACK, 112*0Sstevel@tonic-gate T_INFINITE, /* TSDU_size. Maximum size messages. */ 113*0Sstevel@tonic-gate T_INVALID, /* ETSDU_size. No expedited data. */ 114*0Sstevel@tonic-gate T_INVALID, /* CDATA_size. No connect data. */ 115*0Sstevel@tonic-gate T_INVALID, /* DDATA_size. No disconnect data. */ 116*0Sstevel@tonic-gate 0, /* ADDR_size. */ 117*0Sstevel@tonic-gate 0, /* OPT_size - not initialized here */ 118*0Sstevel@tonic-gate 64 * 1024, /* TIDU_size. rts allows maximum size messages. */ 119*0Sstevel@tonic-gate T_COTS, /* SERV_type. rts supports connection oriented. */ 120*0Sstevel@tonic-gate TS_UNBND, /* CURRENT_state. This is set from rts_state. */ 121*0Sstevel@tonic-gate (XPG4_1) /* PROVIDER_flag */ 122*0Sstevel@tonic-gate }; 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 125*0Sstevel@tonic-gate typedef struct rtspparam_s { 126*0Sstevel@tonic-gate uint_t rts_param_min; 127*0Sstevel@tonic-gate uint_t rts_param_max; 128*0Sstevel@tonic-gate uint_t rts_param_value; 129*0Sstevel@tonic-gate char *rts_param_name; 130*0Sstevel@tonic-gate } rtsparam_t; 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate /* 133*0Sstevel@tonic-gate * Table of ND variables supported by rts. These are loaded into rts_g_nd 134*0Sstevel@tonic-gate * in rts_open. 135*0Sstevel@tonic-gate * All of these are alterable, within the min/max values given, at run time. 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate static rtsparam_t rts_param_arr[] = { 138*0Sstevel@tonic-gate /* min max value name */ 139*0Sstevel@tonic-gate { 4096, 65536, 8192, "rts_xmit_hiwat"}, 140*0Sstevel@tonic-gate { 0, 65536, 1024, "rts_xmit_lowat"}, 141*0Sstevel@tonic-gate { 4096, 65536, 8192, "rts_recv_hiwat"}, 142*0Sstevel@tonic-gate { 65536, 1024*1024*1024, 256*1024, "rts_max_buf"}, 143*0Sstevel@tonic-gate }; 144*0Sstevel@tonic-gate #define rts_xmit_hiwat rts_param_arr[0].rts_param_value 145*0Sstevel@tonic-gate #define rts_xmit_lowat rts_param_arr[1].rts_param_value 146*0Sstevel@tonic-gate #define rts_recv_hiwat rts_param_arr[2].rts_param_value 147*0Sstevel@tonic-gate #define rts_max_buf rts_param_arr[3].rts_param_value 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate static int rts_close(queue_t *q); 150*0Sstevel@tonic-gate static void rts_err_ack(queue_t *q, mblk_t *mp, t_scalar_t t_error, 151*0Sstevel@tonic-gate int sys_error); 152*0Sstevel@tonic-gate static mblk_t *rts_ioctl_alloc(mblk_t *data, cred_t *cr); 153*0Sstevel@tonic-gate static int rts_open(queue_t *q, dev_t *devp, int flag, int sflag, 154*0Sstevel@tonic-gate cred_t *credp); 155*0Sstevel@tonic-gate int rts_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name, 156*0Sstevel@tonic-gate uchar_t *ptr); 157*0Sstevel@tonic-gate int rts_opt_get(queue_t *q, t_scalar_t level, t_scalar_t name, 158*0Sstevel@tonic-gate uchar_t *ptr); 159*0Sstevel@tonic-gate int rts_opt_set(queue_t *q, uint_t optset_context, int level, 160*0Sstevel@tonic-gate int name, uint_t inlen, uchar_t *invalp, uint_t *outlenp, 161*0Sstevel@tonic-gate uchar_t *outvalp, void *thisdg_attrs, cred_t *cr, mblk_t *mblk); 162*0Sstevel@tonic-gate static void rts_param_cleanup(void); 163*0Sstevel@tonic-gate static int rts_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr); 164*0Sstevel@tonic-gate static boolean_t rts_param_register(rtsparam_t *rtspa, int cnt); 165*0Sstevel@tonic-gate static int rts_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, 166*0Sstevel@tonic-gate cred_t *cr); 167*0Sstevel@tonic-gate static void rts_rput(queue_t *q, mblk_t *mp); 168*0Sstevel@tonic-gate static void rts_wput(queue_t *q, mblk_t *mp); 169*0Sstevel@tonic-gate static void rts_wput_iocdata(queue_t *q, mblk_t *mp); 170*0Sstevel@tonic-gate static void rts_wput_other(queue_t *q, mblk_t *mp); 171*0Sstevel@tonic-gate static int rts_wrw(queue_t *q, struiod_t *dp); 172*0Sstevel@tonic-gate 173*0Sstevel@tonic-gate static struct module_info info = { 174*0Sstevel@tonic-gate 129, "rts", 1, INFPSZ, 512, 128 175*0Sstevel@tonic-gate }; 176*0Sstevel@tonic-gate 177*0Sstevel@tonic-gate static struct qinit rinit = { 178*0Sstevel@tonic-gate (pfi_t)rts_rput, NULL, rts_open, rts_close, NULL, &info 179*0Sstevel@tonic-gate }; 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate static struct qinit winit = { 182*0Sstevel@tonic-gate (pfi_t)rts_wput, NULL, NULL, NULL, NULL, &info, 183*0Sstevel@tonic-gate NULL, (pfi_t)rts_wrw, NULL, STRUIOT_STANDARD 184*0Sstevel@tonic-gate }; 185*0Sstevel@tonic-gate 186*0Sstevel@tonic-gate struct streamtab rtsinfo = { 187*0Sstevel@tonic-gate &rinit, &winit 188*0Sstevel@tonic-gate }; 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate static IDP rts_g_nd; /* Points to table of RTS ND variables. */ 191*0Sstevel@tonic-gate uint_t rts_open_streams = 0; 192*0Sstevel@tonic-gate 193*0Sstevel@tonic-gate /* 194*0Sstevel@tonic-gate * This routine allocates the necessary 195*0Sstevel@tonic-gate * message blocks for IOCTL wrapping the 196*0Sstevel@tonic-gate * user data. 197*0Sstevel@tonic-gate */ 198*0Sstevel@tonic-gate static mblk_t * 199*0Sstevel@tonic-gate rts_ioctl_alloc(mblk_t *data, cred_t *cr) 200*0Sstevel@tonic-gate { 201*0Sstevel@tonic-gate mblk_t *mp = NULL; 202*0Sstevel@tonic-gate mblk_t *mp1 = NULL; 203*0Sstevel@tonic-gate ipllc_t *ipllc; 204*0Sstevel@tonic-gate struct iocblk *ioc; 205*0Sstevel@tonic-gate 206*0Sstevel@tonic-gate mp = allocb_cred(sizeof (ipllc_t), cr); 207*0Sstevel@tonic-gate if (mp == NULL) 208*0Sstevel@tonic-gate return (NULL); 209*0Sstevel@tonic-gate mp1 = allocb_cred(sizeof (struct iocblk), cr); 210*0Sstevel@tonic-gate if (mp1 == NULL) { 211*0Sstevel@tonic-gate freeb(mp); 212*0Sstevel@tonic-gate return (NULL); 213*0Sstevel@tonic-gate } 214*0Sstevel@tonic-gate 215*0Sstevel@tonic-gate ipllc = (ipllc_t *)mp->b_rptr; 216*0Sstevel@tonic-gate ipllc->ipllc_cmd = IP_IOC_RTS_REQUEST; 217*0Sstevel@tonic-gate ipllc->ipllc_name_offset = 0; 218*0Sstevel@tonic-gate ipllc->ipllc_name_length = 0; 219*0Sstevel@tonic-gate mp->b_wptr += sizeof (ipllc_t); 220*0Sstevel@tonic-gate mp->b_cont = data; 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate ioc = (struct iocblk *)mp1->b_rptr; 223*0Sstevel@tonic-gate ioc->ioc_cmd = IP_IOCTL; 224*0Sstevel@tonic-gate ioc->ioc_error = 0; 225*0Sstevel@tonic-gate ioc->ioc_cr = NULL; 226*0Sstevel@tonic-gate ioc->ioc_count = msgdsize(mp); 227*0Sstevel@tonic-gate mp1->b_wptr += sizeof (struct iocblk); 228*0Sstevel@tonic-gate mp1->b_datap->db_type = M_IOCTL; 229*0Sstevel@tonic-gate mp1->b_cont = mp; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate return (mp1); 232*0Sstevel@tonic-gate } 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate /* 235*0Sstevel@tonic-gate * This routine closes rts stream, by disabling 236*0Sstevel@tonic-gate * put/srv routines and freeing the this module 237*0Sstevel@tonic-gate * internal datastructure. 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate static int 240*0Sstevel@tonic-gate rts_close(queue_t *q) 241*0Sstevel@tonic-gate { 242*0Sstevel@tonic-gate qprocsoff(q); 243*0Sstevel@tonic-gate 244*0Sstevel@tonic-gate crfree(((rts_t *)q->q_ptr)->rts_credp); 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate mi_free(q->q_ptr); 247*0Sstevel@tonic-gate rts_open_streams--; 248*0Sstevel@tonic-gate /* 249*0Sstevel@tonic-gate * Free the ND table if this was 250*0Sstevel@tonic-gate * the last stream close 251*0Sstevel@tonic-gate */ 252*0Sstevel@tonic-gate rts_param_cleanup(); 253*0Sstevel@tonic-gate return (0); 254*0Sstevel@tonic-gate } 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate /* 257*0Sstevel@tonic-gate * This is the open routine for routing socket. It allocates 258*0Sstevel@tonic-gate * rts_t structure for the stream and sends an IOCTL to 259*0Sstevel@tonic-gate * the down module to indicate that it is a routing socket 260*0Sstevel@tonic-gate * stream. 261*0Sstevel@tonic-gate */ 262*0Sstevel@tonic-gate /* ARGSUSED */ 263*0Sstevel@tonic-gate static int 264*0Sstevel@tonic-gate rts_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) 265*0Sstevel@tonic-gate { 266*0Sstevel@tonic-gate mblk_t *mp = NULL; 267*0Sstevel@tonic-gate rts_t *rts; 268*0Sstevel@tonic-gate 269*0Sstevel@tonic-gate /* If the stream is already open, return immediately. */ 270*0Sstevel@tonic-gate if (q->q_ptr != NULL) 271*0Sstevel@tonic-gate return (0); 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate /* If this is not a push of rts as a module, fail. */ 274*0Sstevel@tonic-gate if (sflag != MODOPEN) 275*0Sstevel@tonic-gate return (EINVAL); 276*0Sstevel@tonic-gate 277*0Sstevel@tonic-gate /* If this is the first open of rts, create the ND table. */ 278*0Sstevel@tonic-gate if (rts_g_nd == NULL) { 279*0Sstevel@tonic-gate if (!rts_param_register(rts_param_arr, A_CNT(rts_param_arr))) 280*0Sstevel@tonic-gate return (ENOMEM); 281*0Sstevel@tonic-gate } 282*0Sstevel@tonic-gate q->q_ptr = mi_zalloc_sleep(sizeof (rts_t)); 283*0Sstevel@tonic-gate WR(q)->q_ptr = q->q_ptr; 284*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate rts->rts_credp = credp; 287*0Sstevel@tonic-gate crhold(credp); 288*0Sstevel@tonic-gate /* 289*0Sstevel@tonic-gate * The receive hiwat is only looked at on the stream head queue. 290*0Sstevel@tonic-gate * Store in q_hiwat in order to return on SO_RCVBUF getsockopts. 291*0Sstevel@tonic-gate */ 292*0Sstevel@tonic-gate q->q_hiwat = rts_recv_hiwat; 293*0Sstevel@tonic-gate /* 294*0Sstevel@tonic-gate * The transmit hiwat/lowat is only looked at on IP's queue. 295*0Sstevel@tonic-gate * Store in q_hiwat/q_lowat in order to return on SO_SNDBUF/SO_SNDLOWAT 296*0Sstevel@tonic-gate * getsockopts. 297*0Sstevel@tonic-gate */ 298*0Sstevel@tonic-gate WR(q)->q_hiwat = rts_xmit_hiwat; 299*0Sstevel@tonic-gate WR(q)->q_lowat = rts_xmit_lowat; 300*0Sstevel@tonic-gate qprocson(q); 301*0Sstevel@tonic-gate /* 302*0Sstevel@tonic-gate * Indicate the down IP module that this is a routing socket 303*0Sstevel@tonic-gate * client by sending an RTS IOCTL without any user data. Although 304*0Sstevel@tonic-gate * this is just a notification message (without any real routing 305*0Sstevel@tonic-gate * request), we pass in any credential for correctness sake. 306*0Sstevel@tonic-gate */ 307*0Sstevel@tonic-gate mp = rts_ioctl_alloc(NULL, credp); 308*0Sstevel@tonic-gate if (mp == NULL) { 309*0Sstevel@tonic-gate rts_param_cleanup(); 310*0Sstevel@tonic-gate qprocsoff(q); 311*0Sstevel@tonic-gate ASSERT(q->q_ptr != NULL); 312*0Sstevel@tonic-gate mi_free(q->q_ptr); 313*0Sstevel@tonic-gate crfree(credp); 314*0Sstevel@tonic-gate return (ENOMEM); 315*0Sstevel@tonic-gate } 316*0Sstevel@tonic-gate rts_open_streams++; 317*0Sstevel@tonic-gate rts->rts_flag |= RTS_OPEN_PENDING; 318*0Sstevel@tonic-gate putnext(WR(q), mp); 319*0Sstevel@tonic-gate while (rts->rts_flag & RTS_OPEN_PENDING) { 320*0Sstevel@tonic-gate if (!qwait_sig(q)) { 321*0Sstevel@tonic-gate (void) rts_close(q); 322*0Sstevel@tonic-gate return (EINTR); 323*0Sstevel@tonic-gate } 324*0Sstevel@tonic-gate } 325*0Sstevel@tonic-gate if (rts->rts_error != 0) { 326*0Sstevel@tonic-gate (void) rts_close(q); 327*0Sstevel@tonic-gate return (ENOTSUP); 328*0Sstevel@tonic-gate } 329*0Sstevel@tonic-gate rts->rts_state = TS_UNBND; 330*0Sstevel@tonic-gate return (0); 331*0Sstevel@tonic-gate } 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate /* 334*0Sstevel@tonic-gate * This routine creates a T_ERROR_ACK message and passes it upstream. 335*0Sstevel@tonic-gate */ 336*0Sstevel@tonic-gate static void 337*0Sstevel@tonic-gate rts_err_ack(queue_t *q, mblk_t *mp, t_scalar_t t_error, int sys_error) 338*0Sstevel@tonic-gate { 339*0Sstevel@tonic-gate if ((mp = mi_tpi_err_ack_alloc(mp, t_error, sys_error)) != NULL) 340*0Sstevel@tonic-gate qreply(q, mp); 341*0Sstevel@tonic-gate } 342*0Sstevel@tonic-gate 343*0Sstevel@tonic-gate /* 344*0Sstevel@tonic-gate * This routine creates a T_OK_ACK message and passes it upstream. 345*0Sstevel@tonic-gate */ 346*0Sstevel@tonic-gate static void 347*0Sstevel@tonic-gate rts_ok_ack(queue_t *q, mblk_t *mp) 348*0Sstevel@tonic-gate { 349*0Sstevel@tonic-gate if ((mp = mi_tpi_ok_ack_alloc(mp)) != NULL) 350*0Sstevel@tonic-gate qreply(q, mp); 351*0Sstevel@tonic-gate } 352*0Sstevel@tonic-gate 353*0Sstevel@tonic-gate /* 354*0Sstevel@tonic-gate * This routine is called by rts_wput to handle T_UNBIND_REQ messages. 355*0Sstevel@tonic-gate * After some error checking, the message is passed downstream to ip. 356*0Sstevel@tonic-gate */ 357*0Sstevel@tonic-gate static void 358*0Sstevel@tonic-gate rts_unbind(queue_t *q, mblk_t *mp) 359*0Sstevel@tonic-gate { 360*0Sstevel@tonic-gate rts_t *rts; 361*0Sstevel@tonic-gate 362*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 363*0Sstevel@tonic-gate /* If a bind has not been done, we can't unbind. */ 364*0Sstevel@tonic-gate if (rts->rts_state != TS_IDLE) { 365*0Sstevel@tonic-gate rts_err_ack(q, mp, TOUTSTATE, 0); 366*0Sstevel@tonic-gate return; 367*0Sstevel@tonic-gate } 368*0Sstevel@tonic-gate rts->rts_state = TS_UNBND; 369*0Sstevel@tonic-gate rts_ok_ack(q, mp); 370*0Sstevel@tonic-gate } 371*0Sstevel@tonic-gate 372*0Sstevel@tonic-gate /* 373*0Sstevel@tonic-gate * This routine is called to handle each 374*0Sstevel@tonic-gate * O_T_BIND_REQ/T_BIND_REQ message passed to 375*0Sstevel@tonic-gate * rts_wput. Note: This routine works with both 376*0Sstevel@tonic-gate * O_T_BIND_REQ and T_BIND_REQ semantics. 377*0Sstevel@tonic-gate */ 378*0Sstevel@tonic-gate static void 379*0Sstevel@tonic-gate rts_bind(queue_t *q, mblk_t *mp) 380*0Sstevel@tonic-gate { 381*0Sstevel@tonic-gate mblk_t *mp1; 382*0Sstevel@tonic-gate struct T_bind_req *tbr; 383*0Sstevel@tonic-gate rts_t *rts; 384*0Sstevel@tonic-gate 385*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 386*0Sstevel@tonic-gate if ((mp->b_wptr - mp->b_rptr) < sizeof (*tbr)) { 387*0Sstevel@tonic-gate (void) mi_strlog(q, 1, SL_ERROR|SL_TRACE, 388*0Sstevel@tonic-gate "rts_bind: bad data, %d", rts->rts_state); 389*0Sstevel@tonic-gate rts_err_ack(q, mp, TBADADDR, 0); 390*0Sstevel@tonic-gate return; 391*0Sstevel@tonic-gate } 392*0Sstevel@tonic-gate if (rts->rts_state != TS_UNBND) { 393*0Sstevel@tonic-gate (void) mi_strlog(q, 1, SL_ERROR|SL_TRACE, 394*0Sstevel@tonic-gate "rts_bind: bad state, %d", rts->rts_state); 395*0Sstevel@tonic-gate rts_err_ack(q, mp, TOUTSTATE, 0); 396*0Sstevel@tonic-gate return; 397*0Sstevel@tonic-gate } 398*0Sstevel@tonic-gate /* 399*0Sstevel@tonic-gate * Reallocate the message to make sure we have enough room for an 400*0Sstevel@tonic-gate * address and the protocol type. 401*0Sstevel@tonic-gate */ 402*0Sstevel@tonic-gate mp1 = reallocb(mp, sizeof (struct T_bind_ack) + sizeof (sin_t), 1); 403*0Sstevel@tonic-gate if (mp1 == NULL) { 404*0Sstevel@tonic-gate rts_err_ack(q, mp, TSYSERR, ENOMEM); 405*0Sstevel@tonic-gate return; 406*0Sstevel@tonic-gate } 407*0Sstevel@tonic-gate mp = mp1; 408*0Sstevel@tonic-gate tbr = (struct T_bind_req *)mp->b_rptr; 409*0Sstevel@tonic-gate if (tbr->ADDR_length != 0) { 410*0Sstevel@tonic-gate (void) mi_strlog(q, 1, SL_ERROR|SL_TRACE, 411*0Sstevel@tonic-gate "rts_bind: bad ADDR_length %d", tbr->ADDR_length); 412*0Sstevel@tonic-gate rts_err_ack(q, mp, TBADADDR, 0); 413*0Sstevel@tonic-gate return; 414*0Sstevel@tonic-gate } 415*0Sstevel@tonic-gate /* Generic request */ 416*0Sstevel@tonic-gate tbr->ADDR_offset = (t_scalar_t)sizeof (struct T_bind_req); 417*0Sstevel@tonic-gate tbr->ADDR_length = 0; 418*0Sstevel@tonic-gate tbr->PRIM_type = T_BIND_ACK; 419*0Sstevel@tonic-gate rts->rts_state = TS_IDLE; 420*0Sstevel@tonic-gate qreply(q, mp); 421*0Sstevel@tonic-gate } 422*0Sstevel@tonic-gate 423*0Sstevel@tonic-gate static void 424*0Sstevel@tonic-gate rts_copy_info(struct T_info_ack *tap, rts_t *rts) 425*0Sstevel@tonic-gate { 426*0Sstevel@tonic-gate *tap = rts_g_t_info_ack; 427*0Sstevel@tonic-gate tap->CURRENT_state = rts->rts_state; 428*0Sstevel@tonic-gate tap->OPT_size = rts_max_optsize; 429*0Sstevel@tonic-gate } 430*0Sstevel@tonic-gate 431*0Sstevel@tonic-gate /* 432*0Sstevel@tonic-gate * This routine responds to T_CAPABILITY_REQ messages. It is called by 433*0Sstevel@tonic-gate * rts_wput. Much of the T_CAPABILITY_ACK information is copied from 434*0Sstevel@tonic-gate * rts_g_t_info_ack. The current state of the stream is copied from 435*0Sstevel@tonic-gate * rts_state. 436*0Sstevel@tonic-gate */ 437*0Sstevel@tonic-gate static void 438*0Sstevel@tonic-gate rts_capability_req(queue_t *q, mblk_t *mp) 439*0Sstevel@tonic-gate { 440*0Sstevel@tonic-gate rts_t *rts = (rts_t *)q->q_ptr; 441*0Sstevel@tonic-gate t_uscalar_t cap_bits1; 442*0Sstevel@tonic-gate struct T_capability_ack *tcap; 443*0Sstevel@tonic-gate 444*0Sstevel@tonic-gate cap_bits1 = ((struct T_capability_req *)mp->b_rptr)->CAP_bits1; 445*0Sstevel@tonic-gate 446*0Sstevel@tonic-gate mp = tpi_ack_alloc(mp, sizeof (struct T_capability_ack), 447*0Sstevel@tonic-gate mp->b_datap->db_type, T_CAPABILITY_ACK); 448*0Sstevel@tonic-gate if (mp == NULL) 449*0Sstevel@tonic-gate return; 450*0Sstevel@tonic-gate 451*0Sstevel@tonic-gate tcap = (struct T_capability_ack *)mp->b_rptr; 452*0Sstevel@tonic-gate tcap->CAP_bits1 = 0; 453*0Sstevel@tonic-gate 454*0Sstevel@tonic-gate if (cap_bits1 & TC1_INFO) { 455*0Sstevel@tonic-gate rts_copy_info(&tcap->INFO_ack, rts); 456*0Sstevel@tonic-gate tcap->CAP_bits1 |= TC1_INFO; 457*0Sstevel@tonic-gate } 458*0Sstevel@tonic-gate 459*0Sstevel@tonic-gate qreply(q, mp); 460*0Sstevel@tonic-gate } 461*0Sstevel@tonic-gate 462*0Sstevel@tonic-gate /* 463*0Sstevel@tonic-gate * This routine responds to T_INFO_REQ messages. It is called by rts_wput. 464*0Sstevel@tonic-gate * Most of the T_INFO_ACK information is copied from rts_g_t_info_ack. 465*0Sstevel@tonic-gate * The current state of the stream is copied from rts_state. 466*0Sstevel@tonic-gate */ 467*0Sstevel@tonic-gate static void 468*0Sstevel@tonic-gate rts_info_req(queue_t *q, mblk_t *mp) 469*0Sstevel@tonic-gate { 470*0Sstevel@tonic-gate rts_t *rts = (rts_t *)q->q_ptr; 471*0Sstevel@tonic-gate 472*0Sstevel@tonic-gate mp = tpi_ack_alloc(mp, sizeof (rts_g_t_info_ack), M_PCPROTO, 473*0Sstevel@tonic-gate T_INFO_ACK); 474*0Sstevel@tonic-gate if (mp == NULL) 475*0Sstevel@tonic-gate return; 476*0Sstevel@tonic-gate rts_copy_info((struct T_info_ack *)mp->b_rptr, rts); 477*0Sstevel@tonic-gate qreply(q, mp); 478*0Sstevel@tonic-gate } 479*0Sstevel@tonic-gate 480*0Sstevel@tonic-gate /* 481*0Sstevel@tonic-gate * This routine gets default values of certain options whose default 482*0Sstevel@tonic-gate * values are maintained by protcol specific code 483*0Sstevel@tonic-gate */ 484*0Sstevel@tonic-gate /* ARGSUSED */ 485*0Sstevel@tonic-gate int 486*0Sstevel@tonic-gate rts_opt_default(queue_t *q, t_scalar_t level, t_scalar_t name, uchar_t *ptr) 487*0Sstevel@tonic-gate { 488*0Sstevel@tonic-gate /* no default value processed by protocol specific code currently */ 489*0Sstevel@tonic-gate return (-1); 490*0Sstevel@tonic-gate } 491*0Sstevel@tonic-gate 492*0Sstevel@tonic-gate /* 493*0Sstevel@tonic-gate * This routine retrieves the current status of socket options. 494*0Sstevel@tonic-gate * It returns the size of the option retrieved. 495*0Sstevel@tonic-gate */ 496*0Sstevel@tonic-gate int 497*0Sstevel@tonic-gate rts_opt_get(queue_t *q, t_scalar_t level, t_scalar_t name, uchar_t *ptr) 498*0Sstevel@tonic-gate { 499*0Sstevel@tonic-gate int *i1 = (int *)ptr; 500*0Sstevel@tonic-gate rts_t *rts = (rts_t *)q->q_ptr; 501*0Sstevel@tonic-gate 502*0Sstevel@tonic-gate switch (level) { 503*0Sstevel@tonic-gate case SOL_SOCKET: 504*0Sstevel@tonic-gate switch (name) { 505*0Sstevel@tonic-gate case SO_DEBUG: 506*0Sstevel@tonic-gate *i1 = rts->rts_debug; 507*0Sstevel@tonic-gate break; 508*0Sstevel@tonic-gate case SO_REUSEADDR: 509*0Sstevel@tonic-gate *i1 = rts->rts_reuseaddr; 510*0Sstevel@tonic-gate break; 511*0Sstevel@tonic-gate case SO_TYPE: 512*0Sstevel@tonic-gate *i1 = SOCK_RAW; 513*0Sstevel@tonic-gate break; 514*0Sstevel@tonic-gate 515*0Sstevel@tonic-gate /* 516*0Sstevel@tonic-gate * The following three items are available here, 517*0Sstevel@tonic-gate * but are only meaningful to IP. 518*0Sstevel@tonic-gate */ 519*0Sstevel@tonic-gate case SO_DONTROUTE: 520*0Sstevel@tonic-gate *i1 = rts->rts_dontroute; 521*0Sstevel@tonic-gate break; 522*0Sstevel@tonic-gate case SO_USELOOPBACK: 523*0Sstevel@tonic-gate *i1 = rts->rts_useloopback; 524*0Sstevel@tonic-gate break; 525*0Sstevel@tonic-gate case SO_BROADCAST: 526*0Sstevel@tonic-gate *i1 = rts->rts_broadcast; 527*0Sstevel@tonic-gate break; 528*0Sstevel@tonic-gate case SO_PROTOTYPE: 529*0Sstevel@tonic-gate *i1 = rts->rts_proto; 530*0Sstevel@tonic-gate break; 531*0Sstevel@tonic-gate /* 532*0Sstevel@tonic-gate * The following two items can be manipulated, 533*0Sstevel@tonic-gate * but changing them should do nothing. 534*0Sstevel@tonic-gate */ 535*0Sstevel@tonic-gate case SO_SNDBUF: 536*0Sstevel@tonic-gate ASSERT(q->q_hiwat <= INT_MAX); 537*0Sstevel@tonic-gate *i1 = (int)(q->q_hiwat); 538*0Sstevel@tonic-gate break; 539*0Sstevel@tonic-gate case SO_RCVBUF: 540*0Sstevel@tonic-gate ASSERT(q->q_hiwat <= INT_MAX); 541*0Sstevel@tonic-gate *i1 = (int)(RD(q)->q_hiwat); 542*0Sstevel@tonic-gate break; 543*0Sstevel@tonic-gate default: 544*0Sstevel@tonic-gate return (-1); 545*0Sstevel@tonic-gate } 546*0Sstevel@tonic-gate break; 547*0Sstevel@tonic-gate default: 548*0Sstevel@tonic-gate return (-1); 549*0Sstevel@tonic-gate } 550*0Sstevel@tonic-gate return ((int)sizeof (int)); 551*0Sstevel@tonic-gate } 552*0Sstevel@tonic-gate 553*0Sstevel@tonic-gate 554*0Sstevel@tonic-gate /* 555*0Sstevel@tonic-gate * This routine sets socket options. 556*0Sstevel@tonic-gate */ 557*0Sstevel@tonic-gate /*ARGSUSED*/ 558*0Sstevel@tonic-gate int 559*0Sstevel@tonic-gate rts_opt_set(queue_t *q, uint_t optset_context, int level, 560*0Sstevel@tonic-gate int name, uint_t inlen, uchar_t *invalp, uint_t *outlenp, 561*0Sstevel@tonic-gate uchar_t *outvalp, void *thisdg_attrs, cred_t *cr, mblk_t *mblk) 562*0Sstevel@tonic-gate { 563*0Sstevel@tonic-gate int *i1 = (int *)invalp; 564*0Sstevel@tonic-gate rts_t *rts = (rts_t *)q->q_ptr; 565*0Sstevel@tonic-gate boolean_t checkonly; 566*0Sstevel@tonic-gate 567*0Sstevel@tonic-gate switch (optset_context) { 568*0Sstevel@tonic-gate case SETFN_OPTCOM_CHECKONLY: 569*0Sstevel@tonic-gate checkonly = B_TRUE; 570*0Sstevel@tonic-gate /* 571*0Sstevel@tonic-gate * Note: Implies T_CHECK semantics for T_OPTCOM_REQ 572*0Sstevel@tonic-gate * inlen != 0 implies value supplied and 573*0Sstevel@tonic-gate * we have to "pretend" to set it. 574*0Sstevel@tonic-gate * inlen == 0 implies that there is no 575*0Sstevel@tonic-gate * value part in T_CHECK request and just validation 576*0Sstevel@tonic-gate * done elsewhere should be enough, we just return here. 577*0Sstevel@tonic-gate */ 578*0Sstevel@tonic-gate if (inlen == 0) { 579*0Sstevel@tonic-gate *outlenp = 0; 580*0Sstevel@tonic-gate return (0); 581*0Sstevel@tonic-gate } 582*0Sstevel@tonic-gate break; 583*0Sstevel@tonic-gate case SETFN_OPTCOM_NEGOTIATE: 584*0Sstevel@tonic-gate checkonly = B_FALSE; 585*0Sstevel@tonic-gate break; 586*0Sstevel@tonic-gate case SETFN_UD_NEGOTIATE: 587*0Sstevel@tonic-gate case SETFN_CONN_NEGOTIATE: 588*0Sstevel@tonic-gate checkonly = B_FALSE; 589*0Sstevel@tonic-gate /* 590*0Sstevel@tonic-gate * Negotiating local and "association-related" options 591*0Sstevel@tonic-gate * through T_UNITDATA_REQ or T_CONN_{REQ,CON} 592*0Sstevel@tonic-gate * Not allowed in this module. 593*0Sstevel@tonic-gate */ 594*0Sstevel@tonic-gate return (EINVAL); 595*0Sstevel@tonic-gate default: 596*0Sstevel@tonic-gate /* 597*0Sstevel@tonic-gate * We should never get here 598*0Sstevel@tonic-gate */ 599*0Sstevel@tonic-gate *outlenp = 0; 600*0Sstevel@tonic-gate return (EINVAL); 601*0Sstevel@tonic-gate } 602*0Sstevel@tonic-gate 603*0Sstevel@tonic-gate ASSERT((optset_context != SETFN_OPTCOM_CHECKONLY) || 604*0Sstevel@tonic-gate (optset_context == SETFN_OPTCOM_CHECKONLY && inlen != 0)); 605*0Sstevel@tonic-gate 606*0Sstevel@tonic-gate /* 607*0Sstevel@tonic-gate * For rts, we should have no ancillary data sent down 608*0Sstevel@tonic-gate * (rts_wput doesn't handle options). 609*0Sstevel@tonic-gate */ 610*0Sstevel@tonic-gate ASSERT(thisdg_attrs == NULL); 611*0Sstevel@tonic-gate 612*0Sstevel@tonic-gate /* 613*0Sstevel@tonic-gate * For fixed length options, no sanity check 614*0Sstevel@tonic-gate * of passed in length is done. It is assumed *_optcom_req() 615*0Sstevel@tonic-gate * routines do the right thing. 616*0Sstevel@tonic-gate */ 617*0Sstevel@tonic-gate 618*0Sstevel@tonic-gate switch (level) { 619*0Sstevel@tonic-gate case SOL_SOCKET: 620*0Sstevel@tonic-gate switch (name) { 621*0Sstevel@tonic-gate case SO_REUSEADDR: 622*0Sstevel@tonic-gate if (!checkonly) 623*0Sstevel@tonic-gate rts->rts_reuseaddr = *i1; 624*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 625*0Sstevel@tonic-gate case SO_DEBUG: 626*0Sstevel@tonic-gate if (!checkonly) 627*0Sstevel@tonic-gate rts->rts_debug = *i1; 628*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 629*0Sstevel@tonic-gate /* 630*0Sstevel@tonic-gate * The following three items are available here, 631*0Sstevel@tonic-gate * but are only meaningful to IP. 632*0Sstevel@tonic-gate */ 633*0Sstevel@tonic-gate case SO_DONTROUTE: 634*0Sstevel@tonic-gate if (!checkonly) 635*0Sstevel@tonic-gate rts->rts_dontroute = *i1; 636*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 637*0Sstevel@tonic-gate case SO_USELOOPBACK: 638*0Sstevel@tonic-gate if (!checkonly) 639*0Sstevel@tonic-gate rts->rts_useloopback = *i1; 640*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 641*0Sstevel@tonic-gate case SO_BROADCAST: 642*0Sstevel@tonic-gate if (!checkonly) 643*0Sstevel@tonic-gate rts->rts_broadcast = *i1; 644*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 645*0Sstevel@tonic-gate case SO_PROTOTYPE: 646*0Sstevel@tonic-gate /* 647*0Sstevel@tonic-gate * Routing socket applications that call socket() with 648*0Sstevel@tonic-gate * a third argument can filter which messages will be 649*0Sstevel@tonic-gate * sent upstream thanks to sockfs. so_socket() sends 650*0Sstevel@tonic-gate * down the SO_PROTOTYPE and rts_queue_input() 651*0Sstevel@tonic-gate * implements the filtering. 652*0Sstevel@tonic-gate */ 653*0Sstevel@tonic-gate if (*i1 != AF_INET && *i1 != AF_INET6) 654*0Sstevel@tonic-gate return (EPROTONOSUPPORT); 655*0Sstevel@tonic-gate if (!checkonly) 656*0Sstevel@tonic-gate rts->rts_proto = *i1; 657*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 658*0Sstevel@tonic-gate /* 659*0Sstevel@tonic-gate * The following two items can be manipulated, 660*0Sstevel@tonic-gate * but changing them should do nothing. 661*0Sstevel@tonic-gate */ 662*0Sstevel@tonic-gate case SO_SNDBUF: 663*0Sstevel@tonic-gate if (*i1 > rts_max_buf) { 664*0Sstevel@tonic-gate *outlenp = 0; 665*0Sstevel@tonic-gate return (ENOBUFS); 666*0Sstevel@tonic-gate } 667*0Sstevel@tonic-gate if (!checkonly) { 668*0Sstevel@tonic-gate q->q_hiwat = *i1; 669*0Sstevel@tonic-gate q->q_next->q_hiwat = *i1; 670*0Sstevel@tonic-gate } 671*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 672*0Sstevel@tonic-gate case SO_RCVBUF: 673*0Sstevel@tonic-gate if (*i1 > rts_max_buf) { 674*0Sstevel@tonic-gate *outlenp = 0; 675*0Sstevel@tonic-gate return (ENOBUFS); 676*0Sstevel@tonic-gate } 677*0Sstevel@tonic-gate if (!checkonly) { 678*0Sstevel@tonic-gate RD(q)->q_hiwat = *i1; 679*0Sstevel@tonic-gate (void) mi_set_sth_hiwat(RD(q), *i1); 680*0Sstevel@tonic-gate } 681*0Sstevel@tonic-gate break; /* goto sizeof (int) option return */ 682*0Sstevel@tonic-gate default: 683*0Sstevel@tonic-gate *outlenp = 0; 684*0Sstevel@tonic-gate return (EINVAL); 685*0Sstevel@tonic-gate } 686*0Sstevel@tonic-gate break; 687*0Sstevel@tonic-gate default: 688*0Sstevel@tonic-gate *outlenp = 0; 689*0Sstevel@tonic-gate return (EINVAL); 690*0Sstevel@tonic-gate } 691*0Sstevel@tonic-gate /* 692*0Sstevel@tonic-gate * Common case of return from an option that is sizeof (int) 693*0Sstevel@tonic-gate */ 694*0Sstevel@tonic-gate *(int *)outvalp = *i1; 695*0Sstevel@tonic-gate *outlenp = (t_uscalar_t)sizeof (int); 696*0Sstevel@tonic-gate return (0); 697*0Sstevel@tonic-gate } 698*0Sstevel@tonic-gate 699*0Sstevel@tonic-gate /* 700*0Sstevel@tonic-gate * This routine frees the ND table if all streams have been closed. 701*0Sstevel@tonic-gate * It is called by rts_close and rts_open. 702*0Sstevel@tonic-gate */ 703*0Sstevel@tonic-gate static void 704*0Sstevel@tonic-gate rts_param_cleanup(void) 705*0Sstevel@tonic-gate { 706*0Sstevel@tonic-gate if (!rts_open_streams) 707*0Sstevel@tonic-gate nd_free(&rts_g_nd); 708*0Sstevel@tonic-gate } 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gate /* 711*0Sstevel@tonic-gate * This routine retrieves the value of an ND variable in a rtsparam_t 712*0Sstevel@tonic-gate * structure. It is called through nd_getset when a user reads the 713*0Sstevel@tonic-gate * variable. 714*0Sstevel@tonic-gate */ 715*0Sstevel@tonic-gate /* ARGSUSED */ 716*0Sstevel@tonic-gate static int 717*0Sstevel@tonic-gate rts_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr) 718*0Sstevel@tonic-gate { 719*0Sstevel@tonic-gate rtsparam_t *rtspa = (rtsparam_t *)cp; 720*0Sstevel@tonic-gate 721*0Sstevel@tonic-gate (void) mi_mpprintf(mp, "%u", rtspa->rts_param_value); 722*0Sstevel@tonic-gate return (0); 723*0Sstevel@tonic-gate } 724*0Sstevel@tonic-gate 725*0Sstevel@tonic-gate /* 726*0Sstevel@tonic-gate * Walk through the param array specified registering each element with the 727*0Sstevel@tonic-gate * named dispatch (ND) handler. 728*0Sstevel@tonic-gate */ 729*0Sstevel@tonic-gate static boolean_t 730*0Sstevel@tonic-gate rts_param_register(rtsparam_t *rtspa, int cnt) 731*0Sstevel@tonic-gate { 732*0Sstevel@tonic-gate for (; cnt-- > 0; rtspa++) { 733*0Sstevel@tonic-gate if (rtspa->rts_param_name != NULL && rtspa->rts_param_name[0]) { 734*0Sstevel@tonic-gate if (!nd_load(&rts_g_nd, rtspa->rts_param_name, 735*0Sstevel@tonic-gate rts_param_get, rts_param_set, (caddr_t)rtspa)) { 736*0Sstevel@tonic-gate nd_free(&rts_g_nd); 737*0Sstevel@tonic-gate return (B_FALSE); 738*0Sstevel@tonic-gate } 739*0Sstevel@tonic-gate } 740*0Sstevel@tonic-gate } 741*0Sstevel@tonic-gate return (B_TRUE); 742*0Sstevel@tonic-gate } 743*0Sstevel@tonic-gate 744*0Sstevel@tonic-gate /* This routine sets an ND variable in a rtsparam_t structure. */ 745*0Sstevel@tonic-gate /* ARGSUSED */ 746*0Sstevel@tonic-gate static int 747*0Sstevel@tonic-gate rts_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr) 748*0Sstevel@tonic-gate { 749*0Sstevel@tonic-gate ulong_t new_value; 750*0Sstevel@tonic-gate rtsparam_t *rtspa = (rtsparam_t *)cp; 751*0Sstevel@tonic-gate 752*0Sstevel@tonic-gate /* 753*0Sstevel@tonic-gate * Fail the request if the new value does not lie within the 754*0Sstevel@tonic-gate * required bounds. 755*0Sstevel@tonic-gate */ 756*0Sstevel@tonic-gate if (ddi_strtoul(value, NULL, 10, &new_value) != 0 || 757*0Sstevel@tonic-gate new_value < rtspa->rts_param_min || 758*0Sstevel@tonic-gate new_value > rtspa->rts_param_max) { 759*0Sstevel@tonic-gate return (EINVAL); 760*0Sstevel@tonic-gate } 761*0Sstevel@tonic-gate 762*0Sstevel@tonic-gate /* Set the new value */ 763*0Sstevel@tonic-gate rtspa->rts_param_value = new_value; 764*0Sstevel@tonic-gate return (0); 765*0Sstevel@tonic-gate } 766*0Sstevel@tonic-gate 767*0Sstevel@tonic-gate /* 768*0Sstevel@tonic-gate * This routine handles synchronous messages passed downstream. It either 769*0Sstevel@tonic-gate * consumes the message or passes it downstream; it never queues a 770*0Sstevel@tonic-gate * a message. The data messages that go down are wrapped in an IOCTL 771*0Sstevel@tonic-gate * message. 772*0Sstevel@tonic-gate * 773*0Sstevel@tonic-gate * Since it is synchronous, it waits for the M_IOCACK/M_IOCNAK so that 774*0Sstevel@tonic-gate * it can return an immediate error (such as ENETUNREACH when adding a route). 775*0Sstevel@tonic-gate * It uses the RTS_WRW_PENDING to ensure that each rts instance has only 776*0Sstevel@tonic-gate * one M_IOCTL outstanding at any given time. 777*0Sstevel@tonic-gate */ 778*0Sstevel@tonic-gate static int 779*0Sstevel@tonic-gate rts_wrw(queue_t *q, struiod_t *dp) 780*0Sstevel@tonic-gate { 781*0Sstevel@tonic-gate mblk_t *mp = dp->d_mp; 782*0Sstevel@tonic-gate mblk_t *mp1; 783*0Sstevel@tonic-gate int error; 784*0Sstevel@tonic-gate rt_msghdr_t *rtm; 785*0Sstevel@tonic-gate rts_t *rts; 786*0Sstevel@tonic-gate 787*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 788*0Sstevel@tonic-gate while (rts->rts_flag & RTS_WRW_PENDING) { 789*0Sstevel@tonic-gate if (qwait_rw(q)) { 790*0Sstevel@tonic-gate rts->rts_error = EINTR; 791*0Sstevel@tonic-gate goto err_ret; 792*0Sstevel@tonic-gate } 793*0Sstevel@tonic-gate } 794*0Sstevel@tonic-gate rts->rts_flag |= RTS_WRW_PENDING; 795*0Sstevel@tonic-gate 796*0Sstevel@tonic-gate if (isuioq(q) && (error = struioget(q, mp, dp, 0))) { 797*0Sstevel@tonic-gate /* 798*0Sstevel@tonic-gate * Uio error of some sort, so just return the error. 799*0Sstevel@tonic-gate */ 800*0Sstevel@tonic-gate rts->rts_error = error; 801*0Sstevel@tonic-gate goto err_ret; 802*0Sstevel@tonic-gate } 803*0Sstevel@tonic-gate /* 804*0Sstevel@tonic-gate * Pass the mblk (chain) onto wput(). 805*0Sstevel@tonic-gate */ 806*0Sstevel@tonic-gate dp->d_mp = 0; 807*0Sstevel@tonic-gate 808*0Sstevel@tonic-gate switch (mp->b_datap->db_type) { 809*0Sstevel@tonic-gate case M_PROTO: 810*0Sstevel@tonic-gate case M_PCPROTO: 811*0Sstevel@tonic-gate /* Expedite other than T_DATA_REQ to below the switch */ 812*0Sstevel@tonic-gate if (((mp->b_wptr - mp->b_rptr) != 813*0Sstevel@tonic-gate sizeof (struct T_data_req)) || 814*0Sstevel@tonic-gate (((union T_primitives *)mp->b_rptr)->type != T_DATA_REQ)) 815*0Sstevel@tonic-gate break; 816*0Sstevel@tonic-gate if ((mp1 = mp->b_cont) == NULL) { 817*0Sstevel@tonic-gate rts->rts_error = EINVAL; 818*0Sstevel@tonic-gate goto err_ret; 819*0Sstevel@tonic-gate } 820*0Sstevel@tonic-gate freeb(mp); 821*0Sstevel@tonic-gate mp = mp1; 822*0Sstevel@tonic-gate /* FALLTHRU */ 823*0Sstevel@tonic-gate case M_DATA: 824*0Sstevel@tonic-gate /* 825*0Sstevel@tonic-gate * The semantics of the routing socket is such that the rtm_pid 826*0Sstevel@tonic-gate * field is automatically filled in during requests with the 827*0Sstevel@tonic-gate * current process' pid. We do this here (where we still have 828*0Sstevel@tonic-gate * user context) after checking we have at least a message the 829*0Sstevel@tonic-gate * size of a routing message header. 830*0Sstevel@tonic-gate */ 831*0Sstevel@tonic-gate if ((mp->b_wptr - mp->b_rptr) < sizeof (rt_msghdr_t)) { 832*0Sstevel@tonic-gate if (!pullupmsg(mp, sizeof (rt_msghdr_t))) { 833*0Sstevel@tonic-gate rts->rts_error = EINVAL; 834*0Sstevel@tonic-gate goto err_ret; 835*0Sstevel@tonic-gate } 836*0Sstevel@tonic-gate } 837*0Sstevel@tonic-gate rtm = (rt_msghdr_t *)mp->b_rptr; 838*0Sstevel@tonic-gate rtm->rtm_pid = curproc->p_pid; 839*0Sstevel@tonic-gate break; 840*0Sstevel@tonic-gate default: 841*0Sstevel@tonic-gate break; 842*0Sstevel@tonic-gate } 843*0Sstevel@tonic-gate rts->rts_flag |= RTS_WPUT_PENDING; 844*0Sstevel@tonic-gate rts_wput(q, mp); 845*0Sstevel@tonic-gate while (rts->rts_flag & RTS_WPUT_PENDING) 846*0Sstevel@tonic-gate if (qwait_rw(q)) { 847*0Sstevel@tonic-gate /* RTS_WPUT_PENDING will be cleared below */ 848*0Sstevel@tonic-gate rts->rts_error = EINTR; 849*0Sstevel@tonic-gate break; 850*0Sstevel@tonic-gate } 851*0Sstevel@tonic-gate err_ret: 852*0Sstevel@tonic-gate rts->rts_flag &= ~(RTS_WPUT_PENDING | RTS_WRW_PENDING); 853*0Sstevel@tonic-gate return (rts->rts_error); 854*0Sstevel@tonic-gate } 855*0Sstevel@tonic-gate 856*0Sstevel@tonic-gate /* 857*0Sstevel@tonic-gate * This routine handles all messages passed downstream. It either 858*0Sstevel@tonic-gate * consumes the message or passes it downstream; it never queues a 859*0Sstevel@tonic-gate * a message. The data messages that go down are wrapped in an IOCTL 860*0Sstevel@tonic-gate * message. 861*0Sstevel@tonic-gate */ 862*0Sstevel@tonic-gate static void 863*0Sstevel@tonic-gate rts_wput(queue_t *q, mblk_t *mp) 864*0Sstevel@tonic-gate { 865*0Sstevel@tonic-gate uchar_t *rptr = mp->b_rptr; 866*0Sstevel@tonic-gate mblk_t *mp1; 867*0Sstevel@tonic-gate 868*0Sstevel@tonic-gate switch (mp->b_datap->db_type) { 869*0Sstevel@tonic-gate case M_DATA: 870*0Sstevel@tonic-gate break; 871*0Sstevel@tonic-gate case M_PROTO: 872*0Sstevel@tonic-gate case M_PCPROTO: 873*0Sstevel@tonic-gate if ((mp->b_wptr - rptr) == sizeof (struct T_data_req)) { 874*0Sstevel@tonic-gate /* Expedite valid T_DATA_REQ to below the switch */ 875*0Sstevel@tonic-gate if (((union T_primitives *)rptr)->type == T_DATA_REQ) { 876*0Sstevel@tonic-gate mp1 = mp->b_cont; 877*0Sstevel@tonic-gate freeb(mp); 878*0Sstevel@tonic-gate if (mp1 == NULL) 879*0Sstevel@tonic-gate return; 880*0Sstevel@tonic-gate mp = mp1; 881*0Sstevel@tonic-gate break; 882*0Sstevel@tonic-gate } 883*0Sstevel@tonic-gate } 884*0Sstevel@tonic-gate /* FALLTHRU */ 885*0Sstevel@tonic-gate default: 886*0Sstevel@tonic-gate rts_wput_other(q, mp); 887*0Sstevel@tonic-gate return; 888*0Sstevel@tonic-gate } 889*0Sstevel@tonic-gate 890*0Sstevel@tonic-gate 891*0Sstevel@tonic-gate mp1 = rts_ioctl_alloc(mp, DB_CRED(mp)); 892*0Sstevel@tonic-gate if (mp1 == NULL) { 893*0Sstevel@tonic-gate rts_t *rts = (rts_t *)q->q_ptr; 894*0Sstevel@tonic-gate 895*0Sstevel@tonic-gate ASSERT(rts != NULL); 896*0Sstevel@tonic-gate freemsg(mp); 897*0Sstevel@tonic-gate if (rts->rts_flag & RTS_WPUT_PENDING) { 898*0Sstevel@tonic-gate rts->rts_error = ENOMEM; 899*0Sstevel@tonic-gate rts->rts_flag &= ~RTS_WPUT_PENDING; 900*0Sstevel@tonic-gate } 901*0Sstevel@tonic-gate return; 902*0Sstevel@tonic-gate } 903*0Sstevel@tonic-gate putnext(q, mp1); 904*0Sstevel@tonic-gate } 905*0Sstevel@tonic-gate 906*0Sstevel@tonic-gate 907*0Sstevel@tonic-gate /* 908*0Sstevel@tonic-gate * Handles all the control message, if it 909*0Sstevel@tonic-gate * can not understand it, it will 910*0Sstevel@tonic-gate * pass down stream. 911*0Sstevel@tonic-gate */ 912*0Sstevel@tonic-gate static void 913*0Sstevel@tonic-gate rts_wput_other(queue_t *q, mblk_t *mp) 914*0Sstevel@tonic-gate { 915*0Sstevel@tonic-gate uchar_t *rptr = mp->b_rptr; 916*0Sstevel@tonic-gate rts_t *rts; 917*0Sstevel@tonic-gate struct iocblk *iocp; 918*0Sstevel@tonic-gate cred_t *cr; 919*0Sstevel@tonic-gate 920*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 921*0Sstevel@tonic-gate 922*0Sstevel@tonic-gate cr = DB_CREDDEF(mp, rts->rts_credp); 923*0Sstevel@tonic-gate 924*0Sstevel@tonic-gate switch (mp->b_datap->db_type) { 925*0Sstevel@tonic-gate case M_PROTO: 926*0Sstevel@tonic-gate case M_PCPROTO: 927*0Sstevel@tonic-gate if ((mp->b_wptr - rptr) < sizeof (t_scalar_t)) { 928*0Sstevel@tonic-gate /* 929*0Sstevel@tonic-gate * If the message does not contain a PRIM_type, 930*0Sstevel@tonic-gate * throw it away. 931*0Sstevel@tonic-gate */ 932*0Sstevel@tonic-gate freemsg(mp); 933*0Sstevel@tonic-gate return; 934*0Sstevel@tonic-gate } 935*0Sstevel@tonic-gate switch (((union T_primitives *)rptr)->type) { 936*0Sstevel@tonic-gate case T_BIND_REQ: 937*0Sstevel@tonic-gate case O_T_BIND_REQ: 938*0Sstevel@tonic-gate rts_bind(q, mp); 939*0Sstevel@tonic-gate return; 940*0Sstevel@tonic-gate case T_UNBIND_REQ: 941*0Sstevel@tonic-gate rts_unbind(q, mp); 942*0Sstevel@tonic-gate return; 943*0Sstevel@tonic-gate case T_CAPABILITY_REQ: 944*0Sstevel@tonic-gate rts_capability_req(q, mp); 945*0Sstevel@tonic-gate return; 946*0Sstevel@tonic-gate case T_INFO_REQ: 947*0Sstevel@tonic-gate rts_info_req(q, mp); 948*0Sstevel@tonic-gate return; 949*0Sstevel@tonic-gate case T_SVR4_OPTMGMT_REQ: 950*0Sstevel@tonic-gate (void) svr4_optcom_req(q, mp, cr, &rts_opt_obj); 951*0Sstevel@tonic-gate return; 952*0Sstevel@tonic-gate case T_OPTMGMT_REQ: 953*0Sstevel@tonic-gate (void) tpi_optcom_req(q, mp, cr, &rts_opt_obj); 954*0Sstevel@tonic-gate return; 955*0Sstevel@tonic-gate case O_T_CONN_RES: 956*0Sstevel@tonic-gate case T_CONN_RES: 957*0Sstevel@tonic-gate case T_DISCON_REQ: 958*0Sstevel@tonic-gate /* Not supported by rts. */ 959*0Sstevel@tonic-gate rts_err_ack(q, mp, TNOTSUPPORT, 0); 960*0Sstevel@tonic-gate return; 961*0Sstevel@tonic-gate case T_DATA_REQ: 962*0Sstevel@tonic-gate case T_EXDATA_REQ: 963*0Sstevel@tonic-gate case T_ORDREL_REQ: 964*0Sstevel@tonic-gate /* Illegal for rts. */ 965*0Sstevel@tonic-gate freemsg(mp); 966*0Sstevel@tonic-gate (void) putnextctl1(RD(q), M_ERROR, EPROTO); 967*0Sstevel@tonic-gate return; 968*0Sstevel@tonic-gate default: 969*0Sstevel@tonic-gate break; 970*0Sstevel@tonic-gate } 971*0Sstevel@tonic-gate break; 972*0Sstevel@tonic-gate case M_IOCTL: 973*0Sstevel@tonic-gate iocp = (struct iocblk *)mp->b_rptr; 974*0Sstevel@tonic-gate switch (iocp->ioc_cmd) { 975*0Sstevel@tonic-gate case ND_SET: 976*0Sstevel@tonic-gate case ND_GET: 977*0Sstevel@tonic-gate if (nd_getset(q, rts_g_nd, mp)) { 978*0Sstevel@tonic-gate qreply(q, mp); 979*0Sstevel@tonic-gate return; 980*0Sstevel@tonic-gate } 981*0Sstevel@tonic-gate break; 982*0Sstevel@tonic-gate case TI_GETPEERNAME: 983*0Sstevel@tonic-gate mi_copyin(q, mp, NULL, 984*0Sstevel@tonic-gate SIZEOF_STRUCT(strbuf, iocp->ioc_flag)); 985*0Sstevel@tonic-gate return; 986*0Sstevel@tonic-gate default: 987*0Sstevel@tonic-gate break; 988*0Sstevel@tonic-gate } 989*0Sstevel@tonic-gate case M_IOCDATA: 990*0Sstevel@tonic-gate rts_wput_iocdata(q, mp); 991*0Sstevel@tonic-gate return; 992*0Sstevel@tonic-gate default: 993*0Sstevel@tonic-gate break; 994*0Sstevel@tonic-gate } 995*0Sstevel@tonic-gate putnext(q, mp); 996*0Sstevel@tonic-gate } 997*0Sstevel@tonic-gate 998*0Sstevel@tonic-gate /* 999*0Sstevel@tonic-gate * Called by rts_wput_other to handle all M_IOCDATA messages. 1000*0Sstevel@tonic-gate */ 1001*0Sstevel@tonic-gate static void 1002*0Sstevel@tonic-gate rts_wput_iocdata(queue_t *q, mblk_t *mp) 1003*0Sstevel@tonic-gate { 1004*0Sstevel@tonic-gate struct sockaddr *rtsaddr; 1005*0Sstevel@tonic-gate mblk_t *mp1; 1006*0Sstevel@tonic-gate STRUCT_HANDLE(strbuf, sb); 1007*0Sstevel@tonic-gate struct iocblk *iocp = (struct iocblk *)mp->b_rptr; 1008*0Sstevel@tonic-gate 1009*0Sstevel@tonic-gate /* Make sure it is one of ours. */ 1010*0Sstevel@tonic-gate switch (iocp->ioc_cmd) { 1011*0Sstevel@tonic-gate case TI_GETPEERNAME: 1012*0Sstevel@tonic-gate break; 1013*0Sstevel@tonic-gate default: 1014*0Sstevel@tonic-gate putnext(q, mp); 1015*0Sstevel@tonic-gate return; 1016*0Sstevel@tonic-gate } 1017*0Sstevel@tonic-gate switch (mi_copy_state(q, mp, &mp1)) { 1018*0Sstevel@tonic-gate case -1: 1019*0Sstevel@tonic-gate return; 1020*0Sstevel@tonic-gate case MI_COPY_CASE(MI_COPY_IN, 1): 1021*0Sstevel@tonic-gate break; 1022*0Sstevel@tonic-gate case MI_COPY_CASE(MI_COPY_OUT, 1): 1023*0Sstevel@tonic-gate /* Copy out the strbuf. */ 1024*0Sstevel@tonic-gate mi_copyout(q, mp); 1025*0Sstevel@tonic-gate return; 1026*0Sstevel@tonic-gate case MI_COPY_CASE(MI_COPY_OUT, 2): 1027*0Sstevel@tonic-gate /* All done. */ 1028*0Sstevel@tonic-gate mi_copy_done(q, mp, 0); 1029*0Sstevel@tonic-gate return; 1030*0Sstevel@tonic-gate default: 1031*0Sstevel@tonic-gate mi_copy_done(q, mp, EPROTO); 1032*0Sstevel@tonic-gate return; 1033*0Sstevel@tonic-gate } 1034*0Sstevel@tonic-gate STRUCT_SET_HANDLE(sb, iocp->ioc_flag, (void *)mp1->b_rptr); 1035*0Sstevel@tonic-gate if (STRUCT_FGET(sb, maxlen) < (int)sizeof (sin_t)) { 1036*0Sstevel@tonic-gate mi_copy_done(q, mp, EINVAL); 1037*0Sstevel@tonic-gate return; 1038*0Sstevel@tonic-gate } 1039*0Sstevel@tonic-gate switch (iocp->ioc_cmd) { 1040*0Sstevel@tonic-gate case TI_GETPEERNAME: 1041*0Sstevel@tonic-gate break; 1042*0Sstevel@tonic-gate default: 1043*0Sstevel@tonic-gate mi_copy_done(q, mp, EPROTO); 1044*0Sstevel@tonic-gate return; 1045*0Sstevel@tonic-gate } 1046*0Sstevel@tonic-gate mp1 = mi_copyout_alloc(q, mp, STRUCT_FGETP(sb, buf), sizeof (sin_t), 1047*0Sstevel@tonic-gate B_TRUE); 1048*0Sstevel@tonic-gate if (mp1 == NULL) 1049*0Sstevel@tonic-gate return; 1050*0Sstevel@tonic-gate STRUCT_FSET(sb, len, (int)sizeof (sin_t)); 1051*0Sstevel@tonic-gate rtsaddr = (struct sockaddr *)mp1->b_rptr; 1052*0Sstevel@tonic-gate mp1->b_wptr = (uchar_t *)&rtsaddr[1]; 1053*0Sstevel@tonic-gate bzero(rtsaddr, sizeof (struct sockaddr)); 1054*0Sstevel@tonic-gate rtsaddr->sa_family = AF_ROUTE; 1055*0Sstevel@tonic-gate /* Copy out the address */ 1056*0Sstevel@tonic-gate mi_copyout(q, mp); 1057*0Sstevel@tonic-gate } 1058*0Sstevel@tonic-gate 1059*0Sstevel@tonic-gate static void 1060*0Sstevel@tonic-gate rts_rput(queue_t *q, mblk_t *mp) 1061*0Sstevel@tonic-gate { 1062*0Sstevel@tonic-gate rts_t *rts; 1063*0Sstevel@tonic-gate struct iocblk *iocp; 1064*0Sstevel@tonic-gate mblk_t *mp1; 1065*0Sstevel@tonic-gate struct T_data_ind *tdi; 1066*0Sstevel@tonic-gate 1067*0Sstevel@tonic-gate rts = (rts_t *)q->q_ptr; 1068*0Sstevel@tonic-gate switch (mp->b_datap->db_type) { 1069*0Sstevel@tonic-gate case M_IOCACK: 1070*0Sstevel@tonic-gate case M_IOCNAK: 1071*0Sstevel@tonic-gate iocp = (struct iocblk *)mp->b_rptr; 1072*0Sstevel@tonic-gate if (rts->rts_flag & (RTS_WPUT_PENDING|RTS_OPEN_PENDING)) { 1073*0Sstevel@tonic-gate if (rts->rts_flag & RTS_WPUT_PENDING) 1074*0Sstevel@tonic-gate rts->rts_flag &= ~RTS_WPUT_PENDING; 1075*0Sstevel@tonic-gate else 1076*0Sstevel@tonic-gate rts->rts_flag &= ~RTS_OPEN_PENDING; 1077*0Sstevel@tonic-gate rts->rts_error = iocp->ioc_error; 1078*0Sstevel@tonic-gate freemsg(mp); 1079*0Sstevel@tonic-gate return; 1080*0Sstevel@tonic-gate } 1081*0Sstevel@tonic-gate break; 1082*0Sstevel@tonic-gate case M_DATA: 1083*0Sstevel@tonic-gate /* 1084*0Sstevel@tonic-gate * Prepend T_DATA_IND to prevent the stream head from 1085*0Sstevel@tonic-gate * consolidating multiple messages together. 1086*0Sstevel@tonic-gate * If the allocation fails just send up the M_DATA. 1087*0Sstevel@tonic-gate */ 1088*0Sstevel@tonic-gate mp1 = allocb(sizeof (*tdi), BPRI_MED); 1089*0Sstevel@tonic-gate if (mp1 != NULL) { 1090*0Sstevel@tonic-gate mp1->b_cont = mp; 1091*0Sstevel@tonic-gate mp = mp1; 1092*0Sstevel@tonic-gate 1093*0Sstevel@tonic-gate mp->b_datap->db_type = M_PROTO; 1094*0Sstevel@tonic-gate mp->b_wptr += sizeof (*tdi); 1095*0Sstevel@tonic-gate tdi = (struct T_data_ind *)mp->b_rptr; 1096*0Sstevel@tonic-gate tdi->PRIM_type = T_DATA_IND; 1097*0Sstevel@tonic-gate tdi->MORE_flag = 0; 1098*0Sstevel@tonic-gate } 1099*0Sstevel@tonic-gate break; 1100*0Sstevel@tonic-gate default: 1101*0Sstevel@tonic-gate break; 1102*0Sstevel@tonic-gate } 1103*0Sstevel@tonic-gate putnext(q, mp); 1104*0Sstevel@tonic-gate } 1105*0Sstevel@tonic-gate 1106*0Sstevel@tonic-gate 1107*0Sstevel@tonic-gate void 1108*0Sstevel@tonic-gate rts_ddi_init(void) 1109*0Sstevel@tonic-gate { 1110*0Sstevel@tonic-gate rts_max_optsize = optcom_max_optsize(rts_opt_obj.odb_opt_des_arr, 1111*0Sstevel@tonic-gate rts_opt_obj.odb_opt_arr_cnt); 1112*0Sstevel@tonic-gate } 1113