DOCSIS: Ensure docsis_ucd has a registered dissection function
[metze/wireshark/wip.git] / plugins / ethercat / packet-ioraw.c
1 /* packet-ioraw.c
2  * Routines for ethercat packet disassembly
3  *
4  * Copyright (c) 2007 by Beckhoff Automation GmbH
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  */
24
25 /* Include files */
26
27 #include "config.h"
28
29 #include <epan/packet.h>
30
31 #include "packet-ioraw.h"
32
33 void proto_register_ioraw(void);
34 void proto_reg_handoff_ioraw(void);
35
36 /* Define the ioraw proto */
37 int proto_ioraw  = -1;
38
39 static int ett_ioraw = -1;
40
41 /* static int hf_ioraw_summary = -1; */
42 static int hf_ioraw_header = -1;
43 static int hf_ioraw_data = -1;
44
45 /*ioraw*/
46 static void IoRawSummaryFormater( char *szText, int nMax)
47 {
48    g_snprintf ( szText, nMax, "Raw IO Data" );
49 }
50
51 static int dissect_ioraw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
52 {
53    proto_item *ti;
54    proto_tree *ioraw_tree;
55    gint offset = 0;
56    char szText[200];
57    int nMax = sizeof(szText)-1;
58
59    guint ioraw_length = tvb_reported_length(tvb);
60
61    col_set_str(pinfo->cinfo, COL_PROTOCOL, "IO-RAW");
62
63    IoRawSummaryFormater(szText, nMax);
64    col_add_str(pinfo->cinfo, COL_INFO, szText);
65
66    if (tree)
67    {
68       ti = proto_tree_add_item(tree, proto_ioraw, tvb, 0, -1, ENC_NA);
69       ioraw_tree = proto_item_add_subtree(ti, ett_ioraw);
70
71       proto_item_append_text(ti,": %s",szText);
72       proto_tree_add_item(ioraw_tree, hf_ioraw_header, tvb, offset, IoRawParserHDR_Len, ENC_NA);
73       offset+=IoRawParserHDR_Len;
74
75       proto_tree_add_item(ioraw_tree, hf_ioraw_data, tvb, offset, ioraw_length - offset, ENC_NA);
76    }
77    return tvb_captured_length(tvb);
78 }
79
80 void proto_register_ioraw(void)
81 {
82    static hf_register_info hf[] =
83       {
84 #if 0
85          { &hf_ioraw_summary,
86            { "Summary of the IoRaw Packet", "ioraw.summary",
87              FT_STRING, BASE_NONE, NULL, 0x0,
88              NULL, HFILL }
89          },
90 #endif
91          { &hf_ioraw_header, { "Header", "ioraw.header",
92                                FT_NONE, BASE_NONE, NULL, 0x0,
93                                NULL, HFILL }
94          },
95          { &hf_ioraw_data, { "VarData", "ioraw.data",
96                              FT_NONE, BASE_NONE, NULL, 0x0,
97                              NULL, HFILL }
98          }
99       };
100
101    static gint *ett[] =
102       {
103          &ett_ioraw
104       };
105
106    proto_ioraw = proto_register_protocol("TwinCAT IO-RAW",
107                                          "IO-RAW","ioraw");
108    proto_register_field_array(proto_ioraw,hf,array_length(hf));
109    proto_register_subtree_array(ett,array_length(ett));
110 }
111
112 void proto_reg_handoff_ioraw(void)
113 {
114    dissector_handle_t ioraw_handle;
115
116    ioraw_handle = create_dissector_handle(dissect_ioraw, proto_ioraw);
117
118    dissector_add_uint("ecatf.type", 3, ioraw_handle);
119 }
120
121 /*
122  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
123  *
124  * Local Variables:
125  * c-basic-offset: 3
126  * tab-width: 8
127  * indent-tabs-mode: nil
128  * End:
129  *
130  * vi: set shiftwidth=3 tabstop=8 expandtab:
131  * :indentSize=3:tabSize=8:noTabs=true:
132  */