inetd_impl.h revision 870ad75a2b67a92c3449d93b4fef8a0baa982b4a
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER START
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The contents of this file are subject to the terms of the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Common Development and Distribution License (the "License").
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * You may not use this file except in compliance with the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * See the License for the specific language governing permissions
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * and limitations under the License.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * When distributing Covered Code, include this CDDL HEADER in each
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * If applicable, add the following below this CDDL HEADER, with the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * fields enclosed by brackets "[]" replaced with your own identifying
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * information: Portions Copyright [yyyy] [name of copyright owner]
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * CDDL HEADER END
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
63b1987d5d7387bda49397c0f3f063b49651a5bcQiyan Sun - Sun Microsystems - San Diego United States * Use is subject to license terms.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Header file containing inetd's shared types/data structures and
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * function declarations.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern "C" {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Number of consecutive retries of a repository operation that failed due
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * to a broken connection performed before giving up and failing.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* retryable SMF method error */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* inetd's syslog ident string */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Is this instance currently executing a method ? */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#define INST_IN_TRANSITION(i) ((i)->next_istate != IIS_NONE)
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Names of properties that inetd uses to store instance state. */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Name of the property group that holds debug flag */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Name of the property which holds the debug flag value */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Instance states used internal to svc.inetd.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * NOTE: The states table in cmd/cmd-inetd/inetd/inetd.c relies on the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * ordering of this enumeration, so take care if modifying it.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef enum {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * inetd's instance methods.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * NOTE: The methods table in cmd/cmd-inetd/inetd/util.c relies on the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * ordering of this enumeration, so take care if modifying it.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef enum {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Collection of information pertaining to a method */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef struct {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Structure returned from wordexp(3c) that contains an expansion of the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * exec property into a form suitable for exec(2).
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Copy of the first argument of the above wordexp_t structure in the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * event that an alternate arg0 is provided, and we replace the first
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * argument with the alternate arg0. This is necessary so the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * contents of the wordexp_t structure can be returned to their
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * original form as returned from wordexp(3c), which is a requirement
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * for calling wordfree(3c), wordexp()'s associated cleanup routine.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* time a method can run for before being considered broken */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef struct {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Structure used to construct a list of int64_t's and their associated
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * scf values. Used to store lists of process ids, internal states, and to
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * store the associated scf value used when writing the values back to the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * repository.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef struct {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Structure containing the state and configuration of a service instance. */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef struct {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* fd we're going to take a connection on */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* number of copies of this instance active */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* connection rate counters */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* failure rate counters */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* bind failure count */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* pids of currently running methods */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* ctids of currently running start methods */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* remote address, used for TCP tracing */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* repository compatible versions of the above 2 states */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Current instance configuration resulting from its repository
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * configuration.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Soon to be applied instance configuration. This configuration was
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * read during a refresh when this instance was online, and the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * instance needed taking offline for this configuration to be applied.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * The instance is currently on its way offline, and this configuration
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * will become the current configuration when it arrives there.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* current pending conrate-offline/method timer; -1 if none pending */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* current pending bind retry timer; -1 if none pending */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Flags that assist in the fanout of an instance arriving in the
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * offline state on-route to some other state.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * Event waiting to be processed. RESTARTER_EVENT_TYPE_INVALID is used
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs * to mean no event waiting.
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs /* link to next instance in list */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* Structure used to store information pertaining to instance method types. */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qstypedef struct {
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs const char *name;
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void msg_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void msg_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* PRINTFLIKE1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void debug_msg(const char *, ...);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* PRINTFLIKE1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void error_msg(const char *, ...);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs/* PRINTFLIKE1 */
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void warn_msg(const char *, ...);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void poll_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void clear_pollfd(int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void enable_blocking(int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void disable_blocking(int);
fe930412c257f961ae67039de3b164b83717976aqsextern rpc_info_t *create_rpc_info(const char *, const char *, const char *,
fe930412c257f961ae67039de3b164b83717976aqs int, int);
fe930412c257f961ae67039de3b164b83717976aqsextern boolean_t rpc_info_equal(const rpc_info_t *, const rpc_info_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int register_rpc_service(const char *, const rpc_info_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void unregister_rpc_service(const char *, const rpc_info_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int create_bound_endpoint(const instance_t *, tlx_info_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int tlx_accept(const char *, tlx_info_t *, struct sockaddr_storage *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void tlx_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int tlx_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern boolean_t tlx_info_equal(const tlx_info_t *, const tlx_info_t *,
fe930412c257f961ae67039de3b164b83717976aqsextern int config_init(void);
fe930412c257f961ae67039de3b164b83717976aqsextern void config_fini(void);
fe930412c257f961ae67039de3b164b83717976aqsextern boolean_t socket_info_equal(const socket_info_t *, const socket_info_t *,
fe930412c257f961ae67039de3b164b83717976aqsextern struct method_context *read_method_context(const char *, const char *,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs const char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern boolean_t bind_config_equal(const basic_cfg_t *, const basic_cfg_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void refresh_debug_flag(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void repval_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int repval_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern scf_error_t store_rep_vals(uu_list_t *, const char *, const char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern scf_error_t retrieve_rep_vals(uu_list_t *, const char *, const char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int add_remove_contract(instance_t *, boolean_t, ctid_t);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int iterate_repository_contracts(instance_t *, int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int contract_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void contract_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsint contract_prefork(const char *, int);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void remove_method_ids(instance_t *, pid_t, ctid_t, instance_method_t);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qschar **set_smf_env(struct method_context *, instance_t *, const char *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int register_method(instance_t *, pid_t, ctid_t cid, instance_method_t,
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern int method_init(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void method_fini(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void process_terminated_methods(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void unregister_instance_methods(const instance_t *);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qsextern void method_preexec(void);
3dec9fcdd56adf1b4a563137b4915c8f2d83b881qs#endif /* _INETD_IMPL_H */