3 * Routines for Amateur Packet Radio protocol dissection
4 * Copyright 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 the "No Layer 3 protocol" PID of the AX.25 Amateur
29 * Packet-Radio Link-Layer Protocol, Version 2.0, October 1984
31 * At the time of writing the specification could be found here:
32 * http://www.tapr.org/pub_ax25.html
34 * Information on the "protocols" recognised by this dissector are drawn from:
36 * A network capture kindly donated by Luca Melette.
38 * http://www.aprs.org/
40 * Inspiration on how to build the dissector drawn from
46 * with the base file built from README.developers.
53 #include <epan/packet.h>
54 #include <epan/prefs.h>
55 #include <epan/wmem/wmem.h>
56 #include <epan/ax25_pids.h>
60 void proto_register_ax25_nol3(void);
61 void proto_reg_handoff_ax25_nol3(void);
63 /* Dissector handles - all the possibles are listed */
64 static dissector_handle_t aprs_handle
;
65 static dissector_handle_t default_handle
;
67 /* Initialize the protocol and registered fields */
68 static int proto_ax25_nol3
= -1;
69 static int proto_dx
= -1;
71 static int hf_dx_report
= -1;
73 /* static int hf_text = -1; */
75 /* Global preferences */
76 static gboolean gPREF_APRS
= FALSE
;
77 static gboolean gPREF_DX
= FALSE
;
79 /* Initialize the subtree pointers */
80 static gint ett_ax25_nol3
= -1;
82 static gint ett_dx
= -1;
85 /* Code to actually dissect the packets */
87 dissect_dx(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
)
96 data_len
= tvb_length_remaining( tvb
, offset
);
98 col_set_str( pinfo
->cinfo
, COL_PROTOCOL
, "DX" );
100 col_add_fstr( pinfo
->cinfo
, COL_INFO
, "%s", tvb_format_text( tvb
, offset
, 15 ) );
104 /* create display subtree for the protocol */
105 ti
= proto_tree_add_protocol_format( parent_tree
, proto_dx
, tvb
, 0, -1,
106 "DX (%s)", tvb_format_text( tvb
, offset
, 15 ) );
107 dx_tree
= proto_item_add_subtree( ti
, ett_dx
);
110 proto_tree_add_item( dx_tree
, hf_dx_report
, tvb
, offset
, data_len
, ENC_ASCII
|ENC_NA
);
147 case '}' : b
= TRUE
; break;
154 dissect_ax25_nol3(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
)
157 proto_tree
*ax25_nol3_tree
;
160 tvbuff_t
*next_tvb
= NULL
;
164 info_buffer
= (char *)wmem_alloc( wmem_packet_scope(), STRLEN
);
165 info_buffer
[0] = '\0';
167 col_set_str( pinfo
->cinfo
, COL_PROTOCOL
, "AX.25-NoL3");
169 col_clear( pinfo
->cinfo
, COL_INFO
);
172 g_snprintf( info_buffer
, STRLEN
, "Text" );
176 dti
= tvb_get_guint8( tvb
, offset
);
178 g_snprintf( info_buffer
, STRLEN
, "APRS" );
182 if ( tvb_get_guint8( tvb
, offset
) == 'D' && tvb_get_guint8( tvb
, offset
+ 1 ) == 'X' )
183 g_snprintf( info_buffer
, STRLEN
, "DX cluster" );
186 col_add_str( pinfo
->cinfo
, COL_INFO
, info_buffer
);
188 /* Call sub-dissectors here */
192 /* create display subtree for the protocol */
193 ti
= proto_tree_add_protocol_format( parent_tree
,
198 "AX.25 No Layer 3 - (%s)", info_buffer
);
199 ax25_nol3_tree
= proto_item_add_subtree( ti
, ett_ax25_nol3
);
201 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
208 call_dissector( aprs_handle
, next_tvb
, pinfo
, ax25_nol3_tree
);
213 if ( tvb_get_guint8( tvb
, offset
) == 'D' && tvb_get_guint8( tvb
, offset
+ 1 ) == 'X' )
216 dissect_dx( next_tvb
, pinfo
, ax25_nol3_tree
);
220 call_dissector( default_handle
, next_tvb
, pinfo
, ax25_nol3_tree
);
226 proto_register_ax25_nol3(void)
228 module_t
*ax25_nol3_module
;
230 /* Setup list of header fields */
231 #if 0 /* not used ? */
232 static hf_register_info hf
[] = {
234 { "Text", "ax25_nol3.text",
235 FT_STRING
, BASE_NONE
, NULL
, 0x0,
241 static hf_register_info hf_dx
[] = {
243 { "DX", "ax25_nol3.dx",
244 FT_STRING
, BASE_NONE
, NULL
, 0x0,
245 "DX cluster", HFILL
}
249 /* Setup protocol subtree array */
250 static gint
*ett
[] = {
255 /* Register the protocol name and description */
256 proto_ax25_nol3
= proto_register_protocol("AX.25 no Layer 3", "AX.25 no L3", "ax25_nol3");
258 /* Required function calls to register the header fields and subtrees used */
259 /* proto_register_field_array( proto_ax25_nol3, hf, array_length(hf ) ); */
260 proto_register_subtree_array( ett
, array_length( ett
) );
262 /* Register preferences module */
263 ax25_nol3_module
= prefs_register_protocol( proto_ax25_nol3
, NULL
);
265 /* Register any preference */
266 prefs_register_bool_preference(ax25_nol3_module
, "showaprs",
267 "Decode the APRS info field",
268 "Enable decoding of the payload as APRS.",
271 prefs_register_bool_preference(ax25_nol3_module
, "showcluster",
272 "Decode DX cluster info field",
273 "Enable decoding of the payload as DX cluster info.",
276 /* Register the sub-protocol name and description */
277 proto_dx
= proto_register_protocol("DX cluster", "DX", "dx");
279 /* Register the dissector */
280 register_dissector( "dx", dissect_dx
, proto_dx
);
282 /* Register the header fields */
283 proto_register_field_array( proto_dx
, hf_dx
, array_length( hf_dx
) );
285 /* Register the subtrees used */
286 /* proto_register_subtree_array( ett_dx, array_length( ett_dx ) ); */
290 proto_reg_handoff_ax25_nol3(void)
292 dissector_add_uint( "ax25.pid", AX25_P_NO_L3
, create_dissector_handle( dissect_ax25_nol3
, proto_ax25_nol3
) );
296 aprs_handle
= find_dissector( "aprs" );
297 default_handle
= find_dissector( "data" );