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 e4465eb..64be308 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,
 };