/src/wireshark/epan/dissectors/packet-xmpp-conference.c
Line | Count | Source |
1 | | /* packet-xmpp-conference.c |
2 | | * Wireshark's XMPP dissector. |
3 | | * |
4 | | * XEP-0298: Delivering Conference Information to Jingle Participants (Coin) |
5 | | * |
6 | | * Copyright 2011, Mariusz Okroj <okrojmariusz[]gmail.com> |
7 | | * |
8 | | * Wireshark - Network traffic analyzer |
9 | | * By Gerald Combs <gerald@wireshark.org> |
10 | | * Copyright 1998 Gerald Combs |
11 | | * |
12 | | * SPDX-License-Identifier: GPL-2.0-or-later |
13 | | */ |
14 | | |
15 | | #include "config.h" |
16 | | |
17 | | #include <epan/packet.h> |
18 | | |
19 | | #include "packet-xmpp.h" |
20 | | #include "packet-xmpp-conference.h" |
21 | | |
22 | | |
23 | | static void xmpp_conf_desc(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
24 | | static void xmpp_conf_state(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
25 | | static void xmpp_conf_users(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
26 | | static void xmpp_conf_user(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
27 | | static void xmpp_conf_endpoint(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
28 | | static void xmpp_conf_media(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element); |
29 | | |
30 | | void |
31 | | xmpp_conferece_info_advert(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
32 | 0 | { |
33 | 0 | proto_item *cinfo_item; |
34 | 0 | proto_tree *cinfo_tree; |
35 | |
|
36 | 0 | xmpp_attr_info attrs_info [] = { |
37 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
38 | 0 | {"isfocus", NULL, true, true, NULL, NULL} |
39 | 0 | }; |
40 | |
|
41 | 0 | cinfo_item = proto_tree_add_item(tree, hf_xmpp_conf_info, tvb, element->offset, element->length, |
42 | 0 | ENC_BIG_ENDIAN); |
43 | 0 | cinfo_tree = proto_item_add_subtree(cinfo_item, ett_xmpp_conf_info); |
44 | |
|
45 | 0 | xmpp_display_attrs(cinfo_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
46 | 0 | xmpp_display_elems(cinfo_tree, element, pinfo, tvb, NULL, 0); |
47 | 0 | } |
48 | | |
49 | | void |
50 | | xmpp_conference_info(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
51 | 0 | { |
52 | 0 | proto_item *cinfo_item; |
53 | 0 | proto_tree *cinfo_tree; |
54 | |
|
55 | 0 | static const char *state_enums[] = {"full", "partial", "deleted"}; |
56 | 0 | xmpp_array_t *state_array = xmpp_ep_init_array_t(pinfo->pool, state_enums, array_length(state_enums)); |
57 | |
|
58 | 0 | xmpp_attr_info attrs_info [] = { |
59 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
60 | 0 | {"entity", NULL, true, true, NULL, NULL}, |
61 | 0 | {"state", NULL, false, true, xmpp_val_enum_list, state_array}, |
62 | 0 | {"version", NULL, false, true, NULL, NULL}, |
63 | 0 | {"sid", &hf_xmpp_conf_info_sid, false, true, NULL, NULL} |
64 | 0 | }; |
65 | |
|
66 | 0 | xmpp_elem_info elems_info [] = { |
67 | 0 | {NAME, "conference-description", xmpp_conf_desc, ONE}, |
68 | 0 | {NAME, "conference-state", xmpp_conf_state, ONE}, |
69 | | /*{NAME, "host-info", xmpp_conf_host_info, ONE},*/ |
70 | 0 | {NAME, "users", xmpp_conf_users, ONE}, |
71 | | /*{NAME, "sidebars-by-ref", xmpp_conf_sidebars_by_ref, ONE},*/ |
72 | | /*{NAME, "sidebars-by-val", xmpp_conf_sidebars_by_val, ONE},*/ |
73 | 0 | }; |
74 | |
|
75 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "CONFERENC-INFO "); |
76 | |
|
77 | 0 | cinfo_item = proto_tree_add_item(tree, hf_xmpp_conf_info, tvb, element->offset, element->length, |
78 | 0 | ENC_BIG_ENDIAN); |
79 | 0 | cinfo_tree = proto_item_add_subtree(cinfo_item, ett_xmpp_conf_info); |
80 | |
|
81 | 0 | xmpp_display_attrs(cinfo_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
82 | 0 | xmpp_display_elems(cinfo_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
83 | 0 | } |
84 | | |
85 | | static void |
86 | | xmpp_conf_desc(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
87 | 0 | { |
88 | 0 | proto_tree *desc_tree; |
89 | |
|
90 | 0 | xmpp_attr_info attrs_info [] = { |
91 | 0 | {"subject", NULL, false, true, NULL, NULL}, |
92 | 0 | {"display-text", NULL, false, false, NULL, NULL}, |
93 | 0 | {"free-text", NULL, false, false, NULL, NULL}, |
94 | 0 | {"max-user-count", NULL, false, false, NULL, NULL}, |
95 | 0 | }; |
96 | | |
97 | | /* |
98 | | xmpp_elem_info elems_info [] = { |
99 | | {NAME, "keywords", xmpp_conf_desc_keywords, ONE}, |
100 | | {NAME, "conf-uris", xmpp_conf_desc_conf_uris, ONE}, |
101 | | {NAME, "service-uris", xmpp_conf_desc_serv_uris, ONE}, |
102 | | {NAME, "available-media", xmpp_conf_desc_avil_media, ONE}, |
103 | | }; |
104 | | */ |
105 | |
|
106 | 0 | desc_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_conf_desc, NULL, "CONFERENCE DESCRIPTION"); |
107 | |
|
108 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "subject", "subject", element, xmpp_transform_func_cdata); |
109 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "display-text", "display-text", element, xmpp_transform_func_cdata); |
110 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "free-text", "free-text", element, xmpp_transform_func_cdata); |
111 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "maximum-user-count", "max-user-count", element, xmpp_transform_func_cdata); |
112 | |
|
113 | 0 | xmpp_display_attrs(desc_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
114 | 0 | xmpp_display_elems(desc_tree, element, pinfo, tvb, NULL,0); |
115 | 0 | } |
116 | | |
117 | | static void |
118 | | xmpp_conf_state(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
119 | 0 | { |
120 | 0 | proto_tree *state_tree; |
121 | |
|
122 | 0 | xmpp_attr_info attrs_info [] = { |
123 | 0 | {"user-count", NULL, false, true, NULL, NULL}, |
124 | 0 | {"active", NULL, false, true, NULL, NULL}, |
125 | 0 | {"locked", NULL, false, true, NULL, NULL} |
126 | 0 | }; |
127 | |
|
128 | 0 | state_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, |
129 | 0 | ett_xmpp_conf_state, NULL, "CONFERENCE STATE"); |
130 | |
|
131 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "user-count", "user-count", element, xmpp_transform_func_cdata); |
132 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "active", "active", element, xmpp_transform_func_cdata); |
133 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "locked", "locked", element, xmpp_transform_func_cdata); |
134 | |
|
135 | 0 | xmpp_display_attrs(state_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
136 | 0 | xmpp_display_elems(state_tree, element, pinfo, tvb, NULL,0); |
137 | |
|
138 | 0 | } |
139 | | |
140 | | static void |
141 | | xmpp_conf_users(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
142 | 0 | { |
143 | 0 | proto_tree *users_tree; |
144 | |
|
145 | 0 | xmpp_attr_info attrs_info [] = { |
146 | 0 | {"state", NULL, false, true, NULL, NULL} |
147 | 0 | }; |
148 | |
|
149 | 0 | xmpp_elem_info elems_info [] = { |
150 | 0 | {NAME, "user", xmpp_conf_user, MANY} |
151 | 0 | }; |
152 | |
|
153 | 0 | users_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_conf_users, NULL, "USERS"); |
154 | |
|
155 | 0 | xmpp_display_attrs(users_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
156 | 0 | xmpp_display_elems(users_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
157 | 0 | } |
158 | | static void |
159 | | xmpp_conf_user(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
160 | 0 | { |
161 | 0 | proto_tree *user_tree; |
162 | |
|
163 | 0 | xmpp_attr_info attrs_info [] = { |
164 | 0 | {"entity", NULL, false, true, NULL, NULL}, |
165 | 0 | {"state", NULL, false, true, NULL, NULL}, |
166 | 0 | {"display-text", NULL, false, true, NULL, NULL}, |
167 | 0 | {"cascaded-focus", NULL, false, true, NULL, NULL} |
168 | 0 | }; |
169 | |
|
170 | 0 | xmpp_elem_info elems_info [] = { |
171 | | /*{NAME, "associated-aors", xmpp_conf_assoc_aors, ONE},*/ |
172 | | /*{NAME, "roles", xmpp_conf_roles, ONE},*/ |
173 | | /*{NAME, "languages", xmpp_conf_langs, ONE},*/ |
174 | 0 | {NAME, "endpoint", xmpp_conf_endpoint, MANY}, |
175 | 0 | }; |
176 | |
|
177 | 0 | user_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_conf_user, NULL, "USERS"); |
178 | |
|
179 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "display-text", "display-text", element, xmpp_transform_func_cdata); |
180 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "cascaded-focus", "cascaded-focus", element, xmpp_transform_func_cdata); |
181 | |
|
182 | 0 | xmpp_display_attrs(user_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
183 | 0 | xmpp_display_elems(user_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
184 | 0 | } |
185 | | |
186 | | static void |
187 | | xmpp_conf_endpoint(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
188 | 0 | { |
189 | 0 | proto_tree *endpoint_tree; |
190 | |
|
191 | 0 | xmpp_attr_info attrs_info [] = { |
192 | 0 | {"entity", NULL, false, true, NULL, NULL}, |
193 | 0 | {"state", NULL, false, true, NULL, NULL}, |
194 | 0 | {"display-text", NULL, false, true, NULL, NULL}, |
195 | 0 | {"status", NULL, false, true, NULL, NULL}, |
196 | 0 | {"joining-method", NULL, false, true, NULL, NULL}, |
197 | 0 | {"disconnection-method", NULL, false, true, NULL, NULL}, |
198 | 0 | }; |
199 | |
|
200 | 0 | xmpp_elem_info elems_info [] = { |
201 | | /*{NAME,"referred",...,ONE},*/ |
202 | | /*{NAME,"joining-info",...,ONE},*/ |
203 | | /*{NAME,"disconnection-info",...,ONE},*/ |
204 | 0 | {NAME,"media", xmpp_conf_media, ONE}, |
205 | | /*{NAME,"call-info",...,ONE},*/ |
206 | |
|
207 | 0 | }; |
208 | |
|
209 | 0 | endpoint_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_conf_endpoint, NULL, "ENDPOINT"); |
210 | |
|
211 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "display-text", "display-text", element, xmpp_transform_func_cdata); |
212 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "status", "status", element, xmpp_transform_func_cdata); |
213 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "joining-method", "joining-method", element, xmpp_transform_func_cdata); |
214 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "disconnection-method", "disconnection-method", element, xmpp_transform_func_cdata); |
215 | | |
216 | |
|
217 | 0 | xmpp_display_attrs(endpoint_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
218 | 0 | xmpp_display_elems(endpoint_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
219 | 0 | } |
220 | | |
221 | | static void |
222 | | xmpp_conf_media(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, xmpp_element_t *element) |
223 | 0 | { |
224 | 0 | proto_tree *media_tree; |
225 | |
|
226 | 0 | xmpp_attr_info attrs_info[] = { |
227 | 0 | {"id", NULL, true, true, NULL, NULL}, |
228 | 0 | {"display-text", NULL, false, true, NULL, NULL}, |
229 | 0 | {"type", NULL, false, true, NULL, NULL}, |
230 | 0 | {"label", NULL, false, true, NULL, NULL}, |
231 | 0 | {"src-id", NULL, false, true, NULL, NULL}, |
232 | 0 | {"status", NULL, false, true, NULL, NULL}, |
233 | 0 | }; |
234 | |
|
235 | 0 | media_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_conf_media, NULL, "MEDIA"); |
236 | |
|
237 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "display-text", "display-text", element, xmpp_transform_func_cdata); |
238 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "type", "type", element, xmpp_transform_func_cdata); |
239 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "label", "label", element, xmpp_transform_func_cdata); |
240 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "src-id", "src-id", element, xmpp_transform_func_cdata); |
241 | 0 | xmpp_change_elem_to_attrib(pinfo->pool, "status", "status", element, xmpp_transform_func_cdata); |
242 | |
|
243 | 0 | xmpp_display_attrs(media_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
244 | | xmpp_display_elems(media_tree, element, pinfo, tvb, NULL, 0); |
245 | 0 | } |
246 | | /* |
247 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
248 | | * |
249 | | * Local variables: |
250 | | * c-basic-offset: 4 |
251 | | * tab-width: 8 |
252 | | * indent-tabs-mode: nil |
253 | | * End: |
254 | | * |
255 | | * ex: set shiftwidth=4 tabstop=8 expandtab: |
256 | | * :indentSize=4:tabSize=8:noTabs=true: |
257 | | */ |