1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016 Intel Corporation
9 #include <netinet/in.h>
10 #include <netinet/ip.h>
18 #define APP_CHECK(exp, st, fmt, ...) \
21 sprintf((st)->parse_msg, fmt "\n", \
28 #define APP_CHECK_PRESENCE(val, str, status) \
29 APP_CHECK(val == 0, status, \
30 "item \"%s\" already present", str)
32 #define APP_CHECK_TOKEN_EQUAL(tokens, index, ref, status) \
33 APP_CHECK(strcmp(tokens[index], ref) == 0, status, \
34 "unrecognized input \"%s\": expect \"%s\"\n", \
38 is_str_num(const char *str)
42 for (i = 0; i < strlen(str); i++)
49 #define APP_CHECK_TOKEN_IS_NUM(tokens, index, status) \
50 APP_CHECK(is_str_num(tokens[index]) == 0, status, \
51 "input \"%s\" is not valid number string", tokens[index])
54 #define INCREMENT_TOKEN_INDEX(index, max_num, status) \
56 APP_CHECK(index + 1 < max_num, status, "reaching the end of " \
62 parse_ipv4_addr(const char *token, struct in_addr *ipv4, uint32_t *mask);
65 parse_ipv6_addr(const char *token, struct in6_addr *ipv6, uint32_t *mask);
68 parse_range(const char *token, uint16_t *low, uint16_t *high);
74 parse_sp4_tokens(char **tokens, uint32_t n_tokens,
75 struct parse_status *status);
81 parse_sp6_tokens(char **tokens, uint32_t n_tokens,
82 struct parse_status *status);
88 parse_sa_tokens(char **tokens, uint32_t n_tokens,
89 struct parse_status *status);
92 parse_rt_tokens(char **tokens, uint32_t n_tokens,
93 struct parse_status *status);
96 parse_cfg_file(const char *cfg_filename);