Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
mate_util.h
1/* mate_util.h
2 *
3 * Copyright 2004, Luis E. Garcia Ontanon <[email protected]>
4 *
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <[email protected]>
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
32extern 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
48extern char* scs_subscribe(SCS_collection* collection, const char* s);
56extern void scs_unsubscribe(SCS_collection* collection, char* s);
57
66extern 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
87typedef struct _avp {
88 char *n;
89 char *v;
90 char o;
91} AVP;
92
93
97typedef struct _avp_node {
99 struct _avp_node *next;
100 struct _avp_node *prev;
101} AVPN;
102
103
110typedef struct _avp_list {
111 char *name;
112 uint32_t len;
114} AVPL;
115
116
120typedef enum _avpl_match_mode {
121 AVPL_NO_MATCH,
122 AVPL_STRICT,
123 AVPL_LOOSE,
124 AVPL_EVERY
125} avpl_match_mode;
126
127
131typedef enum _avpl_replace_mode {
132 AVPL_NO_REPLACE,
133 AVPL_INSERT,
134 AVPL_REPLACE
135} avpl_replace_mode;
136
137
139typedef struct _avpl_transf AVPL_Transf;
140
141
150 char *name;
155 avpl_match_mode match_mode;
156 avpl_replace_mode replace_mode;
158 GHashTable *map;
160};
161
162
166typedef struct _loal_node {
168 struct _loal_node *next;
169 struct _loal_node *prev;
170} LoALnode;
171
172
179typedef struct _loal {
180 char *name;
181 unsigned len;
183} LoAL;
184
185
186/* avp library (re)initialization */
187
194extern void avp_init(void);
195
196/* If enabled set's up the debug facilities for the avp library */
197#ifdef _AVP_DEBUGGING
198extern 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
215extern AVP* new_avp(const char* name, const char* value, char op);
216
225extern AVP* avp_copy(AVP* from);
226
236extern AVP* new_avp_from_finfo(const char* name, field_info* finfo);
237
243extern 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
265extern AVP* match_avp(AVP* src, AVP* op);
266
267
268/*
269 * avplist constructors
270 */
271
278extern AVPL* new_avpl(const char* name);
279
280
289extern AVPL* new_avpl_from_avpl(const char* name, AVPL* avpl, bool copy_avps);
290
302extern AVPL* new_avpl_loose_match(const char* name, AVPL* src, AVPL* op, bool copy_avps);
303
304
317extern 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
333extern 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
347extern bool insert_avp(AVPL* avpl, AVP* avp);
348
355extern void rename_avpl(AVPL* avpl, char* name);
356
367extern void merge_avpl(AVPL* dest, AVPL* src, bool copy);
368
380extern AVP* get_avp_by_name(AVPL* avpl, char* name, void** cookie);
381
391extern AVP* get_next_avp(AVPL* avpl, void** cookie);
392
399extern AVP* extract_first_avp(AVPL* avpl);
400
407extern AVP* extract_last_avp(AVPL* avpl);
408
419extern AVP* extract_avp_by_name(AVPL* avpl, char* name);
420
429extern char* avpl_to_str(AVPL* avpl);
430
439extern char* avpl_to_dotstr(AVPL* avpl);
440
441/* deletes an avp list and eventually its contents */
442
449extern void delete_avpl(AVPL* avpl, bool avps_too);
450
451/*
452 * AVPL transformations
453 */
459extern void delete_avpl_transform(AVPL_Transf* it);
460
467extern void avpl_transform(AVPL* src, AVPL_Transf* op);
468
469
470/*
471 * Lists of AVP lists
472 */
473
482extern LoAL* new_loal(const char* name);
483
493extern LoAL* loal_from_file(char* filename);
494
501extern void loal_append(LoAL* loal, AVPL* avpl);
502
509extern AVPL* extract_first_avpl(LoAL* loal);
510
517extern AVPL* extract_last_avpl(LoAL* loal);
518
528extern AVPL* get_next_avpl(LoAL* loal,void** cookie);
529
537extern void delete_loal(LoAL* loal, bool avpls_too, bool avps_too);
538
539
540#endif
Sorted, named list of AVPs (Attribute-Value Pair List).
Definition mate_util.h:110
AVPN null
Definition mate_util.h:113
char * name
Definition mate_util.h:111
uint32_t len
Definition mate_util.h:112
Doubly-linked list node wrapping a single AVP.
Definition mate_util.h:97
AVP * avp
Definition mate_util.h:98
struct _avp_node * next
Definition mate_util.h:99
struct _avp_node * prev
Definition mate_util.h:100
Attribute-Value Pair (AVP): a named value with an associated match operator.
Definition mate_util.h:87
char * n
Definition mate_util.h:88
char o
Definition mate_util.h:90
char * v
Definition mate_util.h:89
AVPL transformation rule: a named match/replace operation applied to AVP lists.
Definition mate_util.h:149
avpl_match_mode match_mode
Definition mate_util.h:155
AVPL_Transf * next
Definition mate_util.h:159
AVPL * replace
Definition mate_util.h:153
AVPL * match
Definition mate_util.h:152
char * name
Definition mate_util.h:150
avpl_replace_mode replace_mode
Definition mate_util.h:156
GHashTable * map
Definition mate_util.h:158
Doubly-linked list node wrapping a single AVPL, used in a LoAL.
Definition mate_util.h:166
struct _loal_node * prev
Definition mate_util.h:169
AVPL * avpl
Definition mate_util.h:167
struct _loal_node * next
Definition mate_util.h:168
List of AVP Lists (LoAL): a named, doubly-linked collection of AVPLs.
Definition mate_util.h:179
LoALnode null
Definition mate_util.h:182
unsigned len
Definition mate_util.h:181
char * name
Definition mate_util.h:180
Definition mate_util.c:71
Definition proto.h:817