syslogd.h revision 0ea5e3a571e3da934507bdd32924d11659c70704
/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 1983,1984,1985,1986,1987,1988,1989 AT&T.
* All rights reserved.
*
* University Copyright- Copyright (c) 1982, 1986, 1988
* The Regents of the University of California
* All Rights Reserved
*
* University Acknowledgment- Portions of this document are derived from
* software developed by the University of California, Berkeley, and its
* contributors.
*/
#ifndef _SYSLOGD_H
#define _SYSLOGD_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Various constants & tunable values for syslogd
*/
#define DEBUGFILE "/var/adm/syslog.debug"
/*
* host_list_t structure contains a list of hostnames for a given address
*/
typedef struct host_list {
int hl_cnt; /* number of hl_hosts entries */
char **hl_hosts; /* hostnames */
int hl_refcnt; /* reference count */
} host_list_t;
/*
* host_info_t structure contains address information for a host
* from which we received a message.
*/
typedef struct host_info {
} host_info_t;
/*
* statistics structure attached to each filed for debugging
*/
typedef struct filed_stats {
int flag; /* flag word */
int total; /* total messages logged */
int dups; /* duplicate messages */
int cantfwd; /* can't forward */
int errs; /* write errors */
/*
* internal representation of a log message. Includes all routing & bookkeeping
* information for the message. created in the system & network poll routines,
* and passed among the various processing threads as necessary
*/
typedef struct log_message {
int refcnt; /* message reference count */
int pri; /* message priority */
int flags; /* misc flags */
void *ptr; /* for anonymous use */
/*
* format of a saved message. For each active file we are logging
* we save the last message and the current message, to make it
* possible to suppress duplicates on a per file basis. Earlier
* syslogd's used a global buffer for duplicate checking, so
* strict per file duplicate suppression was not always possible.
*/
typedef struct saved_msg {
int pri;
int flags;
/*
* Flags to logmsg().
*/
/*
* This structure represents the files that will have log
* copies printed. There is one instance of this for each
* file that is being logged to.
*/
struct filed {
int f_queue_count; /* count of messages on the queue */
int f_prev_queue_count; /* prev count of msgs on the queue */
short f_type; /* entry type, see below */
short f_orig_type; /* save entry type */
int f_file; /* file descriptor */
int f_msgflag; /* message disposition */
int f_prevcount; /* message repeat count */
union {
struct {
} f_forw; /* forwarding address */
} f_un;
};
/* values for f_type */
#define F_UNUSED 0 /* unused entry */
/*
* values for logit routine
*/
#define CURRENT 0 /* print current message */
/*
* values for f_msgflag
*/
/*
* code translation struct for use in processing config file
*/
struct code {
char *c_name;
int c_val;
};
/*
* structure describing a message to be sent to the wall thread.
* the thread id and attributes are stored in the structure
* passed to the thread, and the thread is created detached.
*/
typedef struct wall_device {
} walldev_t;
/*
* hostname caching struct to reduce hostname name lookup.
*/
struct hostname_cache {
struct hostname_cache *next;
host_list_t *h;
};
#define DEF_HNC_SIZE 2037
#define MAX_BUCKETS 30
/*
* function prototypes
*/
static void usage(void);
static void untty(void);
static void set_flush_msg(struct filed *f);
static void init(void);
static void conf_init(void);
static void getnets(void);
static void bindnet(void);
static int amiloghost(void);
static void prepare_sys_poll(void);
static void getkmsg(int);
static log_message_t *new_msg(void);
static void freehl(host_list_t *h);
static int filed_init(struct filed *h);
static void *writetodev(void *ap);
static int shutdown_msg(void);
static char *alloc_stacks(int);
static void dealloc_stacks(int);
static int checkm4(void);
static void filed_destroy(struct filed *f);
static void open_door(void);
static void close_door(void);
static void delete_doorfiles(void);
static void logerror_format(const char *, char *, va_list);
static int logerror_to_console(int, const char *);
static void properties(void);
static void shutdown_input(void);
static void *hostname_lookup(void *);
static void reconfigure(void);
static void disable_errorlog(void);
static void enable_errorlog(void);
static void hnc_init(int);
struct netconfig *, int *);
static void hnc_register(struct netbuf *,
struct netconfig *, host_list_t *, int);
static void hnc_unreg(struct hostname_cache **);
#ifdef __cplusplus
}
#endif
#endif /* _SYSLOGD_H */