summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPaul Jakma <paul@quagga.net>2012-06-14 10:37:40 +0100
committerPaul Jakma <paul@quagga.net>2012-06-14 10:37:40 +0100
commit2fb2a455263c569119ca32be59b0337a3d8cd9b3 (patch)
tree79f895f78cd4adb43dde3ba3996e8a04a8deac42 /lib
parentad12dde6f9596997337ebc210dd2d4593438556b (diff)
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/sockunion.c12
-rw-r--r--lib/sockunion.h1
2 files changed, 13 insertions, 0 deletions
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);