examples/ip_pipeline: clean config parser
[dpdk.git] / examples / ip_pipeline / pipeline / pipeline_firewall_be.c
index 1c376f7..1981cc7 100644 (file)
@@ -42,6 +42,7 @@
 #include <rte_table_acl.h>
 
 #include "pipeline_firewall_be.h"
+#include "parser.h"
 
 struct pipeline_firewall {
        struct pipeline p;
@@ -308,17 +309,26 @@ pipeline_firewall_parse_args(struct pipeline_firewall *p,
                char *arg_value = params->args_value[i];
 
                if (strcmp(arg_name, "n_rules") == 0) {
-                       if (n_rules_present)
-                               return -1;
+                       int status;
+
+                       PIPELINE_PARSE_ERR_DUPLICATE(
+                               n_rules_present == 0, params->name,
+                               arg_name);
                        n_rules_present = 1;
 
-                       p->n_rules = atoi(arg_value);
+                       status = parser_read_uint32(&p->n_rules,
+                               arg_value);
+                       PIPELINE_PARSE_ERR_INV_VAL((status != -EINVAL),
+                               params->name, arg_name, arg_value);
+                       PIPELINE_PARSE_ERR_OUT_RNG((status != -ERANGE),
+                               params->name, arg_name, arg_value);
                        continue;
                }
 
                if (strcmp(arg_name, "pkt_type") == 0) {
-                       if (pkt_type_present)
-                               return -1;
+                       PIPELINE_PARSE_ERR_DUPLICATE(
+                               pkt_type_present == 0, params->name,
+                               arg_name);
                        pkt_type_present = 1;
 
                        /* ipv4 */
@@ -351,11 +361,12 @@ pipeline_firewall_parse_args(struct pipeline_firewall *p,
                        }
 
                        /* other */
-                       return -1;
+                       PIPELINE_PARSE_ERR_INV_VAL(0, params->name,
+                               arg_name, arg_value);
                }
 
                /* other */
-               return -1;
+               PIPELINE_PARSE_ERR_INV_ENT(0, params->name, arg_name);
        }
 
        return 0;