HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-flexnet.c
blob7406609891378c42fe0c6afea3023f7de03ecbe9
1 /* packet-flexnet.c
3 * Routines for Amateur Packet Radio protocol dissection
4 * Copyright 2005,2006,2007,2008,2009,2010,2012 R.W. Stearn <richard@rns-stearn.demon.co.uk>
6 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * Information on the protocol drawn from:
30 * Inspiration on how to build the dissector drawn from
31 * packet-sdlc.c
32 * packet-x25.c
33 * packet-lapb.c
34 * paket-gprs-llc.c
35 * xdlc.c
36 * with the base file built from README.developers.
39 #include "config.h"
41 #include <glib.h>
43 #include <epan/packet.h>
44 #include <epan/ax25_pids.h>
46 #define FLEXNET_ADRLEN 15
47 #define FLEXNET_CTLLEN 15
48 #define FLEXNET_HDRLEN (FLEXNET_ADRLEN + FLEXNET_ADRLEN + FLEXNET_CTLLEN)
50 static dissector_handle_t default_handle;
52 static int proto_flexnet = -1;
53 static int hf_flexnet_dst = -1;
54 static int hf_flexnet_src = -1;
55 static int hf_flexnet_ctl = -1;
57 static gint ett_flexnet = -1;
58 static gint ett_flexnet_ctl = -1;
60 static void
61 dissect_flexnet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
63 tvbuff_t *next_tvb;
65 col_set_str( pinfo->cinfo, COL_PROTOCOL, "Flexnet");
66 col_clear( pinfo->cinfo, COL_INFO );
68 if ( parent_tree )
70 proto_item *ti;
71 proto_tree *flexnet_tree;
72 int offset;
74 /* create display subtree for the protocol */
76 ti = proto_tree_add_protocol_format( parent_tree, proto_flexnet, tvb, 0, FLEXNET_HDRLEN, "FLEXNET" );
78 flexnet_tree = proto_item_add_subtree( ti, ett_flexnet );
80 offset = 0;
82 proto_tree_add_item( flexnet_tree, hf_flexnet_dst, tvb, offset, FLEXNET_ADRLEN, ENC_NA );
83 offset +=FLEXNET_ADRLEN;
85 proto_tree_add_item( flexnet_tree, hf_flexnet_src, tvb, offset, FLEXNET_ADRLEN, ENC_NA );
86 offset +=FLEXNET_ADRLEN;
88 proto_tree_add_item( flexnet_tree, hf_flexnet_ctl, tvb, offset, FLEXNET_CTLLEN, ENC_NA );
89 /* offset +=FLEXNET_CTLLEN; */
92 /* Call sub-dissectors here */
94 next_tvb = tvb_new_subset_remaining(tvb, FLEXNET_HDRLEN);
95 call_dissector( default_handle , next_tvb, pinfo, parent_tree );
98 void
99 proto_register_flexnet(void)
101 /* Setup list of header fields */
102 static hf_register_info hf[] = {
103 { &hf_flexnet_dst,
104 { "Destination", "flexnet.dst",
105 FT_BYTES, BASE_NONE, NULL, 0x0,
106 "Destination address", HFILL }
108 { &hf_flexnet_src,
109 { "Source", "flexnet.src",
110 FT_BYTES, BASE_NONE, NULL, 0x0,
111 "Source address", HFILL }
113 { &hf_flexnet_ctl,
114 { "Control", "flexnet.ctl",
115 FT_BYTES, BASE_NONE, NULL, 0x0,
116 NULL, HFILL }
120 /* Setup protocol subtree array */
121 static gint *ett[] = {
122 &ett_flexnet,
123 &ett_flexnet_ctl,
126 /* Register the protocol name and description */
127 proto_flexnet = proto_register_protocol("FlexNet", "FLEXNET", "flexnet");
129 /* Required function calls to register the header fields and subtrees used */
130 proto_register_field_array( proto_flexnet, hf, array_length( hf ) );
131 proto_register_subtree_array( ett, array_length( ett ) );
134 void
135 proto_reg_handoff_flexnet(void)
137 dissector_add_uint( "ax25.pid", AX25_P_FLEXNET, create_dissector_handle( dissect_flexnet, proto_flexnet ) );
141 default_handle = find_dissector( "data" );