2N/A/*
2N/A * CDDL HEADER START
2N/A *
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 *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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 *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _INETSVC_H
2N/A#define _INETSVC_H
2N/A
2N/A#include <libscf.h>
2N/A#include <sys/socket.h>
2N/A#include <libuutil.h>
2N/A#include <rpc/rpc.h>
2N/A
2N/A/*
2N/A * Interfaces shared by usr.lib/inetd and its administrative commands.
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#define PROTO_DELIMITERS " ,"
2N/A
2N/A#define INETD_UDS_PATH _PATH_SYSVOL "/inetd.uds"
2N/A#define INETD_INSTANCE_FMRI "svc:/network/inetd:default"
2N/A
2N/A#define PG_NAME_SERVICE_CONFIG "inetd"
2N/A#define PG_NAME_SERVICE_DEFAULTS "defaults"
2N/A#define PG_NAME_INETCONV "inetconv"
2N/A
2N/A#define PR_SVC_NAME_NAME "name"
2N/A#define PR_SOCK_TYPE_NAME "endpoint_type"
2N/A#define PR_PROTO_NAME "proto"
2N/A#define PR_ISRPC_NAME "isrpc"
2N/A#define PR_RPC_LW_VER_NAME "rpc_low_version"
2N/A#define PR_RPC_HI_VER_NAME "rpc_high_version"
2N/A#define PR_ISWAIT_NAME "wait"
2N/A#define PR_CON_RATE_MAX_NAME "max_con_rate"
2N/A#define PR_CON_RATE_OFFLINE_NAME "con_rate_offline"
2N/A#define PR_BIND_ADDR_NAME "bind_addr"
2N/A#define PR_BIND_FAIL_MAX_NAME "bind_fail_max"
2N/A#define PR_BIND_FAIL_INTVL_NAME "bind_fail_interval"
2N/A#define PR_MAX_COPIES_NAME "max_copies"
2N/A#define PR_MAX_FAIL_RATE_CNT_NAME "failrate_cnt"
2N/A#define PR_MAX_FAIL_RATE_INTVL_NAME "failrate_interval"
2N/A#define PR_INHERIT_ENV_NAME "inherit_env"
2N/A#define PR_DO_TCP_WRAPPERS_NAME "tcp_wrappers"
2N/A#define PR_DO_TCP_TRACE_NAME "tcp_trace"
2N/A#define PR_DO_TCP_KEEPALIVE_NAME "tcp_keepalive"
2N/A#define PR_AUTO_CONVERTED_NAME "converted"
2N/A#define PR_VERSION_NAME "version"
2N/A#define PR_SOURCE_LINE_NAME "source_line"
2N/A#define PR_CONNECTION_BACKLOG_NAME "connection_backlog"
2N/A
2N/A/*
2N/A * Provide index values for inetd property locations in the property table, for
2N/A * convenience. If the array is modified, these values MUST be updated.
2N/A */
2N/A#define PT_SVC_NAME_INDEX 0
2N/A#define PT_SOCK_TYPE_INDEX 1
2N/A#define PT_PROTO_INDEX 2
2N/A#define PT_ISRPC_INDEX 3
2N/A#define PT_RPC_LW_VER_INDEX 4
2N/A#define PT_RPC_HI_VER_INDEX 5
2N/A#define PT_ISWAIT_INDEX 6
2N/A#define PT_EXEC_INDEX 7
2N/A#define PT_ARG0_INDEX 8
2N/A#define PT_USER_INDEX 9
2N/A#define PT_BIND_ADDR_INDEX 10
2N/A#define PT_BIND_FAIL_MAX_INDEX 11
2N/A#define PT_BIND_FAIL_INTVL_INDEX 12
2N/A#define PT_CON_RATE_MAX_INDEX 13
2N/A#define PT_MAX_COPIES_INDEX 14
2N/A#define PT_CON_RATE_OFFLINE_INDEX 15
2N/A#define PT_MAX_FAIL_RATE_CNT_INDEX 16
2N/A#define PT_MAX_FAIL_RATE_INTVL_INDEX 17
2N/A#define PT_INHERIT_ENV_INDEX 18
2N/A#define PT_DO_TCP_TRACE_INDEX 19
2N/A#define PT_DO_TCP_WRAPPERS_INDEX 20
2N/A#define PT_CONNECTION_BACKLOG_INDEX 21
2N/A#define PT_DO_TCP_KEEPALIVE_INDEX 22
2N/A
2N/A/*
2N/A * Names of method properties.
2N/A */
2N/A#define PR_EXEC_NAME "exec"
2N/A#define PR_ARG0_NAME "arg0"
2N/A#define PR_USER_NAME "user"
2N/A
2N/A/*
2N/A * Method property group names.
2N/A */
2N/A#define START_METHOD_NAME "inetd_start"
2N/A#define OFFLINE_METHOD_NAME "inetd_offline"
2N/A#define ONLINE_METHOD_NAME "inetd_online"
2N/A#define DISABLE_METHOD_NAME "inetd_disable"
2N/A#define REFRESH_METHOD_NAME "inetd_refresh"
2N/A
2N/A/*
2N/A * Valid socket type values.
2N/A */
2N/A#define SOCKTYPE_STREAM_STR "stream"
2N/A#define SOCKTYPE_DGRAM_STR "dgram"
2N/A#define SOCKTYPE_RAW_STR "raw"
2N/A#define SOCKTYPE_SEQPKT_STR "seqpacket"
2N/A#define SOCKTYPE_TLI_STR "tli"
2N/A#define SOCKTYPE_XTI_STR "xti"
2N/A
2N/A/*
2N/A * Valid socket based service protocols.
2N/A */
2N/A#define SOCKET_PROTO_SCTP6 "sctp6"
2N/A#define SOCKET_PROTO_SCTP6_ONLY "sctp6only"
2N/A#define SOCKET_PROTO_SCTP "sctp"
2N/A#define SOCKET_PROTO_TCP6 "tcp6"
2N/A#define SOCKET_PROTO_TCP6_ONLY "tcp6only"
2N/A#define SOCKET_PROTO_TCP "tcp"
2N/A#define SOCKET_PROTO_UDP6 "udp6"
2N/A#define SOCKET_PROTO_UDP6_ONLY "udp6only"
2N/A#define SOCKET_PROTO_UDP "udp"
2N/A
2N/A/*
2N/A * Return codes for the methods of inetd managed services.
2N/A */
2N/A#define IMRET_SUCCESS 0
2N/A/*
2N/A * Set this value above the range used by unix commands so theres minimal chance
2N/A * of a non-GL cognizant command accidentally returning this code.
2N/A */
2N/A#define IMRET_FAILURE 100
2N/A
2N/A/*
2N/A * Macros for differentiating between sockaddr_in & sockaddr_in6 when
2N/A * dealing with the contents of a sockaddr_storage structure.
2N/A * These differentiate based on the contents of ss_family (either AF_INET
2N/A * or AF_INET6).
2N/A */
2N/A#define SS_ADDRLEN(s) ((s).ss_family == AF_INET ? \
2N/A sizeof (struct sockaddr_in) : sizeof (struct sockaddr_in6))
2N/A#define SS_PORT(s) ((s).ss_family == AF_INET ? \
2N/A ((struct sockaddr_in *)&(s))->sin_port : \
2N/A ((struct sockaddr_in6 *)&(s))->sin6_port)
2N/A#define SS_SETPORT(s, port) ((s).ss_family == AF_INET ? \
2N/A (((struct sockaddr_in *)&(s))->sin_port = port) : \
2N/A (((struct sockaddr_in6 *)&(s))->sin6_port = port))
2N/A#define SS_SINADDR(s) ((s).ss_family == AF_INET ? \
2N/A ((void *) &(((struct sockaddr_in *)&(s))->sin_addr)) : \
2N/A ((void *) &(((struct sockaddr_in6 *)&(s))->sin6_addr)))
2N/A
2N/A/* Collection of information pertaining to rpc based services. */
2N/Atypedef struct {
2N/A struct netbuf netbuf;
2N/A int prognum;
2N/A int lowver;
2N/A int highver;
2N/A char *netid;
2N/A boolean_t is_loopback;
2N/A} rpc_info_t;
2N/A
2N/A/*
2N/A * Structure containing the common elements of both the socket_info_t and the
2N/A * tlx_info_t structures.
2N/A */
2N/Atypedef struct {
2N/A /* proto string causing this entry */
2N/A char *proto;
2N/A
2N/A /* network fd we're listening on; -1 if not listening */
2N/A int listen_fd;
2N/A
2N/A /* associate RPC info structure, if any (NULL if none). */
2N/A rpc_info_t *ri;
2N/A
2N/A uu_list_node_t link;
2N/A
2N/A /* should this fd have the v6 socket option set? */
2N/A boolean_t v6only;
2N/A} proto_info_t;
2N/A
2N/A
2N/A/* TLI/XTI connection indication list construct. */
2N/Atypedef struct {
2N/A struct t_call *call;
2N/A uu_list_node_t link;
2N/A} tlx_conn_ind_t;
2N/A
2N/A/* Collection of information pertaining to tli/xti based services. */
2N/Atypedef struct {
2N/A /* protocol information common to tlx and socket based services */
2N/A proto_info_t pr_info;
2N/A
2N/A /* address we're bound to */
2N/A struct netbuf local_addr;
2N/A
2N/A /* device name supplied to t_open() */
2N/A char *dev_name;
2N/A
2N/A /* queue of pending connection indications */
2N/A uu_list_t *conn_ind_queue;
2N/A} tlx_info_t;
2N/A
2N/A/* Collection of information pertaining to socket based services. */
2N/Atypedef struct {
2N/A /* protocol information common to tlx and socket based services */
2N/A proto_info_t pr_info;
2N/A
2N/A /* address we're bound to */
2N/A struct sockaddr_storage local_addr;
2N/A
2N/A /* SOCK_STREAM/SOCK_DGRAM/SOCK_RAW/SOCK_SEQPACKET */
2N/A int type;
2N/A
2N/A int protocol;
2N/A} socket_info_t;
2N/A
2N/A/* Basic configuration properties for an instance. */
2N/Atypedef struct {
2N/A /* getservbyname() recognized service name */
2N/A char *svc_name;
2N/A
2N/A /* TLI/XTI type service ? */
2N/A boolean_t istlx;
2N/A
2N/A /* list of protocols and associated info */
2N/A uu_list_t *proto_list;
2N/A
2N/A /* wait type service ? */
2N/A boolean_t iswait;
2N/A
2N/A /*
2N/A * Properties from here onwards all have default values in the inetd
2N/A * service instance.
2N/A */
2N/A
2N/A boolean_t do_tcp_wrappers;
2N/A boolean_t do_tcp_trace;
2N/A boolean_t do_tcp_keepalive;
2N/A
2N/A /* inherit inetd's environment, or take an empty one */
2N/A boolean_t inherit_env;
2N/A
2N/A /* failure rate configuration */
2N/A int64_t wait_fail_cnt;
2N/A int wait_fail_interval;
2N/A
2N/A /* maximum concurrent copies limit */
2N/A int64_t max_copies;
2N/A
2N/A /* connection rate configuration */
2N/A int conn_rate_offline;
2N/A int64_t conn_rate_max;
2N/A
2N/A /* bind failure retries configuration */
2N/A int bind_fail_interval;
2N/A int64_t bind_fail_max;
2N/A
2N/A /* specific address to bind instance to */
2N/A char *bind_addr;
2N/A
2N/A /* connection backlog queue size */
2N/A int64_t conn_backlog;
2N/A} basic_cfg_t;
2N/A
2N/Atypedef enum uds_request {
2N/A UR_REFRESH_INETD,
2N/A UR_STOP_INETD
2N/A} uds_request_t;
2N/A
2N/Atypedef union {
2N/A int64_t iv_int;
2N/A uint64_t iv_cnt;
2N/A boolean_t iv_boolean;
2N/A char *iv_string;
2N/A char **iv_string_list;
2N/A} inetd_value_t;
2N/A
2N/Atypedef enum {
2N/A IVE_VALID,
2N/A IVE_UNSET,
2N/A IVE_INVALID
2N/A} iv_error_t;
2N/A
2N/A/*
2N/A * Operations on these types (like valid_default_prop()) need to be modified
2N/A * when this list is changed.
2N/A */
2N/Atypedef enum {
2N/A INET_TYPE_INVALID = 0,
2N/A
2N/A INET_TYPE_BOOLEAN,
2N/A INET_TYPE_COUNT,
2N/A INET_TYPE_INTEGER,
2N/A INET_TYPE_STRING,
2N/A INET_TYPE_STRING_LIST
2N/A} inet_type_t;
2N/A
2N/Atypedef struct {
2N/A const char *ip_name;
2N/A const char *ip_pg;
2N/A inet_type_t ip_type;
2N/A boolean_t ip_default;
2N/A iv_error_t ip_error;
2N/A inetd_value_t ip_value;
2N/A boolean_t from_inetd;
2N/A} inetd_prop_t;
2N/A
2N/Ainetd_prop_t *get_prop_table(size_t *);
2N/Ainetd_prop_t *find_prop(const inetd_prop_t *, const char *, inet_type_t);
2N/Aint64_t get_prop_value_int(const inetd_prop_t *, const char *);
2N/Auint64_t get_prop_value_count(const inetd_prop_t *, const char *);
2N/Aboolean_t get_prop_value_boolean(const inetd_prop_t *, const char *);
2N/Aconst char *get_prop_value_string(const inetd_prop_t *, const char *);
2N/Aconst char **get_prop_value_string_list(const inetd_prop_t *, const char *);
2N/Avoid put_prop_value_int(inetd_prop_t *, const char *, int64_t);
2N/Avoid put_prop_value_count(inetd_prop_t *, const char *, uint64_t);
2N/Avoid put_prop_value_boolean(inetd_prop_t *, const char *, boolean_t);
2N/Aboolean_t put_prop_value_string(inetd_prop_t *, const char *, const char *);
2N/Avoid put_prop_value_string_list(inetd_prop_t *, const char *, char **);
2N/Aboolean_t valid_props(inetd_prop_t *, const char *fmri, basic_cfg_t **,
2N/A uu_list_pool_t *, uu_list_pool_t *);
2N/Avoid destroy_basic_cfg(basic_cfg_t *);
2N/Avoid destroy_proto_list(basic_cfg_t *);
2N/Aboolean_t valid_default_prop(const char *, const void *);
2N/Ascf_error_t read_prop(scf_handle_t *, inetd_prop_t *, int, const char *,
2N/A const char *);
2N/Ainetd_prop_t *read_instance_props(scf_handle_t *, const char *, size_t *,
2N/A scf_error_t *);
2N/Ainetd_prop_t *read_default_props(scf_handle_t *, size_t *, scf_error_t *);
2N/Avoid free_instance_props(inetd_prop_t *);
2N/Aint connect_to_inetd(void);
2N/Aint refresh_inetd(void);
2N/Aint get_sock_type_id(const char *);
2N/Aint get_rpc_prognum(const char *);
2N/Aint calculate_hash(const char *, char **);
2N/Ascf_error_t retrieve_inetd_hash(char **);
2N/Ascf_error_t store_inetd_hash(const char *);
2N/Aconst char *inet_ntop_native(int, const void *, char *, size_t);
2N/Avoid setproctitle(const char *, int, char **);
2N/Avoid dg_template(
2N/A void (*)(int, const struct sockaddr *, int, const void *, size_t), int,
2N/A void *, size_t);
2N/Aint safe_write(int, const void *, size_t);
2N/Aint safe_sendto(int, const void *, size_t, int, const struct sockaddr *, int);
2N/Achar **get_protos(const char *);
2N/Achar **get_netids(char *);
2N/Avoid destroy_strings(char **);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _INETSVC_H */