From c000b546d97aa97144ee2cdf396d46a039bb7f98 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 14 Oct 2011 00:30:54 +0200 Subject: proto-shell: allow passing netmask in ip address format --- proto-static.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'proto-static.c') diff --git a/proto-static.c b/proto-static.c index f5d676a..b8f3412 100644 --- a/proto-static.c +++ b/proto-static.c @@ -103,20 +103,18 @@ static int proto_apply_static_settings(struct interface *iface, struct blob_attr *attr) { struct blob_attr *tb[__OPT_MAX]; - struct in_addr ina; const char *error; - int netmask = 32; + unsigned int netmask = 32; int n_v4 = 0, n_v6 = 0; blobmsg_parse(static_attrs, __OPT_MAX, tb, blob_data(attr), blob_len(attr)); if (tb[OPT_NETMASK]) { - if (!inet_aton(blobmsg_data(tb[OPT_NETMASK]), &ina)) { + netmask = parse_netmask_string(blobmsg_data(tb[OPT_NETMASK]), false); + if (netmask > 32) { error = "INVALID_NETMASK"; goto error; } - - netmask = 32 - fls(~(ntohl(ina.s_addr))); } if (tb[OPT_IPADDR]) -- cgit v1.2.3