3 * Routines for Amateur Packet Radio protocol dissection
4 * Copyright 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 the "No Layer 3 protocol" PID of the AX.25 Amateur
15 * Packet-Radio Link-Layer Protocol, Version 2.0, October 1984
17 * At the time of writing the specification could be found here:
18 * http://www.tapr.org/pub_ax25.html
20 * Information on the "protocols" recognised by this dissector are drawn from:
22 * A network capture kindly donated by Luca Melette.
24 * http://www.aprs.org/
26 * Inspiration on how to build the dissector drawn from
32 * with the base file built from README.developers.
37 #include <epan/packet.h>
38 #include <epan/prefs.h>
39 #include <epan/ax25_pids.h>
43 void proto_register_ax25_nol3(void);
44 void proto_reg_handoff_ax25_nol3(void);
46 /* Dissector handles - all the possibles are listed */
47 static dissector_handle_t aprs_handle
;
49 /* Initialize the protocol and registered fields */
50 static int proto_ax25_nol3
;
53 static int hf_dx_report
;
55 /* static int hf_text; */
57 /* Global preferences */
58 static bool gPREF_APRS
;
61 /* Initialize the subtree pointers */
62 static int ett_ax25_nol3
;
67 /* Code to actually dissect the packets */
69 dissect_dx(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
78 data_len
= tvb_reported_length_remaining( tvb
, offset
);
80 col_set_str( pinfo
->cinfo
, COL_PROTOCOL
, "DX" );
82 col_add_str( pinfo
->cinfo
, COL_INFO
, tvb_format_text( pinfo
->pool
, tvb
, offset
, 15 ) );
86 /* create display subtree for the protocol */
87 ti
= proto_tree_add_protocol_format( parent_tree
, proto_dx
, tvb
, 0, -1,
88 "DX (%s)", tvb_format_text( pinfo
->pool
, tvb
, offset
, 15 ) );
89 dx_tree
= proto_item_add_subtree( ti
, ett_dx
);
92 proto_tree_add_item( dx_tree
, hf_dx_report
, tvb
, offset
, data_len
, ENC_ASCII
);
95 return tvb_captured_length(tvb
);
131 case '}' : b
= true; break;
138 dissect_ax25_nol3(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data _U_
)
141 proto_tree
*ax25_nol3_tree
;
144 tvbuff_t
*next_tvb
= NULL
;
148 info_buffer
= (char *)wmem_alloc( pinfo
->pool
, STRLEN
);
149 info_buffer
[0] = '\0';
151 col_set_str( pinfo
->cinfo
, COL_PROTOCOL
, "AX.25-NoL3");
153 col_clear( pinfo
->cinfo
, COL_INFO
);
156 snprintf( info_buffer
, STRLEN
, "Text" );
160 dti
= tvb_get_uint8( tvb
, offset
);
162 snprintf( info_buffer
, STRLEN
, "APRS" );
166 if ( tvb_get_uint8( tvb
, offset
) == 'D' && tvb_get_uint8( tvb
, offset
+ 1 ) == 'X' )
167 snprintf( info_buffer
, STRLEN
, "DX cluster" );
170 col_add_str( pinfo
->cinfo
, COL_INFO
, info_buffer
);
172 /* Call sub-dissectors here */
174 /* create display subtree for the protocol */
175 ti
= proto_tree_add_protocol_format( parent_tree
,
180 "AX.25 No Layer 3 - (%s)", info_buffer
);
181 ax25_nol3_tree
= proto_item_add_subtree( ti
, ett_ax25_nol3
);
183 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
190 call_dissector( aprs_handle
, next_tvb
, pinfo
, ax25_nol3_tree
);
195 if ( tvb_get_uint8( tvb
, offset
) == 'D' && tvb_get_uint8( tvb
, offset
+ 1 ) == 'X' )
198 dissect_dx( next_tvb
, pinfo
, ax25_nol3_tree
, NULL
);
202 call_data_dissector(next_tvb
, pinfo
, ax25_nol3_tree
);
204 return tvb_captured_length(tvb
);
208 proto_register_ax25_nol3(void)
210 module_t
*ax25_nol3_module
;
212 /* Setup list of header fields */
213 #if 0 /* not used ? */
214 static hf_register_info hf
[] = {
216 { "Text", "ax25_nol3.text",
217 FT_STRING
, BASE_NONE
, NULL
, 0x0,
223 static hf_register_info hf_dx
[] = {
225 { "DX", "ax25_nol3.dx",
226 FT_STRING
, BASE_NONE
, NULL
, 0x0,
227 "DX cluster", HFILL
}
231 /* Setup protocol subtree array */
232 static int *ett
[] = {
237 /* Register the protocol name and description */
238 proto_ax25_nol3
= proto_register_protocol("AX.25 no Layer 3", "AX.25 no L3", "ax25_nol3");
240 /* Required function calls to register the header fields and subtrees used */
241 /* proto_register_field_array( proto_ax25_nol3, hf, array_length(hf ) ); */
242 proto_register_subtree_array( ett
, array_length( ett
) );
244 /* Register preferences module */
245 ax25_nol3_module
= prefs_register_protocol( proto_ax25_nol3
, NULL
);
247 /* Register any preference */
248 prefs_register_bool_preference(ax25_nol3_module
, "showaprs",
249 "Decode the APRS info field",
250 "Enable decoding of the payload as APRS.",
253 prefs_register_bool_preference(ax25_nol3_module
, "showcluster",
254 "Decode DX cluster info field",
255 "Enable decoding of the payload as DX cluster info.",
258 /* Register the sub-protocol name and description */
259 proto_dx
= proto_register_protocol("DX cluster", "DX", "dx");
261 /* Register the dissector */
262 register_dissector( "dx", dissect_dx
, proto_dx
);
264 /* Register the header fields */
265 proto_register_field_array( proto_dx
, hf_dx
, array_length( hf_dx
) );
267 /* Register the subtrees used */
268 /* proto_register_subtree_array( ett_dx, array_length( ett_dx ) ); */
272 proto_reg_handoff_ax25_nol3(void)
274 dissector_add_uint( "ax25.pid", AX25_P_NO_L3
, create_dissector_handle( dissect_ax25_nol3
, proto_ax25_nol3
) );
278 aprs_handle
= find_dissector_add_dependency( "aprs", proto_ax25_nol3
);
282 * Editor modelines - https://www.wireshark.org/tools/modelines.html
287 * indent-tabs-mode: t
290 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
291 * :indentSize=8:tabSize=8:noTabs=false: