#include "quit.h"
#include "cfgfile.h"
-#include "ip6_addr.h"
#include "parse_utils.h"
#include "prox_globals.h"
#include "prox_cfg.h"
#include "log.h"
#include "prox_lua.h"
#include "prox_lua_types.h"
+#include "prox_ipv6.h"
#include "prox_compat.h"
#define MAX_NB_PORT_NAMES PROX_MAX_PORTS
return -1;
}
- prox_strncpy(&cur_var[1], &name[start_var], var_len);
+ strncpy(&cur_var[1], &name[start_var], var_len);
cur_var[1 + var_len] = 0;
if (parse_single_var(parsed, sizeof(parsed), cur_var)) {
return -1;
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;
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)
for (uint8_t i = 0, j = 0; i < ret; ++i, ++j) {
if (*addr_parts[i] == 0) {
- if (omitted == 0) {
+ if (omitted) {
set_errf("Can only omit zeros once");
return -1;
}
omitted = 1;
- j += 8 - ret;
+ j += 2 * (8 - ret) + 1;
}
else {
uint16_t w = strtoll(addr_parts[i], NULL, 16);
return 0;
}
-int parse_mac(struct ether_addr *ether_addr, const char *str2)
+int parse_mac(prox_rte_ether_addr *ether_addr, const char *str2)
{
char str[MAX_STR_LEN_PROC];
char *addr_parts[7];
if (*val >> 22)
return -2;
*val <<= 10;
- __attribute__ ((fallthrough));
+ // __attribute__ ((fallthrough));
case 'M':
if (*val >> 22)
return -2;
*val <<= 10;
- __attribute__ ((fallthrough));
+ // __attribute__ ((fallthrough));
case 'K':
if (*val >> 22)
return -2;