aboutsummaryrefslogtreecommitdiffstats
path: root/common.c
diff options
context:
space:
mode:
authorThomas Gschwantner <tharre3@gmail.com>2019-04-23 22:06:22 +0200
committerThomas Gschwantner <tharre3@gmail.com>2019-06-12 19:05:33 +0200
commit0f06351cb0085c79b617a4acc0bd6749b53c638e (patch)
tree13f6eb367f4ed326817741953166975b912b214e /common.c
parentradix-trie: implement ipp_addrnd_* and related (diff)
downloadwg-dynamic-0f06351cb0085c79b617a4acc0bd6749b53c638e.tar.xz
wg-dynamic-0f06351cb0085c79b617a4acc0bd6749b53c638e.zip
Implement basic lease management
Diffstat (limited to 'common.c')
-rw-r--r--common.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/common.c b/common.c
index a3ce7ae..5be1226 100644
--- a/common.c
+++ b/common.c
@@ -25,12 +25,20 @@ static bool parse_ip_cidr(struct wg_combined_ip *ip, char *value)
{
uintmax_t res;
char *endptr;
- char *sep = strchr(value, '/');
+ char *sep;
+
+ if (value[0] == '\0') {
+ memset(ip, 0, ip->family == AF_INET ? 4 : 16);
+ ip->cidr = 0;
+ return true;
+ }
+
+ sep = strchr(value, '/');
if (!sep)
return false;
*sep = '\0';
- if (inet_pton(ip->family, value, &ip->ip) != 1)
+ if (inet_pton(ip->family, value, ip) != 1)
return false;
res = strtoumax(sep + 1, &endptr, 10);