2 * Reliable Multicast Transport (RMT)
4 * Copyright 2005, Stefano Pettini <spettini@users.sourceforge.net>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
37 #include <epan/packet.h>
38 #include <epan/strutil.h>
40 #include "packet-rmt-common.h"
42 /* Boolean string tables */
43 const true_false_string boolean_set_notset = { "Set", "Not set" };
44 const true_false_string boolean_yes_no = { "Yes", "No" };
46 /* Common RMT exported functions */
47 /* ============================= */
49 /* Scan the tvb and put extensions found in an array */
50 void rmt_ext_parse(GArray *a, tvbuff_t *tvb, guint *offset, guint offset_max)
54 while (*offset < offset_max)
56 /* Clear the temporary extension */
57 memset(&e, 0, sizeof(struct _ext));
59 /* Dissect the extension */
61 e.het = tvb_get_guint8(tvb, *offset);
64 /* If HET <= 127, we have a variable-size extention */
65 e.hel = tvb_get_guint8(tvb, *offset+1);
66 e.hec_offset = *offset + 2;
67 e.hec_size = e.hel * 4 - 2;
70 /* If HET > 127, we have a short 32-bit extention */
71 e.hel = 1; /* even if HEL field is not defined for HET > 127 */
72 e.hec_offset = *offset + 1;
77 /* Prevents infinite loops */
81 g_array_append_val(a, e);
86 /* Add default items to a subtree */
87 void rmt_ext_decode_default_header(struct _ext *e, tvbuff_t *tvb, proto_tree *tree)
91 proto_tree_add_text(tree, tvb, e->offset, 1, "Header Extension Type (HET): %u", e->het);
93 proto_tree_add_text(tree, tvb, e->offset+1, 1, "Header Extension Length (HEL): %u", e->hel);
97 /* Add a default subtree to a tree item */
98 void rmt_ext_decode_default_subtree(struct _ext *e, tvbuff_t *tvb, proto_item *ti, gint ett)
100 proto_tree *ext_tree;
102 ext_tree = proto_item_add_subtree(ti, ett);
103 rmt_ext_decode_default_header(e, tvb, ext_tree);
106 proto_tree_add_text(ext_tree, tvb, e->hec_offset, e->hec_size,
107 "Header Extension Content (HEC): %s", tvb_bytes_to_str(tvb, e->hec_offset, e->hec_size));
110 /* Add a default subtree for unknown extensions */
111 void rmt_ext_decode_default(struct _ext *e, tvbuff_t *tvb, proto_tree *tree, gint ett)
117 ti = proto_tree_add_text(tree, tvb, e->offset, e->length,
118 "Unknown extension (%u)", e->het);
120 rmt_ext_decode_default_subtree(e, tvb, ti, ett);