/*-
 * Copyright (c) 2003-2004 Andrey Simonenko
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *   @(#)$Id: ipa_autorules.h,v 1.1.4.1 2007/02/17 09:21:54 simon Exp $
 */

#ifndef IPA_AUTORULES_H
#define IPA_AUTORULES_H

extern int	create_rule(const char *, u_int, const char *, const char *);
extern int	delete_rule(const char *, u_int);

#ifdef WITH_AUTORULES

#define AUTORULE_NSIZE	10
#define AUTORULE_NALLOC	10

/*
 * autorule{} section.
 */
struct autorule {
	TAILQ_ENTRY(autorule) queue;	/* Active/inactive autorules queue. */
	STAILQ_ENTRY(autorule) link;	/* For list building. */
	char		*arule_name;	/* Name of this autorule. */
	u_int		aruleno;	/* Order number of this autorule. */

	const struct tevent *update_tevent; /* autorule { update_time } */
	const struct tevent *append_tevent; /* autorule { append_time } */

	const struct worktime *worktime;/* autorule { worktime } */
	const struct worktime *worktime_rule; /* autorule { worktime_rule } */
	int		is_active;	/* [IN]ACTIVE_FLAG */

	const struct ac_list *ac_list;	/* autorule { ac_list } */
	const struct db_list *db_list;	/* autorule { db_list } */

	int		debug_exec;	/* autorule { debug_exec } */

	struct cmds_rule rc[2];		/* autorule { startup|shutdown {}} */

#ifdef WITH_LIMITS
	int		debug_limit;	/* autorule { debug_limit } */
	int		debug_limit_init; /* autorule { debug_limit_init } */
	struct limits_list limits;	/* autorule { limit {}} */
#endif

#ifdef WITH_THRESHOLDS
	int		debug_threshold;/* autorule { debug_threshold } */
	int		debug_threshold_init; /* autorule { debug_threshold_init } */
	struct thresholds_list thresholds; /* autorule { threshold {}} */
#endif

	u_int		check_sec;	/* Time when to check autorule. */
	u_int		inactive_sec;	/* Time when to set autorule inactive. */

#ifdef CTL_CHECK_CREDS
	const struct ctl_acl_class *ctl_rule_acl; /* autorule { ctl_rule_acl } */
#endif
};

/* List of all autorules. */
STAILQ_HEAD(autorules_list, autorule);

/* Active/inactive autorules queue. */
TAILQ_HEAD(autorules_queue, autorule);

extern int	debug_autorule;

extern u_int	autorules_active_check_sec;
extern u_int	autorules_inactive_check_sec;

extern ipa_marray *rules_ptr_marray;
extern ipa_marray *autorules_marray;
extern struct autorule *autorules;
extern struct autorules_list autorules_list;

extern int	init_autorules(void);
extern int	deinit_autorules(void);
extern int	deinit_dyn_rule(struct rule *);

extern int	autorules_newday(void);
extern int	check_active_autorules(void);
extern int	check_inactive_autorules(void);

extern void	init_cmds_in_autorule(struct autorule *);
extern void	set_sync_exec_in_autorule(struct autorule *);

#endif /* WITH_AUTORULES */

extern u_int	nautorules;
extern u_int	ndynrules;

#endif /* !IPA_AUTORULES_H */


syntax highlighted by Code2HTML, v. 0.9.1