| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
mate_util.h
1/* mate_util.h
2 *
3 * Copyright 2004, Luis E. Garcia Ontanon <luis@ontanon.org>
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12
13#ifndef __AVP_H_
14#define __AVP_H_
15#include "epan/proto.h"
16#include <sys/types.h>
17
18/* #define _AVP_DEBUGGING */
19
20
21/******* dbg_print *********/
22#define DEBUG_BUFFER_SIZE 4096
23
32 extern void dbg_print(const int* which, int how, FILE* where,
33 const char* fmt, ... ) G_GNUC_PRINTF(4, 5);
34
35
36/******* single copy strings *********/
37typedef struct _scs_collection SCS_collection;
38
39#define SCS_HUGE_SIZE 65535
40
48 extern char* scs_subscribe(SCS_collection* collection, const char* s);
56 extern void scs_unsubscribe(SCS_collection* collection, char* s);
57
66 extern char* scs_subscribe_printf(SCS_collection* collection, char* fmt, ...)
67 G_GNUC_PRINTF(2, 3);
68
69/******* AVPs & Co. *********/
70
71/* these are the defined operators of avps */
72#define AVP_OP_EQUAL '='
73#define AVP_OP_NOTEQUAL '!'
74#define AVP_OP_STARTS '^'
75#define AVP_OP_ENDS '$'
76#define AVP_OP_CONTAINS '~'
77#define AVP_OP_LOWER '<'
78#define AVP_OP_HIGHER '>'
79#define AVP_OP_EXISTS '?'
80#define AVP_OP_ONEOFF '|'
81#define AVP_OP_TRANSF '&'
82
83
87 typedef struct _avp {
88 char *n;
89 char *v;
90 char o;
91} AVP;
92
93
97 typedef struct _avp_node {
98 AVP *avp;
99 struct _avp_node *next;
100 struct _avp_node *prev;
101} AVPN;
102
103
110 typedef struct _avp_list {
111 char *name;
112 uint32_t len;
113 AVPN null;
114} AVPL;
115
116
120 typedef enum _avpl_match_mode {
121 AVPL_NO_MATCH,
122 AVPL_STRICT,
123 AVPL_LOOSE,
124 AVPL_EVERY
125} avpl_match_mode;
126
127
131 typedef enum _avpl_replace_mode {
132 AVPL_NO_REPLACE,
133 AVPL_INSERT,
134 AVPL_REPLACE
135} avpl_replace_mode;
136
137
139 typedef struct _avpl_transf AVPL_Transf;
140
141
149 struct _avpl_transf {
150 char *name;
151
152 AVPL *match;
153 AVPL *replace;
154
155 avpl_match_mode match_mode;
156 avpl_replace_mode replace_mode;
157
158 GHashTable *map;
159 AVPL_Transf *next;
160};
161
162
166 typedef struct _loal_node {
167 AVPL *avpl;
168 struct _loal_node *next;
169 struct _loal_node *prev;
170} LoALnode;
171
172
179 typedef struct _loal {
180 char *name;
181 unsigned len;
182 LoALnode null;
183} LoAL;
184
185
186/* avp library (re)initialization */
187
194 extern void avp_init(void);
195
196/* If enabled set's up the debug facilities for the avp library */
197#ifdef _AVP_DEBUGGING
198 extern void setup_avp_debug(FILE* fp, int* general, int* avp, int* avp_op, int* avpl, int* avpl_op);
199#endif /* _AVP_DEBUGGING */
200
201/*
202 * avp constructors
203 */
204
205/* creates a new avp */
206
215 extern AVP* new_avp(const char* name, const char* value, char op);
216
225 extern AVP* avp_copy(AVP* from);
226
236 extern AVP* new_avp_from_finfo(const char* name, field_info* finfo);
237
243 extern void delete_avp(AVP* avp);
244
245/*
246 * avp methods
247 */
254#define avp_to_str(avp) (ws_strdup_printf("%s%c%s",avp->n,avp->o,avp->v))
255
265 extern AVP* match_avp(AVP* src, AVP* op);
266
267
268/*
269 * avplist constructors
270 */
271
278 extern AVPL* new_avpl(const char* name);
279
280
289 extern AVPL* new_avpl_from_avpl(const char* name, AVPL* avpl, bool copy_avps);
290
302 extern AVPL* new_avpl_loose_match(const char* name, AVPL* src, AVPL* op, bool copy_avps);
303
304
317 extern AVPL* new_avpl_pairs_match(const char* name, AVPL* src, AVPL* op, bool strict, bool copy_avps);
318
319/* uses mode to call one of the former matches. NO_MATCH = merge(merge(copy(src),op)) */
320
333 extern AVPL* new_avpl_from_match(avpl_match_mode mode, const char* name,AVPL* src, AVPL* op, bool copy_avps);
334
335
336/*
337 * functions on avpls
338 */
339
347 extern bool insert_avp(AVPL* avpl, AVP* avp);
348
355 extern void rename_avpl(AVPL* avpl, char* name);
356
367 extern void merge_avpl(AVPL* dest, AVPL* src, bool copy);
368
380 extern AVP* get_avp_by_name(AVPL* avpl, char* name, void** cookie);
381
391 extern AVP* get_next_avp(AVPL* avpl, void** cookie);
392
399 extern AVP* extract_first_avp(AVPL* avpl);
400
407 extern AVP* extract_last_avp(AVPL* avpl);
408
419 extern AVP* extract_avp_by_name(AVPL* avpl, char* name);
420
429 extern char* avpl_to_str(AVPL* avpl);
430
439 extern char* avpl_to_dotstr(AVPL* avpl);
440
441/* deletes an avp list and eventually its contents */
442
449 extern void delete_avpl(AVPL* avpl, bool avps_too);
450
451/*
452 * AVPL transformations
453 */
459 extern void delete_avpl_transform(AVPL_Transf* it);
460
467 extern void avpl_transform(AVPL* src, AVPL_Transf* op);
468
469
470/*
471 * Lists of AVP lists
472 */
473
482 extern LoAL* new_loal(const char* name);
483
493 extern LoAL* loal_from_file(char* filename);
494
501 extern void loal_append(LoAL* loal, AVPL* avpl);
502
509 extern AVPL* extract_first_avpl(LoAL* loal);
510
517 extern AVPL* extract_last_avpl(LoAL* loal);
518
528 extern AVPL* get_next_avpl(LoAL* loal,void** cookie);
529
537 extern void delete_loal(LoAL* loal, bool avpls_too, bool avps_too);
538
539
540#endif
proto.h
_avp_list
Sorted, named list of AVPs (Attribute-Value Pair List).
Definition mate_util.h:110
_avp_list::null
AVPN null
Definition mate_util.h:113
_avp_list::name
char * name
Definition mate_util.h:111
_avp_list::len
uint32_t len
Definition mate_util.h:112
_avp_node
Doubly-linked list node wrapping a single AVP.
Definition mate_util.h:97
_avp_node::avp
AVP * avp
Definition mate_util.h:98
_avp_node::next
struct _avp_node * next
Definition mate_util.h:99
_avp_node::prev
struct _avp_node * prev
Definition mate_util.h:100
_avp
Attribute-Value Pair (AVP): a named value with an associated match operator.
Definition mate_util.h:87
_avp::n
char * n
Definition mate_util.h:88
_avp::o
char o
Definition mate_util.h:90
_avp::v
char * v
Definition mate_util.h:89
_avpl_transf
AVPL transformation rule: a named match/replace operation applied to AVP lists.
Definition mate_util.h:149
_avpl_transf::match_mode
avpl_match_mode match_mode
Definition mate_util.h:155
_avpl_transf::next
AVPL_Transf * next
Definition mate_util.h:159
_avpl_transf::replace
AVPL * replace
Definition mate_util.h:153
_avpl_transf::match
AVPL * match
Definition mate_util.h:152
_avpl_transf::name
char * name
Definition mate_util.h:150
_avpl_transf::replace_mode
avpl_replace_mode replace_mode
Definition mate_util.h:156
_avpl_transf::map
GHashTable * map
Definition mate_util.h:158
_loal_node
Doubly-linked list node wrapping a single AVPL, used in a LoAL.
Definition mate_util.h:166
_loal_node::prev
struct _loal_node * prev
Definition mate_util.h:169
_loal_node::avpl
AVPL * avpl
Definition mate_util.h:167
_loal_node::next
struct _loal_node * next
Definition mate_util.h:168
_loal
List of AVP Lists (LoAL): a named, doubly-linked collection of AVPLs.
Definition mate_util.h:179
_loal::null
LoALnode null
Definition mate_util.h:182
_loal::len
unsigned len
Definition mate_util.h:181
_loal::name
char * name
Definition mate_util.h:180
_scs_collection
Definition mate_util.c:71
field_info
Definition proto.h:822