/src/wireshark/epan/dissectors/packet-xmpp-gtalk.c
Line | Count | Source |
1 | | /* packet-xmpp-gtalk.c |
2 | | * Wireshark's XMPP dissector. |
3 | | * |
4 | | * GTalk extensions. |
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-gtalk.h" |
21 | | #include "packet-xmpp-conference.h" |
22 | | |
23 | | |
24 | | static void xmpp_gtalk_session_desc(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
25 | | static void xmpp_gtalk_session_desc_payload(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
26 | | static void xmpp_gtalk_session_cand(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
27 | | static void xmpp_gtalk_session_reason(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
28 | | static void xmpp_gtalk_jingleinfo_stun(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
29 | | static void xmpp_gtalk_jingleinfo_server(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
30 | | static void xmpp_gtalk_jingleinfo_relay(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
31 | | static void xmpp_gtalk_jingleinfo_relay_serv(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
32 | | static void xmpp_gtalk_mail_mail_info(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
33 | | static void xmpp_gtalk_mail_senders(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
34 | | static void xmpp_gtalk_mail_sender(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
35 | | static void xmpp_gtalk_mail_snippet(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
36 | | static void xmpp_gtalk_status_status_list(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
37 | | static void xmpp_gtalk_transport_p2p_cand(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element); |
38 | | |
39 | | void |
40 | | xmpp_gtalk_session(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
41 | 0 | { |
42 | 0 | proto_item *session_item; |
43 | 0 | proto_tree *session_tree; |
44 | |
|
45 | 0 | xmpp_attr_info attrs_info [] = { |
46 | 0 | {"xmlns", &hf_xmpp_xmlns, true, false, NULL, NULL}, |
47 | 0 | {"type", &hf_xmpp_gtalk_session_type, true, true, NULL, NULL}, |
48 | 0 | {"initiator", NULL, false, true, NULL, NULL}, |
49 | 0 | {"id", NULL, true, true, NULL, NULL} |
50 | 0 | }; |
51 | |
|
52 | 0 | xmpp_elem_info elems_info [] = { |
53 | 0 | {NAME,"description", xmpp_gtalk_session_desc, ONE}, |
54 | 0 | {NAME, "candidate", xmpp_gtalk_session_cand, MANY}, |
55 | 0 | {NAME, "reason", xmpp_gtalk_session_reason, ONE}, |
56 | 0 | {NAME_AND_ATTR, xmpp_name_attr_struct(pinfo->pool, "transport", "xmlns", "http://www.google.com/transport/p2p"), xmpp_gtalk_transport_p2p, ONE}, |
57 | 0 | {NAME, "conference-info", xmpp_conferece_info_advert, ONE} |
58 | 0 | }; |
59 | |
|
60 | 0 | xmpp_attr_t *attr_type = xmpp_get_attr(element, "type"); |
61 | |
|
62 | 0 | col_append_fstr(pinfo->cinfo, COL_INFO, "GTALK-SESSION(%s) ", attr_type?attr_type->value:""); |
63 | |
|
64 | 0 | session_item = proto_tree_add_item(tree, hf_xmpp_gtalk_session, tvb, element->offset, element->length, ENC_BIG_ENDIAN); |
65 | 0 | session_tree = proto_item_add_subtree(session_item, ett_xmpp_gtalk_session); |
66 | |
|
67 | 0 | xmpp_display_attrs(session_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
68 | |
|
69 | 0 | xmpp_display_elems(session_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
70 | 0 | } |
71 | | |
72 | | static void |
73 | | xmpp_gtalk_session_desc(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
74 | 0 | { |
75 | 0 | proto_tree *desc_tree; |
76 | |
|
77 | 0 | xmpp_attr_info attrs_info[] = { |
78 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
79 | 0 | {"xml:lang", NULL, false, false, NULL, NULL} |
80 | 0 | }; |
81 | |
|
82 | 0 | xmpp_elem_info elems_info[] = { |
83 | 0 | {NAME, "payload-type", xmpp_gtalk_session_desc_payload, MANY} |
84 | 0 | }; |
85 | |
|
86 | 0 | desc_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_session_desc, NULL, "DESCRIPTION"); |
87 | |
|
88 | 0 | xmpp_display_attrs(desc_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
89 | 0 | xmpp_display_elems(desc_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
90 | 0 | } |
91 | | |
92 | | static void |
93 | | xmpp_gtalk_session_desc_payload(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
94 | 0 | { |
95 | 0 | proto_tree *payload_tree; |
96 | |
|
97 | 0 | xmpp_attr_info attrs_info[] = { |
98 | 0 | {"xmlns", &hf_xmpp_xmlns, false, true, NULL, NULL}, |
99 | 0 | {"id", NULL, false, true, NULL, NULL}, |
100 | 0 | {"name", NULL, false, true, NULL, NULL}, |
101 | 0 | {"channels", NULL, false, false, NULL, NULL}, |
102 | 0 | {"clockrate", NULL, false, false, NULL, NULL}, |
103 | 0 | {"bitrate", NULL, false, false, NULL, NULL}, |
104 | 0 | {"width", NULL, false, false, NULL, NULL}, |
105 | 0 | {"height", NULL, false, false, NULL, NULL}, |
106 | 0 | {"framerate", NULL, false, false, NULL, NULL}, |
107 | 0 | }; |
108 | |
|
109 | 0 | payload_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_session_desc_payload, NULL, "PAYLOAD-TYPE"); |
110 | |
|
111 | 0 | xmpp_display_attrs(payload_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
112 | 0 | xmpp_display_elems(payload_tree, element, pinfo, tvb, NULL, 0); |
113 | 0 | } |
114 | | |
115 | | static void |
116 | | xmpp_gtalk_session_cand(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
117 | 0 | { |
118 | 0 | proto_tree *cand_tree; |
119 | |
|
120 | 0 | xmpp_attr_info attrs_info[] = { |
121 | 0 | {"name", NULL, true, true, NULL, NULL}, |
122 | 0 | {"address", NULL, true, false, NULL, NULL}, |
123 | 0 | {"port", NULL, true, false, NULL, NULL}, |
124 | 0 | {"preference", NULL, true, false, NULL, NULL}, |
125 | 0 | {"type", NULL, true, true, NULL, NULL}, |
126 | 0 | {"protocol", NULL, true, true, NULL, NULL}, |
127 | 0 | {"network", NULL, true, false, NULL, NULL}, |
128 | 0 | {"username", NULL, true, false, NULL, NULL}, |
129 | 0 | {"password", NULL, true, false, NULL, NULL}, |
130 | 0 | {"generation", NULL, true, false, NULL, NULL}, |
131 | 0 | {"foundation", NULL, false, false, NULL, NULL}, |
132 | 0 | {"component", NULL, false, false, NULL, NULL} |
133 | 0 | }; |
134 | |
|
135 | 0 | cand_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_session_cand, NULL, "CANDIDATE"); |
136 | |
|
137 | 0 | xmpp_display_attrs(cand_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
138 | 0 | xmpp_display_elems(cand_tree, element, pinfo, tvb, NULL, 0); |
139 | 0 | } |
140 | | |
141 | | static void |
142 | | xmpp_gtalk_session_reason(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
143 | 0 | { |
144 | 0 | proto_tree *reason_tree; |
145 | |
|
146 | 0 | xmpp_attr_info attrs_info[] = { |
147 | 0 | {"condition", NULL, true, true, NULL, NULL}, |
148 | 0 | {"text", NULL, false, false, NULL, NULL} |
149 | 0 | }; |
150 | |
|
151 | 0 | xmpp_element_t *condition; |
152 | 0 | xmpp_element_t *text; |
153 | |
|
154 | 0 | static const char *reason_names[] = { "success", "busy", "cancel"}; |
155 | |
|
156 | 0 | reason_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_session_reason, NULL, "REASON"); |
157 | | |
158 | | |
159 | | /*Looks for reason description.*/ |
160 | 0 | if((condition = xmpp_steal_element_by_names(element, reason_names, array_length(reason_names)))!=NULL) |
161 | 0 | { |
162 | 0 | xmpp_attr_t *fake_cond = xmpp_ep_init_attr_t(pinfo->pool, condition->name, condition->offset, condition->length); |
163 | 0 | g_hash_table_insert(element->attrs, (void *)"condition", fake_cond); |
164 | |
|
165 | 0 | } |
166 | |
|
167 | 0 | if((text = xmpp_steal_element_by_name(element, "text"))!=NULL) |
168 | 0 | { |
169 | 0 | xmpp_attr_t *fake_text = xmpp_ep_init_attr_t(pinfo->pool, text->data?text->data->value:"", text->offset, text->length); |
170 | 0 | g_hash_table_insert(element->attrs, (void *)"text", fake_text); |
171 | 0 | } |
172 | |
|
173 | 0 | xmpp_display_attrs(reason_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
174 | |
|
175 | 0 | xmpp_unknown(reason_tree, tvb, pinfo, element); |
176 | 0 | } |
177 | | |
178 | | void |
179 | | xmpp_gtalk_jingleinfo_query(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
180 | 0 | { |
181 | 0 | proto_item *query_item; |
182 | 0 | proto_tree *query_tree; |
183 | |
|
184 | 0 | xmpp_attr_info attrs_info[] = { |
185 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL} |
186 | 0 | }; |
187 | |
|
188 | 0 | xmpp_elem_info elems_info [] = { |
189 | 0 | {NAME, "stun", xmpp_gtalk_jingleinfo_stun, ONE}, |
190 | 0 | {NAME, "relay", xmpp_gtalk_jingleinfo_relay, ONE} |
191 | 0 | }; |
192 | |
|
193 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "QUERY(google:jingleinfo) "); |
194 | |
|
195 | 0 | query_item = proto_tree_add_item(tree, hf_xmpp_query, tvb, element->offset, element->length, |
196 | 0 | ENC_BIG_ENDIAN); |
197 | 0 | query_tree = proto_item_add_subtree(query_item, ett_xmpp_query); |
198 | |
|
199 | 0 | xmpp_display_attrs(query_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
200 | 0 | xmpp_display_elems(query_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
201 | 0 | } |
202 | | |
203 | | static void |
204 | | xmpp_gtalk_jingleinfo_stun(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
205 | 0 | { |
206 | 0 | proto_tree *stun_tree; |
207 | |
|
208 | 0 | xmpp_elem_info elems_info [] = { |
209 | 0 | {NAME, "server", xmpp_gtalk_jingleinfo_server, MANY}, |
210 | 0 | }; |
211 | |
|
212 | 0 | stun_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_jingleinfo_stun, NULL, "STUN"); |
213 | |
|
214 | 0 | xmpp_display_attrs(stun_tree, element, pinfo, tvb, NULL, 0); |
215 | 0 | xmpp_display_elems(stun_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
216 | |
|
217 | 0 | } |
218 | | |
219 | | static void |
220 | | xmpp_gtalk_jingleinfo_server(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
221 | 0 | { |
222 | 0 | proto_tree *serv_tree; |
223 | |
|
224 | 0 | xmpp_attr_info attrs_info[] = { |
225 | 0 | {"host", NULL, true, true, NULL, NULL}, |
226 | 0 | {"udp", NULL, true, true, NULL, NULL} |
227 | 0 | }; |
228 | |
|
229 | 0 | serv_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_jingleinfo_server, NULL, "SERVER"); |
230 | |
|
231 | 0 | xmpp_display_attrs(serv_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
232 | 0 | xmpp_display_elems(serv_tree, element, pinfo, tvb, NULL, 0); |
233 | 0 | } |
234 | | |
235 | | static void |
236 | | xmpp_gtalk_jingleinfo_relay(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
237 | 0 | { |
238 | 0 | proto_tree *relay_tree; |
239 | |
|
240 | 0 | xmpp_attr_info attrs_info[] = { |
241 | 0 | {"token", NULL, false, false, NULL, NULL} |
242 | 0 | }; |
243 | |
|
244 | 0 | xmpp_elem_info elems_info [] = { |
245 | 0 | {NAME, "server", xmpp_gtalk_jingleinfo_relay_serv, ONE} |
246 | 0 | }; |
247 | |
|
248 | 0 | xmpp_element_t *token; |
249 | |
|
250 | 0 | relay_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_jingleinfo_relay, NULL, "RELAY"); |
251 | |
|
252 | 0 | if((token = xmpp_steal_element_by_name(element, "token"))!=NULL) |
253 | 0 | { |
254 | 0 | xmpp_attr_t *fake_token = xmpp_ep_init_attr_t(pinfo->pool, token->data?token->data->value:"", token->offset, token->length); |
255 | 0 | g_hash_table_insert(element->attrs, (void *)"token", fake_token); |
256 | 0 | } |
257 | |
|
258 | 0 | xmpp_display_attrs(relay_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
259 | 0 | xmpp_display_elems(relay_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
260 | 0 | } |
261 | | |
262 | | static void |
263 | | xmpp_gtalk_jingleinfo_relay_serv(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
264 | 0 | { |
265 | 0 | proto_tree *serv_tree; |
266 | |
|
267 | 0 | xmpp_attr_info attrs_info[] = { |
268 | 0 | {"host", NULL, true, true, NULL, NULL}, |
269 | 0 | {"udp", NULL, false, true, NULL, NULL}, |
270 | 0 | {"tcp", NULL, false, true, NULL, NULL}, |
271 | 0 | {"tcpssl", NULL, false, true, NULL, NULL} |
272 | 0 | }; |
273 | |
|
274 | 0 | serv_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_jingleinfo_relay_serv, NULL, "SERVER"); |
275 | |
|
276 | 0 | xmpp_display_attrs(serv_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
277 | 0 | xmpp_display_elems(serv_tree, element, pinfo, tvb, NULL, 0); |
278 | 0 | } |
279 | | |
280 | | void |
281 | | xmpp_gtalk_usersetting(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
282 | 0 | { |
283 | 0 | proto_item *sett_item; |
284 | 0 | proto_tree *sett_tree; |
285 | |
|
286 | 0 | xmpp_attr_info attrs_info [] = { |
287 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL} |
288 | 0 | }; |
289 | |
|
290 | 0 | unsigned i; |
291 | |
|
292 | 0 | sett_item = proto_tree_add_item(tree, hf_xmpp_gtalk_setting, tvb, element->offset, element->length, ENC_BIG_ENDIAN); |
293 | 0 | sett_tree = proto_item_add_subtree(sett_item, ett_xmpp_gtalk_setting); |
294 | |
|
295 | 0 | xmpp_display_attrs(sett_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
296 | |
|
297 | 0 | for(i = 0; i < g_list_length(element->elements); i++) |
298 | 0 | { |
299 | 0 | GList *elem_l = g_list_nth(element->elements,i); |
300 | 0 | xmpp_element_t *elem = (xmpp_element_t *)(elem_l?elem_l->data:NULL); |
301 | |
|
302 | 0 | if(elem) |
303 | 0 | { |
304 | 0 | xmpp_attr_t *val = xmpp_get_attr(elem,"value"); |
305 | 0 | proto_tree_add_string_format(sett_tree, hf_xmpp_gtalk_setting_element, tvb, elem->offset, elem->length, val?val->value:"", |
306 | 0 | "%s [%s]",elem->name,val?val->value:""); |
307 | 0 | } |
308 | 0 | } |
309 | 0 | } |
310 | | |
311 | | void |
312 | | xmpp_gtalk_nosave_x(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
313 | 0 | { |
314 | 0 | proto_item *x_item; |
315 | 0 | proto_tree *x_tree; |
316 | |
|
317 | 0 | xmpp_attr_info attrs_info [] = { |
318 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
319 | 0 | {"value", NULL, false, true, NULL, NULL} |
320 | 0 | }; |
321 | |
|
322 | 0 | x_item = proto_tree_add_item(tree, hf_xmpp_gtalk_nosave_x, tvb, element->offset, element->length, |
323 | 0 | ENC_BIG_ENDIAN); |
324 | 0 | x_tree = proto_item_add_subtree(x_item, ett_xmpp_gtalk_nosave_x); |
325 | |
|
326 | 0 | xmpp_display_attrs(x_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
327 | 0 | xmpp_display_elems(x_tree, element, pinfo, tvb, NULL, 0); |
328 | 0 | } |
329 | | |
330 | | void |
331 | | xmpp_gtalk_mail_query(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
332 | 0 | { |
333 | 0 | proto_item *query_item; |
334 | 0 | proto_tree *query_tree; |
335 | |
|
336 | 0 | xmpp_attr_info attrs_info[] = { |
337 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
338 | 0 | {"newer-than-time", NULL, false, true, NULL, NULL}, |
339 | 0 | {"newer-than-tid", NULL, false, true, NULL, NULL}, |
340 | 0 | {"q", NULL, false, true, NULL, NULL} |
341 | 0 | }; |
342 | |
|
343 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "QUERY(google:mail:notify) "); |
344 | |
|
345 | 0 | query_item = proto_tree_add_item(tree, hf_xmpp_query, tvb, element->offset, element->length, |
346 | 0 | ENC_BIG_ENDIAN); |
347 | 0 | query_tree = proto_item_add_subtree(query_item, ett_xmpp_query); |
348 | |
|
349 | 0 | xmpp_display_attrs(query_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
350 | 0 | xmpp_display_elems(query_tree, element, pinfo, tvb, NULL, 0); |
351 | 0 | } |
352 | | |
353 | | void |
354 | | xmpp_gtalk_mail_mailbox(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
355 | 0 | { |
356 | 0 | proto_item *mail_item; |
357 | 0 | proto_tree *mail_tree; |
358 | |
|
359 | 0 | xmpp_attr_info attrs_info [] = { |
360 | 0 | {"xmlns", &hf_xmpp_xmlns, false, true, NULL, NULL}, |
361 | 0 | {"result-time", NULL, false, true, NULL, NULL}, |
362 | 0 | {"total-matched", NULL, false, true, NULL, NULL}, |
363 | 0 | {"total-estimate", NULL, false, true, NULL, NULL}, |
364 | 0 | {"url", NULL, false, true, NULL, NULL} |
365 | 0 | }; |
366 | |
|
367 | 0 | xmpp_elem_info elems_info [] = { |
368 | 0 | {NAME,"mail-thread-info", xmpp_gtalk_mail_mail_info, MANY} |
369 | 0 | }; |
370 | |
|
371 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "MAILBOX "); |
372 | |
|
373 | 0 | mail_item = proto_tree_add_item(tree, hf_xmpp_gtalk_mail_mailbox, tvb, element->offset, element->length, ENC_BIG_ENDIAN); |
374 | 0 | mail_tree = proto_item_add_subtree(mail_item, ett_xmpp_gtalk_mail_mailbox); |
375 | |
|
376 | 0 | xmpp_display_attrs(mail_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
377 | 0 | xmpp_display_elems(mail_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
378 | 0 | } |
379 | | |
380 | | static void |
381 | | xmpp_gtalk_mail_mail_info(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
382 | 0 | { |
383 | 0 | proto_tree *mail_info_tree; |
384 | |
|
385 | 0 | xmpp_attr_info attrs_info [] = { |
386 | 0 | {"tid", NULL, false, false, NULL, NULL}, |
387 | 0 | {"participation", NULL, false, false, NULL, NULL}, |
388 | 0 | {"messages", NULL, false, true, NULL, NULL}, |
389 | 0 | {"date", NULL, false, true, NULL, NULL}, |
390 | 0 | {"url", NULL, false, false, NULL, NULL}, |
391 | 0 | {"labels", NULL, false, false, NULL, NULL}, |
392 | 0 | {"subject", NULL, false, true, NULL, NULL} |
393 | 0 | }; |
394 | |
|
395 | 0 | xmpp_elem_info elems_info [] = { |
396 | 0 | {NAME, "senders", xmpp_gtalk_mail_senders, ONE}, |
397 | 0 | {NAME, "snippet", xmpp_gtalk_mail_snippet, ONE}/*or MANY?*/ |
398 | 0 | }; |
399 | |
|
400 | 0 | xmpp_element_t *labels, *subject; |
401 | |
|
402 | 0 | mail_info_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_mail_mail_info, NULL, "MAIL-THREAD-INFO"); |
403 | |
|
404 | 0 | if((labels = xmpp_steal_element_by_name(element,"labels"))!=NULL) |
405 | 0 | { |
406 | 0 | xmpp_attr_t *fake_labels = xmpp_ep_init_attr_t(pinfo->pool, labels->data?labels->data->value:"",labels->offset, labels->length); |
407 | 0 | g_hash_table_insert(element->attrs, (void *)"labels", fake_labels); |
408 | 0 | } |
409 | 0 | if((subject = xmpp_steal_element_by_name(element,"subject"))!=NULL) |
410 | 0 | { |
411 | 0 | xmpp_attr_t *fake_subject = xmpp_ep_init_attr_t(pinfo->pool, subject->data?subject->data->value:"",subject->offset, subject->length); |
412 | 0 | g_hash_table_insert(element->attrs, (void *)"subject", fake_subject); |
413 | 0 | } |
414 | |
|
415 | 0 | xmpp_display_attrs(mail_info_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
416 | 0 | xmpp_display_elems(mail_info_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
417 | 0 | } |
418 | | |
419 | | |
420 | | static void |
421 | | xmpp_gtalk_mail_senders(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
422 | 0 | { |
423 | 0 | proto_tree *senders_tree; |
424 | |
|
425 | 0 | xmpp_elem_info elems_info [] = { |
426 | 0 | {NAME, "sender", xmpp_gtalk_mail_sender, MANY} |
427 | 0 | }; |
428 | |
|
429 | 0 | senders_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_mail_senders, NULL, "SENDERS"); |
430 | |
|
431 | 0 | xmpp_display_attrs(senders_tree, element, pinfo, tvb, NULL, 0); |
432 | 0 | xmpp_display_elems(senders_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
433 | 0 | } |
434 | | |
435 | | static void |
436 | | xmpp_gtalk_mail_sender(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
437 | 0 | { |
438 | 0 | proto_tree *sender_tree; |
439 | |
|
440 | 0 | xmpp_attr_info attrs_info [] = { |
441 | 0 | {"name", NULL, false, true, NULL, NULL}, |
442 | 0 | {"address", NULL, false, true, NULL, NULL}, |
443 | 0 | {"originator", NULL, false, true, NULL, NULL}, |
444 | 0 | {"unread", NULL, false, true, NULL, NULL} |
445 | 0 | }; |
446 | |
|
447 | 0 | sender_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_mail_sender, NULL, "SENDER"); |
448 | |
|
449 | 0 | xmpp_display_attrs(sender_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
450 | 0 | xmpp_display_elems(sender_tree, element, pinfo, tvb, NULL, 0); |
451 | 0 | } |
452 | | |
453 | | static void |
454 | | xmpp_gtalk_mail_snippet(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
455 | 0 | { |
456 | 0 | proto_tree_add_string(tree, hf_xmpp_gtalk_mail_snippet, tvb, element->offset, element->length, element->data?element->data->value:""); |
457 | 0 | xmpp_unknown(tree, tvb, pinfo, element); |
458 | 0 | } |
459 | | |
460 | | void |
461 | | xmpp_gtalk_mail_new_mail(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
462 | 0 | { |
463 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "NEW-MAIL "); |
464 | 0 | proto_tree_add_item(tree, hf_xmpp_gtalk_mail_new_mail, tvb, element->offset, element->length, |
465 | 0 | ENC_BIG_ENDIAN); |
466 | 0 | xmpp_unknown(tree, tvb, pinfo, element); |
467 | 0 | } |
468 | | |
469 | | |
470 | | void |
471 | | xmpp_gtalk_status_query(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
472 | 0 | { |
473 | 0 | proto_item *query_item; |
474 | 0 | proto_tree *query_tree; |
475 | |
|
476 | 0 | xmpp_attr_info attrs_info[] = { |
477 | 0 | {"xmlns", &hf_xmpp_xmlns, true, true, NULL, NULL}, |
478 | 0 | {"version", NULL, false, true, NULL, NULL}, |
479 | 0 | {"status-max", NULL, false, false, NULL, NULL}, |
480 | 0 | {"status-list-max", NULL, false, false, NULL, NULL}, |
481 | 0 | {"status-list-contents-max", NULL, false, false, NULL, NULL}, |
482 | 0 | {"status-min-ver", NULL, false, true, NULL, NULL}, |
483 | 0 | {"show", NULL, false, true, NULL, NULL}, |
484 | 0 | {"status", NULL, false, true, NULL, NULL}, |
485 | 0 | {"invisible", NULL, false, true, NULL, NULL}, |
486 | 0 | }; |
487 | |
|
488 | 0 | xmpp_elem_info elems_info [] = { |
489 | 0 | {NAME, "status-list", xmpp_gtalk_status_status_list, MANY} |
490 | 0 | }; |
491 | |
|
492 | 0 | xmpp_element_t *status, *show, *invisible; |
493 | |
|
494 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "QUERY(google:shared-status) "); |
495 | |
|
496 | 0 | query_item = proto_tree_add_item(tree, hf_xmpp_query, tvb, element->offset, element->length, |
497 | 0 | ENC_BIG_ENDIAN); |
498 | 0 | query_tree = proto_item_add_subtree(query_item, ett_xmpp_query); |
499 | |
|
500 | 0 | if((status = xmpp_steal_element_by_name(element,"status"))!=NULL) |
501 | 0 | { |
502 | 0 | xmpp_attr_t *fake_status = xmpp_ep_init_attr_t(pinfo->pool, status->data?status->data->value:"",status->offset, status->length); |
503 | 0 | g_hash_table_insert(element->attrs, (void *)"status", fake_status); |
504 | 0 | } |
505 | |
|
506 | 0 | if((show = xmpp_steal_element_by_name(element,"show"))!=NULL) |
507 | 0 | { |
508 | 0 | xmpp_attr_t *fake_show = xmpp_ep_init_attr_t(pinfo->pool, show->data?show->data->value:"",show->offset, show->length); |
509 | 0 | g_hash_table_insert(element->attrs, (void *)"show", fake_show); |
510 | 0 | } |
511 | |
|
512 | 0 | if((invisible = xmpp_steal_element_by_name(element,"invisible"))!=NULL) |
513 | 0 | { |
514 | 0 | xmpp_attr_t *value = xmpp_get_attr(invisible, "value"); |
515 | 0 | xmpp_attr_t *fake_invisible = xmpp_ep_init_attr_t(pinfo->pool, value?value->value:"",invisible->offset, invisible->length); |
516 | 0 | g_hash_table_insert(element->attrs, (void *)"invisible", fake_invisible); |
517 | 0 | } |
518 | |
|
519 | 0 | xmpp_display_attrs(query_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
520 | 0 | xmpp_display_elems(query_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
521 | 0 | } |
522 | | |
523 | | static void |
524 | | xmpp_gtalk_status_status_list(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
525 | 0 | { |
526 | 0 | proto_tree *list_tree; |
527 | |
|
528 | 0 | xmpp_attr_info attrs_info [] = { |
529 | 0 | {"show", NULL, true, true, NULL, NULL} |
530 | 0 | }; |
531 | |
|
532 | 0 | xmpp_element_t *status; |
533 | |
|
534 | 0 | list_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_status_status_list, NULL, "STATUS LIST"); |
535 | |
|
536 | 0 | while((status = xmpp_steal_element_by_name(element, "status"))!=NULL) |
537 | 0 | { |
538 | 0 | proto_tree_add_string(list_tree, hf_xmpp_gtalk_status_status_list, tvb, status->offset, status->length, status->data?status->data->value:""); |
539 | 0 | } |
540 | |
|
541 | 0 | xmpp_display_attrs(list_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
542 | 0 | xmpp_display_elems(list_tree, element, pinfo, tvb, NULL, 0); |
543 | 0 | } |
544 | | |
545 | | /*http://www.google.com/transport/p2p*/ |
546 | | void |
547 | | xmpp_gtalk_transport_p2p(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) |
548 | 0 | { |
549 | 0 | proto_item *trans_item; |
550 | 0 | proto_tree *trans_tree; |
551 | |
|
552 | 0 | xmpp_attr_info attrs_info[] = { |
553 | 0 | {"xmlns", &hf_xmpp_xmlns, false, true, NULL, NULL} |
554 | 0 | }; |
555 | |
|
556 | 0 | xmpp_elem_info elems_info [] = { |
557 | 0 | {NAME, "candidate", xmpp_gtalk_transport_p2p_cand, MANY} |
558 | 0 | }; |
559 | |
|
560 | 0 | trans_item = proto_tree_add_item(tree, hf_xmpp_gtalk_transport_p2p, tvb, element->offset, element->length, ENC_BIG_ENDIAN); |
561 | 0 | trans_tree = proto_item_add_subtree(trans_item, ett_xmpp_gtalk_transport_p2p); |
562 | |
|
563 | 0 | xmpp_display_attrs(trans_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
564 | |
|
565 | 0 | xmpp_display_elems(trans_tree, element, pinfo, tvb, elems_info, array_length(elems_info)); |
566 | 0 | } |
567 | | |
568 | | static void |
569 | 0 | xmpp_gtalk_transport_p2p_cand(proto_tree* tree, tvbuff_t* tvb, packet_info* pinfo, xmpp_element_t* element) { |
570 | 0 | proto_tree *cand_tree; |
571 | |
|
572 | 0 | xmpp_attr_info attrs_info[] = { |
573 | 0 | {"xmlns", &hf_xmpp_xmlns, false, false, NULL, NULL}, |
574 | 0 | {"name", NULL, false, true, NULL, NULL}, |
575 | 0 | {"generation", NULL, false, false, NULL, NULL}, |
576 | 0 | {"network", NULL, false, false, NULL, NULL}, |
577 | 0 | {"component", NULL, false, false, NULL, NULL}, |
578 | 0 | {"type", NULL, false, false, NULL, NULL}, |
579 | 0 | {"protocol", NULL, false, true, NULL, NULL}, |
580 | 0 | {"preference", NULL, false, false, NULL, NULL}, |
581 | 0 | {"password", NULL, false, false, NULL, NULL}, |
582 | 0 | {"username", NULL, false, false, NULL, NULL}, |
583 | 0 | {"port", NULL, false, true, NULL, NULL}, |
584 | 0 | {"address", NULL, false, true, NULL, NULL} |
585 | 0 | }; |
586 | |
|
587 | 0 | cand_tree = proto_tree_add_subtree(tree, tvb, element->offset, element->length, ett_xmpp_gtalk_transport_p2p_cand, NULL, "CANDIDATE"); |
588 | |
|
589 | 0 | xmpp_display_attrs(cand_tree, element, pinfo, tvb, attrs_info, array_length(attrs_info)); |
590 | 0 | xmpp_display_elems(cand_tree, element, pinfo, tvb, NULL, 0); |
591 | |
|
592 | 0 | } |
593 | | /* |
594 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
595 | | * |
596 | | * Local variables: |
597 | | * c-basic-offset: 4 |
598 | | * tab-width: 8 |
599 | | * indent-tabs-mode: nil |
600 | | * End: |
601 | | * |
602 | | * ex: set shiftwidth=4 tabstop=8 expandtab: |
603 | | * :indentSize=4:tabSize=8:noTabs=true: |
604 | | */ |