diff options
author | Michele Marchetto <michele@cvs.openbsd.org> | 2009-08-02 16:19:18 +0000 |
---|---|---|
committer | Michele Marchetto <michele@cvs.openbsd.org> | 2009-08-02 16:19:18 +0000 |
commit | d39d8390343be0240365f612fe409018c18f13d5 (patch) | |
tree | ff1fa2b53ec6933319ba077ca0273e368f18218f /usr.sbin/ldpctl/ldpctl.c | |
parent | ce067087ed3da82f031e1e2c4a115f2fa3e1a016 (diff) |
"ldpctl show lib" output cleanup.
- Show only the remote/local labels of the prefixes currently present
in fib.
- Write a "-" instead of "0" when a remote label is not present (the
prefix is directly connected). It avoids confusion with explicit null label.
ok claudio@
Diffstat (limited to 'usr.sbin/ldpctl/ldpctl.c')
-rw-r--r-- | usr.sbin/ldpctl/ldpctl.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c index cc49650131e..205da0ac94b 100644 --- a/usr.sbin/ldpctl/ldpctl.c +++ b/usr.sbin/ldpctl/ldpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpctl.c,v 1.3 2009/08/01 12:47:02 michele Exp $ +/* $OpenBSD: ldpctl.c,v 1.4 2009/08/02 16:19:17 michele Exp $ * * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -308,7 +308,7 @@ int show_lib_msg(struct imsg *imsg) { struct ctl_rt *rt; - char *dstnet; + char *dstnet, *remote; switch (imsg->hdr.type) { case IMSG_CTL_SHOW_LIB: @@ -317,10 +317,19 @@ show_lib_msg(struct imsg *imsg) rt->prefixlen) == -1) err(1, NULL); - printf("%-20s %-17s %-17u %u\n", dstnet, + if (rt->connected) { + if (asprintf(&remote, "-") == -1) + err(1, NULL); + } else { + if (asprintf(&remote, "%u", (ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET)) == -1) + err(1, NULL); + } + + printf("%-20s %-17s %-17u %s\n", dstnet, inet_ntoa(rt->nexthop), (ntohl(rt->local_label) >> MPLS_LABEL_OFFSET), - (ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET)); + remote); + free(remote); free(dstnet); break; |