Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
packet-xmpp-utils.h
1/* packet-xmpp-utils.h
2 *
3 * Copyright 2011, Mariusz Okroj <okrojmariusz[]gmail.com>
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#ifndef XMPP_UTILS_H
13#define XMPP_UTILS_H
14
15#include "ws_symbol_export.h"
16#include <epan/tvbuff.h>
17#include <epan/dissectors/packet-xml.h>
18#include <epan/wmem_scopes.h>
19
20#define xmpp_elem_cdata(elem) \
21elem->data?elem->data->value:""
22
23typedef struct _xmpp_array_t
24{
25 void *data;
26 int length;
27} xmpp_array_t;
28
29typedef struct _xmpp_attr_t{
30 const char *value;
31 const char *name;
32 int offset;
33 int length;
34
35 bool was_read;
36} xmpp_attr_t;
37
38typedef struct _xmpp_data_t{
39 char *value;
40
41 int offset;
42 int length;
43} xmpp_data_t;
44
45typedef struct _xmpp_element_t{
46 char* name;
47
48 /*abbreviation that appears before tag name (<nos:x .../>)
49 if abbrev doesn't appear then NULL*/
50 char* default_ns_abbrev;
51 /*pair of namespace abbrev and namespace*/
52 GHashTable *namespaces;
53
54 GHashTable *attrs;
55 GList *elements;
56 xmpp_data_t *data;
57
58 int offset;
59 int length;
60
61 bool was_read;
62 /* nesting depth, 0 for the stanza itself */
63 unsigned depth;
64} xmpp_element_t;
65
66/*informations about attributes that are displayed in proto tree*/
67typedef struct _xmpp_attr_info{
68 const char *name;
69 const int *phf;
70 bool is_required;
71 bool in_short_list;
72
73 /*function validates this attribute
74 it may impose other restrictions (e.g. validating attribute's name, ...)*/
75 void (*val_func)(packet_info *pinfo, proto_item *item, const char *name, const char *value, const void *data);
76 void *data;
77} xmpp_attr_info;
78
79typedef struct _xmpp_attr_info_ext{
80 const char* ns;
81 xmpp_attr_info info;
82} xmpp_attr_info_ext;
83
84typedef enum _xmpp_elem_info_type{
85 NAME,
86 ATTR,
87 NAME_AND_ATTR,
88 NAMES
89} xmpp_elem_info_type;
90
91typedef enum _xmpp_elem_info_occurrence
92{
93 ONE,MANY
94} xmpp_elem_info_occurrence;
95
96/*informations about elements that are displayed in proto tree*/
97typedef struct _xmpp_elem_info{
98 xmpp_elem_info_type type;
99 const void *data;
100 /*function that displays element in tree*/
101 void (*elem_func)(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element);
102 xmpp_elem_info_occurrence occurrence;
103} xmpp_elem_info;
104
105typedef struct _xmpp_conv_info_t {
106 wmem_tree_t *req_resp;
107 wmem_tree_t *jingle_sessions;
108 wmem_tree_t *ibb_sessions;
109 wmem_tree_t *gtalk_sessions;
110 uint32_t ssl_start;
111} xmpp_conv_info_t;
112
117 uint32_t req_frame;
118 uint32_t resp_frame;
119} xmpp_transaction_t;
120
126extern void xmpp_iq_reqresp_track(packet_info *pinfo, xmpp_element_t *packet, xmpp_conv_info_t *xmpp_info);
127
131extern void xmpp_jingle_session_track(packet_info *pinfo, xmpp_element_t *packet, xmpp_conv_info_t *xmpp_info);
132
136extern void xmpp_ibb_session_track(packet_info *pinfo, xmpp_element_t *packet, xmpp_conv_info_t *xmpp_info);
137
141extern void xmpp_gtalk_session_track(packet_info *pinfo, xmpp_element_t *packet, xmpp_conv_info_t *xmpp_info);
142
147extern void xmpp_unknown(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element);
148
154extern void xmpp_cdata(proto_tree *tree, tvbuff_t *tvb, xmpp_element_t *element, int hf);
155
159extern void xmpp_simple_cdata_elem(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element);
160
163extern xmpp_element_t* xmpp_xml_frame_to_element_t(packet_info *pinfo, xml_frame_t *xml_frame, xmpp_element_t *parent, tvbuff_t *tvb);
164
168extern void xmpp_element_t_tree_free(xmpp_element_t *root);
169
171extern xmpp_array_t* xmpp_ep_init_array_t(wmem_allocator_t *pool, const char** array, int len);
172
173/*Allocs ephemeral memory for xmpp_attr_t struct*/
174extern xmpp_attr_t* xmpp_ep_init_attr_t(wmem_allocator_t *pool, const char *value, int offset, int length);
175
179
180extern xmpp_element_t* xmpp_steal_element_by_name(xmpp_element_t *packet, const char *name);
181extern xmpp_element_t* xmpp_steal_element_by_names(xmpp_element_t *packet, const char **names, int names_len);
182extern xmpp_element_t* xmpp_steal_element_by_attr(xmpp_element_t *packet, const char *attr_name, const char *attr_value);
183extern xmpp_element_t* xmpp_steal_element_by_name_and_attr(xmpp_element_t *packet, const char *name, const char *attr_name, const char *attr_value);
184
185/*Returns first child in element*/
186extern xmpp_element_t* xmpp_get_first_element(xmpp_element_t *packet);
187
188/*Converts element to string. Returns memory allocated from the given pool.*/
189extern char* xmpp_element_to_string(wmem_allocator_t *pool, tvbuff_t *tvb, xmpp_element_t *element);
190
191/* Returns attribute by name and set as read. If attrib is set as read, it may be found
192 * one more time, but it is invisible for function xmpp_unknown_attrib*/
193extern xmpp_attr_t* xmpp_get_attr(xmpp_element_t *element, const char* attr_name);
194
195/*Function hides first element in tree.*/
196extern void xmpp_proto_tree_hide_first_child(proto_tree *tree);
197
198/*Function shows first element in tree.*/
199extern void xmpp_proto_tree_show_first_child(proto_tree *tree);
200
201/*Function returns item as text. Memory is allocated from the given pool.*/
202extern char* proto_item_get_text(wmem_allocator_t *pool, proto_item *item);
203
204/*Function returns struct that contains 3 strings. It is used to build xmpp_attr_info struct.*/
205extern void *xmpp_name_attr_struct(wmem_allocator_t *pool, const char *name, const char *attr_name, const char *attr_value);
206
215extern void xmpp_display_attrs(proto_tree *tree, xmpp_element_t *element, packet_info *pinfo, tvbuff_t *tvb, const xmpp_attr_info *attrs, unsigned n);
216
229extern void xmpp_display_attrs_ext(proto_tree *tree, xmpp_element_t *element, packet_info *pinfo, tvbuff_t *tvb, const xmpp_attr_info_ext *attrs, unsigned n);
230
236extern void xmpp_display_elems(proto_tree *tree, xmpp_element_t *parent, packet_info *pinfo, tvbuff_t *tvb, xmpp_elem_info *elems, unsigned n);
237
238/* Validates attribute value. Takes string array(char**) in parameter data.
239 * Is used in XMPP_ATTR_INFO struct.
240 */
241extern void xmpp_val_enum_list(packet_info *pinfo, proto_item *item, const char *name, const char *value, const void *data);
242
247extern void xmpp_change_elem_to_attrib(wmem_allocator_t *pool, const char *elem_name, const char *attr_name, xmpp_element_t *parent, xmpp_attr_t* (*transform_func)(wmem_allocator_t *pool, xmpp_element_t *element));
248
251extern xmpp_attr_t* xmpp_transform_func_cdata(wmem_allocator_t *pool, xmpp_element_t *elem);
252
253#endif /* XMPP_UTILS_H */
struct _packet_info packet_info
Represents the metadata and indexing information for a single captured frame.
proto_node proto_item
Definition proto.h:952
struct _wmem_tree_t wmem_tree_t
Opaque type representing a red-black tree in the wmem system.
Definition wmem_tree.h:49
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
Definition packet-xmpp-utils.h:24
Definition packet-xmpp-utils.h:79
Definition packet-xmpp-utils.h:67
Definition packet-xmpp-utils.h:29
Definition packet-xmpp-utils.h:105
Definition packet-xmpp-utils.h:38
Definition packet-xmpp-utils.h:97
Definition packet-xmpp-utils.h:45
Definition packet-xmpp-utils.h:116