add validation rules to proto static
authorJohn Crispin <blogic@openwrt.org>
Mon, 17 Feb 2014 12:12:24 +0000 (12:12 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 17 Feb 2014 14:10:11 +0000 (15:10 +0100)
Signed-off-by: John Crispin <blogic@openwrt.org>
proto.c

diff --git a/proto.c b/proto.c
index e4465eb14e2a1900d3b38a3296dfc4c75f6ea47e..64be308c970a39e210401edf6d28eb66dc9d5d4e 100644 (file)
--- a/proto.c
+++ b/proto.c
@@ -55,9 +55,20 @@ static const struct uci_blob_param_info proto_ip_attr_info[__OPT_MAX] = {
        [OPT_IP6PREFIX] = { .type = BLOBMSG_TYPE_STRING },
 };
 
+static const char * const proto_ip_validate[__OPT_MAX] = {
+       [OPT_IPADDR] = "ip4addr",
+       [OPT_IP6ADDR] = "ip6addr",
+       [OPT_NETMASK] = "netmask",
+       [OPT_BROADCAST] = "ipaddr",
+       [OPT_GATEWAY] = "ip4addr",
+       [OPT_IP6GW] = "ip6addr",
+       [OPT_IP6PREFIX] = "ip6addr",
+};
+
 const struct uci_blob_param_list proto_ip_attr = {
        .n_params = __OPT_MAX,
        .params = proto_ip_attributes,
+       .validate = proto_ip_validate,
        .info = proto_ip_attr_info,
 };