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>
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:
34 * It uses Ether ID 0x08ff which is not not officially registered.
42 #include <epan/packet.h>
43 #include <epan/etypes.h>
45 #include "packet-bpq.h"
46 #include "packet-ax25.h"
50 #define BPQ_HEADER_SIZE 2 /* length of bpq_len */
52 static dissector_handle_t ax25_handle;
54 static int proto_bpq = -1;
55 static int hf_bpq_len = -1;
57 static gint ett_bpq = -1;
60 dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree )
66 void *saved_private_data;
70 col_set_str( pinfo->cinfo, COL_PROTOCOL, "BPQ" );
72 col_clear( pinfo->cinfo, COL_INFO );
74 /* protocol offset for the BPQ header */
77 bpq_len = tvb_get_letohs( tvb, offset );
79 col_add_fstr( pinfo->cinfo, COL_INFO, "%u", bpq_len );
83 /* protocol offset for the BPQ header */
86 /* create display subtree for the protocol */
87 ti = proto_tree_add_protocol_format( parent_tree, proto_bpq, tvb, offset, BPQ_HEADER_SIZE,
89 bpq_len & 0xfff /* XXX - lower 12 bits? */
92 bpq_tree = proto_item_add_subtree( ti, ett_bpq );
94 proto_tree_add_item( bpq_tree, hf_bpq_len, tvb, offset, BPQ_HEADER_SIZE, ENC_LITTLE_ENDIAN );
98 offset += BPQ_HEADER_SIZE;
100 saved_private_data = pinfo->private_data;
101 /* XXX - use the length */
102 next_tvb = tvb_new_subset( tvb, offset, -1, -1 );
103 call_dissector( ax25_handle, next_tvb, pinfo, parent_tree );
104 pinfo->private_data = saved_private_data;
108 capture_bpq( const guchar *pd, int offset, int len, packet_counts *ld)
112 if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
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 );
124 proto_register_bpq(void)
126 /* Setup list of header fields */
127 static hf_register_info hf[] = {
129 { "BPQ len", "bpq.len",
130 FT_UINT16, BASE_DEC, NULL, 0x0,
135 /* Setup protocol subtree array */
136 static gint *ett[] = {
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 ) );
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" );