diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-11-17 20:57:14 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-11-17 20:57:14 +0000 |
commit | 33629cc80105384f0e703115fcde5d5d950de131 (patch) | |
tree | 3f3a8f5cafd4a6b5d2e140ee9692a9ac5ea54a40 /plugins/rdm/packet-rdm.c | |
parent | dc69087b0cabf9c55d2528c319f633ca2dd9bab2 (diff) |
From Erwin Rol: initial ENTTEC support and RDM support.
svn path=/trunk/; revision=8985
Diffstat (limited to 'plugins/rdm/packet-rdm.c')
-rw-r--r-- | plugins/rdm/packet-rdm.c | 271 |
1 files changed, 271 insertions, 0 deletions
diff --git a/plugins/rdm/packet-rdm.c b/plugins/rdm/packet-rdm.c new file mode 100644 index 0000000000..914e8a6968 --- /dev/null +++ b/plugins/rdm/packet-rdm.c @@ -0,0 +1,271 @@ +/* packet-rdm.c + * Routines for RDM packet disassembly + * + * $Id: packet-rdm.c,v 1.1 2003/11/17 20:57:14 guy Exp $ + * + * Copyright (c) 2003 by Erwin Rol <erwin@erwinrol.com> + * + * Ethereal - Network traffic analyzer + * By Gerald Combs <gerald@ethereal.com> + * Copyright 1999 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* Include files */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "plugins/plugin_api.h" + +#include "moduleinfo.h" + +#include <stdio.h> +#include <stdlib.h> +#include <gmodule.h> +#include <ctype.h> +#include <time.h> +#include <string.h> +#include <epan/packet.h> +#include <epan/resolv.h> +#include "etypes.h" +#include <epan/strutil.h> + +#include "plugins/plugin_api_defs.h" + +/* Define version if we are not building ethereal statically */ + +#ifndef ENABLE_STATIC +G_MODULE_EXPORT const gchar version[] = VERSION; +#endif + +/* + * See http://www.esta.org/tsp/E1-20inst.htm + * + */ + +void proto_reg_handoff_rdm(void); + +/* Define the rdm proto */ +static int proto_rdm = -1; + +/* Header */ +static int hf_rdm_sub_start_code = -1; +static int hf_rdm_slot_count = -1; +static int hf_rdm_dest_uid = -1; +static int hf_rdm_src_uid = -1; +static int hf_rdm_seq_nr = -1; +static int hf_rdm_res_type = -1; +static int hf_rdm_msg_count = -1; +static int hf_rdm_sub_device = -1; +static int hf_rdm_mdb = -1; +static int hf_rdm_checksum = -1; + +/* Define the tree for rdm */ +static int ett_rdm = -1; + +static void +dissect_rdm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { + gint offset = 0; + gint mdb_size; + proto_tree *ti=NULL,*rdm_tree=NULL; + + /* Set the protocol column */ + if(check_col(pinfo->cinfo,COL_PROTOCOL)){ + col_set_str(pinfo->cinfo,COL_PROTOCOL,"RDM"); + } + + /* Clear out stuff in the info column */ + if(check_col(pinfo->cinfo,COL_INFO)){ + col_clear(pinfo->cinfo,COL_INFO); + } + + if (tree) { + ti = proto_tree_add_item(tree, proto_rdm, tvb, offset, -1, FALSE); + rdm_tree = proto_item_add_subtree(ti, ett_rdm); + } + + if (check_col(pinfo->cinfo, COL_INFO)) { + col_append_fstr(pinfo->cinfo, COL_INFO, "%s", + "RDM"); + } + + if (tree) + { + proto_tree_add_item(rdm_tree, hf_rdm_sub_start_code, tvb, + offset, 1, FALSE); + offset += 1; + + mdb_size = tvb_get_guint8(tvb, offset) - 19; + proto_tree_add_item(rdm_tree, hf_rdm_slot_count, tvb, + offset, 1, FALSE); + offset += 1; + + proto_tree_add_item(rdm_tree, hf_rdm_dest_uid, tvb, + offset, 6, FALSE); + offset += 6; + + proto_tree_add_item(rdm_tree, hf_rdm_src_uid, tvb, + offset, 6, FALSE); + offset += 6; + + proto_tree_add_item(rdm_tree, hf_rdm_seq_nr, tvb, + offset, 1, FALSE); + offset += 1; + + proto_tree_add_item(rdm_tree, hf_rdm_res_type, tvb, + offset, 1, FALSE); + offset += 1; + + proto_tree_add_item(rdm_tree, hf_rdm_msg_count, tvb, + offset, 1, FALSE); + offset += 1; + + proto_tree_add_item(rdm_tree, hf_rdm_sub_device, tvb, + offset, 1, FALSE); + offset += 1; + + proto_tree_add_item(rdm_tree, hf_rdm_mdb, tvb, + offset, mdb_size, FALSE); + offset += mdb_size; + + proto_tree_add_item(rdm_tree, hf_rdm_checksum, tvb, + offset, 2, FALSE); + offset += 2; + } +} + +void +proto_register_rdm(void) { + static hf_register_info hf[] = { + { &hf_rdm_sub_start_code, + { "Sub Start Code", + "rdm.sub_start_code", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Sub Start Code", HFILL }}, + + { &hf_rdm_slot_count, + { "Slot Count", + "rdm.slot_count", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Slot Count", HFILL }}, + + { &hf_rdm_dest_uid, + { "Dest. UID", + "rdm.dest_uid", + FT_BYTES, BASE_HEX, NULL, 0x0, + "Dest. UID", HFILL }}, + + { &hf_rdm_src_uid, + { "Source UID", + "rdm.src_uid", + FT_BYTES, BASE_HEX, NULL, 0x0, + "Source UID", HFILL }}, + + { &hf_rdm_seq_nr, + { "Sequence Number", + "rdm.seq_nr", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Sequence Number", HFILL }}, + + { &hf_rdm_res_type, + { "Response Type", + "rdm.res_type", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Response Type", HFILL }}, + + { &hf_rdm_msg_count, + { "Message Count", + "rdm.msg_count", + FT_UINT8, BASE_DEC, NULL, 0x0, + "Message Count", HFILL }}, + + { &hf_rdm_sub_device, + { "Sub Device", + "rdm.sub_device", + FT_UINT8, BASE_HEX, NULL, 0x0, + "Sub Device", HFILL }}, + + { &hf_rdm_mdb, + { "MDB", + "rdm.mdb", + FT_BYTES, BASE_HEX, NULL, 0x0, + "MDB", HFILL }}, + + { &hf_rdm_checksum, + { "Checksum", + "rdm.checksum", + FT_UINT16, BASE_HEX, NULL, 0x0, + "Checksum", HFILL }} + }; + + static gint *ett[] = { + &ett_rdm, + }; + + proto_rdm = proto_register_protocol("RDM","RDM","rdm"); + + proto_register_field_array(proto_rdm,hf,array_length(hf)); + proto_register_subtree_array(ett,array_length(ett)); + + register_dissector("rdm", dissect_rdm, proto_rdm); +} + +/* The registration hand-off routing */ + +void +proto_reg_handoff_rdm(void) { + static int rdm_initialized = FALSE; + static dissector_handle_t rdm_handle; + + if(!rdm_initialized) { + rdm_handle = create_dissector_handle(dissect_rdm,proto_rdm); + rdm_initialized = TRUE; + } else { + dissector_delete("udp.port",0,rdm_handle); + } + + dissector_add("udp.port",0,rdm_handle); +} + +/* Start the functions we need for the plugin stuff */ + +#ifndef ENABLE_STATIC + +G_MODULE_EXPORT void +plugin_reg_handoff(void){ + proto_reg_handoff_rdm(); +} + +G_MODULE_EXPORT void +plugin_init(plugin_address_table_t *pat +#ifndef PLUGINS_NEED_ADDRESS_TABLE +_U_ +#endif +){ + /* initialise the table of pointers needed in Win32 DLLs */ + plugin_address_table_init(pat); + /* register the new protocol, protocol fields, and subtrees */ + if (proto_rdm == -1) { /* execute protocol initialization only once */ + proto_register_rdm(); + } +} + +#endif + +/* End the functions we need for plugin stuff */ + |