2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1988, 2011, Oracle and/or its affiliates. All rights reserved. 2N/A/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 2N/A/* All Rights Reserved */ 2N/A * The following is based on XTI standard. 2N/A * We block all signals during the TI_OPTMGMT operation 2N/A * as option change being done could potentially be a 2N/A * non-idempotent operation. 2N/A * Note that sig_mutex_lock() only defers signals, it does not 2N/A * block them, so interruptible syscalls could still get EINTR. 2N/A * Note: assumes (correctly) that ti_ctlsize is large enough 2N/A * to hold sizeof (struct T_bind_req) 2N/A * effective option length in local variable "optlen" 2N/A * Note: can change for XTI for T_ALLOPT. XTI spec states 2N/A * that options after the T_ALLOPT option are to be ignored 2N/A * therefore we trncate the option buffer there and modify 2N/A * the effective length accordingly later. 2N/A * Verify integrity of option buffer according to 2N/A * XTI t_optmgmt() semantics. 2N/A /* option buffer should atleast have an t_opthdr */ 2N/A * XXX We interpret that an option has to start on an 2N/A * aligned buffer boundary. This is not very explcit in 2N/A * XTI spec in text but the picture in Section 6.2 shows 2N/A * "opt.buf" at start of buffer and in combination with 2N/A * text can be construed to be restricting it to start 2N/A * on an aligned boundary. [Whether similar restriction 2N/A * applies to output buffer "ret->opt.buf" is an "interesting 2N/A * question" but we ignore it for now as that is the problem 2N/A * for the application not our implementation which will 2N/A * does not enforce any alignment requirement.] 2N/A * If start of buffer is not aligned, we signal an error. 2N/A /* LINTED pointer cast */ 2N/A * Make sure we have enough in the message to dereference 2N/A * the option header. 2N/A * If there are multiple options, they all have to be 2N/A * the same level (so says XTI semantics). 2N/A * Make sure we have enough in the message to 2N/A * dereference the option header. 2N/A * We now compute pointer to next option in buffer 2N/A * 'next_opt' the next_opt computation above below 2N/A * 'opt->len' initialized by application which cannot 2N/A * be trusted. The usual value too large will be 2N/A * captured by the loop termination condition above. 2N/A * We check for the following which it will miss. 2N/A * (1)pointer space wraparound arithmetic overflow 2N/A * (2)last option in buffer with 'opt->len' being 2N/A * (only reason 'next_opt' should equal or exceed 2N/A * 'opt_end' for last option is roundup unless 2N/A * (3) we also enforce the XTI restriction that 2N/A * all options in the buffer have to be the 2N/A /* LINTED pointer cast */ 2N/A * XTI semantics: options in the buffer after 2N/A * the T_ALLOPT option can be ignored 2N/A * there are options following, ignore 2N/A * them and truncate input 2N/A /* LINTED pointer cast */ 2N/A * Aligned copy will overflow buffer allocated 2N/A * based on maximum transport option size information 2N/A /* LINTED pointer cast */ 2N/A * Note: TPI is not clear about what really is carries in the 2N/A * T_OPTMGMT_ACK MGMT_flags fields. For T_OPTMGMT_ACK in response 2N/A * to T_SVR4_OPTMGMT_REQ, the Internet protocols in Solaris 2.X return 2N/A * the result code only (T_SUCCESS). For T_OPTMGMT_ACK in response 2N/A * to T_OPTMGMT_REQ, currently "worst status" code required for 2N/A * XTI is carried from the set of options OR'd with request flag. 2N/A * (This can change in future and "worst status" computation done 2N/A * with a scan in this routine. 2N/A * Note: Even for T_OPTMGMT_ACK is response to T_SVR4_OPTMGMT_REQ, 2N/A * removing request flag should be OK though it will not be set. 2N/A * There is no real change of state in state table for option 2N/A * management. The state change macro is used below only for its 2N/A * debugging and logging capabilities. 2N/A * The TLI "(mis)feature" (option management only in T_IDLE state) 2N/A * has been deprecated in XTI and our state table reflect updated for 2N/A * both TLI and XTI to reflect that. 2N/A * TLI semantics can be enforced by the transport providers that 2N/A * desire it at TPI level. 2N/A * There is no need to enforce this in the library since 2N/A * sane transport providers that do allow it (e.g TCP and it *needs* 2N/A * to allow it) should be allowed to work fine. 2N/A * The only transport providers that return TOUTSTATE for TLI 2N/A * t_optmgmt() are the drivers used for conformance testing to the 2N/A * broken TLI standard. 2N/A * These are /dev/{ticots,ticotsord,ticlts} used by the Sparc ABI test 2N/A * suite. Others are /dev/{tivc,tidg} used by the SVVS test suite. 2N/A "t_optmgmt: invalid state event T_OPTMGMT");