Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
uat-int.h File Reference
#include <glib.h>
#include "uat.h"
#include "ws_symbol_export.h"

Go to the source code of this file.

Classes

struct  _fld_data_t
 Holds per-field display and cleanup state for a single column in a UAT record's GUI representation. More...
 
struct  epan_uat
 Represents a User Accessible Table (UAT), managing a set of user-editable records exposed to a dissector. More...
 

Macros

#define UAT_UPDATE(uat)   do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
 
#define UAT_INDEX_PTR(uat, idx)   (uat->raw_data->data + (uat->record_size * (idx)))
 
#define UAT_USER_INDEX_PTR(uat, idx)   (uat->user_data->data + (uat->record_size * (idx)))
 

Typedefs

typedef struct _uat_fld_rep_t uat_fld_rep_t
 
typedef struct _uat_rep_t uat_rep_t
 
typedef void(* uat_rep_fld_free_cb_t) (uat_fld_rep_t *)
 
typedef void(* uat_rep_free_cb_t) (uat_rep_t *)
 
typedef struct _fld_data_t fld_data_t
 Holds per-field display and cleanup state for a single column in a UAT record's GUI representation.
 

Functions

WS_DLL_PUBLIC char * uat_get_actual_filename (uat_t *uat, bool for_writing, const char *app_env_var_prefix)
 Get the actual filename for the UAT.
 
WS_DLL_PUBLIC void * uat_add_record (uat_t *uat, const void *orig_rec_ptr, bool valid_rec)
 Clones the given record and stores it internally in the UAT. If it is considered a valid record, then it will also be cloned and stored in the externally visible list.
 
WS_DLL_PUBLIC void uat_update_record (uat_t *uat, const void *record, bool valid_rec)
 Marks the internal record in the UAT as valid or invalid. The record must exist in the UAT.
 
WS_DLL_PUBLIC void uat_swap (uat_t *uat, unsigned idx_a, unsigned idx_b)
 Changes the order of two internal UAT records.
 
WS_DLL_PUBLIC void uat_insert_record_idx (uat_t *uat, unsigned rec_idx, const void *src_record)
 Inserts the record at the given index in the internal record list.
 
WS_DLL_PUBLIC void uat_remove_record_idx (uat_t *uat, unsigned rec_idx)
 Removes the record with the given index from the internal record list.
 
WS_DLL_PUBLIC void uat_remove_record_range (uat_t *uat, unsigned rec_idx, unsigned count)
 Removes the given number of records starting with the given index from the internal record list. If the UAT has a free_cb it is called for the removed records.
 
WS_DLL_PUBLIC void uat_move_index (uat_t *uat, unsigned old_idx, unsigned new_idx)
 Moves the entry from the old position to the new one.
 
WS_DLL_PUBLIC void uat_clear (uat_t *uat)
 Removes and destroys all records from the UAT.
 
WS_DLL_PUBLIC bool uat_save (uat_t *uat, const char *app_env_var_prefix, char **error)
 Saves the records from an UAT to file. Returns true on success and false on failure, storing the reason in 'error' (which must be freed using g_free).
 
void uat_load_all (const char *app_env_var_prefix)
 Loads the records for all registered UATs from file.
 
WS_DLL_PUBLIC char * uat_fld_tostr (void *rec, uat_field_t *f)
 Dump given UAT record to string in form which can be later loaded with uat_load_str().
 
WS_DLL_PUBLIC char * uat_record_tostr (const uat_t *uat, void *rec)
 Dump UAT record entries to string in form which can be later loaded with uat_load_str(). Returns a g_malloced string.
 

Detailed Description

User Accessible Tables Maintain an array of user accessible data structures Internal interface

(c) 2007, Luis E. Garcia Ontanon luis@.nosp@m.onta.nosp@m.non.o.nosp@m.rg

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

◆ UAT_INDEX_PTR

#define UAT_INDEX_PTR (   uat,
  idx 
)    (uat->raw_data->data + (uat->record_size * (idx)))

Get a record from the array of all UAT entries, whether they are semantically valid or not. This memory must only be used internally in the UAT core and must not be exposed to dissectors.

◆ UAT_UPDATE

#define UAT_UPDATE (   uat)    do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)

Exposes the array of valid records to the UAT consumer (dissectors), updating the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').

◆ UAT_USER_INDEX_PTR

#define UAT_USER_INDEX_PTR (   uat,
  idx 
)    (uat->user_data->data + (uat->record_size * (idx)))

Get a record from the array of all valid entries. These records will be shared with UAT consumers (dissectors).

Function Documentation

◆ uat_add_record()

WS_DLL_PUBLIC void * uat_add_record ( uat_t uat,
const void *  orig_rec_ptr,
bool  valid_rec 
)

Clones the given record and stores it internally in the UAT. If it is considered a valid record, then it will also be cloned and stored in the externally visible list.

