From 9208b86b5ecf72b69743a09cd0c8a99078c0fc0f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 30 Apr 2009 01:33:21 +0200 Subject: [PATCH] parseaddr: add new call pa_is_ip_address() --- src/pulsecore/parseaddr.c | 15 +++++++++++++++ src/pulsecore/parseaddr.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/src/pulsecore/parseaddr.c b/src/pulsecore/parseaddr.c index 5b53122..1cd010b 100644 --- a/src/pulsecore/parseaddr.c +++ b/src/pulsecore/parseaddr.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -131,3 +132,17 @@ int pa_parse_address(const char *name, pa_parsed_address *ret_p) { return 0; } + +pa_bool_t pa_is_ip_address(const char *a) { + char buf[INET6_ADDRSTRLEN]; + + pa_assert(a); + + if (inet_pton(AF_INET6, a, buf) >= 1) + return TRUE; + + if (inet_pton(AF_INET, a, buf) >= 1) + return TRUE; + + return FALSE; +} diff --git a/src/pulsecore/parseaddr.h b/src/pulsecore/parseaddr.h index 5fbcb9a..0728b5e 100644 --- a/src/pulsecore/parseaddr.h +++ b/src/pulsecore/parseaddr.h @@ -39,4 +39,6 @@ typedef struct pa_parsed_address { int pa_parse_address(const char *a, pa_parsed_address *ret_p); +pa_bool_t pa_is_ip_address(const char *a); + #endif -- 2.7.4