diff options
author | Thomas Gschwantner <tharre3@gmail.com> | 2019-04-23 22:06:22 +0200 |
---|---|---|
committer | Thomas Gschwantner <tharre3@gmail.com> | 2019-06-12 19:05:33 +0200 |
commit | 0f06351cb0085c79b617a4acc0bd6749b53c638e (patch) | |
tree | 13f6eb367f4ed326817741953166975b912b214e /common.c | |
parent | radix-trie: implement ipp_addrnd_* and related (diff) | |
download | wg-dynamic-0f06351cb0085c79b617a4acc0bd6749b53c638e.tar.xz wg-dynamic-0f06351cb0085c79b617a4acc0bd6749b53c638e.zip |
Implement basic lease management
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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); |