diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-06-07 13:24:24 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-06-07 13:24:24 +0000 |
commit | 1b43dc959acf0334dd9dc0371d3bcefa2500ddbb (patch) | |
tree | 3e1d770515e8d30f4f0fc596ce93f9e5cd4926ed /usr.sbin/ldpctl | |
parent | 37b7fe5a53c211dd6f0c2c53b162de8984a4909f (diff) |
Store all labels in ldpd in host byte order without any additional shifting.
Add the necessary ntohl() and shifts in various places and cleanup the byte
order mess we had before. michele@ agrees.
Diffstat (limited to 'usr.sbin/ldpctl')
-rw-r--r-- | usr.sbin/ldpctl/ldpctl.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/usr.sbin/ldpctl/ldpctl.c b/usr.sbin/ldpctl/ldpctl.c index e88611f5898..3316763ba2a 100644 --- a/usr.sbin/ldpctl/ldpctl.c +++ b/usr.sbin/ldpctl/ldpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ldpctl.c,v 1.9 2010/04/13 15:42:09 michele Exp $ +/* $OpenBSD: ldpctl.c,v 1.10 2010/06/07 13:24:23 claudio Exp $ * * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -320,7 +320,6 @@ show_lib_msg(struct imsg *imsg) { struct ctl_rt *rt; char *dstnet, *remote; - int remote_label; switch (imsg->hdr.type) { case IMSG_CTL_SHOW_LIB: @@ -328,26 +327,23 @@ show_lib_msg(struct imsg *imsg) if (asprintf(&dstnet, "%s/%d", inet_ntoa(rt->prefix), rt->prefixlen) == -1) err(1, NULL); - remote_label = ntohl(rt->remote_label) >> MPLS_LABEL_OFFSET; if (!rt->in_use) { if (asprintf(&remote, "-") == -1) err(1, NULL); - } else if (rt->connected || - (remote_label == (NO_LABEL >> MPLS_LABEL_OFFSET))) { + } else if (rt->connected || rt->remote_label == NO_LABEL) { if (asprintf(&remote, "Untagged") == -1) err(1, NULL); - } else if (remote_label == MPLS_LABEL_IMPLNULL) { + } else if (rt->remote_label == MPLS_LABEL_IMPLNULL) { if (asprintf(&remote, "Pop tag") == -1) err(1, NULL); } else { - if (asprintf(&remote, "%u", remote_label) == -1) + if (asprintf(&remote, "%u", rt->remote_label) == -1) err(1, NULL); } printf("%-20s %-17s %-14u %-14s %s\n", dstnet, - inet_ntoa(rt->nexthop), - (ntohl(rt->local_label) >> MPLS_LABEL_OFFSET), - remote, rt->in_use ? "yes" : "no"); + inet_ntoa(rt->nexthop), rt->local_label, remote, + rt->in_use ? "yes" : "no"); free(remote); free(dstnet); @@ -439,21 +435,17 @@ show_lfib_msg(struct imsg *imsg) if (k->local_label == NO_LABEL) { printf("%-18s", "-"); - } else if (ntohl(k->local_label) >> MPLS_LABEL_OFFSET == - MPLS_LABEL_IMPLNULL) { + } else if (k->local_label == MPLS_LABEL_IMPLNULL) { printf("%-18s", "imp-null"); } else - printf("%-18u", (ntohl(k->local_label) >> - MPLS_LABEL_OFFSET)); + printf("%-18u", k->local_label); if (k->remote_label == NO_LABEL) { printf("-"); - } else if (htonl(k->remote_label) >> MPLS_LABEL_OFFSET == - MPLS_LABEL_IMPLNULL) { + } else if (k->remote_label == MPLS_LABEL_IMPLNULL) { printf("Pop"); } else { - printf("%u", (ntohl(k->remote_label) >> - MPLS_LABEL_OFFSET)); + printf("%u", k->remote_label); } printf("\n"); |