diff options
author | thompsa <thompsa@FreeBSD.org> | 2005-10-07 00:32:16 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2005-10-07 00:32:16 +0000 |
commit | 2e47ce1265a5abd752e51ed0211443920d031efe (patch) | |
tree | 428ce521c8f7323ab35a5b18c7097914d129328c /sbin | |
parent | 275062eb87e78dfa2892ce20beacf11c442dc88a (diff) | |
download | FreeBSD-src-2e47ce1265a5abd752e51ed0211443920d031efe.zip FreeBSD-src-2e47ce1265a5abd752e51ed0211443920d031efe.tar.gz |
Display the status of the spanning tree for each port.
member: xl0 flags=7<LEARNING,DISCOVER,STP>
member: gem0 flags=7<LEARNING,DISCOVER,STP>
to:
member: xl0 flags=7<LEARNING,DISCOVER,STP>
port 3 priority 128 path cost 55 forwarding
member: gem0 flags=7<LEARNING,DISCOVER,STP>
port 1 priority 128 path cost 55 learning
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifbridge.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sbin/ifconfig/ifbridge.c b/sbin/ifconfig/ifbridge.c index bf41ea8..36e308b 100644 --- a/sbin/ifconfig/ifbridge.c +++ b/sbin/ifconfig/ifbridge.c @@ -111,7 +111,7 @@ do_bridgeflag(int sock, const char *ifs, int flag, int set) } static void -bridge_interfaces(int s, const char *prefix, int flags) +bridge_interfaces(int s, const char *prefix) { static const char *stpstates[] = { "disabled", @@ -123,8 +123,18 @@ bridge_interfaces(int s, const char *prefix, int flags) struct ifbifconf bifc; struct ifbreq *req; char *inbuf = NULL, *ninbuf; + char *p, *pad; int i, len = 8192; + pad = strdup(prefix); + if (pad == NULL) + err(1, "strdup"); + /* replace the prefix with whitespace */ + for (p = pad; *p != '\0'; p++) { + if(isprint(*p)) + *p = ' '; + } + for (;;) { ninbuf = realloc(inbuf, len); if (ninbuf == NULL) @@ -144,12 +154,10 @@ bridge_interfaces(int s, const char *prefix, int flags) printb("flags", req->ifbr_ifsflags, IFBIFBITS); printf("\n"); - if (!flags) continue; - - printf("%s\t", prefix); - printf("port %u priority %u", - req->ifbr_portno, req->ifbr_priority); if (req->ifbr_ifsflags & IFBIF_STP) { + printf("%s", pad); + printf("port %u priority %u", + req->ifbr_portno, req->ifbr_priority); printf(" path cost %u", req->ifbr_path_cost); if (req->ifbr_state < sizeof(stpstates) / sizeof(stpstates[0])) @@ -157,8 +165,8 @@ bridge_interfaces(int s, const char *prefix, int flags) else printf(" <unknown state %d>", req->ifbr_state); + printf("\n"); } - printf("\n"); } free(inbuf); @@ -225,7 +233,7 @@ bridge_status(int s) printf("\tpriority %u hellotime %u fwddelay %u maxage %u\n", pri, ht, fd, ma); - bridge_interfaces(s, "\tmember: ", 0); + bridge_interfaces(s, "\tmember: "); return; |