| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
stats_tree_priv.h File Reference
`#include "stats_tree.h"`
`#include "ws_symbol_export.h"`

Go to the source code of this file.

## Classes
struct | _range_pair
| Represents an inclusive integer range with a lower and upper bound. More...
struct | _burst_bucket
| Represents a single time bucket in a burst analysis sliding window, linked into a doubly-linked list. More...
struct | _stat_node
| Represents a node in a hierarchical statistics tree. More...
struct | _stats_tree
| Represents a live statistics tree instance, holding runtime state for accumulating and displaying tap statistics. More...
struct | _stats_tree_cfg
| Defines the static configuration and callbacks for a statistics tree type, shared across all instances of that tree. More...

## Macros
#define | INDENT_MAX 32
#define | NUM_BUF_SIZE 32

## Typedefs
typedef struct _st_node_pres | st_node_pres
typedef struct _tree_pres | tree_pres
typedef struct _tree_cfg_pres | tree_cfg_pres
typedef struct _stat_node | stat_node
typedef struct _range_pair | range_pair_t
| Represents an inclusive integer range with a lower and upper bound.
typedef struct _burst_bucket | burst_bucket

## Functions
WS_DLL_PUBLIC void | stats_tree_presentation (void(*registry_iterator)(void *, void *, void *), void(*setup_node_pr)(stat_node *), void(*free_tree_pr)(stats_tree *), void *data)
| Registers callback functions for presenting statistics tree.
WS_DLL_PUBLIC stats_tree * | stats_tree_new (stats_tree_cfg *cfg, tree_pres *pr, const char *filter)
| Creates a new statistics tree.
WS_DLL_PUBLIC tap_packet_status | stats_tree_packet (void *p, packet_info *pinfo, epan_dissect_t *edt, const void *pri, tap_flags_t flags)
| Process a packet for statistics tree.
WS_DLL_PUBLIC void | stats_tree_reset (void *p_st)
| Resets a statistics tree.
WS_DLL_PUBLIC void | stats_tree_reinit (void *p_st)
| Reinitializes a statistics tree.
WS_DLL_PUBLIC void | stats_tree_free (stats_tree *st)
| Frees a stats_tree structure.
WS_DLL_PUBLIC char * | stats_tree_get_abbr (const char *ws_optarg)
| Retrieves an abbreviation from a given option argument.
WS_DLL_PUBLIC stats_tree_cfg * | stats_tree_get_cfg_by_abbr (const char *abbr)
| Retrieves configuration for a statistics tree by its abbreviation.
WS_DLL_PUBLIC GList * | stats_tree_get_cfg_list (void)
| Retrieves a list of configuration items for statistics trees.
WS_DLL_PUBLIC unsigned | stats_tree_branch_max_namelen (const stat_node *node, unsigned indent)
| Calculate the maximum name length of a branch in the statistics tree.
WS_DLL_PUBLIC char * | stats_tree_node_to_str (const stat_node *node, char *buffer, unsigned len)
| Convert a statistics tree node to a string.
WS_DLL_PUBLIC char * | stats_tree_get_displayname (const char *fullname)
| Get the display name for a statistics tree node.
WS_DLL_PUBLIC int | stats_tree_get_default_sort_col (stats_tree *st)
| Get the default sort column for a statistics tree.
WS_DLL_PUBLIC bool | stats_tree_is_default_sort_DESC (stats_tree *st)
| Check if the default sort order for a stats tree is descending.
WS_DLL_PUBLIC const char * | stats_tree_get_column_name (stats_tree_cfg *st_config, int col_index)
| Get the column name for a given index in the stats tree configuration.
WS_DLL_PUBLIC int | stats_tree_get_column_size (int col_index)
| Get the size of a column in the statistics tree.
WS_DLL_PUBLIC char ** | stats_tree_get_values_from_node (const stat_node *node)
| Retrieves values from a statistics tree node.
WS_DLL_PUBLIC int | stats_tree_sort_compare (const stat_node *a, const stat_node *b, int sort_column, bool sort_descending)
| Compare two stat_node elements for sorting.
WS_DLL_PUBLIC int | stat_node_array_sortcmp (const void *a, const void *b, void *user_data)
| Compare two stat_node pointers for sorting purposes.
WS_DLL_PUBLIC GString * | stats_tree_format_as_str (const stats_tree *st, st_format_type format_type, int sort_column, bool sort_descending)
| Formats a stats tree as a string based on the specified format type.
WS_DLL_PUBLIC void | stats_tree_format_node_as_str (const stat_node *node, GString *s, st_format_type format_type, unsigned indent, const char *path, int maxnamelen, int sort_column, bool sort_descending)
| Formats a node in the statistics tree as a string.

## Detailed Description

implementor's API for stats_tree 2005, Luis E. G. Ontanon

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

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

## Typedef Documentation

## ◆ st_node_pres

typedef struct _st_node_pres st_node_pres

implementations should define this to contain its own node related data as well as some operations on it

