From a092a89d8f052072e562861f2968573d89e10dd5 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 16 Nov 2011 20:17:12 +0100 Subject: udhcpc6: rudimentary code to export data to script; fix IAADDR parsing Signed-off-by: Denys Vlasenko --- networking/udhcp/common.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'networking/udhcp/common.c') diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 2e6113627..a89dce3ae 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -539,3 +539,22 @@ int FAST_FUNC udhcp_str2optset(const char *const_str, void *arg) return retval; } + +/* note: ip is a pointer to an IPv6 in network order, possibly misaliged */ +int FAST_FUNC sprint_nip6(char *dest, /*const char *pre,*/ const uint8_t *ip) +{ + char hexstrbuf[16 * 2]; + bin2hex(hexstrbuf, (void*)ip, 16); + return sprintf(dest, /* "%s" */ + "%.4s:%.4s:%.4s:%.4s:%.4s:%.4s:%.4s:%.4s", + /* pre, */ + hexstrbuf + 0 * 4, + hexstrbuf + 1 * 4, + hexstrbuf + 2 * 4, + hexstrbuf + 3 * 4, + hexstrbuf + 4 * 4, + hexstrbuf + 5 * 4, + hexstrbuf + 6 * 4, + hexstrbuf + 7 * 4 + ); +} -- cgit v1.2.3