diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/cmds.c | 6 | ||||
-rw-r--r-- | nest/config.Y | 39 | ||||
-rw-r--r-- | nest/password.c | 9 | ||||
-rw-r--r-- | nest/password.h | 4 | ||||
-rw-r--r-- | nest/proto.c | 10 | ||||
-rw-r--r-- | nest/protocol.h | 4 | ||||
-rw-r--r-- | nest/route.h | 4 | ||||
-rw-r--r-- | nest/rt-show.c | 2 | ||||
-rw-r--r-- | nest/rt-table.c | 10 |
9 files changed, 58 insertions, 30 deletions
diff --git a/nest/cmds.c b/nest/cmds.c index 371e8877..ca601ef2 100644 --- a/nest/cmds.c +++ b/nest/cmds.c @@ -25,12 +25,12 @@ cmd_show_status(void) byte tim[TM_DATETIME_BUFFER_SIZE]; cli_msg(-1000, "BIRD " BIRD_VERSION); - tm_format_datetime(tim, &config->tf_base, now); + tm_format_time(tim, &config->tf_base, current_time()); cli_msg(-1011, "Router ID is %R", config->router_id); cli_msg(-1011, "Current server time is %s", tim); - tm_format_datetime(tim, &config->tf_base, boot_time TO_S); + tm_format_time(tim, &config->tf_base, boot_time); cli_msg(-1011, "Last reboot on %s", tim); - tm_format_datetime(tim, &config->tf_base, config->load_time); + tm_format_time(tim, &config->tf_base, config->load_time); cli_msg(-1011, "Last reconfiguration on %s", tim); graceful_restart_show_status(); diff --git a/nest/config.Y b/nest/config.Y index 220fa8b0..ef29fb96 100644 --- a/nest/config.Y +++ b/nest/config.Y @@ -73,6 +73,7 @@ CF_KEYWORDS(ALGORITHM, KEYED, HMAC, MD5, SHA1, SHA256, SHA384, SHA512) CF_KEYWORDS(PRIMARY, STATS, COUNT, BY, FOR, COMMANDS, PREEXPORT, NOEXPORT, GENERATE) CF_KEYWORDS(LISTEN, BGP, V6ONLY, DUAL, ADDRESS, PORT, PASSWORDS, DESCRIPTION, SORTED) CF_KEYWORDS(RELOAD, IN, OUT, MRTDUMP, MESSAGES, RESTRICT, MEMORY, IGP_METRIC, CLASS, DSCP) +CF_KEYWORDS(TIMEFORMAT, ISO, SHORT, LONG, ROUTE, PROTOCOL, BASE, LOG, S, MS, US) CF_KEYWORDS(GRACEFUL, RESTART, WAIT, MAX, FLUSH, AS) /* For r_args_channel */ @@ -295,6 +296,7 @@ limit_spec: | OFF { $$ = (struct channel_limit){}; } ; + CF_ADDTO(conf, debug_default) debug_default: @@ -304,6 +306,31 @@ debug_default: /* MRTDUMP PROTOCOLS is in systep/unix/config.Y */ +CF_ADDTO(conf, timeformat_base) + +timeformat_which: + ROUTE { $$ = &new_config->tf_route; } + | PROTOCOL { $$ = &new_config->tf_proto; } + | BASE { $$ = &new_config->tf_base; } + | LOG { $$ = &new_config->tf_log; } + ; + +timeformat_spec: + timeformat_which TEXT { *$1 = (struct timeformat){$2, NULL, 0}; } + | timeformat_which TEXT expr TEXT { *$1 = (struct timeformat){$2, $4, (s64) $3 S_}; } + | timeformat_which ISO SHORT { *$1 = TM_ISO_SHORT_S; } + | timeformat_which ISO SHORT MS { *$1 = TM_ISO_SHORT_MS; } + | timeformat_which ISO SHORT US { *$1 = TM_ISO_SHORT_US; } + | timeformat_which ISO LONG { *$1 = TM_ISO_LONG_S; } + | timeformat_which ISO LONG MS { *$1 = TM_ISO_LONG_MS; } + | timeformat_which ISO LONG US { *$1 = TM_ISO_LONG_US; } + ; + +timeformat_base: + TIMEFORMAT timeformat_spec ';' + ; + + /* Interface patterns */ iface_patt_node_init: @@ -462,12 +489,12 @@ password_item_begin: password_item_params: /* empty */ { } - | GENERATE FROM datetime ';' password_item_params { this_p_item->genfrom = $3; } - | GENERATE TO datetime ';' password_item_params { this_p_item->gento = $3; } - | ACCEPT FROM datetime ';' password_item_params { this_p_item->accfrom = $3; } - | ACCEPT TO datetime ';' password_item_params { this_p_item->accto = $3; } - | FROM datetime ';' password_item_params { this_p_item->genfrom = this_p_item->accfrom = $2; } - | TO datetime ';' password_item_params { this_p_item->gento = this_p_item->accto = $2; } + | GENERATE FROM time ';' password_item_params { this_p_item->genfrom = $3; } + | GENERATE TO time ';' password_item_params { this_p_item->gento = $3; } + | ACCEPT FROM time ';' password_item_params { this_p_item->accfrom = $3; } + | ACCEPT TO time ';' password_item_params { this_p_item->accto = $3; } + | FROM time ';' password_item_params { this_p_item->genfrom = this_p_item->accfrom = $2; } + | TO time ';' password_item_params { this_p_item->gento = this_p_item->accto = $2; } | ID expr ';' password_item_params { this_p_item->id = $2; if ($2 <= 0) cf_error("Password ID has to be greated than zero."); } | ALGORITHM password_algorithm ';' password_item_params { this_p_item->alg = $2; } ; diff --git a/nest/password.c b/nest/password.c index e4813741..72f23f5d 100644 --- a/nest/password.c +++ b/nest/password.c @@ -19,12 +19,13 @@ password_find(list *l, int first_fit) { struct password_item *pi; struct password_item *pf = NULL; + btime now_ = current_real_time(); if (l) { WALK_LIST(pi, *l) { - if ((pi->genfrom < now_real) && (pi->gento > now_real)) + if ((pi->genfrom < now_) && (pi->gento > now_)) { if (first_fit) return pi; @@ -41,12 +42,13 @@ struct password_item * password_find_by_id(list *l, uint id) { struct password_item *pi; + btime now_ = current_real_time(); if (!l) return NULL; WALK_LIST(pi, *l) - if ((pi->id == id) && (pi->accfrom <= now_real) && (now_real < pi->accto)) + if ((pi->id == id) && (pi->accfrom <= now_) && (now_ < pi->accto)) return pi; return NULL; @@ -56,12 +58,13 @@ struct password_item * password_find_by_value(list *l, char *pass, uint size) { struct password_item *pi; + btime now_ = current_real_time(); if (!l) return NULL; WALK_LIST(pi, *l) - if (password_verify(pi, pass, size) && (pi->accfrom <= now_real) && (now_real < pi->accto)) + if (password_verify(pi, pass, size) && (pi->accfrom <= now_) && (now_ < pi->accto)) return pi; return NULL; diff --git a/nest/password.h b/nest/password.h index 78244985..c4017848 100644 --- a/nest/password.h +++ b/nest/password.h @@ -10,15 +10,13 @@ #ifndef PASSWORD_H #define PASSWORD_H -#include "sysdep/unix/timer.h" - struct password_item { node n; char *password; /* Key data, null terminated */ uint length; /* Key length, without null */ uint id; /* Key ID */ uint alg; /* MAC algorithm */ - bird_clock_t accfrom, accto, genfrom, gento; + btime accfrom, accto, genfrom, gento; }; extern struct password_item *last_password_item; diff --git a/nest/proto.c b/nest/proto.c index 65375c35..3043b648 100644 --- a/nest/proto.c +++ b/nest/proto.c @@ -162,7 +162,7 @@ proto_add_channel(struct proto *p, struct channel_config *cf) c->channel_state = CS_DOWN; c->export_state = ES_DOWN; - c->last_state_change = now; + c->last_state_change = current_time(); c->reloadable = 1; CALL(c->channel->init, c, cf); @@ -341,7 +341,7 @@ channel_set_state(struct channel *c, uint state) return; c->channel_state = state; - c->last_state_change = now; + c->last_state_change = current_time(); switch (state) { @@ -672,7 +672,7 @@ proto_init(struct proto_config *c, node *n) struct proto *p = pr->init(c); p->proto_state = PS_DOWN; - p->last_state_change = now; + p->last_state_change = current_time(); insert_node(&p->n, n); p->event = ev_new(proto_pool); @@ -1500,7 +1500,7 @@ proto_notify_state(struct proto *p, uint state) return; p->proto_state = state; - p->last_state_change = now; + p->last_state_change = current_time(); switch (state) { @@ -1631,7 +1631,7 @@ proto_cmd_show(struct proto *p, uint verbose, int cnt) buf[0] = 0; if (p->proto->get_status) p->proto->get_status(p, buf); - tm_format_datetime(tbuf, &config->tf_proto, p->last_state_change); + tm_format_time(tbuf, &config->tf_proto, p->last_state_change); cli_msg(-1002, "%-8s %-8s %-8s %-5s %-10s %s", p->name, p->proto->name, diff --git a/nest/protocol.h b/nest/protocol.h index eed0a291..abd11aff 100644 --- a/nest/protocol.h +++ b/nest/protocol.h @@ -159,7 +159,7 @@ struct proto { byte down_sched; /* Shutdown is scheduled for later (PDS_*) */ byte down_code; /* Reason for shutdown (PDC_* codes) */ u32 hash_key; /* Random key used for hashing of neighbors */ - bird_clock_t last_state_change; /* Time of last state transition */ + btime last_state_change; /* Time of last state transition */ char *last_state_name_announced; /* Last state name we've announced to the user */ /* @@ -508,7 +508,7 @@ struct channel { u8 gr_lock; /* Graceful restart mechanism should wait for this channel */ u8 gr_wait; /* Route export to channel is postponed until graceful restart */ - bird_clock_t last_state_change; /* Time of last state transition */ + btime last_state_change; /* Time of last state transition */ }; diff --git a/nest/route.h b/nest/route.h index c1a60ccc..2aa2bcd8 100644 --- a/nest/route.h +++ b/nest/route.h @@ -159,8 +159,8 @@ typedef struct rtable { * obstacle from this routing table. */ struct event *rt_event; /* Routing table event */ + btime gc_time; /* Time of last GC */ int gc_counter; /* Number of operations since last GC */ - bird_clock_t gc_time; /* Time of last GC */ byte prune_state; /* Table prune state, 1 -> scheduled, 2-> running */ byte hcu_scheduled; /* Hostcache update is scheduled */ byte nhu_state; /* Next Hop Update state */ @@ -213,7 +213,7 @@ typedef struct rte { byte flags; /* Flags (REF_...) */ byte pflags; /* Protocol-specific flags */ word pref; /* Route preference */ - bird_clock_t lastmod; /* Last modified */ + btime lastmod; /* Last modified */ union { /* Protocol-dependent data (metrics etc.) */ #ifdef CONFIG_RIP struct { diff --git a/nest/rt-show.c b/nest/rt-show.c index afde2810..9989afa4 100644 --- a/nest/rt-show.c +++ b/nest/rt-show.c @@ -39,7 +39,7 @@ rt_show_rte(struct cli *c, byte *ia, rte *e, struct rt_show_data *d, ea_list *tm void (*get_route_info)(struct rte *, byte *buf, struct ea_list *attrs); struct nexthop *nh; - tm_format_datetime(tm, &config->tf_route, e->lastmod); + tm_format_time(tm, &config->tf_route, e->lastmod); if (ipa_nonzero(a->from) && !ipa_equal(a->from, a->nh.gw)) bsprintf(from, " from %I", a->from); else diff --git a/nest/rt-table.c b/nest/rt-table.c index 2bb78cf2..c42d3a97 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -1173,7 +1173,7 @@ rte_recalculate(struct channel *c, net *net, rte *new, struct rte_src *src) } if (new) - new->lastmod = now; + new->lastmod = current_time(); /* Log the route change */ if (p->debug & D_ROUTES) @@ -1201,7 +1201,7 @@ rte_recalculate(struct channel *c, net *net, rte *new, struct rte_src *src) if (!net->routes && (table->gc_counter++ >= table->config->gc_max_ops) && - (table->gc_time + table->config->gc_min_time <= now)) + (table->gc_time + table->config->gc_min_time <= current_time())) rt_schedule_prune(table); if (old_ok && p->rte_remove) @@ -1497,7 +1497,7 @@ rte_dump(rte *e) { net *n = e->net; debug("%-1N ", n->n.addr); - debug("KF=%02x PF=%02x pref=%d lm=%d ", n->n.flags, e->pflags, e->pref, now-e->lastmod); + debug("KF=%02x PF=%02x pref=%d ", n->n.flags, e->pflags, e->pref); rta_dump(e->attrs); if (e->attrs->src->proto->proto->dump_attrs) e->attrs->src->proto->proto->dump_attrs(e); @@ -1609,7 +1609,7 @@ rt_setup(pool *p, rtable *t, char *name, struct rtable_config *cf) t->rt_event = ev_new(p); t->rt_event->hook = rt_event; t->rt_event->data = t; - t->gc_time = now; + t->gc_time = current_time(); } } @@ -1708,7 +1708,7 @@ again: #endif tab->gc_counter = 0; - tab->gc_time = now; + tab->gc_time = current_time(); /* state change 2->0, 3->1 */ tab->prune_state &= 1; |