MSWSP: fix dissect_mswsp_smb()
[wireshark-wip.git] / epan / dissectors / packet-bpq.c
blobd6c08cbcc452d5374b531e69c38145ce7d0fe23e
1 /* packet-bpq.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 * This dissector is for:
29 * Ethernet encapsulated Amateur AX.25 (AX.25 over Ethernet)
31 * Information was drawn from:
32 * ?
34 * It uses Ether ID 0x08ff which is not not officially registered.
38 #include "config.h"
40 #include <glib.h>
42 #include <epan/packet.h>
43 #include <epan/etypes.h>
45 #include "packet-bpq.h"
46 #include "packet-ax25.h"
48 #define STRLEN 80
50 #define BPQ_HEADER_SIZE 2 /* length of bpq_len */
52 void proto_register_bpq(void);
53 void proto_reg_handoff_bpq(void);
55 static dissector_handle_t ax25_handle;
57 static int proto_bpq = -1;
58 static int hf_bpq_len = -1;
60 static gint ett_bpq = -1;
62 static void
63 dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
65 proto_item *ti;
66 proto_tree *bpq_tree;
67 int offset;
68 guint16 bpq_len;
69 tvbuff_t *next_tvb;
72 col_set_str( pinfo->cinfo, COL_PROTOCOL, "BPQ" );
74 col_clear( pinfo->cinfo, COL_INFO );
76 /* protocol offset for the BPQ header */
77 offset = 0;
79 bpq_len = tvb_get_letohs( tvb, offset );
81 col_add_fstr( pinfo->cinfo, COL_INFO, "%u", bpq_len );
83 if ( parent_tree )
85 /* protocol offset for the BPQ header */
86 offset = 0;
88 /* create display subtree for the protocol */
89 ti = proto_tree_add_protocol_format( parent_tree, proto_bpq, tvb, offset, BPQ_HEADER_SIZE,
90 "BPQ, Len: %u",
91 bpq_len & 0xfff /* XXX - lower 12 bits? */
94 bpq_tree = proto_item_add_subtree( ti, ett_bpq );
96 proto_tree_add_item( bpq_tree, hf_bpq_len, tvb, offset, BPQ_HEADER_SIZE, ENC_LITTLE_ENDIAN );
100 offset += BPQ_HEADER_SIZE;
102 /* XXX - use the length */
103 next_tvb = tvb_new_subset_remaining( tvb, offset );
104 call_dissector( ax25_handle, next_tvb, pinfo, parent_tree );
107 void
108 capture_bpq( const guchar *pd, int offset, int len, packet_counts *ld)
110 int l_offset;
112 if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
114 ld->other++;
115 return;
118 l_offset = offset;
119 l_offset += BPQ_HEADER_SIZE; /* step over bpq header to point at the AX.25 packet*/
120 capture_ax25( pd, l_offset, len, ld );
123 void
124 proto_register_bpq(void)
126 /* Setup list of header fields */
127 static hf_register_info hf[] = {
128 { &hf_bpq_len,
129 { "BPQ len", "bpq.len",
130 FT_UINT16, BASE_DEC, NULL, 0x0,
131 NULL, HFILL }
135 /* Setup protocol subtree array */
136 static gint *ett[] = {
137 &ett_bpq,
140 /* Register the protocol name and description */
141 proto_bpq = proto_register_protocol( "Amateur Radio BPQ", "BPQ", "bpq" );
143 /* Register the dissector */
144 register_dissector( "bpq", dissect_bpq, proto_bpq );
146 /* Required function calls to register the header fields and subtrees used */
147 proto_register_field_array( proto_bpq, hf, array_length( hf ) );
148 proto_register_subtree_array( ett, array_length( ett ) );
151 void
152 proto_reg_handoff_bpq(void)
154 dissector_handle_t bpq_handle;
156 bpq_handle = create_dissector_handle( dissect_bpq, proto_bpq );
157 dissector_add_uint("ethertype", ETHERTYPE_BPQ, bpq_handle);
159 /* BPQ is only implemented for AX.25 */
160 ax25_handle = find_dissector( "ax25" );