optcom.h revision ff550d0e264b51131fb34e9e83163b348d916640
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1990 Mentat Inc. */
#ifndef _INET_OPTCOM_H
#define _INET_OPTCOM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/* Options Description Structure */
typedef struct opdes_s {
int opdes_access_nopriv; /* permissions for non-privileged */
int opdes_access_priv; /* permissions for privileged */
int opdes_access_req_priv; /* required privilege, OP_NP if none */
int opdes_props; /* properties of associated with option */
/* [ or maxlen if variable */
/* length(OP_VARLEN) property set for option] */
union {
/*
*
* Note: C semantics:
* static initializer of "union" type assume
* the constant on RHS is of the type of the
* first member of the union. So what comes first
* is important.
*/
#define OPDES_DEFSZ_MAX 64
char opdes_def_charbuf[OPDES_DEFSZ_MAX];
} opdes_def;
} opdes_t;
/*
* Flags to set in opdes_acces_{all,priv} fields in opdes_t
*
* OA_R read access
* OA_W write access
* OA_RW read-write access
* OA_X execute access
*
* Note: - semantics "execute" access used for operations excuted using
* option management interface
* - no bits set means this option is not visible. Some options may not
* even be visible to all but priviliged users.
*/
#define OA_R 0x1
#define OA_W 0x2
#define OA_X 0x4
/*
* Utility macros to test permissions needed to compose more
* complex ones. (Only a few really used directly in code).
*/
#define OP_CONFIG (0) /* Network configuration */
/*
* Following macros supply the option and their privilege and
* are used to determine permissions.
*/
#define OA_POLICY_OK(x, c) \
#define OA_POLICY_ONLY_OK(x, c) \
OA_POLICY_ONLY_OK((x), (c)))
#define OA_READ_PERMISSION(x, c) (OA_R_NOPRIV(x) || \
(OA_R_ANYPRIV(x) && OA_POLICY_OK((x), (c))))
#define OA_WRITE_OR_EXECUTE(x, c) (OA_WX_NOPRIV(x) || \
(OA_WX_ANYPRIV(x) && OA_POLICY_OK((x), (c))))
#define OA_READONLY_PERMISSION(x, c) (OA_RONLY_NOPRIV(x) || \
(OA_RONLY_ANYPRIV(x) && OA_POLICY_OK((x), (c))))
#define OA_WRITE_PERMISSION(x, c) (OA_W_NOPRIV(x) || \
(OA_W_ANYPRIV(x) && OA_POLICY_ONLY_OK((x), (c))))
#define OA_EXECUTE_PERMISSION(x, c) (OA_X_NOPRIV(x) || \
(OA_X_ANYPRIV(x) && OA_POLICY_ONLY_OK((x), (c))))
#define OA_NO_PERMISSION(x, c) (OA_MATCHED_PRIV((x), (c)) ? \
((x)->opdes_access_priv == 0) : ((x)->opdes_access_nopriv == 0))
/*
* Other properties set in opdes_props field.
*/
/* i.e. failure to negotiate does not */
/* abort primitive ("ignore" semantics ok) */
/* value, not from static table */
/*
* Structure to represent attributed of option management specific
* to one particular layer of "transport".
*/
typedef t_uscalar_t optlevel_t;
typedef struct optdb_obj {
/* provider or downstream */
/* count of option levels supported */
/* array of option levels supported */
} optdb_obj_t;
/*
* This is used to restart option processing. This goes inside an M_CTL
* which is prepended to the packet. IP may need to become exclusive on
* an ill for setting some options. For dg. IP_ADD_MEMBERSHIP. Since
* there can be more than 1 option packed in an option buffer, we need to
* remember where to restart option processing after resuming from a wait
* for exclusive condition in IP.
*/
typedef struct opt_restart_s {
int or_private; /* currently used by CGTP */
/*
* Values for "optset_context" parameter passed to
* transport specific "setfn()" routines
*/
/*
* Object to represent database of options to search passed to
* {sock,tpi}optcom_req() interface routine to take care of option
* management and associated methods.
*/
extern optdb_obj_t tcp_opt_obj;
extern optdb_obj_t udp_opt_obj;
extern optdb_obj_t ip_opt_obj;
extern uint_t tcp_max_optsize;
extern uint_t udp_max_optsize;
/*
* Function prototypes
*/
cred_t *, optdb_obj_t *, void *, int *);
#endif /* defined(_KERNEL) && defined(__STDC__) */
#ifdef __cplusplus
}
#endif
#endif /* _INET_OPTCOM_H */