-/* $OpenBSD: ifstated.c,v 1.47 2017/07/02 14:28:45 benno Exp $ */
+/* $OpenBSD: ifstated.c,v 1.48 2017/07/02 15:28:26 benno Exp $ */
/*
* Copyright (c) 2004 Marco Pfatschbacher <mpf@openbsd.org>
if (conf != NULL)
clear_config(conf);
conf = newconf;
- conf->always.entered = time(NULL);
+ conf->initstate.entered = time(NULL);
fetch_state();
- external_evtimer_setup(&conf->always, IFSD_EVTIMER_ADD);
- adjust_external_expressions(&conf->always);
- eval_state(&conf->always);
+ external_evtimer_setup(&conf->initstate, IFSD_EVTIMER_ADD);
+ adjust_external_expressions(&conf->initstate);
+ eval_state(&conf->initstate);
if (conf->curstate != NULL) {
log_info("initial state: %s", conf->curstate->name);
conf->curstate->entered = time(NULL);
void
sigchld_handler(int fd, short event, void *arg)
{
- check_external_status(&conf->always);
+ check_external_status(&conf->initstate);
if (conf->curstate != NULL)
check_external_status(conf->curstate);
}
struct ifsd_state *state;
int cur_eval = 0;
- if (scan_ifstate_single(ifindex, s, &conf->always) && do_eval)
- eval_state(&conf->always);
+ if (scan_ifstate_single(ifindex, s, &conf->initstate) && do_eval)
+ eval_state(&conf->initstate);
TAILQ_FOREACH(state, &conf->states, entries) {
if (scan_ifstate_single(ifindex, s, state) &&
(do_eval && state == conf->curstate))
{
struct ifsd_state *state;
- external_evtimer_setup(&conf->always, IFSD_EVTIMER_DEL);
+ external_evtimer_setup(&conf->initstate, IFSD_EVTIMER_DEL);
if (conf != NULL && conf->curstate != NULL)
external_evtimer_setup(conf->curstate, IFSD_EVTIMER_DEL);
while ((state = TAILQ_FIRST(&oconf->states)) != NULL) {
free(state->name);
free(state);
}
- remove_action(oconf->always.init, &oconf->always);
- remove_action(oconf->always.body, &oconf->always);
+ remove_action(oconf->initstate.init, &oconf->initstate);
+ remove_action(oconf->initstate.body, &oconf->initstate);
free(oconf);
}
-/* $OpenBSD: ifstated.h,v 1.14 2017/07/02 14:30:35 benno Exp $ */
+/* $OpenBSD: ifstated.h,v 1.15 2017/07/02 15:28:26 benno Exp $ */
/*
* Copyright (c) 2004 Ryan McBride
TAILQ_HEAD(ifsd_state_list, ifsd_state);
struct ifsd_config {
- struct ifsd_state always;
+ struct ifsd_state initstate;
struct ifsd_state_list states;
struct ifsd_state *curstate;
struct ifsd_state *nextstate;
-/* $OpenBSD: parse.y,v 1.42 2017/07/02 14:27:30 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.43 2017/07/02 15:28:26 benno Exp $ */
/*
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
if (curstate != NULL)
curaction = curstate->init;
else
- curaction = conf->always.init;
+ curaction = conf->initstate.init;
} action_block {
if (curstate != NULL)
curaction = curstate->body;
else
- curaction = conf->always.body;
+ curaction = conf->initstate.body;
}
;
} optnl '{' optnl stateopts_l '}' {
TAILQ_INSERT_TAIL(&conf->states, curstate, entries);
curstate = NULL;
- curaction = conf->always.body;
+ curaction = conf->initstate.body;
}
;
TAILQ_INIT(&conf->states);
- init_state(&conf->always);
- curaction = conf->always.body;
+ init_state(&conf->initstate);
+ curaction = conf->initstate.body;
conf->opts = opts;
yyparse();
if (curstate != NULL)
state = curstate;
else
- state = &conf->always;
+ state = &conf->initstate;
TAILQ_FOREACH(ifstate, &state->interface_states, entries)
if (ifstate->ifindex == ifindex && ifstate->ifstate == s)
if (curstate != NULL)
state = curstate;
else
- state = &conf->always;
+ state = &conf->initstate;
TAILQ_FOREACH(external, &state->external_tests, entries)
if (strcmp(external->command, command) == 0 &&