Data Structure Description
- Enumerated variables of the multi-pattern rule matching engine:
typedef enum { MMPM_MATCHER_NONE = 0, MMPM_MATCHER_TYPE_HASH, MMPM_MATCHER_TYPE_AC, MMPM_MATCHER_TYPE_MAX } mmpm_matcher_type; - Error code of multi-pattern rule matching:
#define MMPM_SUCCESS 0 #define MMPM_INVALID_PARA (-1) #define MMPM_MALLOC_FAIL (-2) #define MMPM_BUILT_ALREADY (-3) #define MMPM_FIND_FAIL (-4) #define MMPM_INIT_RWLOCK_FAIL (-5) #define MMPM_MEMCPY_FAIL (-6) #define MMPM_NOT_SUPPORTED (-7)
Table 1 Error codes Error Code
Return Value
Description
Solution
MMPM_INVALID_PARA
-1
Null pointer or invalid rule, where key_len is 0 or is inconsistent with the actual key length.
Check the validity of input parameters for the reported function.
MMPM_MALLOC_FAIL
-2
Heap memory allocation failed.
Check if the system memory is heavily utilized by other programs, and if too many rules are input when building the matching engine.
MMPM_BUILT_ALREADY
-3
The matching engine has been successfully built. Do not build it again.
Check for erroneous multiple builds of the matching engine.
MMPM_FIND_FAIL
-4
Rule matching failed (the rule failed to be found in the matching engine).
-
MMPM_INIT_RWLOCK_FAIL
-5
Lock initialization failed when a hash-based matching engine is initialized.
Check if the system memory is heavily utilized by other programs.
MMPM_MEMCPY_FAIL
-6
Memory copy failed.
-
MMPM_NOT_SUPPORTED
-7
The handle of the AC matching engine is transferred to the rule removal function.
Check for any attempts to remove rules related to the AC matching engine.
- Rule structure of multi-pattern rule matching:
typedef struct { uint32_t alias; /* Rule alias, where duplicate names are allowed. */ uint32_t key_len; uint8_t *key; /* Rule matching key, which is the unique identifier. */ } mmpm_rule_t; - Matching engine handle data structure of multi-pattern rule matching:
typedef struct { void *mmpm_matcher; /* Matching engine handle */ mmpm_matcher_type type; /* Matching engine type */ bool is_built; /* Whether the matching engine is built. */ } mmpm_handler_t;