From db471b541a1ffb7880e92f5956cae2258b606b4d Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 28 Oct 2008 16:04:44 -0700 Subject: [PATCH] --- yaml --- r: 121509 b: refs/heads/master c: 689afa7da106032a3e859ae35494f80dd6eac640 h: refs/heads/master i: 121507: 9b5a132b9cd1b54192024374e488fab2cf1dc58f v: v3 --- [refs] | 2 +- trunk/lib/vsprintf.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 120fda381c16..da9348de0e5e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3a2dfbe8acb154905fdc2fd03ec56df42e6c4cc4 +refs/heads/master: 689afa7da106032a3e859ae35494f80dd6eac640 diff --git a/trunk/lib/vsprintf.c b/trunk/lib/vsprintf.c index 0deaaaf2b14e..cb5bc04ff82b 100644 --- a/trunk/lib/vsprintf.c +++ b/trunk/lib/vsprintf.c @@ -598,6 +598,24 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width, return string(buf, end, mac_addr, field_width, precision, flags & ~SPECIAL); } +static char *ip6_addr_string(char *buf, char *end, u8 *addr, int field_width, + int precision, int flags) +{ + char ip6_addr[8 * 5]; /* (8 * 4 hex digits), 7 colons and trailing zero */ + char *p = ip6_addr; + int i; + + for (i = 0; i < 8; i++) { + p = pack_hex_byte(p, addr[2 * i]); + p = pack_hex_byte(p, addr[2 * i + 1]); + if (!(flags & SPECIAL) && i != 7) + *p++ = ':'; + } + *p = '\0'; + + return string(buf, end, ip6_addr, field_width, precision, flags & ~SPECIAL); +} + /* * Show a '%p' thing. A kernel extension is that the '%p' is followed * by an extra set of alphanumeric characters that are extended format @@ -611,6 +629,8 @@ static char *mac_address_string(char *buf, char *end, u8 *addr, int field_width, * addresses (not the name nor the flags) * - 'M' For a 6-byte MAC address, it prints the address in the * usual colon-separated hex notation + * - '6' For a IPv6 address prints the address in network-ordered 16 bit hex + * with colon separators * * Note: The difference between 'S' and 'F' is that on ia64 and ppc64 * function pointers are really function descriptors, which contain a @@ -628,6 +648,8 @@ static char *pointer(const char *fmt, char *buf, char *end, void *ptr, int field return resource_string(buf, end, ptr, field_width, precision, flags); case 'M': return mac_address_string(buf, end, ptr, field_width, precision, flags); + case '6': + return ip6_addr_string(buf, end, ptr, field_width, precision, flags); } flags |= SMALL; if (field_width == -1) {