| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Classes | Macros | Functions
dfilter-int.h File Reference
`#include "dfilter.h"`
`#include "syntax-tree.h"`
`#include <epan/proto.h>`
`#include <stdio.h>`

Go to the source code of this file.

## Classes
struct | df_reference_t
| Reference to a display filter field. More...
struct | df_cell_t
| A container for a pointer array, typically holding field references. More...
struct | df_cell_iter_t
| Iterator for navigating through a df_cell_t array. More...
struct | epan_dfilter
| The compiled display filter object passed back to the user. More...
struct | dfstate_t
| State structure for display filter evaluation or processing. More...
struct | dfsyntax_t
| State for the first stage of display filter compilation (parsing). More...
struct | dfwork_t
| State for the second stage of display filter compilation (semantic check and code generation). More...

## Macros
#define | SCAN_FAILED -1
| Indicates a scanning failure. Not 0, as 0 means end-of-input.
#define | df_cell_ptr(rp)

## Functions
void * | DfilterAlloc (void *(*)(size_t))
| Allocator for the display filter.
void | DfilterFree (void *, void(*)(void *))
| Deallocator for the display filter.
void | Dfilter (void *yyp, int yymajor, stnode_t *yyminor, dfsyntax_t *)
| Evaluates a token in the Lemon Parser.
WS_DLL_PUBLIC void | dfilter_vfail (void *state, int code, df_loc_t err_loc, const char *format, va_list args)
| Report a failure in a display filter.
WS_DLL_PUBLIC void | dfilter_fail (void *state, int code, df_loc_t err_loc, const char *format,...)
| Handle a filter failure and log an error message.
WS_DLL_PUBLIC WS_NORETURN void | dfilter_fail_throw (void *state, int code, df_loc_t err_loc, const char *format,...)
| Throw a filter failure with an error message.
void | dfw_set_error_location (dfwork_t *dfw, df_loc_t err_loc)
| Set the error location for a given dfwork_t object.
void | add_deprecated_token (GPtrArray *deprecated, const char *token)
| Adds a deprecated token to an array.
void | add_compile_warning (dfwork_t *dfw, const char *format,...)
| Adds a compile warning to the given dfwork_t structure.
void | free_deprecated (GPtrArray *deprecated)
| Frees memory allocated for deprecated items.
void | DfilterTrace (FILE *TraceFILE, char *zTracePrompt)
| Writes a trace prompt to the specified file.
header_field_info * | dfilter_resolve_unparsed (const char *name, GPtrArray *deprecated)
| Resolve an unparsed filter name to a header field info.
bool | dfilter_fvalue_from_literal (dfwork_t *dfw, ftenum_t ftype, stnode_t *st, bool allow_partial_value, header_field_info *hfinfo_value_string)
| Creates a fvalue from a literal string.
bool | dfilter_fvalue_from_string (dfwork_t *dfw, ftenum_t ftype, stnode_t *st, header_field_info *hfinfo_value_string)
| Converts a string to a filter value.
void | dfilter_fvalue_from_charconst (dfwork_t *dfw, ftenum_t ftype, stnode_t *st)
| Create a new filter value from a character constant.
void | dfilter_fvalue_from_number (dfwork_t *dfw, ftenum_t ftype, stnode_t *st)
| Create an filter value from a number token.
const char * | tokenstr (int token)
| Retrieves a string representation of a token.
df_reference_t * | reference_new (const field_info *finfo, bool raw)
| Creates a new reference for a field.
void | reference_free (df_reference_t *ref)
| Frees a reference.
WS_DLL_PUBLIC void | df_cell_append (df_cell_t *rp, fvalue_t *fv)
| Append a fvalue to a df_cell.
WS_DLL_PUBLIC GPtrArray * | df_cell_ref (df_cell_t *rp)
| Get a reference to the array in a df_cell_t structure.
WS_DLL_PUBLIC size_t | df_cell_size (const df_cell_t *rp)
| Get the size of a df_cell_t.
WS_DLL_PUBLIC fvalue_t ** | df_cell_array (const df_cell_t *rp)
| Retrieves an array of fvalue_t pointers from a df_cell_t.
WS_DLL_PUBLIC bool | df_cell_is_empty (const df_cell_t *rp)
| Checks if a df_cell_t is empty.
WS_DLL_PUBLIC bool | df_cell_is_null (const df_cell_t *rp)
| Check if the given cell is null.
WS_DLL_PUBLIC void | df_cell_init (df_cell_t *rp, bool free_seg)
| Initialize a df_cell_t structure.
WS_DLL_PUBLIC void | df_cell_clear (df_cell_t *rp)
| Clear a df_cell_t structure.
WS_DLL_PUBLIC void | df_cell_iter_init (df_cell_t *rp, df_cell_iter_t *iter)
| Initialize an iterator for a cell.
WS_DLL_PUBLIC fvalue_t * | df_cell_iter_next (df_cell_iter_t *iter)
| Advances the iterator to the next cell and returns its value.

