summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJan Moskyto Matejka <mq@ucw.cz>2017-03-28 17:35:32 +0200
committerJan Moskyto Matejka <mq@ucw.cz>2017-03-28 17:35:32 +0200
commit2282030b2a4fb07805a0cd8b82a9aab73b7586d8 (patch)
treea094b4731e7d1c32f0757e99df2aa6db59317d94 /lib
parentef57b70fa51687865e5823c0af2df2c6de338215 (diff)
Simpler format of VPN RD
Diffstat (limited to 'lib')
-rw-r--r--lib/net.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/net.c b/lib/net.c
index c29ed299..e6053812 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -59,9 +59,12 @@ rd_format(const u64 rd, char *buf, int buflen)
{
switch (rd >> 48)
{
- case 0: return bsnprintf(buf, buflen, "0:%u:%u", (u32) (rd >> 32), (u32) rd);
- case 1: return bsnprintf(buf, buflen, "1:%I4:%u", ip4_from_u32(rd >> 16), (u32) (rd & 0xffff));
- case 2: return bsnprintf(buf, buflen, "2:%u:%u", (u32) (rd >> 16), (u32) (rd & 0xffff));
+ case 0: return bsnprintf(buf, buflen, "%u:%u", (u32) (rd >> 32), (u32) rd);
+ case 1: return bsnprintf(buf, buflen, "%I4:%u", ip4_from_u32(rd >> 16), (u32) (rd & 0xffff));
+ case 2: if (((u32) (rd >> 16)) >> 16)
+ return bsnprintf(buf, buflen, "%u:%u", (u32) (rd >> 16), (u32) (rd & 0xffff));
+ else
+ return bsnprintf(buf, buflen, "2:%u:%u", (u32) (rd >> 16), (u32) (rd & 0xffff));
default: return bsnprintf(buf, buflen, "X:%08x:%08x", (u32) (rd >> 32), (u32) rd);
}
}