1
2
3
4
5#ifndef __INCLUDE_SOFTNIC_PARSER_H__
6#define __INCLUDE_SOFTNIC_PARSER_H__
7
8#include <stdint.h>
9
10#include <rte_ip.h>
11#include <rte_ether.h>
12
13#define PARSE_DELIMITER " \f\n\r\t\v"
14
15#define skip_white_spaces(pos) \
16({ \
17 __typeof__(pos) _p = (pos); \
18 for ( ; isspace(*_p); _p++) \
19 ; \
20 _p; \
21})
22
23static inline size_t
24skip_digits(const char *src)
25{
26 size_t i;
27
28 for (i = 0; isdigit(src[i]); i++)
29 ;
30
31 return i;
32}
33
34int softnic_parser_read_arg_bool(const char *p);
35
36int softnic_parser_read_int32(int32_t *value, const char *p);
37
38int softnic_parser_read_uint64(uint64_t *value, const char *p);
39int softnic_parser_read_uint32(uint32_t *value, const char *p);
40int softnic_parser_read_uint16(uint16_t *value, const char *p);
41int softnic_parser_read_uint8(uint8_t *value, const char *p);
42
43int softnic_parser_read_uint64_hex(uint64_t *value, const char *p);
44int softnic_parser_read_uint32_hex(uint32_t *value, const char *p);
45int softnic_parser_read_uint16_hex(uint16_t *value, const char *p);
46int softnic_parser_read_uint8_hex(uint8_t *value, const char *p);
47
48int softnic_parse_hex_string(char *src, uint8_t *dst, uint32_t *size);
49
50int softnic_parse_ipv4_addr(const char *token, struct in_addr *ipv4);
51int softnic_parse_ipv6_addr(const char *token, struct in6_addr *ipv6);
52int softnic_parse_mac_addr(const char *token, struct rte_ether_addr *addr);
53int softnic_parse_mpls_labels(char *string,
54 uint32_t *labels, uint32_t *n_labels);
55
56struct softnic_cpu_core_params {
57 uint32_t socket_id;
58 uint32_t core_id;
59 uint32_t thread_id;
60};
61
62int softnic_parse_cpu_core(const char *entry,
63 struct softnic_cpu_core_params *p);
64
65int softnic_parse_tokenize_string(char *string,
66 char *tokens[], uint32_t *n_tokens);
67
68#endif
69