Wireshark 4.7.0
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
 
struct  df_cell_t
 
struct  df_cell_iter_t
 
struct  epan_dfilter
 
struct  dfstate_t
 
struct  dfsyntax_t
 
struct  dfwork_t
 

Macros

#define SCAN_FAILED   -1 /* not 0, as that means end-of-input */
 
#define df_cell_ptr(rp)   ((rp)->array)
 

Functions

void * DfilterAlloc (void *(*)(size_t))
 
void DfilterFree (void *, void(*)(void *))
 
void Dfilter (void *, int, stnode_t *, dfsyntax_t *)
 
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_infodfilter_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_treference_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_tdf_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

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
dfwPointer to the dfwork_t structure where the warning will be stored.
formatFormat 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
deprecatedPointer to the GPtrArray where deprecated tokens are stored.
tokenThe 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
rpPointer to the df_cell where the fvalue will be appended.
fvPointer 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
rpPointer 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
rpPointer 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
rpPointer to the df_cell_t structure to initialize.
free_segPass 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
rpPointer 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
rpPointer 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
rpPointer to the cell to iterate over.
iterPointer 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
iterPointer 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
rpPointer 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
rpPointer to the df_cell_t structure.
Returns
The number of elements in the array, or 0 if the array is NULL.

◆ 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
stateThe state of the dfilter.
codeThe error code associated with the failure.
err_locThe location in the filter where the error occurred.
formatA 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
stateThe state of the filter.
codeThe error code.
err_locThe location of the error.
formatThe 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
dfwThe current dfilter work context.
ftypeThe type of the field value.
stThe 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
dfwThe current working state of the display filter.
ftypeThe type of the field.
stThe syntax tree node to be replaced with the fvalue.
allow_partial_valueWhether partial values are allowed.
hfinfo_value_stringInformation 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
dfwPointer to the dfwork_t structure where the fvalue will be stored.
ftypeThe desired data type for the fvalue (e.g., FT_INT64, FT_DOUBLE).
stPointer 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
dfwThe current working state of the dfilter.
ftypeThe type of the field.
stThe node where the result will be stored.
hfinfo_value_stringInformation 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
nameThe name of the filter to resolve.
deprecatedA 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
statePointer to the state of the display filter.
codeError code indicating the type of error.
err_locLocation information where the error occurred.
formatFormat string for the error message.
argsVariable arguments list for the format string.

◆ DfilterTrace()

void DfilterTrace ( FILE *  TraceFILE,
char *  zTracePrompt 
)

Writes a trace prompt to the specified file.

Parameters
TraceFILEPointer to the file where the trace prompt will be written.
zTracePromptThe 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
dfwPointer to the dfwork_t object.
err_locThe error location to set.

◆ free_deprecated()

void free_deprecated ( GPtrArray *  deprecated)

Frees memory allocated for deprecated items.

Parameters
deprecatedPointer to the GPtrArray containing deprecated items.

◆ reference_free()

void reference_free ( df_reference_t ref)

Frees a reference.

Parameters
refThe 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
finfoPointer to the field information.
rawFlag 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
tokenThe 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.