## ◆ tree_cfg_pres

typedef struct _tree_cfg_pres tree_cfg_pres

implementations should define this to contain its own static tree related data as well as some operations on it

## ◆ tree_pres

typedef struct _tree_pres tree_pres

implementations should define this to contain its own dynamic tree related data as well as some operations on it

## Function Documentation

## ◆ stat_node_array_sortcmp()

WS_DLL_PUBLIC int stat_node_array_sortcmp | ( | const void * | a,
|  | const void * | b,
|  | void * | user_data )

Compare two stat_node pointers for sorting purposes.

Wrapper for stats_tree_sort_compare() function that can be called from array sort. Compares two stat_node pointers based on the sort column and order specified in user_data.

Parameters

  a | Pointer to the first stat_node to compare.
  b | Pointer to the second stat_node to compare.
  user_data | Pointer to a sortinfo structure containing the sort column and order.

Returns
  An integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

## ◆ stats_tree_branch_max_namelen()

WS_DLL_PUBLIC unsigned stats_tree_branch_max_namelen | ( | const stat_node * | node,
|  | unsigned | indent )

Calculate the maximum name length of a branch in the statistics tree.

Used to calculate the size of the indentation and the longest string

Parameters

  node | The current node in the statistics tree.
  indent | The current indentation level.

Returns
  The maximum name length of the branch.

## ◆ stats_tree_format_as_str()

WS_DLL_PUBLIC GString * stats_tree_format_as_str | ( | const stats_tree * | st,
|  | st_format_type | format_type,
|  | int | sort_column,
|  | bool | sort_descending )

Formats a stats tree as a string based on the specified format type.

Copy stats_tree into GString. format determines output format

Parameters

  st | Pointer to the stats_tree structure.
  format_type | The desired output format (e.g., YAML, XML, CSV).
  sort_column | The column index to use for sorting.
  sort_descending | Whether to sort in descending order.

Returns
  A GString containing the formatted stats tree or NULL on failure.

## ◆ stats_tree_format_node_as_str()

WS_DLL_PUBLIC void stats_tree_format_node_as_str | ( | const stat_node * | node,
|  | GString * | s,
|  | st_format_type | format_type,
|  | unsigned | indent,
|  | const char * | path,
|  | int | maxnamelen,
|  | int | sort_column,
|  | bool | sort_descending )

Formats a node in the statistics tree as a string.

Helper function to add note to formatted stats_tree

Parameters

  node | The node to format.
  s | The GString where the formatted output will be appended.
  format_type | The type of format to use (e.g., YAML).
  indent | The number of spaces for indentation.
  path | The path to the node.
  maxnamelen | The maximum length of column names.
  sort_column | The column to sort by.
  sort_descending | Whether to sort in descending order.

helper function to add note to formatted stats_tree

## ◆ stats_tree_free()

WS_DLL_PUBLIC void stats_tree_free | ( | stats_tree * | st | ) |

Frees a stats_tree structure.

Parameters

  st | Pointer to the stats_tree structure to be freed.

## ◆ stats_tree_get_abbr()

WS_DLL_PUBLIC char * stats_tree_get_abbr | ( | const char * | ws_optarg | ) |

Retrieves an abbreviation from a given option argument.

given an ws_optarg splits the abbr part and returns a newly allocated buffer containing it

Parameters

  ws_optarg | The option argument string to process.

Returns
  A dynamically allocated string containing the abbreviation, or NULL if no comma is found.

## ◆ stats_tree_get_cfg_by_abbr()

WS_DLL_PUBLIC stats_tree_cfg * stats_tree_get_cfg_by_abbr | ( | const char * | abbr | ) |

Retrieves configuration for a statistics tree by its abbreviation.

obtains a stats tree from the registry given its abbr

Parameters

  abbr | The abbreviation of the statistics tree configuration to retrieve.

Returns
  Pointer to the statistics tree configuration if found, NULL otherwise.

## ◆ stats_tree_get_cfg_list()

WS_DLL_PUBLIC GList * stats_tree_get_cfg_list | ( | void |  | ) |

Retrieves a list of configuration items for statistics trees.

obtains a stats tree list from the registry caller should free returned list with g_list_free()

Returns
  A GList containing pointers to stats_tree_cfg structures.

## ◆ stats_tree_get_column_name()

WS_DLL_PUBLIC const char * stats_tree_get_column_name | ( | stats_tree_cfg * | st_config,
|  | int | col_index )

Get the column name for a given index in the stats tree configuration.

Returns the column name for a given column index

Parameters

  st_config | Pointer to the stats tree configuration structure.
  col_index | Index of the column for which to retrieve the name.

Returns
  const char* The name of the column, or a default name if the index is invalid.

## ◆ stats_tree_get_column_size()

WS_DLL_PUBLIC int stats_tree_get_column_size | ( | int | col_index | ) |

Get the size of a column in the statistics tree.

Returns the maximum number of characters in the value of a column

Parameters

  col_index | The index of the column to get the size for.

