1 /* packet-mesh-header.c
2 * Routines for Mesh Header dissection
3 * Javier Cardona <javier@cozybit.com>
4 * Copyright 2007, Marvell Semiconductors Inc.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 #include <epan/packet.h>
37 /* Initialize the protocol and registered fields */
38 static int proto_mesh = -1;
39 static int hf_mesh_ttl = -1;
40 static int hf_mesh_e2eseq = -1;
42 /* Initialize the subtree pointers */
43 static gint ett_mesh = -1;
45 /* Code to actually dissect the packets */
47 dissect_mesh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
49 /* Set up structures needed to add the protocol subtree and manage it */
51 proto_tree *mesh_tree;
55 /* Make entries in Protocol column and Info column on summary display */
56 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Mesh");
59 ti = proto_tree_add_item(tree, proto_mesh, tvb, 0, 5, FALSE);
60 mesh_tree = proto_item_add_subtree(ti, ett_mesh);
62 /* add an item to the subtree, see section 1.6 for more information */
63 mesh_ttl = tvb_get_guint8(tvb, 2);
64 proto_tree_add_uint(mesh_tree, hf_mesh_ttl, tvb, 2, 1, mesh_ttl);
66 mesh_e2eseq = tvb_get_ntohs(tvb, 3);
67 proto_tree_add_uint(mesh_tree, hf_mesh_e2eseq, tvb, 3, 2, mesh_e2eseq);
70 /* Return the amount of data this dissector was able to dissect */
75 /* Register the protocol with Wireshark */
77 /* this format is require because a script is used to build the C function
78 that calls all the protocol registration.
82 proto_register_mesh(void)
84 /* Setup list of header fields See Section 1.6.1 for details*/
85 static hf_register_info hf[] = {
87 { "Mesh TTL", "mesh.ttl", FT_UINT8, BASE_DEC,
88 NULL, 0x0, NULL, HFILL }},
91 { "Mesh End-to-end Seq", "mesh.e2eseq", FT_UINT16, BASE_HEX,
92 NULL, 0x0, NULL, HFILL }},
95 /* Setup protocol subtree array */
96 static gint *ett[] = {
100 /* Register the protocol name and description */
101 proto_mesh = proto_register_protocol("Mesh Header", "Mesh", "mesh");
103 /* Required function calls to register the header fields and subtrees used */
104 proto_register_field_array(proto_mesh, hf, array_length(hf));
105 proto_register_subtree_array(ett, array_length(ett));
107 new_register_dissector("mesh", dissect_mesh, proto_mesh);