proto_set.c revision 0f1702c5201310f0529cd5abb77652e5e9b241b6
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/sysmacros.h>
#include <sys/tpicommon.h>
#include <sys/socket_proto.h>
#include <inet/ipclassifier.h>
{
struct sock_proto_props sopp;
} else {
struct stroptions *stropt;
return (B_FALSE);
}
return (B_TRUE);
}
{
struct sock_proto_props sopp;
} else {
struct stroptions *stropt;
return (B_FALSE);
}
return (B_TRUE);
}
/*
* Set maximum packet size. This is the maximum amount of data the protocol
* wants to be given at any time, Larger data needs to be broken in multiples
* of maximum packet size and given to the protocol one at a time.
*/
{
struct sock_proto_props sopp;
return (B_TRUE);
} else {
/*
* At this point change of a queue parameter is not allowed
* when a multiplexor is sitting on top.
*/
return (B_FALSE);
return (B_TRUE);
}
}
/* ARGSUSED */
{
struct sock_proto_props sopp;
} else {
struct stroptions *stropt;
return (B_FALSE);
}
return (B_TRUE);
}
{
struct sock_proto_props sopp;
} else {
struct stroptions *stropt;
return (B_FALSE);
}
return (B_TRUE);
}
{
struct sock_proto_props sopp;
/* XXX workaround for CR6757374 */
} else {
struct stroptions *stropt;
return (B_FALSE);
}
return (B_TRUE);
}
/*
* set OOBINLINE processing on the socket
*/
void
{
struct sock_proto_props sopp;
}
/*
* Translate a TLI(/XTI) error into a system error as best we can.
*/
static const int tli_errs[] = {
0, /* no error */
EADDRNOTAVAIL, /* TBADADDR */
ENOPROTOOPT, /* TBADOPT */
EACCES, /* TACCES */
EBADF, /* TBADF */
EADDRNOTAVAIL, /* TNOADDR */
EPROTO, /* TOUTSTATE */
ECONNABORTED, /* TBADSEQ */
0, /* TSYSERR - will never get */
EPROTO, /* TLOOK - should never be sent by transport */
EMSGSIZE, /* TBADDATA */
EMSGSIZE, /* TBUFOVFLW */
EPROTO, /* TFLOW */
EWOULDBLOCK, /* TNODATA */
EPROTO, /* TNODIS */
EPROTO, /* TNOUDERR */
EINVAL, /* TBADFLAG */
EPROTO, /* TNOREL */
EOPNOTSUPP, /* TNOTSUPPORT */
EPROTO, /* TSTATECHNG */
/* following represent error namespace expansion with XTI */
EPROTO, /* TNOSTRUCTYPE - never sent by transport */
EPROTO, /* TBADNAME - never sent by transport */
EPROTO, /* TBADQLEN - never sent by transport */
EADDRINUSE, /* TADDRBUSY */
EBADF, /* TINDOUT */
EBADF, /* TPROVMISMATCH */
EBADF, /* TRESQLEN */
EBADF, /* TRESADDR */
EPROTO, /* TQFULL - never sent by transport */
EPROTO, /* TPROTO */
};
int
proto_tlitosyserr(int terr)
{
return (EPROTO);
else
}
/*
* Since this is a generic function we do not test for port being zero
* as some protocols like icmp do not require a port
*/
int
{
return (EINVAL);
switch (family) {
case AF_INET:
return (EAFNOSUPPORT);
}
return (EINVAL);
}
break;
case AF_INET6: {
#ifdef DEBUG
struct sockaddr_in6 *sin6;
#endif /* DEBUG */
return (EAFNOSUPPORT);
}
return (EINVAL);
}
#ifdef DEBUG
/* Verify that apps don't forget to clear sin6_scope_id etc */
if (sin6->sin6_scope_id != 0 &&
"(%d) on socket. Pid = %d\n",
}
#endif /* DEBUG */
break;
}
default:
return (EINVAL);
}
return (0);
}
/*
* Do a lookup of the options in the array.
* Rerurn NULL if there isn't a match.
*/
opdes_t *
{
optd++) {
return (optd);
}
return (NULL);
}
/*
* Do a lookup of the options in the array and do permission and length checking
* Returns zero if there is no error (note: for non-tpi-providers not being able
* to find the option is not an error). TPI errors are returned as -ve.
*/
int
{
/* Find the option in the opt_arr. */
NULL) {
/*
* Not found, that is a bad thing if
* the caller is a tpi provider
*/
if (topmost_tpiprovider)
return (-TBADOPT);
else
return (0); /* skip unmodified */
}
/* Additional checks dependent on operation. */
if (negotiate) {
/* Cannot be true at the same time */
/* can't negotiate option */
OA_WX_ANYPRIV(optd)) {
/*
* not privileged but privilege
* will help negotiate option.
*/
return (-TACCES);
} else {
return (-TBADOPT);
}
}
/*
* Verify size for options
* Note: For retaining compatibility with historical
* behavior, variable lengths options will have their
* length verified in the setfn() processing.
* In order to be compatible with SunOS 4.X we return
* EINVAL errors for bad lengths.
*/
/* fixed length - size must match */
return (EINVAL);
}
}
} else {
if (check) {
if (!OA_RWX_ANYPRIV(optd))
/* any of "rwx" permission but not none */
return (-TBADOPT);
}
/*
* XXX Change the comments.
*
* XXX Since T_CURRENT was not there in TLI and the
* official TLI inspired TPI standard, getsockopt()
* API uses T_CHECK (for T_CURRENT semantics)
* The following fallthru makes sense because of its
* historical use as semantic equivalent to T_CURRENT.
*/
/* FALLTHRU */
/* can't read option value */
OA_R_ANYPRIV(optd)) {
/*
* not privileged but privilege
* will help in reading option value.
*/
return (-TACCES);
} else {
return (-TBADOPT);
}
}
}
/* We liked it. Keep going. */
return (0);
}