2 * Routines for ENTTEC packet disassembly
6 * Copyright (c) 2003 by Erwin Rol <erwin@erwinrol.com>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
10 * Copyright 1999 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.
33 #include "plugins/plugin_api.h"
35 #include "moduleinfo.h"
43 #include <epan/packet.h>
44 #include <epan/addr_resolv.h>
45 #include <epan/prefs.h>
46 #include <epan/strutil.h>
48 #include "plugins/plugin_api_defs.h"
50 /* Define version if we are not building ethereal statically */
53 G_MODULE_EXPORT const gchar version[] = VERSION;
59 * http://www.enttec.com/docs/enttec_protocol.pdf
62 /* Define udp_port for ENTTEC */
64 #define UDP_PORT_ENTTEC 0x0D05
66 void proto_reg_handoff_enttec(void);
68 /* Define the enttec proto */
69 static int proto_enttec = -1;
72 static int hf_enttec_head = -1;
74 /* Define the tree for enttec */
75 static int ett_enttec = -1;
78 * Here are the global variables associated with the preferences
82 static guint global_udp_port_enttec = UDP_PORT_ENTTEC;
83 static guint udp_port_enttec = UDP_PORT_ENTTEC;
85 /* A static handle for the ip dissector */
86 static dissector_handle_t ip_handle;
87 static dissector_handle_t rdm_handle;
90 dissect_enttec(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
92 proto_tree *ti,*enttec_tree=NULL;
94 /* Set the protocol column */
95 if(check_col(pinfo->cinfo,COL_PROTOCOL)){
96 col_set_str(pinfo->cinfo,COL_PROTOCOL,"ENTTEC");
99 /* Clear out stuff in the info column */
100 if(check_col(pinfo->cinfo,COL_INFO)){
101 col_clear(pinfo->cinfo,COL_INFO);
105 ti = proto_tree_add_item(tree, proto_enttec, tvb, offset, -1, FALSE);
106 enttec_tree = proto_item_add_subtree(ti, ett_enttec);
111 proto_tree_add_item(enttec_tree, hf_enttec_head, tvb,
118 proto_register_enttec(void) {
119 static hf_register_info hf[] = {
126 FT_STRING, BASE_HEX, NULL, 0x0,
130 static gint *ett[] = {
134 module_t *enttec_module;
136 proto_enttec = proto_register_protocol("ENTTEC",
138 proto_register_field_array(proto_enttec,hf,array_length(hf));
139 proto_register_subtree_array(ett,array_length(ett));
141 enttec_module = prefs_register_protocol(proto_enttec,
142 proto_reg_handoff_enttec);
143 prefs_register_uint_preference(enttec_module, "udp_port",
145 "The UDP port on which "
147 "packets will be sent",
148 10,&global_udp_port_enttec);
152 /* The registration hand-off routing */
155 proto_reg_handoff_enttec(void) {
156 static int enttec_initialized = FALSE;
157 static dissector_handle_t enttec_handle;
159 ip_handle = find_dissector("ip");
160 rdm_handle = find_dissector("rdm");
163 if(!enttec_initialized) {
164 enttec_handle = create_dissector_handle(dissect_enttec,proto_enttec);
165 enttec_initialized = TRUE;
167 dissector_delete("udp.port",udp_port_enttec,enttec_handle);
170 udp_port_enttec = global_udp_port_enttec;
172 dissector_add("udp.port",global_udp_port_enttec,enttec_handle);
175 /* Start the functions we need for the plugin stuff */
177 #ifndef ENABLE_STATIC
180 plugin_reg_handoff(void){
181 proto_reg_handoff_enttec();
185 plugin_init(plugin_address_table_t *pat
186 #ifndef PLUGINS_NEED_ADDRESS_TABLE
190 /* initialise the table of pointers needed in Win32 DLLs */
191 plugin_address_table_init(pat);
192 /* register the new protocol, protocol fields, and subtrees */
193 if (proto_enttec == -1) { /* execute protocol initialization only once */
194 proto_register_enttec();
200 /* End the functions we need for plugin stuff */