diff options
author | João Valverde <joao.valverde@tecnico.ulisboa.pt> | 2018-01-15 12:40:55 +0000 |
---|---|---|
committer | João Valverde <j@v6e.pt> | 2018-01-16 08:51:37 +0000 |
commit | 5352ef42f94b5c14a24eb2e5559440c71fdcae8f (patch) | |
tree | 22901b1d228d76360b22af10021564bcee36390e /plugins/epan/ethercat/packet-ioraw.c | |
parent | a069a4f856c29b25bae05f2a91d7b2b71e1905f3 (diff) |
plugins: Add source tree subfolder for plugin library
This allows some simplification and makes things more consistent,
particularly for loading plugins from the build dir.
Also fixes the issue reported here:
https://www.wireshark.org/lists/wireshark-dev/201801/msg00061.html
Change-Id: I0d8a000ee679172bccad546a3b0c47a79486f44d
Reviewed-on: https://code.wireshark.org/review/25329
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: João Valverde <j@v6e.pt>
Diffstat (limited to 'plugins/epan/ethercat/packet-ioraw.c')
-rw-r--r-- | plugins/epan/ethercat/packet-ioraw.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/plugins/epan/ethercat/packet-ioraw.c b/plugins/epan/ethercat/packet-ioraw.c new file mode 100644 index 0000000000..125de9ebbe --- /dev/null +++ b/plugins/epan/ethercat/packet-ioraw.c @@ -0,0 +1,132 @@ +/* packet-ioraw.c + * Routines for ethercat packet disassembly + * + * Copyright (c) 2007 by Beckhoff Automation GmbH + * + * 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. + */ + +/* Include files */ + +#include "config.h" + +#include <epan/packet.h> + +#include "packet-ioraw.h" + +void proto_register_ioraw(void); +void proto_reg_handoff_ioraw(void); + +/* Define the ioraw proto */ +int proto_ioraw = -1; + +static int ett_ioraw = -1; + +/* static int hf_ioraw_summary = -1; */ +static int hf_ioraw_header = -1; +static int hf_ioraw_data = -1; + +/*ioraw*/ +static void IoRawSummaryFormater( char *szText, int nMax) +{ + g_snprintf ( szText, nMax, "Raw IO Data" ); +} + +static int dissect_ioraw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) +{ + proto_item *ti; + proto_tree *ioraw_tree; + gint offset = 0; + char szText[200]; + int nMax = sizeof(szText)-1; + + guint ioraw_length = tvb_reported_length(tvb); + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "IO-RAW"); + + IoRawSummaryFormater(szText, nMax); + col_add_str(pinfo->cinfo, COL_INFO, szText); + + if (tree) + { + ti = proto_tree_add_item(tree, proto_ioraw, tvb, 0, -1, ENC_NA); + ioraw_tree = proto_item_add_subtree(ti, ett_ioraw); + + proto_item_append_text(ti,": %s",szText); + proto_tree_add_item(ioraw_tree, hf_ioraw_header, tvb, offset, IoRawParserHDR_Len, ENC_NA); + offset+=IoRawParserHDR_Len; + + proto_tree_add_item(ioraw_tree, hf_ioraw_data, tvb, offset, ioraw_length - offset, ENC_NA); + } + return tvb_captured_length(tvb); +} + +void proto_register_ioraw(void) +{ + static hf_register_info hf[] = + { +#if 0 + { &hf_ioraw_summary, + { "Summary of the IoRaw Packet", "ioraw.summary", + FT_STRING, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, +#endif + { &hf_ioraw_header, { "Header", "ioraw.header", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL } + }, + { &hf_ioraw_data, { "VarData", "ioraw.data", + FT_NONE, BASE_NONE, NULL, 0x0, + NULL, HFILL } + } + }; + + static gint *ett[] = + { + &ett_ioraw + }; + + proto_ioraw = proto_register_protocol("TwinCAT IO-RAW", + "IO-RAW","ioraw"); + proto_register_field_array(proto_ioraw,hf,array_length(hf)); + proto_register_subtree_array(ett,array_length(ett)); +} + +void proto_reg_handoff_ioraw(void) +{ + dissector_handle_t ioraw_handle; + + ioraw_handle = create_dissector_handle(dissect_ioraw, proto_ioraw); + + dissector_add_uint("ecatf.type", 3, ioraw_handle); +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local Variables: + * c-basic-offset: 3 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=3 tabstop=8 expandtab: + * :indentSize=3:tabSize=8:noTabs=true: + */ |