#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
#define IFSD_LINKDOWN 1
#define IFSD_LINKUP 2
int prevstate;
u_int32_t refcount;
char ifname[IFNAMSIZ];
};
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;
time_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 *command;
struct ifsd_state *nextstate;
char *statename;
struct {
struct ifsd_action_list actions;
struct ifsd_expression *expression;
} c;
} act;
u_int32_t type;
#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 *body;
time_t entered;
char *name;
};
TAILQ_HEAD(ifsd_state_list, ifsd_state);
struct ifsd_config {
struct ifsd_state initstate;
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;
};
enum { IFSD_EVTIMER_ADD, IFSD_EVTIMER_DEL };
struct ifsd_config *parse_config(char *, int);
int cmdline_symset(char *);
void clear_config(struct ifsd_config *);