summaryrefslogtreecommitdiffstats
path: root/VNFs/DPPD-PROX/parse_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'VNFs/DPPD-PROX/parse_utils.c')
-rw-r--r--VNFs/DPPD-PROX/parse_utils.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/VNFs/DPPD-PROX/parse_utils.c b/VNFs/DPPD-PROX/parse_utils.c
index ab0e03b7..9ceb1c59 100644
--- a/VNFs/DPPD-PROX/parse_utils.c
+++ b/VNFs/DPPD-PROX/parse_utils.c
@@ -311,7 +311,7 @@ int parse_ip(uint32_t *addr, const char *str2)
return 0;
}
-int parse_ip4_cidr(struct ip4_subnet *val, const char *str2)
+int parse_ip4_and_prefix(struct ip4_subnet *val, const char *str2)
{
char str[MAX_STR_LEN_PROC];
char *slash;
@@ -341,10 +341,16 @@ int parse_ip4_cidr(struct ip4_subnet *val, const char *str2)
if (parse_ip(&val->ip, str))
return -2;
+ return 0;
+}
+
+int parse_ip4_cidr(struct ip4_subnet *val, const char *str2)
+{
+ int rc = parse_ip4_and_prefix(val, str2);
/* Apply mask making all bits outside the prefix zero */
- val->ip &= ((int)(1 << 31)) >> (prefix - 1);
+ val->ip &= ((int)(1 << 31)) >> (val->prefix - 1);
- return 0;
+ return rc;
}
int parse_ip6_cidr(struct ip6_subnet *val, const char *str2)