2007-01-28 10:31:32 +00:00
|
|
|
/*
|
|
|
|
* uat-int.h
|
|
|
|
*
|
|
|
|
* User Accessible Tables
|
2015-11-15 20:06:10 +00:00
|
|
|
* Maintain an array of user accessible data structures
|
2007-01-28 10:31:32 +00:00
|
|
|
* Internal interface
|
|
|
|
*
|
2008-08-05 21:03:46 +00:00
|
|
|
* (c) 2007, Luis E. Garcia Ontanon <luis@ontanon.org>
|
2007-01-29 04:47:58 +00:00
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 2001 Gerald Combs
|
2014-02-25 20:42:35 +00:00
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2007-01-28 10:31:32 +00:00
|
|
|
*
|
|
|
|
*/
|
2013-07-25 23:49:47 +00:00
|
|
|
#ifndef __UAT_INT_H__
|
|
|
|
#define __UAT_INT_H__
|
2007-01-28 10:31:32 +00:00
|
|
|
|
|
|
|
#include "uat.h"
|
2013-03-01 23:53:11 +00:00
|
|
|
#include "ws_symbol_export.h"
|
2007-01-28 10:31:32 +00:00
|
|
|
|
2013-07-25 23:49:47 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
2007-01-28 10:31:32 +00:00
|
|
|
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*);
|
|
|
|
|
2007-02-03 14:25:02 +00:00
|
|
|
typedef struct _fld_data_t {
|
2013-04-07 15:57:28 +00:00
|
|
|
guint colnum;
|
|
|
|
uat_fld_rep_t* rep;
|
|
|
|
uat_rep_fld_free_cb_t free_rep;
|
2007-02-03 14:25:02 +00:00
|
|
|
} fld_data_t;
|
2007-01-28 10:31:32 +00:00
|
|
|
|
2013-12-03 21:35:36 +00:00
|
|
|
struct epan_uat {
|
2016-12-21 10:50:47 +00:00
|
|
|
char* name;
|
2013-04-07 15:57:28 +00:00
|
|
|
size_t record_size;
|
2016-12-21 10:50:47 +00:00
|
|
|
char* filename;
|
2013-04-07 15:57:28 +00:00
|
|
|
gboolean from_profile;
|
2016-12-21 10:50:47 +00:00
|
|
|
char* help;
|
2013-04-07 15:57:28 +00:00
|
|
|
guint flags;
|
2016-08-31 22:30:23 +00:00
|
|
|
void** user_ptr; /**< Pointer to a dissector variable where an array of valid records are stored. */
|
|
|
|
guint* nrows_p; /**< Pointer to a dissector variable where the number of valid records in user_ptr are written. */
|
2013-04-07 15:57:28 +00:00
|
|
|
uat_copy_cb_t copy_cb;
|
|
|
|
uat_update_cb_t update_cb;
|
|
|
|
uat_free_cb_t free_cb;
|
|
|
|
uat_post_update_cb_t post_update_cb;
|
2016-12-21 10:50:47 +00:00
|
|
|
uat_reset_cb_t reset_cb;
|
2013-04-07 15:57:28 +00:00
|
|
|
|
|
|
|
uat_field_t* fields;
|
|
|
|
guint ncols;
|
2016-08-31 22:30:23 +00:00
|
|
|
GArray* user_data; /**< An array of valid records that will be exposed to the dissector. */
|
|
|
|
GArray* raw_data; /**< An array of records containing possibly invalid data. For internal use only. */
|
|
|
|
GArray* valid_data; /**< An array of booleans describing whether the records in 'raw_data' are valid or not. */
|
2013-04-07 15:57:28 +00:00
|
|
|
gboolean changed;
|
|
|
|
uat_rep_t* rep;
|
|
|
|
uat_rep_free_cb_t free_rep;
|
|
|
|
gboolean loaded;
|
|
|
|
gboolean from_global;
|
2007-01-28 10:31:32 +00:00
|
|
|
};
|
|
|
|
|
2013-07-25 23:49:47 +00:00
|
|
|
WS_DLL_PUBLIC
|
2007-01-28 10:31:32 +00:00
|
|
|
gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing);
|
2007-02-03 14:25:02 +00:00
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
void* uat_add_record(uat_t *uat, const void *orig_rec_ptr, gboolean valid_rec);
|
2007-02-03 14:25:02 +00:00
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Marks the internal record in the UAT as valid or invalid. The record must
|
|
|
|
* exist in the UAT.
|
|
|
|
*/
|
2015-02-14 14:36:09 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
void uat_update_record(uat_t *uat, const void *record, gboolean valid_rec);
|
2015-02-14 14:36:09 +00:00
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Changes the order of two internal UAT records.
|
|
|
|
*/
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
void uat_swap(uat_t *uat, guint idx_a, guint idx_b);
|
2007-02-04 05:19:02 +00:00
|
|
|
|
2016-09-30 08:46:28 +00:00
|
|
|
/**
|
|
|
|
* Inserts the record at the given index in the internal record list.
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
void uat_insert_record_idx(uat_t *uat, guint rec_idx, const void *src_record);
|
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Removes the record with the given index from the internal record list.
|
|
|
|
*/
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
void uat_remove_record_idx(uat_t *uat, guint rec_idx);
|
2007-02-03 14:25:02 +00:00
|
|
|
|
2017-06-27 14:36:19 +00:00
|
|
|
/**
|
|
|
|
* Moves the entry from the old position to the new one
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
void uat_move_index(uat_t *uat, guint old_idx, guint new_idx);
|
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Removes and destroys all records from the UAT.
|
|
|
|
*/
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
void uat_clear(uat_t *uat);
|
2007-02-11 16:09:21 +00:00
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
*/
|
2013-03-01 23:53:11 +00:00
|
|
|
WS_DLL_PUBLIC
|
2016-08-31 22:30:23 +00:00
|
|
|
gboolean uat_save(uat_t *uat, char **error);
|
2007-02-03 14:25:02 +00:00
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Loads the records for all registered UATs from file.
|
|
|
|
*/
|
2007-02-03 14:25:02 +00:00
|
|
|
void uat_load_all(void);
|
2007-01-28 10:31:32 +00:00
|
|
|
|
2017-05-15 13:07:34 +00:00
|
|
|
/**
|
|
|
|
* Dump given UAT record to string in form, which can be later loaded with uat_load_str().
|
|
|
|
*/
|
|
|
|
WS_DLL_PUBLIC
|
|
|
|
char *uat_fld_tostr(void *rec, uat_field_t *f);
|
|
|
|
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Exposes the array of valid records to the UAT consumer (dissectors), updating
|
|
|
|
* the contents of 'data_ptr' and 'num_items_ptr' (see 'uat_new').
|
|
|
|
*/
|
2007-01-28 10:31:32 +00:00
|
|
|
#define UAT_UPDATE(uat) do { *((uat)->user_ptr) = (void*)((uat)->user_data->data); *((uat)->nrows_p) = (uat)->user_data->len; } while(0)
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2013-04-22 02:10:49 +00:00
|
|
|
#define UAT_INDEX_PTR(uat,idx) (uat->raw_data->data + (uat->record_size * (idx)))
|
2016-08-31 22:30:23 +00:00
|
|
|
/**
|
|
|
|
* Get a record from the array of all valid entries. These records will be
|
|
|
|
* shared with UAT consumers (dissectors).
|
|
|
|
*/
|
2013-04-22 02:10:49 +00:00
|
|
|
#define UAT_USER_INDEX_PTR(uat,idx) (uat->user_data->data + (uat->record_size * (idx)))
|
2013-07-25 23:49:47 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* __UAT_INT_H__ */
|
2013-04-07 15:57:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=4 tabstop=8 expandtab:
|
|
|
|
* :indentSize=4:tabSize=8:noTabs=true:
|
|
|
|
*/
|