|
Wireshark 4.7.0
The Wireshark network protocol analyzer
|
#include <stdio.h>#include <inttypes.h>#include <wsutil/ws_assert.h>#include <wsutil/wslog.h>#include <epan/ftypes/ftypes.h>#include "dfilter-loc.h"Go to the source code of this file.
Classes | |
| struct | sttype_t |
| Describes a syntax tree node type, including its lifecycle and serialization callbacks. More... | |
| struct | stnode |
| A single node instance in the display filter syntax tree. More... | |
Macros | |
| #define | ASSERT_STTYPE_NOT_REACHED(st) ws_error("Invalid syntax node type '%s'.", sttype_name(st)) |
| #define | ASSERT_STNODE_OP_NOT_REACHED(op) ws_error("Invalid stnode op '%s'.", stnode_op_name(op)) |
| #define | STFLAG_UNPARSED (1 << 0) |
| Lexical value is ambiguous and may represent either a protocol field or a literal value. | |
| #define | stnode_todisplay(node) stnode_tostr(node, true) |
| Convert a syntax tree node to a printable string. | |
| #define | stnode_todebug(node) stnode_tostr(node, false) |
| Convert a syntax tree node to a debug string. | |
| #define | log_node(node) (void)0 |
| #define | log_test(node) (void)0 |
| #define | LOG_NODE(node) (void)0 |
| #define | ws_assert_magic(obj, mnum) (void)0 |
Typedefs | |
| typedef void *(* | STTypeNewFunc) (void *data) |
| Allocates and initializes type-specific data for a syntax tree node. | |
| typedef void *(* | STTypeDupFunc) (const void *data) |
| Performs a deep copy of type-specific node data. | |
| typedef void(* | STTypeFreeFunc) (void *data) |
| Releases type-specific data associated with a syntax tree node. | |
| typedef char *(* | STTypeToStrFunc) (const void *data, bool pretty) |
| Converts type-specific node data to a human-readable string. | |
| typedef struct stnode | stnode_t |
| A single node instance in the display filter syntax tree. | |
Functions | |
| void | sttype_register_field (void) |
| Register the field type in the syntax tree type system. | |
| void | sttype_register_function (void) |
| Register the function type in the syntax tree type system. | |
| void | sttype_register_number (void) |
| Register the number type in the syntax tree type system. | |
| void | sttype_register_pointer (void) |
| Register the pointer type in the syntax tree type system. | |
| void | sttype_register_set (void) |
| Register the set type in the syntax tree type system. | |
| void | sttype_register_slice (void) |
| Register the slice type in the syntax tree type system. | |
| void | sttype_register_string (void) |
| Register the string type in the syntax tree type system. | |
| void | sttype_register_opers (void) |
| Register the operator types in the syntax tree type system. | |
| void | sttype_init (void) |
| Initialize the syntax tree types. | |
| void | sttype_cleanup (void) |
| Cleans up resources associated with the syntax tree types. | |
| void | sttype_register (sttype_t *type) |
| Registers a syntax tree type. | |
| WS_DLL_PUBLIC const char * | sttype_name (const sttype_id_t type) |
| Get the name of a syntax tree type. | |
| WS_DLL_PUBLIC const char * | stnode_op_name (const stnode_op_t op) |
| Get the name of an operation based on its type. | |
| WS_DLL_PUBLIC stnode_t * | stnode_new (sttype_id_t type_id, void *data, char *token, df_loc_t loc) |
| Creates a new syntax tree node with the given type ID, data, token, and location. | |
| WS_DLL_PUBLIC stnode_t * | stnode_new_empty (sttype_id_t type_id) |
| Creates a new empty syntax tree node. | |
| WS_DLL_PUBLIC stnode_t * | stnode_dup (const stnode_t *org) |
| Duplicates a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_clear (stnode_t *node) |
| Clears the contents of a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_init (stnode_t *node, sttype_id_t type_id, void *data, char *token, df_loc_t loc) |
| Initialize a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_replace (stnode_t *node, sttype_id_t type_id, void *data) |
| Replaces a node in the syntax tree with a new type and data. | |
| WS_DLL_PUBLIC void | stnode_mutate (stnode_t *node, sttype_id_t type_id) |
| Mutates the type of a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_free (stnode_t *node) |
| Frees a syntax tree node. | |
| WS_DLL_PUBLIC const char * | stnode_type_name (const stnode_t *node) |
| Get the type name of a syntax tree node. | |
| WS_DLL_PUBLIC sttype_id_t | stnode_type_id (const stnode_t *node) |
| Retrieves the type ID of a syntax tree node. | |
| WS_DLL_PUBLIC void * | stnode_data (stnode_t *node) |
| Retrieves the data associated with a syntax tree node. | |
| WS_DLL_PUBLIC GString * | stnode_string (stnode_t *node) |
| Retrieves the string data from a syntax tree node. | |
| WS_DLL_PUBLIC void * | stnode_steal_data (stnode_t *node) |
| Steals and returns the data associated with a syntax tree node. | |
| WS_DLL_PUBLIC const char * | stnode_token (const stnode_t *node) |
| Retrieves the token representation of a syntax tree node. | |
| WS_DLL_PUBLIC df_loc_t | stnode_location (const stnode_t *node) |
| Get the location of a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_set_location (stnode_t *node, df_loc_t loc) |
| Set the location for a syntax tree node. | |
| WS_DLL_PUBLIC bool | stnode_get_flags (stnode_t *node, uint16_t flags) |
| Get flags from a syntax tree node. | |
| WS_DLL_PUBLIC void | stnode_set_flags (stnode_t *node, uint16_t flags) |
| Sets flags for a syntax tree node. | |
| void | stnode_merge_location (stnode_t *dst, stnode_t *n1, stnode_t *n2) |
| Merges location information from two syntax tree nodes into a destination node. | |
| WS_DLL_PUBLIC const char * | stnode_tostr (stnode_t *node, bool pretty) |
| Convert a syntax tree node to a string representation. | |
| void | log_node_full (enum ws_log_level level, const char *file, int line, const char *func, stnode_t *node, const char *msg) |
| Logs a full message with detailed information about a syntax tree node. | |
| void | log_test_full (enum ws_log_level level, const char *file, int line, const char *func, stnode_t *node, const char *msg) |
| Logs a full test message for a syntax tree node. | |
| char * | dump_syntax_tree_str (stnode_t *root) |
| Dumps a syntax tree to a string. | |
| void | log_syntax_tree (enum ws_log_level level, stnode_t *root, const char *msg, char **cache_ptr) |
| Logs a syntax tree with an optional message and caches the result. | |
| #define stnode_todebug | ( | node | ) | stnode_tostr(node, false) |
Convert a syntax tree node to a debug string.
This function returns a string representation of the syntax tree node that is suitable for debugging purposes.
| node | The syntax tree node to convert. |
| #define stnode_todisplay | ( | node | ) | stnode_tostr(node, true) |
Convert a syntax tree node to a printable string.
This function returns a string representation of the syntax tree node that is suitable for display purposes.
| node | The syntax tree node to convert. |
| typedef void *(* STTypeDupFunc) (const void *data) |
Performs a deep copy of type-specific node data.
| data | Pointer to the source type data to duplicate. |
| typedef void(* STTypeFreeFunc) (void *data) |
Releases type-specific data associated with a syntax tree node.
| data | Pointer to the type data to free. |
| typedef void *(* STTypeNewFunc) (void *data) |
Allocates and initializes type-specific data for a syntax tree node.
| data | Pointer to initialization data passed to the constructor. |
| typedef char *(* STTypeToStrFunc) (const void *data, bool pretty) |
Converts type-specific node data to a human-readable string.
| data | Pointer to the type data to render. |
| pretty | If true, produce a display-friendly representation; otherwise a debug form. |
| enum stmatch_t |
Quantifier controlling how many field values must satisfy a match condition.
| enum stnode_op_t |
Operator types for test and arithmetic syntax tree nodes.
| enum stnumber_t |
| enum sttype_id_t |
Type identifier tags for syntax tree nodes in the display filter compiler.
| char * dump_syntax_tree_str | ( | stnode_t * | root | ) |
Dumps a syntax tree to a string.
| root | Pointer to the root node of the syntax tree. |
| void log_node_full | ( | enum ws_log_level | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| stnode_t * | node, | ||
| const char * | msg | ||
| ) |
Logs a full message with detailed information about a syntax tree node.
| level | The log level for this message. |
| file | The source file where the function is called. |
| line | The line number in the source file where the function is called. |
| func | The name of the function calling this one. |
| node | The syntax tree node to be logged. |
| msg | A custom message to accompany the log entry. |
| void log_syntax_tree | ( | enum ws_log_level | level, |
| stnode_t * | root, | ||
| const char * | msg, | ||
| char ** | cache_ptr | ||
| ) |
Logs a syntax tree with an optional message and caches the result.
| level | The log level to use for logging. |
| root | The root node of the syntax tree to log. |
| msg | An optional message to include in the log entry. |
| cache_ptr | A pointer to a char pointer where the logged string will be cached, or NULL if not needed. |
| void log_test_full | ( | enum ws_log_level | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| stnode_t * | node, | ||
| const char * | msg | ||
| ) |
Logs a full test message for a syntax tree node.
| level | The log level to use. |
| file | The source file name where the function is called. |
| line | The line number in the source file where the function is called. |
| func | The function name where the function is called. |
| node | The syntax tree node to log. |
| msg | A message describing the test. |
| WS_DLL_PUBLIC void stnode_clear | ( | stnode_t * | node | ) |
Clears the contents of a syntax tree node.
This function releases any resources associated with the node and resets its fields to their initial state.
| node | Pointer to the syntax tree node to be cleared. |
| WS_DLL_PUBLIC void * stnode_data | ( | stnode_t * | node | ) |
Retrieves the data associated with a syntax tree node.
| node | Pointer to the syntax tree node. |
Duplicates a syntax tree node.
Creates a new syntax tree node that is a deep copy of the given node.
| org | The original syntax tree node to duplicate. |
| WS_DLL_PUBLIC void stnode_free | ( | stnode_t * | node | ) |
Frees a syntax tree node.
| node | Pointer to the syntax tree node to be freed. |
| WS_DLL_PUBLIC bool stnode_get_flags | ( | stnode_t * | node, |
| uint16_t | flags | ||
| ) |
Get flags from a syntax tree node.
| node | Pointer to the syntax tree node. |
| flags | Flags to retrieve. |
| WS_DLL_PUBLIC void stnode_init | ( | stnode_t * | node, |
| sttype_id_t | type_id, | ||
| void * | data, | ||
| char * | token, | ||
| df_loc_t | loc | ||
| ) |
Initialize a syntax tree node.
| node | Pointer to the syntax tree node to initialize. |
| type_id | Type identifier for the node. |
| data | Data associated with the node. |
| token | Token string representing the node. |
| loc | Location information for the node. |
Get the location of a syntax tree node.
| node | The syntax tree node to get the location from. |
Merges location information from two syntax tree nodes into a destination node.
This function updates the location of the destination node to encompass the locations of both input nodes.
| dst | Pointer to the destination syntax tree node where the merged location will be stored. |
| n1 | Pointer to the first source syntax tree node. |
| n2 | Pointer to the second source syntax tree node. |
| WS_DLL_PUBLIC void stnode_mutate | ( | stnode_t * | node, |
| sttype_id_t | type_id | ||
| ) |
Mutates the type of a syntax tree node.
| node | Pointer to the syntax tree node to be mutated. |
| type_id | The new type ID for the node. |
| WS_DLL_PUBLIC stnode_t * stnode_new | ( | sttype_id_t | type_id, |
| void * | data, | ||
| char * | token, | ||
| df_loc_t | loc | ||
| ) |
Creates a new syntax tree node with the given type ID, data, token, and location.
| type_id | The type ID of the node. |
| data | The data associated with the node. |
| token | The token representing the node. |
| loc | The location information for the node. |
| WS_DLL_PUBLIC stnode_t * stnode_new_empty | ( | sttype_id_t | type_id | ) |
Creates a new empty syntax tree node.
| type_id | The type identifier for the new node. |
| WS_DLL_PUBLIC const char * stnode_op_name | ( | const stnode_op_t | op | ) |
Get the name of an operation based on its type.
| op | The operation type to get the name for. |
| WS_DLL_PUBLIC void stnode_replace | ( | stnode_t * | node, |
| sttype_id_t | type_id, | ||
| void * | data | ||
| ) |
Replaces a node in the syntax tree with a new type and data.
| node | Pointer to the node to be replaced. |
| type_id | The new type ID for the node. |
| data | Pointer to the new data for the node. |
| WS_DLL_PUBLIC void stnode_set_flags | ( | stnode_t * | node, |
| uint16_t | flags | ||
| ) |
Sets flags for a syntax tree node.
| node | Pointer to the syntax tree node. |
| flags | Flags to be set. |
Set the location for a syntax tree node.
| node | The syntax tree node to set the location for. |
| loc | The new location to set. |
| WS_DLL_PUBLIC void * stnode_steal_data | ( | stnode_t * | node | ) |
Steals and returns the data associated with a syntax tree node.
| node | The syntax tree node from which to steal the data. |
| WS_DLL_PUBLIC GString * stnode_string | ( | stnode_t * | node | ) |
Retrieves the string data from a syntax tree node.
| node | Pointer to the syntax tree node. |
| WS_DLL_PUBLIC const char * stnode_token | ( | const stnode_t * | node | ) |
Retrieves the token representation of a syntax tree node.
| node | Pointer to the syntax tree node. |
| WS_DLL_PUBLIC const char * stnode_tostr | ( | stnode_t * | node, |
| bool | pretty | ||
| ) |
Convert a syntax tree node to a string representation.
| node | The syntax tree node to convert. |
| pretty | If true, produce a pretty-printed string; otherwise, produce a debug-friendly string. |
| WS_DLL_PUBLIC sttype_id_t stnode_type_id | ( | const stnode_t * | node | ) |
Retrieves the type ID of a syntax tree node.
| node | Pointer to the syntax tree node. |
| WS_DLL_PUBLIC const char * stnode_type_name | ( | const stnode_t * | node | ) |
Get the type name of a syntax tree node.
| node | Pointer to the syntax tree node. |
| void sttype_cleanup | ( | void | ) |
Cleans up resources associated with the syntax tree types.
This function is responsible for releasing any resources that were allocated during the registration of various syntax tree types, such as strings, literals, and unparsed types.
| void sttype_init | ( | void | ) |
Initialize the syntax tree types.
This function initializes the various types used in the syntax tree, including fvalue, pcre, and charconst types.
| WS_DLL_PUBLIC const char * sttype_name | ( | const sttype_id_t | type | ) |
Get the name of a syntax tree type.
| type | The syntax tree type ID. |
| void sttype_register | ( | sttype_t * | type | ) |
Registers a syntax tree type.
This function adds a new syntax tree type to the system, allowing it to be used in the construction of syntax trees.
| type | The syntax tree type to register. |