diff options
author | Guy Harris <guy@alum.mit.edu> | 2009-05-02 21:51:51 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2009-05-02 21:51:51 +0000 |
commit | 359381545502871e573fa7e08ae46e7bea50bd52 (patch) | |
tree | 1cd96ed8d6c1055262ff4dc8b4a1a63c85b0be38 /epan/dissectors | |
parent | 3b23d3dbd524b67438efcdd5a1122988c8adf6d2 (diff) |
Add the mesh header dissector for OLPC mesh network packets, and have
the LLC dissector recognize and handle those packets.
svn path=/trunk/; revision=28253
Diffstat (limited to 'epan/dissectors')
-rw-r--r-- | epan/dissectors/Makefile.common | 1 | ||||
-rw-r--r-- | epan/dissectors/packet-llc.c | 45 | ||||
-rw-r--r-- | epan/dissectors/packet-mesh.c | 114 |
3 files changed, 160 insertions, 0 deletions
diff --git a/epan/dissectors/Makefile.common b/epan/dissectors/Makefile.common index def6cb32f4..da74226ba4 100644 --- a/epan/dissectors/Makefile.common +++ b/epan/dissectors/Makefile.common @@ -603,6 +603,7 @@ DISSECTOR_SRC = \ packet-media.c \ packet-megaco.c \ packet-memcache.c \ + packet-mesh.c \ packet-mgcp.c \ packet-mikey.c \ packet-miop.c \ diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c index 9eb6fadc65..2d6eb508ce 100644 --- a/epan/dissectors/packet-llc.c +++ b/epan/dissectors/packet-llc.c @@ -87,12 +87,15 @@ static gint ett_llc_basicxid = -1; static dissector_table_t subdissector_table; static dissector_table_t xid_subdissector_table; +static dissector_table_t ethertype_subdissector_table; + static dissector_handle_t bpdu_handle; static dissector_handle_t eth_withoutfcs_handle; static dissector_handle_t eth_withfcs_handle; static dissector_handle_t fddi_handle; static dissector_handle_t tr_handle; static dissector_handle_t turbo_handle; +static dissector_handle_t mesh_handle; static dissector_handle_t data_handle; /* @@ -371,6 +374,16 @@ capture_snap(const guchar *pd, int offset, int len, packet_counts *ld) capture_ethertype(etype, pd, offset+5, len, ld); break; + case OUI_MARVELL: + /* + * OLPC packet. The PID is an Ethertype, but + * there's a mesh header between the PID and + * the payload. (We assume the header is + * 5 bytes, for now). + */ + capture_ethertype(etype, pd, offset+5+5, len, ld); + break; + default: ld->other++; break; @@ -582,6 +595,7 @@ dissect_snap(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, oui_info_t *oui_info; dissector_table_t subdissector_table; int hf; + int mesh_header_len; /* * XXX - what about non-UI frames? @@ -696,6 +710,31 @@ dissect_snap(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, call_dissector(turbo_handle, next_tvb, pinfo, tree); break; + case OUI_MARVELL: + /* + * OLPC packet. The PID is an Ethertype, but + * there's a mesh header between the PID and + * the payload. + */ + if (XDLC_IS_INFORMATION(control)) { + if (tree) { + proto_tree_add_uint(snap_tree, hf_llc_type, + tvb, offset+3, 2, etype); + } + next_tvb = tvb_new_subset(tvb, offset+5, -1, -1); + mesh_header_len = call_dissector(mesh_handle, + next_tvb, pinfo, tree); + next_tvb = tvb_new_subset(tvb, offset+5+mesh_header_len, + -1, -1); + if (!dissector_try_port(ethertype_subdissector_table, + etype, next_tvb, pinfo, tree)) + call_dissector(data_handle,next_tvb, pinfo, tree); + } else { + next_tvb = tvb_new_subset(tvb, offset+5, -1, -1); + call_dissector(data_handle,next_tvb, pinfo, tree); + } + break; + default: /* * Do we have information for this OUI? @@ -891,8 +930,14 @@ proto_reg_handoff_llc(void) fddi_handle = find_dissector("fddi"); tr_handle = find_dissector("tr"); turbo_handle = find_dissector("turbocell"); + mesh_handle = find_dissector("mesh"); data_handle = find_dissector("data"); + /* + * Get the Ethertype dissector table. + */ + ethertype_subdissector_table = find_dissector_table("ethertype"); + llc_handle = find_dissector("llc"); dissector_add("wtap_encap", WTAP_ENCAP_ATM_RFC1483, llc_handle); /* RFC 2043 */ diff --git a/epan/dissectors/packet-mesh.c b/epan/dissectors/packet-mesh.c new file mode 100644 index 0000000000..d88ca84771 --- /dev/null +++ b/epan/dissectors/packet-mesh.c @@ -0,0 +1,114 @@ +/* packet-mesh-header.c + * Routines for Mesh Header dissection + * Javier Cardona <javier@cozybit.com> + * Copyright 2007, Marvell Semiconductors Inc. + * + * $Id$ + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <glib.h> + +#include <epan/packet.h> + +/* Forward declaration we need below */ +void proto_reg_handoff_mesh(void); + +/* Initialize the protocol and registered fields */ +static int proto_mesh = -1; +static int hf_mesh_ttl = -1; +static int hf_mesh_e2eseq = -1; + +/* Initialize the subtree pointers */ +static gint ett_mesh = -1; + +/* Code to actually dissect the packets */ +static int +dissect_mesh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) +{ + /* Set up structures needed to add the protocol subtree and manage it */ + proto_item *ti; + proto_tree *mesh_tree; + guint8 mesh_ttl; + guint16 mesh_e2eseq; + + /* Make entries in Protocol column and Info column on summary display */ + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_set_str(pinfo->cinfo, COL_PROTOCOL, "Mesh"); + + if (tree) { + ti = proto_tree_add_item(tree, proto_mesh, tvb, 0, 5, FALSE); + mesh_tree = proto_item_add_subtree(ti, ett_mesh); + + /* add an item to the subtree, see section 1.6 for more information */ + mesh_ttl = tvb_get_guint8(tvb, 2); + proto_tree_add_uint(mesh_tree, hf_mesh_ttl, tvb, 2, 1, mesh_ttl); + + mesh_e2eseq = tvb_get_ntohs(tvb, 3); + proto_tree_add_uint(mesh_tree, hf_mesh_e2eseq, tvb, 3, 2, mesh_e2eseq); + } + + /* Return the amount of data this dissector was able to dissect */ + return 5; +} + + +/* Register the protocol with Wireshark */ + +/* this format is require because a script is used to build the C function + that calls all the protocol registration. +*/ + +void +proto_register_mesh(void) +{ + /* Setup list of header fields See Section 1.6.1 for details*/ + static hf_register_info hf[] = { + { &hf_mesh_ttl, + { "Mesh TTL", "mesh.ttl", FT_UINT8, BASE_DEC, + NULL, 0x0, "", HFILL }}, + + { &hf_mesh_e2eseq, + { "Mesh End-to-end Seq", "mesh.e2eseq", FT_UINT16, BASE_HEX, + NULL, 0x0, "", HFILL }}, + }; + + /* Setup protocol subtree array */ + static gint *ett[] = { + &ett_mesh + }; + + /* Register the protocol name and description */ + proto_mesh = proto_register_protocol("Mesh Header", "Mesh", "mesh"); + + /* Required function calls to register the header fields and subtrees used */ + proto_register_field_array(proto_mesh, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); + + new_register_dissector("mesh", dissect_mesh, proto_mesh); +} |