diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-10-14 00:30:54 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-10-14 00:30:54 +0200 |
commit | c000b546d97aa97144ee2cdf396d46a039bb7f98 (patch) | |
tree | 90668d89cd3d96c041f9a117fc4c10d492125338 /proto-static.c | |
parent | b021a49efe0641f7c5ca763bc43e5ba73b7a1b5f (diff) |
proto-shell: allow passing netmask in ip address format
Diffstat (limited to 'proto-static.c')
-rw-r--r-- | proto-static.c | 8 |
1 files changed, 3 insertions, 5 deletions
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]) |