inetsvc.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _INETSVC_H
#define _INETSVC_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <libscf.h>
#include <libuutil.h>
/*
*/
#ifdef __cplusplus
extern "C" {
#endif
#define PROTO_DELIMITERS " ,"
#define INETD_UDS_PATH "/var/run/.inetd.uds"
#define INETD_INSTANCE_FMRI "svc:/network/inetd:default"
#define PG_NAME_SERVICE_CONFIG "inetd"
#define PG_NAME_SERVICE_DEFAULTS "defaults"
#define PG_NAME_INETCONV "inetconv"
#define PR_SVC_NAME_NAME "name"
#define PR_SOCK_TYPE_NAME "endpoint_type"
#define PR_PROTO_NAME "proto"
#define PR_ISRPC_NAME "isrpc"
#define PR_RPC_LW_VER_NAME "rpc_low_version"
#define PR_RPC_HI_VER_NAME "rpc_high_version"
#define PR_ISWAIT_NAME "wait"
#define PR_CON_RATE_MAX_NAME "max_con_rate"
#define PR_CON_RATE_OFFLINE_NAME "con_rate_offline"
#define PR_BIND_ADDR_NAME "bind_addr"
#define PR_BIND_FAIL_MAX_NAME "bind_fail_max"
#define PR_BIND_FAIL_INTVL_NAME "bind_fail_interval"
#define PR_MAX_COPIES_NAME "max_copies"
#define PR_MAX_FAIL_RATE_CNT_NAME "failrate_cnt"
#define PR_MAX_FAIL_RATE_INTVL_NAME "failrate_interval"
#define PR_INHERIT_ENV_NAME "inherit_env"
#define PR_DO_TCP_WRAPPERS_NAME "tcp_wrappers"
#define PR_DO_TCP_TRACE_NAME "tcp_trace"
#define PR_AUTO_CONVERTED_NAME "converted"
#define PR_VERSION_NAME "version"
#define PR_SOURCE_LINE_NAME "source_line"
/*
* Provide index values for inetd property locations in the property table, for
* convenience. If the array is modified, these values MUST be updated.
*/
#define PT_SVC_NAME_INDEX 0
#define PT_SOCK_TYPE_INDEX 1
#define PT_PROTO_INDEX 2
#define PT_ISRPC_INDEX 3
#define PT_RPC_LW_VER_INDEX 4
#define PT_RPC_HI_VER_INDEX 5
#define PT_ISWAIT_INDEX 6
#define PT_EXEC_INDEX 7
#define PT_ARG0_INDEX 8
#define PT_USER_INDEX 9
#define PT_BIND_ADDR_INDEX 10
#define PT_BIND_FAIL_MAX_INDEX 11
#define PT_BIND_FAIL_INTVL_INDEX 12
#define PT_CON_RATE_MAX_INDEX 13
#define PT_MAX_COPIES_INDEX 14
#define PT_CON_RATE_OFFLINE_INDEX 15
#define PT_MAX_FAIL_RATE_CNT_INDEX 16
#define PT_MAX_FAIL_RATE_INTVL_INDEX 17
#define PT_INHERIT_ENV_INDEX 18
#define PT_DO_TCP_TRACE_INDEX 19
#define PT_DO_TCP_WRAPPERS_INDEX 20
/*
* Names of method properties.
*/
#define PR_EXEC_NAME "exec"
#define PR_ARG0_NAME "arg0"
#define PR_USER_NAME "user"
/*
* Method property group names.
*/
#define START_METHOD_NAME "inetd_start"
#define OFFLINE_METHOD_NAME "inetd_offline"
#define ONLINE_METHOD_NAME "inetd_online"
#define DISABLE_METHOD_NAME "inetd_disable"
#define REFRESH_METHOD_NAME "inetd_refresh"
/*
* Valid socket type values.
*/
#define SOCKTYPE_STREAM_STR "stream"
#define SOCKTYPE_DGRAM_STR "dgram"
#define SOCKTYPE_RAW_STR "raw"
#define SOCKTYPE_SEQPKT_STR "seqpacket"
#define SOCKTYPE_TLI_STR "tli"
#define SOCKTYPE_XTI_STR "xti"
/*
* Valid socket based service protocols.
*/
#define SOCKET_PROTO_SCTP6 "sctp6"
#define SOCKET_PROTO_SCTP6_ONLY "sctp6only"
#define SOCKET_PROTO_SCTP "sctp"
#define SOCKET_PROTO_TCP6 "tcp6"
#define SOCKET_PROTO_TCP6_ONLY "tcp6only"
#define SOCKET_PROTO_TCP "tcp"
#define SOCKET_PROTO_UDP6 "udp6"
#define SOCKET_PROTO_UDP6_ONLY "udp6only"
#define SOCKET_PROTO_UDP "udp"
/*
* Return codes for the methods of inetd managed services.
*/
#define IMRET_SUCCESS 0
/*
* Set this value above the range used by unix commands so theres minimal chance
* of a non-GL cognizant command accidentally returning this code.
*/
#define IMRET_FAILURE 100
/*
* Macros for differentiating between sockaddr_in & sockaddr_in6 when
* dealing with the contents of a sockaddr_storage structure.
* These differentiate based on the contents of ss_family (either AF_INET
* or AF_INET6).
*/
sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6))
((struct sockaddr_in *)&(s))->sin_port : \
((struct sockaddr_in6 *)&(s))->sin6_port)
((void *) &(((struct sockaddr_in *)&(s))->sin_addr)) : \
((void *) &(((struct sockaddr_in6 *)&(s))->sin6_addr)))
/* Collection of information pertaining to rpc based services. */
typedef struct {
int prognum;
int lowver;
int highver;
char *netid;
} rpc_info_t;
/*
* Structure containing the common elements of both the socket_info_t and the
* tlx_info_t structures.
*/
typedef struct {
/* proto string causing this entry */
char *proto;
/* network fd we're listening on; -1 if not listening */
int listen_fd;
/* associate RPC info structure, if any (NULL if none). */
rpc_info_t *ri;
/* should this fd have the v6 socket option set? */
} proto_info_t;
typedef struct {
typedef struct {
/* protocol information common to tlx and socket based services */
/* address we're bound to */
struct netbuf local_addr;
/* device name supplied to t_open() */
char *dev_name;
/* queue of pending connection indications */
} tlx_info_t;
/* Collection of information pertaining to socket based services. */
typedef struct {
/* protocol information common to tlx and socket based services */
/* address we're bound to */
struct sockaddr_storage local_addr;
int type;
int protocol;
/* Basic configuration properties for an instance. */
typedef struct {
/* getservbyname() recognized service name */
char *svc_name;
/* list of protocols and associated info */
/* wait type service ? */
/*
* Properties from here onwards all have default values in the inetd
* service instance.
*/
/* inherit inetd's environment, or take an empty one */
/* failure rate configuration */
int wait_fail_interval;
/* maximum concurrent copies limit */
/* connection rate configuration */
int conn_rate_offline;
/* bind failure retries configuration */
int bind_fail_interval;
/* specific address to bind instance to */
char *bind_addr;
} basic_cfg_t;
typedef enum uds_request {
typedef union {
char *iv_astring;
char **iv_proto_list;
typedef enum {
} iv_error_t;
typedef struct {
char *ip_name;
char *ip_pg;
} inetd_prop_t;
void *get_prop_value(const inetd_prop_t *, char *);
int put_prop_value(inetd_prop_t *, char *, void *);
uu_list_pool_t *, uu_list_pool_t *);
void destroy_basic_cfg(basic_cfg_t *);
void destroy_proto_list(basic_cfg_t *);
boolean_t valid_default_prop(char *, void *);
const char *);
scf_error_t *);
void free_instance_props(inetd_prop_t *);
int connect_to_inetd(void);
int refresh_inetd(void);
int get_sock_type_id(const char *);
int get_rpc_prognum(const char *);
int calculate_hash(const char *, char **);
scf_error_t retrieve_inetd_hash(char **);
scf_error_t store_inetd_hash(const char *);
const char *inet_ntop_native(int, const void *, char *, size_t);
void setproctitle(const char *, int, char **);
void dg_template(
void *, size_t);
int safe_write(int, const void *, size_t);
char **get_protos(const char *);
char **get_netids(char *);
void destroy_strings(char **);
#ifdef __cplusplus
}
#endif
#endif /* _INETSVC_H */