1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
6 #include <netinet/in.h>
7 #include <netinet/ip.h>
17 #define APP_CHECK(exp, st, fmt, ...) \
20 sprintf((st)->parse_msg, fmt "\n", \
27 #define APP_CHECK_PRESENCE(val, str, status) \
28 APP_CHECK(val == 0, status, \
29 "item \"%s\" already present", str)
31 #define APP_CHECK_TOKEN_EQUAL(tokens, index, ref, status) \
32 APP_CHECK(strcmp(tokens[index], ref) == 0, status, \
33 "unrecognized input \"%s\": expect \"%s\"\n", \
37 is_str_num(const char *str)
41 for (i = 0; i < strlen(str); i++)
48 #define APP_CHECK_TOKEN_IS_NUM(tokens, index, status) \
49 APP_CHECK(is_str_num(tokens[index]) == 0, status, \
50 "input \"%s\" is not valid number string", tokens[index])
53 #define INCREMENT_TOKEN_INDEX(index, max_num, status) \
55 APP_CHECK(index + 1 < max_num, status, "reaching the end of " \
61 parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask);
64 parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask);
67 parse_range(const char *token, uint16_t *low, uint16_t *high);
70 parse_sp4_tokens(char **tokens, uint32_t n_tokens,
71 struct parse_status *status);
74 parse_sp6_tokens(char **tokens, uint32_t n_tokens,
75 struct parse_status *status);
78 parse_sa_tokens(char **tokens, uint32_t n_tokens,
79 struct parse_status *status);
82 parse_rt_tokens(char **tokens, uint32_t n_tokens,
83 struct parse_status *status);
86 parse_cfg_file(const char *cfg_filename);