diff options
-rw-r--r-- | lib/sockunion.c | 12 | ||||
-rw-r--r-- | lib/sockunion.h | 1 |
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); |