File: [local] / src / usr.sbin / ifstated / ifstated.h (download)
Revision 1.4, Wed Mar 10 00:13:38 2004 UTC (20 years, 2 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_4_2_BASE, OPENBSD_4_2, OPENBSD_4_1_BASE, OPENBSD_4_1, OPENBSD_4_0_BASE, OPENBSD_4_0, OPENBSD_3_9_BASE, OPENBSD_3_9, OPENBSD_3_8_BASE, OPENBSD_3_8, OPENBSD_3_7_BASE, OPENBSD_3_7, OPENBSD_3_6_BASE, OPENBSD_3_6, OPENBSD_3_5_BASE, OPENBSD_3_5 Changes since 1.3: +3 -3 lines
spacing
|
/* $OpenBSD: ifstated.h,v 1.4 2004/03/10 00:13:38 deraadt 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
#define IFSD_OPT_NOACTION 0x00000004
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 };
struct ifsd_config *parse_config(char *, int);
int cmdline_symset(char *);
void clear_config(struct ifsd_config *);