epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-bpq.c
blob76c8054178b69f9b70a08f6deebc582c97e49b94
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 * 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:
18 * ?
20 * It uses Ether ID 0x08ff which is not officially registered.
24 #include "config.h"
26 #include <epan/packet.h>
27 #include <epan/etypes.h>
28 #include <epan/capture_dissectors.h>
30 #define STRLEN 80
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;
42 static int proto_bpq;
43 static int hf_bpq_len;
45 static int ett_bpq;
47 static int
48 dissect_bpq( tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_ )
50 proto_item *ti;
51 proto_tree *bpq_tree;
52 int offset;
53 uint16_t bpq_len;
54 tvbuff_t *next_tvb;
57 col_set_str( pinfo->cinfo, COL_PROTOCOL, "BPQ" );
59 col_clear( pinfo->cinfo, COL_INFO );
61 /* protocol offset for the BPQ header */
62 offset = 0;
64 bpq_len = tvb_get_letohs( tvb, offset );
66 col_add_fstr( pinfo->cinfo, COL_INFO, "%u", bpq_len );
68 if ( parent_tree )
70 /* protocol offset for the BPQ header */
71 offset = 0;
73 /* create display subtree for the protocol */
74 ti = proto_tree_add_protocol_format( parent_tree, proto_bpq, tvb, offset, BPQ_HEADER_SIZE,
75 "BPQ, Len: %u",
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);
93 static bool
94 capture_bpq( const unsigned char *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
96 int l_offset;
98 if ( ! BYTES_ARE_IN_FRAME( offset, len, BPQ_HEADER_SIZE ) )
99 return false;
101 l_offset = offset;
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 );
106 void
107 proto_register_bpq(void)
109 /* Setup list of header fields */
110 static hf_register_info hf[] = {
111 { &hf_bpq_len,
112 { "BPQ len", "bpq.len",
113 FT_UINT16, BASE_DEC, NULL, 0x0,
114 NULL, HFILL }
118 /* Setup protocol subtree array */
119 static int *ett[] = {
120 &ett_bpq,
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 ) );
134 void
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
152 * Local variables:
153 * c-basic-offset: 8
154 * tab-width: 8
155 * indent-tabs-mode: t
156 * End:
158 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
159 * :indentSize=8:tabSize=8:noTabs=false: