diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-09-14 11:49:26 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-09-14 11:49:26 +0000 |
commit | 15a3e8853859cbe52bda8c7a38613274f7e374df (patch) | |
tree | 024009d39085a463f5745768912a2aa25f6d8312 /usr.sbin/dvmrpctl/dvmrpctl.c | |
parent | 59b6c9cab8ebff096556ff3792cd31dae17bd54d (diff) |
Switch the various link state printing codes to use the new if_media
independent LINK_STATE_DESCRIPTIONS. Code is now more or less a one to
one copy of get_linkstate() in route/route.c.
OK henning, michele, sthen, deraadt
Diffstat (limited to 'usr.sbin/dvmrpctl/dvmrpctl.c')
-rw-r--r-- | usr.sbin/dvmrpctl/dvmrpctl.c | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/usr.sbin/dvmrpctl/dvmrpctl.c b/usr.sbin/dvmrpctl/dvmrpctl.c index 6cac076e5a3..5671258d51e 100644 --- a/usr.sbin/dvmrpctl/dvmrpctl.c +++ b/usr.sbin/dvmrpctl/dvmrpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dvmrpctl.c,v 1.7 2009/06/06 07:52:04 pyr Exp $ */ +/* $OpenBSD: dvmrpctl.c,v 1.8 2009/09/14 11:49:25 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -279,8 +279,8 @@ show_interface_msg(struct imsg *imsg) iface->name, netid, if_state_name(iface->state), iface->probe_timer == 0 ? "00:00:00" : fmt_timeframe_core(iface->probe_timer), - get_linkstate(get_ifms_type(iface->mediatype), - iface->linkstate), iface->uptime == 0 ? "00:00:00" : + get_linkstate(iface->mediatype, iface->linkstate), + iface->uptime == 0 ? "00:00:00" : fmt_timeframe_core(iface->uptime), iface->group_cnt); free(netid); break; @@ -310,8 +310,7 @@ show_interface_detail_msg(struct imsg *imsg) inet_ntoa(iface->addr), mask2prefixlen(iface->mask.s_addr)); printf(" Linkstate %s\n", - get_linkstate(get_ifms_type(iface->mediatype), - iface->linkstate)); + get_linkstate(iface->mediatype, iface->linkstate)); printf(" Network type %s, cost: %d\n", if_type_name(iface->type), iface->metric); printf(" State %s, querier ", if_state_name(iface->state)); @@ -652,30 +651,19 @@ show_mfc_detail_msg(struct imsg *imsg) return (0); } -const int ifm_status_valid_list[] = IFM_STATUS_VALID_LIST; -const struct ifmedia_status_description - ifm_status_descriptions[] = IFM_STATUS_DESCRIPTIONS; -const struct ifmedia_description - ifm_type_descriptions[] = IFM_TYPE_DESCRIPTIONS; +const struct if_status_description + if_status_descriptions[] = LINK_STATE_DESCRIPTIONS; const char * get_linkstate(int media_type, int link_state) { - const struct ifmedia_status_description *p; - int i; - - if (link_state == LINK_STATE_UNKNOWN) - return ("unknown"); - - for (i = 0; ifm_status_valid_list[i] != 0; i++) - for (p = ifm_status_descriptions; p->ifms_valid != 0; p++) { - if (p->ifms_type != media_type || - p->ifms_valid != ifm_status_valid_list[i]) - continue; - if (LINK_STATE_IS_UP(link_state)) - return (p->ifms_string[1]); - return (p->ifms_string[0]); - } + const struct if_status_description *p; + static char buf[8]; - return ("unknown link state"); + for (p = if_status_descriptions; p->ifs_string != NULL; p++) { + if (LINK_STATE_DESC_MATCH(p, media_type, link_state)) + return (p->ifs_string); + } + snprintf(buf, sizeof(buf), "[#%d]", link_state); + return (buf); } |