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 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
14 * This dissector is for:
15 * Ethernet encapsulated Amateur AX.25 (AX.25 over Ethernet)
17 * Information was drawn from:
20 * It uses Ether ID 0x08ff which is not officially registered.
26 #include <epan/packet.h>
27 #include <epan/etypes.h>
28 #include <epan/capture_dissectors.h>
32 #define BPQ_HEADER_SIZE 2 /* length of bpq_len */
34 void proto_register_bpq(void);
35 void proto_reg_handoff_bpq(void);
37 static dissector_handle_t bpq_handle
;
38 static dissector_handle_t ax25_handle
;
40 static capture_dissector_handle_t ax25_cap_handle
;
43 static int hf_bpq_len
;
48 dissect_bpq( tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
57 col_set_str( pinfo
->cinfo
, COL_PROTOCOL
, "BPQ" );
59 col_clear( pinfo
->cinfo
, COL_INFO
);
61 /* protocol offset for the BPQ header */
64 bpq_len
= tvb_get_letohs( tvb
, offset
);
66 col_add_fstr( pinfo
->cinfo
, COL_INFO
, "%u", bpq_len
);
70 /* protocol offset for the BPQ header */
73 /* create display subtree for the protocol */
74 ti
= proto_tree_add_protocol_format( parent_tree
, proto_bpq
, tvb
, offset
, BPQ_HEADER_SIZE
,
76 bpq_len
& 0xfff /* XXX - lower 12 bits? */
79 bpq_tree
= proto_item_add_subtree( ti
, ett_bpq
);
81 proto_tree_add_item( bpq_tree
, hf_bpq_len
, tvb
, offset
, BPQ_HEADER_SIZE
, ENC_LITTLE_ENDIAN
);
85 offset
+= BPQ_HEADER_SIZE
;
87 /* XXX - use the length */
88 next_tvb
= tvb_new_subset_remaining( tvb
, offset
);
89 call_dissector( ax25_handle
, next_tvb
, pinfo
, parent_tree
);
90 return tvb_captured_length(tvb
);
94 capture_bpq( const unsigned char *pd
, int offset
, int len
, capture_packet_info_t
*cpinfo
, const union wtap_pseudo_header
*pseudo_header
)
98 if ( ! BYTES_ARE_IN_FRAME( offset
, len
, BPQ_HEADER_SIZE
) )
102 l_offset
+= BPQ_HEADER_SIZE
; /* step over bpq header to point at the AX.25 packet*/
103 return call_capture_dissector( ax25_cap_handle
, pd
, l_offset
, len
, cpinfo
, pseudo_header
);
107 proto_register_bpq(void)
109 /* Setup list of header fields */
110 static hf_register_info hf
[] = {
112 { "BPQ len", "bpq.len",
113 FT_UINT16
, BASE_DEC
, NULL
, 0x0,
118 /* Setup protocol subtree array */
119 static int *ett
[] = {
123 /* Register the protocol name and description */
124 proto_bpq
= proto_register_protocol( "Amateur Radio BPQ", "BPQ", "bpq" );
126 /* Register the dissector */
127 bpq_handle
= register_dissector("bpq", dissect_bpq
, proto_bpq
);
129 /* Required function calls to register the header fields and subtrees used */
130 proto_register_field_array( proto_bpq
, hf
, array_length( hf
) );
131 proto_register_subtree_array( ett
, array_length( ett
) );
135 proto_reg_handoff_bpq(void)
137 capture_dissector_handle_t bpq_cap_handle
;
139 dissector_add_uint("ethertype", ETHERTYPE_BPQ
, bpq_handle
);
140 bpq_cap_handle
= create_capture_dissector_handle(capture_bpq
, proto_bpq
);
141 capture_dissector_add_uint("ethertype", ETHERTYPE_BPQ
, bpq_cap_handle
);
143 /* BPQ is only implemented for AX.25 */
144 ax25_handle
= find_dissector_add_dependency( "ax25", proto_bpq
);
146 ax25_cap_handle
= find_capture_dissector( "ax25" );
150 * Editor modelines - https://www.wireshark.org/tools/modelines.html
155 * indent-tabs-mode: t
158 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
159 * :indentSize=8:tabSize=8:noTabs=false: