This will be used at various places, there's no sense in open coding the
conversion everywhere.

Signed-off-by: Jiri Benc <jb...@redhat.com>
---
 lib/dynamic-string.c | 9 +++++++++
 lib/dynamic-string.h | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/lib/dynamic-string.c b/lib/dynamic-string.c
index 914af64c1649..68497879e030 100644
--- a/lib/dynamic-string.c
+++ b/lib/dynamic-string.c
@@ -171,6 +171,15 @@ ds_put_format_valist(struct ds *ds, const char *format, 
va_list args_)
 }
 
 void
+ds_put_in6_addr(struct ds *ds, const struct in6_addr *addr)
+{
+    char buf[INET6_ADDRSTRLEN];
+
+    inet_ntop(AF_INET6, addr, buf, sizeof buf);
+    ds_put_cstr(ds, buf);
+}
+
+void
 ds_put_printable(struct ds *ds, const char *s, size_t n)
 {
     ds_reserve(ds, ds->length + n);
diff --git a/lib/dynamic-string.h b/lib/dynamic-string.h
index dc5981ac2ba8..2a2a3c1c03b0 100644
--- a/lib/dynamic-string.h
+++ b/lib/dynamic-string.h
@@ -17,6 +17,7 @@
 #ifndef DYNAMIC_STRING_H
 #define DYNAMIC_STRING_H 1
 
+#include <netinet/in.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stddef.h>
@@ -54,6 +55,7 @@ void ds_put_and_free_cstr(struct ds *, char *);
 void ds_put_format(struct ds *, const char *, ...) OVS_PRINTF_FORMAT(2, 3);
 void ds_put_format_valist(struct ds *, const char *, va_list)
     OVS_PRINTF_FORMAT(2, 0);
+void ds_put_in6_addr(struct ds *, const struct in6_addr *);
 void ds_put_printable(struct ds *, const char *, size_t);
 void ds_put_hex_dump(struct ds *ds, const void *buf_, size_t size,
                      uintptr_t ofs, bool ascii);
-- 
1.8.3.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to