Returns
  The size of the specified column, or 0 if the column is invalid.

## ◆ stats_tree_get_default_sort_col()

WS_DLL_PUBLIC int stats_tree_get_default_sort_col | ( | stats_tree * | st | ) |

Get the default sort column for a statistics tree.

Returns the column number of the default column to sort on

Parameters

  st | Pointer to the statistics tree structure.

Returns
  The index of the default sort column.

## ◆ stats_tree_get_displayname()

WS_DLL_PUBLIC char * stats_tree_get_displayname | ( | const char * | fullname | ) |

Get the display name for a statistics tree node.

Get the display name for the stats_tree (or node name) based on the st_sort_showfullname preference. If not set remove everything before last unescaped backslash. Caller must free the result *

Parameters

  fullname | The full name of the statistics tree node.

Returns
  A dynamically allocated string containing the display name.

## ◆ stats_tree_get_values_from_node()

WS_DLL_PUBLIC char ** stats_tree_get_values_from_node | ( | const stat_node * | node | ) |

Retrieves values from a statistics tree node.

returns the formatted column values for the current node as array of char*. Caller must free entries and free array

Parameters

  node | Pointer to the stat_node structure containing the data.

Returns
  Array of strings representing the values for different columns.

## ◆ stats_tree_is_default_sort_DESC()

WS_DLL_PUBLIC bool stats_tree_is_default_sort_DESC | ( | stats_tree * | st | ) |

Check if the default sort order for a stats tree is descending.

Returns the default sort order to use

Parameters

  st | Pointer to the stats_tree structure.

Returns
  true if the default sort order is descending, false otherwise.

## ◆ stats_tree_new()

WS_DLL_PUBLIC stats_tree * stats_tree_new | ( | stats_tree_cfg * | cfg,
|  | tree_pres * | pr,
|  | const char * | filter )

Creates a new statistics tree.

Initializes a new statistics tree with the given configuration and filter.

Parameters

  cfg | Pointer to the statistics tree configuration.
  pr | Pointer to the tree presentation structure.
  filter | The filter string for the statistics tree.

Returns
  Pointer to the newly created statistics tree.

## ◆ stats_tree_node_to_str()

WS_DLL_PUBLIC char * stats_tree_node_to_str | ( | const stat_node * | node,
|  | char * | buffer,
|  | unsigned | len )

Convert a statistics tree node to a string.

a text representation of a node, if buffer is NULL returns a newly allocated string

Parameters

  node | The statistics tree node to convert.
  buffer | The buffer to store the resulting string, or NULL to allocate a new one.
  len | The length of the buffer if provided.

Returns
  A pointer to the resulting string.

## ◆ stats_tree_packet()

WS_DLL_PUBLIC tap_packet_status stats_tree_packet | ( | void * | p,
|  | packet_info * | pinfo,
|  | epan_dissect_t * | edt,
|  | const void * | pri,
|  | tap_flags_t | flags )

Process a packet for statistics tree.

callback for taps

Parameters

  p | Pointer to the stats_tree structure.
  pinfo | Pointer to the packet_info structure.
  edt | Pointer to the epan_dissect_t structure.
  pri | Pointer to additional private data.
  flags | Flags indicating processing options.

Returns
  tap_packet_status Status of packet processing.

## ◆ stats_tree_presentation()

WS_DLL_PUBLIC void stats_tree_presentation | ( | void(* | registry_iterator )(void *, void *, void *),
|  | void(* | setup_node_pr )(stat_node *),
|  | void(* | free_tree_pr )(stats_tree *),
|  | void * | data )

Registers callback functions for presenting statistics tree.

Parameters

  registry_iterator | Callback to iterate over the registry.
  setup_node_pr | Callback to set up a node in the statistics tree.
  free_tree_pr | Callback to free the statistics tree.
  data | User-defined data passed to callbacks.

## ◆ stats_tree_reinit()

WS_DLL_PUBLIC void stats_tree_reinit | ( | void * | p_st | ) |

Reinitializes a statistics tree.

callback for clear

Parameters

  p_st | Pointer to the statistics tree structure.

## ◆ stats_tree_reset()

WS_DLL_PUBLIC void stats_tree_reset | ( | void * | p_st | ) |

Resets a statistics tree.

callback for reset

Parameters

  p_st | Pointer to the statistics tree structure to be reset.

## ◆ stats_tree_sort_compare()

WS_DLL_PUBLIC int stats_tree_sort_compare | ( | const stat_node * | a,
|  | const stat_node * | b,
|  | int | sort_column,
|  | bool | sort_descending )

Compare two stat_node elements for sorting.

Compare two nodes for sort, based on sort_column

Parameters

  a | Pointer to the first stat_node element.
  b | Pointer to the second stat_node element.
  sort_column | The column index to sort by.
  sort_descending | Whether to sort in descending order.

Returns
  An integer less than, equal to, or greater than zero if a is found, respectively, to be less than, to match, or be greater than b.