diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2006-03-09 18:11:35 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2006-03-09 18:11:35 +0000 |
commit | 36b32be082b3a821442bae3180bb6f9a98d4a6e3 (patch) | |
tree | d8ab358e01d3e0097e011b3c138e546fc46030d0 /usr.sbin | |
parent | 859c243f8c81031ff33af109cd87ba1bb79453d1 (diff) |
Track interface uptime.
ok claudio@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospfctl/ospfctl.c | 4 | ||||
-rw-r--r-- | usr.sbin/ospfd/interface.c | 11 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c index 9add33ec700..4b88142327d 100644 --- a/usr.sbin/ospfctl/ospfctl.c +++ b/usr.sbin/ospfctl/ospfctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfctl.c,v 1.27 2006/03/09 15:44:07 claudio Exp $ */ +/* $OpenBSD: ospfctl.c,v 1.28 2006/03/09 18:11:33 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -339,6 +339,8 @@ show_interface_msg(struct imsg *imsg) else printf(" Hello timer due in %s\n", fmt_timeframe_core(iface->hello_timer)); + printf(" Uptime %s\n", iface->uptime == 0 ? + "00:00:00" : fmt_timeframe_core(iface->uptime)); printf(" Neighbor count is %d, adjacent neighbor count is " "%d\n", iface->nbr_cnt, iface->adj_cnt); if (iface->auth_type > 0) { diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index 7bee9a1b0d9..7060c7d21ae 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.45 2006/03/09 15:43:21 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.46 2006/03/09 18:11:34 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -321,6 +321,7 @@ int if_act_start(struct iface *iface) { struct in_addr addr; + struct timeval now; if (!((iface->flags & IFF_UP) && (iface->linkstate == LINK_STATE_UP || @@ -344,6 +345,9 @@ if_act_start(struct iface *iface) return (0); } + gettimeofday(&now, NULL); + iface->uptime = now.tv_sec; + switch (iface->type) { case IF_TYPE_POINTOPOINT: inet_aton(AllSPFRouters, &addr); @@ -669,6 +673,11 @@ if_to_ctl(struct iface *iface) } else ictl.hello_timer = -1; + if (iface->state != IF_STA_DOWN) { + ictl.uptime = now.tv_sec - iface->uptime; + } else + ictl.uptime = 0; + LIST_FOREACH(nbr, &iface->nbr_list, entry) { if (nbr == iface->self) continue; diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 1829da5ba12..db291510a9c 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.50 2006/03/09 15:43:21 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.51 2006/03/09 18:11:34 norby Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -339,6 +339,7 @@ struct iface { u_int32_t dead_interval; u_int32_t ls_ack_cnt; u_int32_t crypt_seq_num; + time_t uptime; unsigned int ifindex; int fd; int state; @@ -418,6 +419,7 @@ struct ctl_iface { struct in_addr bdr_id; struct in_addr bdr_addr; time_t hello_timer; + time_t uptime; u_int32_t baudrate; u_int32_t dead_interval; unsigned int ifindex; |