diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2017-03-28 17:35:32 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2017-03-28 17:35:32 +0200 |
commit | 2282030b2a4fb07805a0cd8b82a9aab73b7586d8 (patch) | |
tree | a094b4731e7d1c32f0757e99df2aa6db59317d94 /lib/net.c | |
parent | ef57b70fa51687865e5823c0af2df2c6de338215 (diff) |
Simpler format of VPN RD
Diffstat (limited to 'lib/net.c')
-rw-r--r-- | lib/net.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -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); } } |