2 * Routines for ethercat packet disassembly
6 * Copyright (c) 2007 by Beckhoff Automation GmbH
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.
41 #include <epan/packet.h>
42 #include <epan/addr_resolv.h>
43 #include <epan/strutil.h>
45 #include "packet-ioraw.h"
47 /* Define the ioraw proto */
50 static int ett_ioraw = -1;
52 static int hf_ioraw_summary = -1;
53 static int hf_ioraw_header = -1;
54 static int hf_ioraw_data = -1;
57 static void IoRawSummaryFormater( char *szText, int nMax)
59 g_snprintf ( szText, nMax, "Raw IO Data" );
62 static void dissect_ioraw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
65 proto_tree *ioraw_tree;
68 int nMax = sizeof(szText)-1;
70 guint ioraw_length = tvb_reported_length(tvb);
72 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IO-RAW");
74 if (check_col(pinfo->cinfo, COL_INFO))
75 col_clear(pinfo->cinfo, COL_INFO);
78 IoRawSummaryFormater(szText, nMax);
79 if (check_col(pinfo->cinfo, COL_INFO))
80 col_append_str(pinfo->cinfo, COL_INFO, szText);
84 ti = proto_tree_add_item(tree, proto_ioraw, tvb, 0, -1, TRUE);
85 ioraw_tree = proto_item_add_subtree(ti, ett_ioraw);
87 proto_item_append_text(ti,": %s",szText);
88 proto_tree_add_item(ioraw_tree, hf_ioraw_header, tvb, offset, IoRawParserHDR_Len, TRUE);
89 offset+=IoRawParserHDR_Len;
91 proto_tree_add_item(ioraw_tree, hf_ioraw_data, tvb, offset, ioraw_length - offset, TRUE);
95 void proto_register_ioraw(void)
97 static hf_register_info hf[] =
100 { "Summary of the IoRaw Packet", "ioraw.summary",
101 FT_STRING, BASE_NONE, NULL, 0x0,
104 { &hf_ioraw_header, { "Header", "ioraw.header",
105 FT_NONE, BASE_NONE, NULL, 0x0,
108 { &hf_ioraw_data, { "VarData", "ioraw.data",
109 FT_NONE, BASE_NONE, NULL, 0x0,
119 proto_ioraw = proto_register_protocol("TwinCAT IO-RAW",
121 proto_register_field_array(proto_ioraw,hf,array_length(hf));
122 proto_register_subtree_array(ett,array_length(ett));
125 void proto_reg_handoff_ioraw(void)
127 dissector_handle_t ioraw_handle;
129 ioraw_handle = create_dissector_handle(dissect_ioraw, proto_ioraw);
130 dissector_add("ecatf.type", 3, ioraw_handle);