## Detailed Description

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 2001 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

## Macro Definition Documentation

## ◆ df_cell_ptr

#define df_cell_ptr | ( |  | rp | ) |

Value:
((rp)->array)

## Function Documentation

## ◆ add_compile_warning()

void add_compile_warning | ( | dfwork_t * | dfw,
|  | const char * | format,
|  |  | ... )

Adds a compile warning to the given dfwork_t structure.

Parameters

  dfw | Pointer to the dfwork_t structure where the warning will be stored.
  format | Format string for the warning message, followed by variable arguments.

## ◆ add_deprecated_token()

void add_deprecated_token | ( | GPtrArray * | deprecated,
|  | const char * | token )

Adds a deprecated token to an array.

Parameters

  deprecated | Pointer to the GPtrArray where deprecated tokens are stored.
  token | The token to add, which will not be added if it already exists in the array.

## ◆ df_cell_append()

WS_DLL_PUBLIC void df_cell_append | ( | df_cell_t * | rp,
|  | fvalue_t * | fv )

Append a fvalue to a df_cell.

Parameters

  rp | Pointer to the df_cell where the fvalue will be appended.
  fv | Pointer to the fvalue to append.

## ◆ df_cell_array()

WS_DLL_PUBLIC fvalue_t ** df_cell_array | ( | const df_cell_t * | rp | ) |

Retrieves an array of fvalue_t pointers from a df_cell_t.

Parameters

  rp | Pointer to the df_cell_t structure.

Returns
  A pointer to an array of fvalue_t pointers, or NULL if the array is empty.

## ◆ df_cell_clear()

WS_DLL_PUBLIC void df_cell_clear | ( | df_cell_t * | rp | ) |

Clear a df_cell_t structure.

This function clears the contents of a df_cell_t structure, releasing any resources it holds.

Parameters

  rp | Pointer to the df_cell_t structure to be cleared.

## ◆ df_cell_init()

WS_DLL_PUBLIC void df_cell_init | ( | df_cell_t * | rp,
|  | bool | free_seg )

Initialize a df_cell_t structure.

Parameters

  rp | Pointer to the df_cell_t structure to initialize.
  free_seg | Pass true to free the array contents when the cell is cleared.

## ◆ df_cell_is_empty()

WS_DLL_PUBLIC bool df_cell_is_empty | ( | const df_cell_t * | rp | ) |

Checks if a df_cell_t is empty.

Parameters

  rp | Pointer to the df_cell_t structure to check.

Returns
  true if the cell is empty, false otherwise.

## ◆ df_cell_is_null()

WS_DLL_PUBLIC bool df_cell_is_null | ( | const df_cell_t * | rp | ) |

Check if the given cell is null.

Parameters

  rp | Pointer to the df_cell_t structure to check.

Returns
  true if the cell's array is NULL, false otherwise.

## ◆ df_cell_iter_init()

WS_DLL_PUBLIC void df_cell_iter_init | ( | df_cell_t * | rp,
|  | df_cell_iter_t * | iter )

Initialize an iterator for a cell.

Note
  Cell must not be cleared while iter is alive.

Parameters

  rp | Pointer to the cell to iterate over.
  iter | Pointer to the iterator structure to initialize.

## ◆ df_cell_iter_next()

WS_DLL_PUBLIC fvalue_t * df_cell_iter_next | ( | df_cell_iter_t * | iter | ) |

Advances the iterator to the next cell and returns its value.

Parameters

  iter | Pointer to the iterator structure.

Returns
  fcell_t* Pointer to the next cell's value, or NULL if there are no more cells.

## ◆ df_cell_ref()

WS_DLL_PUBLIC GPtrArray * df_cell_ref | ( | df_cell_t * | rp | ) |

Get a reference to the array in a df_cell_t structure.

Parameters

  rp | Pointer to the df_cell_t structure.

Returns
  A pointer to the referenced array, or NULL if the array is not initialized.

## ◆ df_cell_size()

WS_DLL_PUBLIC size_t df_cell_size | ( | const df_cell_t * | rp | ) |

Get the size of a df_cell_t.

Parameters

  rp | Pointer to the df_cell_t structure.

Returns
  The number of elements in the array, or 0 if the array is NULL.

## ◆ Dfilter()

void Dfilter | ( | void * | yyp,
|  | int | yymajor,
|  | stnode_t * | yyminor,
|  | dfsyntax_t * | )

Evaluates a token in the Lemon Parser.

Parameters

  yyp | The parser instance.
  yymajor | The major token type.
  yyminor | The minor token data.

## ◆ dfilter_fail()

WS_DLL_PUBLIC void dfilter_fail | ( | void * | state,
|  | int | code,
|  | df_loc_t | err_loc,
|  | const char * | format,
|  |  | ... )

Handle a filter failure and log an error message.

This function is called when a filter fails to compile or execute, and it logs an error message with the specified code and location.

Parameters

  state | The state of the dfilter.
  code | The error code associated with the failure.
  err_loc | The location in the filter where the error occurred.
  format | A format string for the error message.

