2 * Reliable Multicast Transport (RMT)
4 * Copyright 2005, Stefano Pettini <spettini@users.sourceforge.net>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
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.
36 #include <epan/packet.h>
37 #include <epan/strutil.h>
39 #include "packet-rmt-common.h"
41 /* Common RMT exported functions */
42 /* ============================= */
44 /* Scan the tvb and put extensions found in an array */
45 void rmt_ext_parse(GArray *a, tvbuff_t *tvb, guint *offset, guint offset_max)
49 while (*offset < offset_max)
51 /* Clear the temporary extension */
52 memset(&e, 0, sizeof(struct _ext));
54 /* Dissect the extension */
56 e.het = tvb_get_guint8(tvb, *offset);
59 /* If HET <= 127, we have a variable-size extension */
60 e.hel = tvb_get_guint8(tvb, *offset+1);
61 e.hec_offset = *offset + 2;
62 e.hec_size = e.hel * 4 - 2;
65 /* If HET > 127, we have a short 32-bit extension */
66 e.hel = 1; /* even if HEL field is not defined for HET > 127 */
67 e.hec_offset = *offset + 1;
72 /* Prevents infinite loops */
76 g_array_append_val(a, e);
81 /* Add default items to a subtree */
82 void rmt_ext_decode_default_header(struct _ext *e, tvbuff_t *tvb, proto_tree *tree)
86 proto_tree_add_text(tree, tvb, e->offset, 1, "Header Extension Type (HET): %u", e->het);
88 proto_tree_add_text(tree, tvb, e->offset+1, 1, "Header Extension Length (HEL): %u", e->hel);
92 /* Add a default subtree to a tree item */
93 void rmt_ext_decode_default_subtree(struct _ext *e, tvbuff_t *tvb, proto_item *ti, gint ett)
97 ext_tree = proto_item_add_subtree(ti, ett);
98 rmt_ext_decode_default_header(e, tvb, ext_tree);
101 proto_tree_add_text(ext_tree, tvb, e->hec_offset, e->hec_size,
102 "Header Extension Content (HEC): %s", tvb_bytes_to_str(tvb, e->hec_offset, e->hec_size));
105 /* Add a default subtree for unknown extensions */
106 void rmt_ext_decode_default(struct _ext *e, tvbuff_t *tvb, proto_tree *tree, gint ett)
112 ti = proto_tree_add_text(tree, tvb, e->offset, e->length,
113 "Unknown extension (%u)", e->het);
115 rmt_ext_decode_default_subtree(e, tvb, ti, ett);