diff options
author | Jan Moskyto Matejka <mq@ucw.cz> | 2016-05-13 13:48:04 +0200 |
---|---|---|
committer | Jan Moskyto Matejka <mq@ucw.cz> | 2016-05-13 13:48:04 +0200 |
commit | 5af7b59660be615fbbd7c20b92b71321c003c43a (patch) | |
tree | 59bc962b18ae5a4ac6bf088863cfe210c9123b57 /lib/printf.c | |
parent | d39d41fbda2ec86ea2bac27308eb4fb16ecc4702 (diff) | |
parent | b66a9e2f3376b4cb07ef4cc318f70a9c794f407a (diff) |
Merge branch 'int-new' of gitlab.labs.nic.cz:labs/bird into int-new
Diffstat (limited to 'lib/printf.c')
-rw-r--r-- | lib/printf.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/lib/printf.c b/lib/printf.c index 318cee2c..844f5969 100644 --- a/lib/printf.c +++ b/lib/printf.c @@ -124,9 +124,10 @@ static char * number(char * str, long num, int base, int size, int precision, * standard IP address width which depends on whether we use IPv4 or IPv6; |%I4| * or |%I6| can be used for explicit ip4_addr / ip6_addr arguments, |%N| for * generic network addresses (net_addr *), |%R| for Router / Network ID (u32 - * value printed as IPv4 address) and |%m| resp. |%M| for error messages (uses - * strerror() to translate @errno code to message text). On the other hand, it - * doesn't support floating point numbers. + * value printed as IPv4 address), |%lR| for 64bit Router / Network ID (u64 + * value printed as eight :-separated octets) and |%m| resp. |%M| for error + * messages (uses strerror() to translate @errno code to message text). On the + * other hand, it doesn't support floating point numbers. * * Result: number of characters of the output string or -1 if * the buffer space was insufficient. @@ -137,6 +138,7 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args) unsigned long num; int i, base; u32 x; + u64 X; char *str, *start; const char *s; char ipbuf[NET_MAX_TEXT_LENGTH+1]; @@ -338,8 +340,23 @@ int bvsnprintf(char *buf, int size, const char *fmt, va_list args) /* Router/Network ID - essentially IPv4 address in u32 value */ case 'R': - x = va_arg(args, u32); - ip4_ntop(ip4_from_u32(x), ipbuf); + if (qualifier == 'l') { + X = va_arg(args, u64); + bsprintf(ipbuf, "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + ((X >> 56) & 0xff), + ((X >> 48) & 0xff), + ((X >> 40) & 0xff), + ((X >> 32) & 0xff), + ((X >> 24) & 0xff), + ((X >> 16) & 0xff), + ((X >> 8) & 0xff), + (X & 0xff)); + } + else + { + x = va_arg(args, u32); + ip4_ntop(ip4_from_u32(x), ipbuf); + } s = ipbuf; goto str; |