## ◆ dfilter_fail_throw()

WS_DLL_PUBLIC WS_NORETURN void dfilter_fail_throw | ( | void * | state,
|  | int | code,
|  | df_loc_t | err_loc,
|  | const char * | format,
|  |  | ... )

Throw a filter failure with an error message.

Parameters

  state | The state of the filter.
  code | The error code.
  err_loc | The location of the error.
  format | The format string for the error message.

## ◆ dfilter_fvalue_from_charconst()

void dfilter_fvalue_from_charconst | ( | dfwork_t * | dfw,
|  | ftenum_t | ftype,
|  | stnode_t * | st )

Create a new filter value from a character constant.

Parameters

  dfw | The current dfilter work context.
  ftype | The type of the field value.
  st | The node containing the data to be converted.

## ◆ dfilter_fvalue_from_literal()

bool dfilter_fvalue_from_literal | ( | dfwork_t * | dfw,
|  | ftenum_t | ftype,
|  | stnode_t * | st,
|  | bool | allow_partial_value,
|  | header_field_info * | hfinfo_value_string )

Creates a fvalue from a literal string.

Parameters

  dfw | The current working state of the display filter.
  ftype | The type of the field.
  st | The syntax tree node to be replaced with the fvalue.
  allow_partial_value | Whether partial values are allowed.
  hfinfo_value_string | Information about the value string.

Returns
  true if the create syntax node has a (value) string type, false otherwise.

## ◆ dfilter_fvalue_from_number()

void dfilter_fvalue_from_number | ( | dfwork_t * | dfw,
|  | ftenum_t | ftype,
|  | stnode_t * | st )

Create an filter value from a number token.

This function converts a number token into an fvalue based on its type and stores it in the dfwork_t structure.

Parameters

  dfw | Pointer to the dfwork_t structure where the fvalue will be stored.
  ftype | The desired data type for the fvalue (e.g., FT_INT64, FT_DOUBLE).
  st | Pointer to the stnode_t structure containing the number token.

## ◆ dfilter_fvalue_from_string()

bool dfilter_fvalue_from_string | ( | dfwork_t * | dfw,
|  | ftenum_t | ftype,
|  | stnode_t * | st,
|  | header_field_info * | hfinfo_value_string )

Converts a string to a filter value.

Parameters

  dfw | The current working state of the dfilter.
  ftype | The type of the field.
  st | The node where the result will be stored.
  hfinfo_value_string | Information about the header field.

## ◆ dfilter_resolve_unparsed()

header_field_info * dfilter_resolve_unparsed | ( | const char * | name,
|  | GPtrArray * | deprecated )

Resolve an unparsed filter name to a header field info.

Parameters

  name | The name of the filter to resolve.
  deprecated | A pointer to a GPtrArray where deprecated tokens will be stored, or NULL if not needed.

Returns
  header_field_info* The resolved header field info, or NULL if not found.

## ◆ dfilter_vfail()

WS_DLL_PUBLIC void dfilter_vfail | ( | void * | state,
|  | int | code,
|  | df_loc_t | err_loc,
|  | const char * | format,
|  | va_list | args )

Report a failure in a display filter.

This function is used to report an error in a display filter. If an error has already been reported, it will not overwrite the existing error.

Parameters

  state | Pointer to the state of the display filter.
  code | Error code indicating the type of error.
  err_loc | Location information where the error occurred.
  format | Format string for the error message.
  args | Variable arguments list for the format string.

## ◆ DfilterTrace()

void DfilterTrace | ( | FILE * | TraceFILE,
|  | char * | zTracePrompt )

Writes a trace prompt to the specified file.

Parameters

  TraceFILE | Pointer to the file where the trace prompt will be written.
  zTracePrompt | The trace prompt string to write.

## ◆ dfw_set_error_location()

void dfw_set_error_location | ( | dfwork_t * | dfw,
|  | df_loc_t | err_loc )

Set the error location for a given dfwork_t object.

Parameters

  dfw | Pointer to the dfwork_t object.
  err_loc | The error location to set.

## ◆ free_deprecated()

void free_deprecated | ( | GPtrArray * | deprecated | ) |

Frees memory allocated for deprecated items.

Parameters

  deprecated | Pointer to the GPtrArray containing deprecated items.

## ◆ reference_free()

void reference_free | ( | df_reference_t * | ref | ) |

Frees a reference.

Parameters

  ref | The reference to be freed.

## ◆ reference_new()

df_reference_t * reference_new | ( | const field_info * | finfo,
|  | bool | raw )

Creates a new reference for a field.

Parameters

  finfo | Pointer to the field information.
  raw | Flag indicating whether to use raw value.

Returns
  df_reference_t* Pointer to the newly created reference.

## ◆ tokenstr()

const char * tokenstr | ( | int | token | ) |

Retrieves a string representation of a token.

Parameters

  token | The integer value of the token to convert.

Returns
  A constant character pointer to the string representation of the token, or NULL if the token is invalid.