Parameters
uatThe UAT to which the record will be added.
orig_rec_ptrPointer to the record to be added.
valid_recWhether the record is considered valid or not.
Returns
A pointer to the internal record stored in the UAT.

◆ uat_clear()

WS_DLL_PUBLIC void uat_clear ( uat_t uat)

Removes and destroys all records from the UAT.

Parameters
uatThe UAT containing the records.

◆ uat_fld_tostr()

WS_DLL_PUBLIC char * uat_fld_tostr ( void *  rec,
uat_field_t f 
)

Dump given UAT record to string in form which can be later loaded with uat_load_str().

XXX - In fact this only dumps a single field. To produce the format for uat_load_str(), join all the fields as CSV records, escaping and double- quoting field types other than PT_TXTMOD_HEXBYTES. Perhaps we should have a function that dumps the entire record.

Parameters
recPointer to the record to be dumped.
fPointer to the field to be dumped.
Returns
A g_malloced string containing the dumped field.

◆ uat_get_actual_filename()

WS_DLL_PUBLIC char * uat_get_actual_filename ( uat_t uat,
bool  for_writing,
const char *  app_env_var_prefix 
)

Get the actual filename for the UAT.

Parameters
uatThe UAT for which to get the filename.
for_writingWhether the file is being written to.
app_env_var_prefixThe prefix for the application environment variable.
Returns
A pointer to the actual filename string.

◆ uat_insert_record_idx()

WS_DLL_PUBLIC void uat_insert_record_idx ( uat_t uat,
unsigned  rec_idx,
const void *  src_record 
)

Inserts the record at the given index in the internal record list.

Parameters
uatThe UAT containing the records.
rec_idxIndex at which to insert the record.
src_recordPointer to the record to be inserted.

◆ uat_load_all()

void uat_load_all ( const char *  app_env_var_prefix)

Loads the records for all registered UATs from file.

Parameters
app_env_var_prefixThe prefix of the environment variable to be used for the filename. The actual environment variable name will be this prefix followed by "_UAT_FILENAME". If the environment variable is not set, a default filename will be used.

◆ uat_move_index()

WS_DLL_PUBLIC void uat_move_index ( uat_t uat,
unsigned  old_idx,
unsigned  new_idx 
)

Moves the entry from the old position to the new one.

Parameters
uatThe UAT containing the records.
old_idxIndex of the record to be moved.
new_idxIndex where the record should be moved.

◆ uat_record_tostr()

WS_DLL_PUBLIC char * uat_record_tostr ( const uat_t uat,
void *  rec 
)

Dump UAT record entries to string in form which can be later loaded with uat_load_str(). Returns a g_malloced string.

Parameters
uatThe UAT containing the record to be dumped.
recPointer to the record to be dumped.
Returns
A g_malloced string containing the dumped record.

◆ uat_remove_record_idx()

WS_DLL_PUBLIC void uat_remove_record_idx ( uat_t uat,
unsigned  rec_idx 
)

Removes the record with the given index from the internal record list.

Parameters
uatThe UAT containing the records.
rec_idxIndex of the record to be removed.

◆ uat_remove_record_range()

WS_DLL_PUBLIC void uat_remove_record_range ( uat_t uat,
unsigned  rec_idx,
unsigned  count 
)

Removes the given number of records starting with the given index from the internal record list. If the UAT has a free_cb it is called for the removed records.

Parameters
uatThe UAT containing the records.
rec_idxIndex of the first record to be removed.
countNumber of records to be removed.

◆ uat_save()

WS_DLL_PUBLIC bool uat_save ( uat_t uat,
const char *  app_env_var_prefix,
char **  error 
)

Saves the records from an UAT to file. Returns true on success and false on failure, storing the reason in 'error' (which must be freed using g_free).

Parameters
uatThe UAT containing the records to be saved.
app_env_var_prefixThe prefix of the environment variable to be used for the filename. The actual environment variable name will be this prefix followed by "_UAT_FILENAME". If the environment variable is not set, a default filename will be used.
errorPointer to a char* where an error message will be stored in case of failure. The caller is responsible for freeing this memory using g_free.
Returns
true on success, false on failure.

◆ uat_swap()

WS_DLL_PUBLIC void uat_swap ( uat_t uat,
unsigned  idx_a,
unsigned  idx_b 
)

Changes the order of two internal UAT records.

Parameters
uatThe UAT containing the records.
idx_aIndex of the first record.
idx_bIndex of the second record.

◆ uat_update_record()

WS_DLL_PUBLIC void uat_update_record ( uat_t uat,
const void *  record,
bool  valid_rec 
)

Marks the internal record in the UAT as valid or invalid. The record must exist in the UAT.

Parameters
uatThe UAT containing the record.
recordPointer to the record to be updated.
valid_recWhether the record is considered valid or not.