From 28d3b5f76b73111b9b7bc68a0151dc42e6316f8f Mon Sep 17 00:00:00 2001 From: tobhe Date: Wed, 8 Sep 2021 11:38:39 +0000 Subject: [PATCH] Print correct RTP_PROPOSAL types with 'unwindctl status autoconf'. Feedback and ok florian@ --- usr.sbin/unwindctl/unwindctl.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/usr.sbin/unwindctl/unwindctl.c b/usr.sbin/unwindctl/unwindctl.c index 32bc7b73624..9380abb937e 100644 --- a/usr.sbin/unwindctl/unwindctl.c +++ b/usr.sbin/unwindctl/unwindctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unwindctl.c,v 1.27 2021/02/27 10:32:29 florian Exp $ */ +/* $OpenBSD: unwindctl.c,v 1.28 2021/09/08 11:38:39 tobhe Exp $ */ /* * Copyright (c) 2005 Claudio Jeker @@ -49,11 +49,28 @@ int show_autoconf_msg(struct imsg *); int show_mem_msg(struct imsg *); void histogram_header(void); void print_histogram(const char *name, int64_t[], size_t); +const char *prio2str(int); struct imsgbuf *ibuf; int info_cnt; struct ctl_resolver_info info[UW_RES_NONE]; +const char * +prio2str(int prio) +{ + switch(prio) { + case RTP_PROPOSAL_DHCLIENT: + return "DHCP"; + case RTP_PROPOSAL_SLAAC: + return "SLAAC"; + case RTP_PROPOSAL_STATIC: + return "STATIC"; + case RTP_PROPOSAL_UMB: + return "UMB"; + } + return "OTHER"; +} + __dead void usage(void) { @@ -274,8 +291,8 @@ show_autoconf_msg(struct imsg *imsg) fwd_line[0] = '\0'; } label_len = snprintf(fwd_line, sizeof(fwd_line), - "%s[%s]:", cfi->src == RTP_PROPOSAL_DHCLIENT ? - " DHCP" : "SLAAC", if_name ? if_name : "unknown"); + "%6s[%s]:", prio2str(cfi->src), + if_name ? if_name : "unknown"); line_len = label_len; last_if_index = cfi->if_index; last_src = cfi->src; -- 2.20.1