2 * Wireshark's XMPP dissector.
4 * XEP-0298: Delivering Conference Information to Jingle Participants (Coin)
6 * Copyright 2011, Mariusz Okroj <okrojmariusz[]gmail.com>
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 #include <epan/packet.h>
35 #include <epan/dissectors/packet-xml.h>
37 #include <packet-xmpp.h>
38 #include <packet-xmpp-utils.h>
39 #include <packet-xmpp-conference.h>
42 static void xmpp_conf_desc(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
43 static void xmpp_conf_state(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
44 static void xmpp_conf_users(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
45 static void xmpp_conf_user(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
46 static void xmpp_conf_endpoint(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
47 static void xmpp_conf_media(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
);
50 xmpp_conferece_info_advert(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
52 proto_item
*cinfo_item
;
53 proto_tree
*cinfo_tree
;
55 xmpp_attr_info attrs_info
[] = {
56 {"xmlns", hf_xmpp_xmlns
, TRUE
, TRUE
, NULL
, NULL
},
57 {"isfocus", -1, TRUE
, TRUE
, NULL
, NULL
}
60 cinfo_item
= proto_tree_add_item(tree
, hf_xmpp_conf_info
, tvb
, element
->offset
, element
->length
,
62 cinfo_tree
= proto_item_add_subtree(cinfo_item
, ett_xmpp_conf_info
);
64 xmpp_display_attrs(cinfo_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
65 xmpp_display_elems(cinfo_tree
, element
, pinfo
, tvb
, NULL
, 0);
69 xmpp_conference_info(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
71 proto_item
*cinfo_item
;
72 proto_tree
*cinfo_tree
;
74 static const gchar
*state_enums
[] = {"full", "partial", "deleted"};
75 xmpp_array_t
*state_array
= xmpp_ep_init_array_t(state_enums
, array_length(state_enums
));
77 xmpp_attr_info attrs_info
[] = {
78 {"xmlns", hf_xmpp_xmlns
, TRUE
, TRUE
, NULL
, NULL
},
79 {"entity", -1, TRUE
, TRUE
, NULL
, NULL
},
80 {"state", -1, FALSE
, TRUE
, xmpp_val_enum_list
, state_array
},
81 {"version", -1, FALSE
, TRUE
, NULL
, NULL
},
82 {"sid", hf_xmpp_conf_info_sid
, FALSE
, TRUE
, NULL
, NULL
}
85 xmpp_elem_info elems_info
[] = {
86 {NAME
, "conference-description", xmpp_conf_desc
, ONE
},
87 {NAME
, "conference-state", xmpp_conf_state
, ONE
},
88 /*{NAME, "host-info", xmpp_conf_host_info, ONE},*/
89 {NAME
, "users", xmpp_conf_users
, ONE
},
90 /*{NAME, "sidebars-by-ref", xmpp_conf_sidebars_by_ref, ONE},*/
91 /*{NAME, "sidebars-by-val", xmpp_conf_sidebars_by_val, ONE},*/
94 col_append_str(pinfo
->cinfo
, COL_INFO
, "CONFERENC-INFO ");
96 cinfo_item
= proto_tree_add_item(tree
, hf_xmpp_conf_info
, tvb
, element
->offset
, element
->length
,
98 cinfo_tree
= proto_item_add_subtree(cinfo_item
, ett_xmpp_conf_info
);
100 xmpp_display_attrs(cinfo_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
101 xmpp_display_elems(cinfo_tree
, element
, pinfo
, tvb
, elems_info
, array_length(elems_info
));
105 xmpp_conf_desc(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
107 proto_item
*desc_item
;
108 proto_tree
*desc_tree
;
110 xmpp_attr_info attrs_info
[] = {
111 {"subject", -1, FALSE
, TRUE
, NULL
, NULL
},
112 {"display-text", -1, FALSE
, FALSE
, NULL
, NULL
},
113 {"free-text", -1, FALSE
, FALSE
, NULL
, NULL
},
114 {"max-user-count", -1, FALSE
, FALSE
, NULL
, NULL
},
118 xmpp_elem_info elems_info [] = {
119 {NAME, "keywords", xmpp_conf_desc_keywords, ONE},
120 {NAME, "conf-uris", xmpp_conf_desc_conf_uris, ONE},
121 {NAME, "service-uris", xmpp_conf_desc_serv_uris, ONE},
122 {NAME, "available-media", xmpp_conf_desc_avil_media, ONE},
126 desc_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "CONFERENCE DESCRIPTION");
127 desc_tree
= proto_item_add_subtree(desc_item
, ett_xmpp_conf_desc
);
129 xmpp_change_elem_to_attrib("subject", "subject", element
, xmpp_transform_func_cdata
);
130 xmpp_change_elem_to_attrib("display-text", "display-text", element
, xmpp_transform_func_cdata
);
131 xmpp_change_elem_to_attrib("free-text", "free-text", element
, xmpp_transform_func_cdata
);
132 xmpp_change_elem_to_attrib("maximum-user-count", "max-user-count", element
, xmpp_transform_func_cdata
);
134 xmpp_display_attrs(desc_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
135 xmpp_display_elems(desc_tree
, element
, pinfo
, tvb
, NULL
,0);
139 xmpp_conf_state(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
141 proto_item
*state_item
;
142 proto_tree
*state_tree
;
144 xmpp_attr_info attrs_info
[] = {
145 {"user-count", -1, FALSE
, TRUE
, NULL
, NULL
},
146 {"active", -1, FALSE
, TRUE
, NULL
, NULL
},
147 {"locked", -1, FALSE
, TRUE
, NULL
, NULL
}
150 state_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "CONFERENCE STATE");
151 state_tree
= proto_item_add_subtree(state_item
, ett_xmpp_conf_state
);
153 xmpp_change_elem_to_attrib("user-count", "user-count", element
, xmpp_transform_func_cdata
);
154 xmpp_change_elem_to_attrib("active", "active", element
, xmpp_transform_func_cdata
);
155 xmpp_change_elem_to_attrib("locked", "locked", element
, xmpp_transform_func_cdata
);
157 xmpp_display_attrs(state_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
158 xmpp_display_elems(state_tree
, element
, pinfo
, tvb
, NULL
,0);
163 xmpp_conf_users(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
165 proto_item
*users_item
;
166 proto_tree
*users_tree
;
168 xmpp_attr_info attrs_info
[] = {
169 {"state", -1, FALSE
, TRUE
, NULL
, NULL
}
172 xmpp_elem_info elems_info
[] = {
173 {NAME
, "user", xmpp_conf_user
, MANY
}
176 users_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "USERS");
177 users_tree
= proto_item_add_subtree(users_item
, ett_xmpp_conf_users
);
179 xmpp_display_attrs(users_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
180 xmpp_display_elems(users_tree
, element
, pinfo
, tvb
, elems_info
, array_length(elems_info
));
183 xmpp_conf_user(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
185 proto_item
*user_item
;
186 proto_tree
*user_tree
;
188 xmpp_attr_info attrs_info
[] = {
189 {"entity", -1, FALSE
, TRUE
, NULL
, NULL
},
190 {"state", -1, FALSE
, TRUE
, NULL
, NULL
},
191 {"display-text", -1, FALSE
, TRUE
, NULL
, NULL
},
192 {"cascaded-focus", -1, FALSE
, TRUE
, NULL
, NULL
}
195 xmpp_elem_info elems_info
[] = {
196 /*{NAME, "associated-aors", xmpp_conf_assoc_aors, ONE},*/
197 /*{NAME, "roles", xmpp_conf_roles, ONE},*/
198 /*{NAME, "languages", xmpp_conf_langs, ONE},*/
199 {NAME
, "endpoint", xmpp_conf_endpoint
, MANY
},
202 user_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "USERS");
203 user_tree
= proto_item_add_subtree(user_item
, ett_xmpp_conf_user
);
205 xmpp_change_elem_to_attrib("display-text", "display-text", element
, xmpp_transform_func_cdata
);
206 xmpp_change_elem_to_attrib("cascaded-focus", "cascaded-focus", element
, xmpp_transform_func_cdata
);
208 xmpp_display_attrs(user_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
209 xmpp_display_elems(user_tree
, element
, pinfo
, tvb
, elems_info
, array_length(elems_info
));
213 xmpp_conf_endpoint(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
215 proto_item
*endpoint_item
;
216 proto_tree
*endpoint_tree
;
218 xmpp_attr_info attrs_info
[] = {
219 {"entity", -1, FALSE
, TRUE
, NULL
, NULL
},
220 {"state", -1, FALSE
, TRUE
, NULL
, NULL
},
221 {"display-text", -1, FALSE
, TRUE
, NULL
, NULL
},
222 {"status", -1, FALSE
, TRUE
, NULL
, NULL
},
223 {"joining-method", -1, FALSE
, TRUE
, NULL
, NULL
},
224 {"disconnection-method", -1, FALSE
, TRUE
, NULL
, NULL
},
227 xmpp_elem_info elems_info
[] = {
228 /*{NAME,"referred",...,ONE},*/
229 /*{NAME,"joining-info",...,ONE},*/
230 /*{NAME,"disconnection-info",...,ONE},*/
231 {NAME
,"media", xmpp_conf_media
, ONE
},
232 /*{NAME,"call-info",...,ONE},*/
236 endpoint_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "ENDPOINT");
237 endpoint_tree
= proto_item_add_subtree(endpoint_item
, ett_xmpp_conf_endpoint
);
239 xmpp_change_elem_to_attrib("display-text", "display-text", element
, xmpp_transform_func_cdata
);
240 xmpp_change_elem_to_attrib("status", "status", element
, xmpp_transform_func_cdata
);
241 xmpp_change_elem_to_attrib("joining-method", "joining-method", element
, xmpp_transform_func_cdata
);
242 xmpp_change_elem_to_attrib("disconnection-method", "disconnection-method", element
, xmpp_transform_func_cdata
);
245 xmpp_display_attrs(endpoint_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
246 xmpp_display_elems(endpoint_tree
, element
, pinfo
, tvb
, elems_info
, array_length(elems_info
));
250 xmpp_conf_media(proto_tree
*tree
, tvbuff_t
*tvb
, packet_info
*pinfo
, xmpp_element_t
*element
)
252 proto_item
*media_item
;
253 proto_tree
*media_tree
;
255 xmpp_attr_info attrs_info
[] = {
256 {"id", -1, TRUE
, TRUE
, NULL
, NULL
},
257 {"display-text", -1, FALSE
, TRUE
, NULL
, NULL
},
258 {"type", -1, FALSE
, TRUE
, NULL
, NULL
},
259 {"label", -1, FALSE
, TRUE
, NULL
, NULL
},
260 {"src-id", -1, FALSE
, TRUE
, NULL
, NULL
},
261 {"status", -1, FALSE
, TRUE
, NULL
, NULL
},
264 media_item
= proto_tree_add_text(tree
, tvb
, element
->offset
, element
->length
, "MEDIA");
265 media_tree
= proto_item_add_subtree(media_item
, ett_xmpp_conf_media
);
267 xmpp_change_elem_to_attrib("display-text", "display-text", element
, xmpp_transform_func_cdata
);
268 xmpp_change_elem_to_attrib("type", "type", element
, xmpp_transform_func_cdata
);
269 xmpp_change_elem_to_attrib("label", "label", element
, xmpp_transform_func_cdata
);
270 xmpp_change_elem_to_attrib("src-id", "src-id", element
, xmpp_transform_func_cdata
);
271 xmpp_change_elem_to_attrib("status", "status", element
, xmpp_transform_func_cdata
);
273 xmpp_display_attrs(media_tree
, element
, pinfo
, tvb
, attrs_info
, array_length(attrs_info
));
274 xmpp_display_elems(media_tree
, element
, pinfo
, tvb
, NULL
, 0);
277 * Editor modelines - http://www.wireshark.org/tools/modelines.html
282 * indent-tabs-mode: nil
285 * ex: set shiftwidth=4 tabstop=8 expandtab:
286 * :indentSize=4:tabSize=8:noTabs=true: