diff options
author | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-02-04 23:47:50 +0000 |
---|---|---|
committer | Ryan Thomas McBride <mcbride@cvs.openbsd.org> | 2004-02-04 23:47:50 +0000 |
commit | 76cee6cf3c1cb3ae97985e5f5dac813e1ab04017 (patch) | |
tree | 3aa753beddacbbcf8a4a708e17c379bf7770eefd /usr.sbin/ifstated/ifstated.h | |
parent | f6b5cb8c267b47e74cac5bbb4d402b08c73e06bd (diff) |
Update to ifstated; replace parser, introduce the concept of states,
external tests, and boolean logic. Allows ifstated to handle partial
failures on firewalls that are CARPd to each other.
ok deraadt@
Diffstat (limited to 'usr.sbin/ifstated/ifstated.h')
-rw-r--r-- | usr.sbin/ifstated/ifstated.h | 141 |
1 files changed, 141 insertions, 0 deletions
diff --git a/usr.sbin/ifstated/ifstated.h b/usr.sbin/ifstated/ifstated.h new file mode 100644 index 00000000000..3998fe5afdb --- /dev/null +++ b/usr.sbin/ifstated/ifstated.h @@ -0,0 +1,141 @@ +/* $OpenBSD: ifstated.h,v 1.1 2004/02/04 23:47:49 mcbride Exp $ */ + +/* + * Copyright (c) 2004 Ryan McBride + * 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 ``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 HIS RELATIVES 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 MIND, 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. + */ + +#include <sys/types.h> +#include <sys/queue.h> + + +struct ifsd_expression; +TAILQ_HEAD(ifsd_expression_list, ifsd_expression); + +struct ifsd_ifstate { + TAILQ_ENTRY(ifsd_ifstate) entries; + struct ifsd_expression_list expressions; + int ifstate; +#define IFSD_LINKUNKNOWN 0 /* LINK_STATE_UNKNOWN */ +#define IFSD_LINKDOWN 1 /* LINK_STATE_DOWN */ +#define IFSD_LINKUP 2 /* LINK_STATE_UP */ + int prevstate; + u_int32_t refcount; + u_short ifindex; +}; + +struct ifsd_external { + TAILQ_ENTRY(ifsd_external) entries; + struct event ev; + struct ifsd_expression_list expressions; + char *command; + int prevstatus; + u_int32_t frequency; + u_int32_t refcount; + u_int32_t lastexec; + pid_t pid; +}; + +struct ifsd_action; +TAILQ_HEAD(ifsd_action_list, ifsd_action); + +struct ifsd_action { + TAILQ_ENTRY(ifsd_action) entries; + struct ifsd_action *parent; + union { + char *logmessage; + char *command; + struct ifsd_state *nextstate; + char *statename; + struct { + struct ifsd_action_list actions; + struct ifsd_expression *expression; + u_int8_t ignore_init; + } c; + } act; + u_int32_t type; +#define IFSD_ACTION_LOG 0 +#define IFSD_ACTION_COMMAND 1 +#define IFSD_ACTION_CHANGESTATE 2 +#define IFSD_ACTION_CONDITION 3 +}; + + +struct ifsd_expression { + TAILQ_ENTRY(ifsd_expression) entries; + TAILQ_ENTRY(ifsd_expression) eval; + struct ifsd_expression *parent; + struct ifsd_action *action; + struct ifsd_expression *left; + struct ifsd_expression *right; + union { + struct ifsd_ifstate *ifstate; + struct ifsd_external *external; + } u; + int depth; + u_int32_t type; +#define IFSD_OPER_AND 1 +#define IFSD_OPER_OR 2 +#define IFSD_OPER_NOT 3 +#define IFSD_OPER_EXTERNAL 4 +#define IFSD_OPER_IFSTATE 5 + u_int8_t truth; +}; + +TAILQ_HEAD(ifsd_ifstate_list, ifsd_ifstate); +TAILQ_HEAD(ifsd_external_list, ifsd_external); + +struct ifsd_state { + struct event ev; + struct ifsd_ifstate_list interface_states; + struct ifsd_external_list external_tests; + TAILQ_ENTRY(ifsd_state) entries; + struct ifsd_action *init; + struct ifsd_action *always; + u_int32_t entered; + char *name; +}; + +TAILQ_HEAD(ifsd_state_list, ifsd_state); + +struct ifsd_config { + struct ifsd_state always; + struct ifsd_state_list states; + struct ifsd_state *curstate; + struct ifsd_state *nextstate; + u_int32_t opts; +#define IFSD_OPT_VERBOSE 0x00000001 +#define IFSD_OPT_VERBOSE2 0x00000002 + int maxdepth; + u_int8_t loglevel; +#define IFSD_LOG_NONE 0 +#define IFSD_LOG_QUIET 1 +#define IFSD_LOG_NORMAL 2 +#define IFSD_LOG_VERBOSE 3 +#define IFSD_LOG_DEBUG 4 +}; + +enum { IFSD_EVTIMER_ADD, IFSD_EVTIMER_DEL }; +int parse_config(char *, struct ifsd_config *); +int cmdline_symset(char *); |