1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2010-2016 Intel Corporation 3 */ 4 5 #ifndef __INCLUDE_PARSER_H__ 6 #define __INCLUDE_PARSER_H__ 7 8 #include <ctype.h> 9 #include <stdint.h> 10 11 #include <rte_ip.h> 12 #include <rte_ether.h> 13 14 #define PARSE_DELIMITER " \f\n\r\t\v" 15 16 static inline size_t 17 skip_digits(const char *src) 18 { 19 size_t i; 20 21 for (i = 0; isdigit(src[i]); i++) 22 ; 23 24 return i; 25 } 26 27 int parser_read_arg_bool(const char *p); 28 29 int parser_read_uint64(uint64_t *value, const char *p); 30 int parser_read_uint32(uint32_t *value, const char *p); 31 int parser_read_uint16(uint16_t *value, const char *p); 32 int parser_read_uint8(uint8_t *value, const char *p); 33 34 int parser_read_uint64_hex(uint64_t *value, const char *p); 35 int parser_read_uint32_hex(uint32_t *value, const char *p); 36 int parser_read_uint16_hex(uint16_t *value, const char *p); 37 int parser_read_uint8_hex(uint8_t *value, const char *p); 38 39 int parse_hex_string(char *src, uint8_t *dst, uint32_t *size); 40 41 int parse_ipv4_addr(const char *token, struct in_addr *ipv4); 42 int parse_ipv6_addr(const char *token, struct rte_ipv6_addr *ipv6); 43 int parse_mac_addr(const char *token, struct rte_ether_addr *addr); 44 int parse_mpls_labels(char *string, uint32_t *labels, uint32_t *n_labels); 45 46 struct cpu_core_params { 47 uint32_t socket_id; 48 uint32_t core_id; 49 uint32_t thread_id; 50 }; 51 52 int parse_cpu_core(const char *entry, struct cpu_core_params *p); 53 54 int parse_tokenize_string(char *string, char *tokens[], uint32_t *n_tokens); 55 56 #endif 57