1/*
2 * Copyright (c) 2016  Intel Corporation.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef __PARSE_H__
17#define __PARSE_H__
18
19#include <sched.h>
20
21#define PARSE_LIST_DELIM "-"
22
23union parse_val {
24	uint64_t u64;
25	struct {
26		uint16_t family;
27		union {
28			struct in_addr addr4;
29			struct in6_addr addr6;
30		};
31	} in;
32	struct ether_addr mac;
33	rte_cpuset_t cpuset;
34};
35
36static const char *
37format_addr(const struct sockaddr_storage *sp, char buf[], size_t len)
38{
39	const struct sockaddr_in *i4;
40	const struct sockaddr_in6 *i6;
41	const void *addr;
42
43	if (sp->ss_family == AF_INET) {
44		i4 = (const struct sockaddr_in *)sp;
45		addr = &i4->sin_addr;
46	} else if (sp->ss_family == AF_INET6) {
47		i6 = (const struct sockaddr_in6 *)sp;
48		addr = &i6->sin6_addr;
49	} else
50		return NULL;
51
52
53	return inet_ntop(sp->ss_family, addr, buf, len);
54}
55
56int parse_netbe_arg(struct netbe_port *prt, const char *arg,
57	rte_cpuset_t *pcpu);
58
59int netbe_parse_dest(const char *fname, struct netbe_dest_prm *prm);
60
61int netfe_parse_cfg(const char *fname, struct netfe_lcore_prm *lp);
62
63int
64parse_app_options(int argc, char **argv, struct netbe_cfg *cfg,
65	struct tle_ctx_param *ctx_prm,
66	char *fecfg_fname, char *becfg_fname);
67
68#endif /* __PARSE_H__ */
69
70