regex_api.h (1906B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 */ 8 #ifndef _RE_H_ 9 #define _RE_H_ 10 11 #if defined(INCLUDE_REGEX) 12 13 #define DFA_TRAVERSE_START 0x1 14 #define DFA_TRAVERSE_END 0x2 15 #define DFA_STATE_FINAL 0x4 16 17 typedef enum { 18 REGEX_ERROR_NONE = 0, 19 REGEX_ERROR_INVALID_CLASS = -1, 20 REGEX_ERROR_EXPANSION_FAIL = -2, 21 REGEX_ERROR_NO_POST = -3, 22 REGEX_ERROR_NO_DFA = -4, 23 REGEX_ERROR_NO_NFA = -5, 24 REGEX_ERROR_NO_MEMORY = -6, 25 REGEX_ERROR = -7 26 } regex_error; 27 28 typedef enum { 29 REGEX_CB_OK = 0, 30 REGEX_CB_ABORT, 31 } regex_cb_error_t; 32 33 #define BCM_TR3_REGEX_CFLAG_EXPAND_LCUC 0x01 34 #define BCM_TR3_REGEX_CFLAG_EXPAND_UC 0x02 35 #define BCM_TR3_REGEX_CFLAG_EXPAND_LC 0x04 36 #define BCM_TR3_REGEX_CFLAG_ANCHORED 0x08 37 38 #define REGEX_MAX_CHARACTER_CLASSES 256 39 #define REGEX_MAX_CHARACTER_CLASS_BYTES (BITS2BYTES(REGEX_MAX_CHARACTER_CLASSES)) 40 #define REGEX_MAX_CHARACTER_CLASS_WORDS (BITS2WORDS(REGEX_MAX_CHARACTER_CLASSES)) 41 42 /* 43 * Call user provided callback to map a DFA State to HW. 44 */ 45 typedef regex_cb_error_t (*regex_dfa_state_cb)(unsigned int flags, 46 int match_idx, int in_state, int from_c, int to_c, 47 int to_state, int num_dfa_state, void *user_data); 48 49 50 int bcm_regex_compile(char **re, unsigned int *res_flags, 51 int num_pattern, unsigned int cflags, void** dfa); 52 53 int bcm_regex_dfa_traverse(void *dfa, regex_dfa_state_cb compile_dfa_cb, 54 void *user_data); 55 56 int bcm_regex_dfa_free(void *dfa); 57 58 extern void _bcm_regex_sw_dump(int unit); 59 60 #endif /* INCLUDE_REGEX */ 61 62 #endif /* _RE_H_ */