app/test-fib: get rid of libresolv dependency
Get rid of using inet_net_pton(). Implement it internally in the app. Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
This commit is contained in:
parent
d19034ae63
commit
8cd3ef5635
@ -11,8 +11,6 @@ CFLAGS += -O3
|
|||||||
CFLAGS += $(WERROR_FLAGS)
|
CFLAGS += $(WERROR_FLAGS)
|
||||||
CFLAGS += -DALLOW_EXPERIMENTAL_API
|
CFLAGS += -DALLOW_EXPERIMENTAL_API
|
||||||
|
|
||||||
LDFLAGS += -lresolv
|
|
||||||
|
|
||||||
# all source are stored in SRCS-y
|
# all source are stored in SRCS-y
|
||||||
SRCS-y := main.c
|
SRCS-y := main.c
|
||||||
|
|
||||||
|
@ -2,14 +2,10 @@
|
|||||||
* Copyright(c) 2019 Intel Corporation
|
* Copyright(c) 2019 Intel Corporation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rte_string_fns.h>
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include <rte_cycles.h>
|
#include <rte_cycles.h>
|
||||||
#include <rte_errno.h>
|
#include <rte_errno.h>
|
||||||
@ -443,6 +439,32 @@ gen_rnd_lookup_tbl(int af)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_inet_net_pton(int af, char *prefix, void *addr)
|
||||||
|
{
|
||||||
|
const char *dlm = "/";
|
||||||
|
char *s, *sp;
|
||||||
|
int ret, depth;
|
||||||
|
unsigned int max_depth;
|
||||||
|
|
||||||
|
if ((prefix == NULL) || (addr == NULL))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
s = strtok_r(prefix, dlm, &sp);
|
||||||
|
if (s == NULL)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = inet_pton(af, s, addr);
|
||||||
|
if (ret != 1)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
s = strtok_r(NULL, dlm, &sp);
|
||||||
|
max_depth = (af == AF_INET) ? 32 : 128;
|
||||||
|
GET_CB_FIELD(s, depth, 0, max_depth, 0);
|
||||||
|
|
||||||
|
return depth;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_rt_4(FILE *f)
|
parse_rt_4(FILE *f)
|
||||||
{
|
{
|
||||||
@ -463,8 +485,7 @@ parse_rt_4(FILE *f)
|
|||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = inet_net_pton(AF_INET, in[RT_PREFIX], &rt[j].addr,
|
ret = _inet_net_pton(AF_INET, in[RT_PREFIX], &rt[j].addr);
|
||||||
sizeof(rt[j].addr));
|
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
@ -478,30 +499,6 @@ parse_rt_4(FILE *f)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
__inet_net_pton6(char *prefix, uint8_t *addr)
|
|
||||||
{
|
|
||||||
const char *dlm = "/";
|
|
||||||
char *s, *sp;
|
|
||||||
int ret, depth;
|
|
||||||
|
|
||||||
if ((prefix == NULL) || (addr == NULL))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
s = strtok_r(prefix, dlm, &sp);
|
|
||||||
if (s == NULL)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ret = inet_pton(AF_INET6, s, addr);
|
|
||||||
if (ret != 1)
|
|
||||||
return -errno;
|
|
||||||
|
|
||||||
s = strtok_r(NULL, dlm, &sp);
|
|
||||||
GET_CB_FIELD(s, depth, 0, 128, 0);
|
|
||||||
|
|
||||||
return depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
parse_rt_6(FILE *f)
|
parse_rt_6(FILE *f)
|
||||||
{
|
{
|
||||||
@ -522,7 +519,7 @@ parse_rt_6(FILE *f)
|
|||||||
s = NULL;
|
s = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = __inet_net_pton6(in[RT_PREFIX], rt[j].addr);
|
ret = _inet_net_pton(AF_INET6, in[RT_PREFIX], rt[j].addr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user