From 2fb2a455263c569119ca32be59b0337a3d8cd9b3 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Thu, 14 Jun 2012 10:37:40 +0100 Subject: lib: Add back sockunion_str2su * sockunion.h: Add back sockunion_str2su, its removal breaks things needlessly (e.g. our own unit tests). * sockunion.c: (sockunion_str2su) implement on top of str2sockunion. --- lib/sockunion.c | 12 ++++++++++++ lib/sockunion.h | 1 + 2 files changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/sockunion.c b/lib/sockunion.c index 37dc3f90..5dcf7256 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -174,6 +174,18 @@ sockunion2str (union sockunion *su, char *buf, size_t len) return NULL; } +union sockunion * +sockunion_str2su (const char *str) +{ + union sockunion *su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); + + if (!str2sockunion (str, su)) + return su; + + XFREE (MTYPE_SOCKUNION, su); + return NULL; +} + /* Convert IPv4 compatible IPv6 address to IPv4 address. */ static void sockunion_normalise_mapped (union sockunion *su) diff --git a/lib/sockunion.h b/lib/sockunion.h index 1a0a3c95..b9f35142 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -88,6 +88,7 @@ extern const char *sockunion2str (union sockunion *, char *, size_t); extern int sockunion_cmp (union sockunion *, union sockunion *); extern int sockunion_same (union sockunion *, union sockunion *); +extern union sockunion *sockunion_str2su (const char *str); extern int sockunion_accept (int sock, union sockunion *); extern int sockunion_stream_socket (union sockunion *); extern int sockopt_reuseaddr (int); -- cgit v1.2.1