1 /* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: t
2 * vi: set shiftwidth=2 tabstop=2 noexpandtab:
3 * :indentSize=2:tabSize=2:noTabs=false:
6 /* packet-atn-cpdlc-template.c
7 * By Mathias Guettler <guettler@web.de>
10 * Routines for ATN Cpdlcc protocol packet disassembly
13 * http://en.wikipedia.org/wiki/CPDLC
14 * http://members.optusnet.com.au/~cjr/introduction.htm
17 * http://legacy.icao.int/anb/panels/acp/repository.cfm
20 * We are dealing with ATN/CPDLC aka ICAO Doc 9705 Ed2 here
21 * (CPDLC may also be transmitted via ACARS/AOA aka "FANS-1/A ").
24 * Wireshark - Network traffic analyzer
25 * By Gerald Combs <gerald@wireshark.org>
26 * Copyright 1998 Gerald Combs
28 * This program is free software; you can redistribute it and/or
29 * modify it under the terms of the GNU General Public License
30 * as published by the Free Software Foundation; either version 2
31 * of the License, or (at your option) any later version.
33 * This program is distributed in the hope that it will be useful,
34 * but WITHOUT ANY WARRANTY; without even the implied warranty of
35 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 * GNU General Public License for more details.
38 * You should have received a copy of the GNU General Public License
39 * along with this program; if not, write to the Free Software
40 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
45 Which CPDLC messages are supported ?
46 Protected Mode CPDLC (AeQualifier 22) and Plain Old CPDLC (AeQualifier 2)
47 The dissector has been tested with ICAO doc9705 Edition2 compliant traffic.
53 #include <epan/packet.h>
54 #include <epan/exceptions.h>
55 #include <epan/conversation.h>
56 #include <epan/dissectors/packet-ber.h>
57 #include <epan/dissectors/packet-per.h>
62 #include "packet-atn-ulcs.h"
64 #define ATN_CPDLC_PROTO "ICAO Doc9705 CPDLC"
66 void proto_register_atn_cpdlc(void);
67 void proto_reg_handoff_atn_cpdlc(void);
69 static const char *object_identifier_id;
71 /* forward declarations */
72 static void dissect_GroundPDUs_PDU(
74 packet_info *pinfo _U_,
75 proto_tree *tree _U_);
76 static void dissect_AircraftPDUs_PDU(
78 packet_info *pinfo _U_,
79 proto_tree *tree _U_);
80 static void dissect_ProtectedGroundPDUs_PDU(
82 packet_info *pinfo _U_,
83 proto_tree *tree _U_);
84 static void dissect_ProtectedAircraftPDUs_PDU(
86 packet_info *pinfo _U_,
87 proto_tree *tree _U_);
89 #include "packet-atn-cpdlc-hf.c"
91 #include "packet-atn-cpdlc-ett.c"
92 static gint ett_atn_cpdlc = -1;
94 #include "packet-atn-cpdlc-fn.c"
96 /* Wireshark ID of CPDLC protocol */
97 static int proto_atn_cpdlc = -1;
108 /* there are two co-existing applications of CPDLC: */
109 /* "plain old" (ae-qualifier 2) and */
110 /* "protected mode" (ae-qualifier 22) CPDLC. */
111 /* "protected mode" was introduced to cope with a */
112 /* safety issue in which a message would sent to the wrong aircraft. */
115 /* The protection is an additional checksum and covers the message content, */
116 /* the 24-bit address of the aircraft, the current flight id and */
117 /* the current ground facility so that an aircraft would be able to reject */
118 /* messages which are unexpected (i.e. messages to another flight or */
119 /* messages from the wrong center). */
122 /* although "plain old" CPDLC is more or less deprecated */
123 /* many aircraft cannot perform */
124 /* "protected mode" for this largely depends on */
125 /* upgraded avionics packages */
128 /* The use of CPDLC is *optional* as the pilot */
129 /* may always use a voice radio channel to talk to the controller.*/
131 proto_item *ti = NULL;
132 proto_tree *atn_cpdlc_tree = NULL;
133 atn_conversation_t *atn_cv = NULL;
136 /* we need the ae qualifier stored within the conversation */
137 /* to decode "plain old cpdlc" or */
138 /* "protected mode cpdlc correctly " */
140 /* DT: dstref present, srcref is always zero */
141 if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
142 atn_cv = find_atn_conversation(
147 /* CR: srcref present, dstref is always zero */
148 if((!pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
149 atn_cv = find_atn_conversation(
154 /* CC: srcref and dstref present, always use src/srcref & dst */
155 if((pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
156 atn_cv = find_atn_conversation(
162 if(!atn_cv){ /* atn conversation not found */
165 ti = proto_tree_add_text(
169 tvb_reported_length_remaining(tvb, 0) ,
172 atn_cpdlc_tree = proto_item_add_subtree(
176 switch(atn_cv->ae_qualifier){
178 if( check_heur_msg_type(pinfo) == um ) {
179 /* uplink PDU's = Ground PDU's */
180 dissect_ProtectedGroundPDUs_PDU(
184 }else { /* downlink PDU's = Aircraft PDU's */
185 dissect_ProtectedAircraftPDUs_PDU(
192 if( check_heur_msg_type(pinfo) == um ) {
193 /* uplink PDU's = Ground PDU's */
194 dissect_GroundPDUs_PDU(
198 }else { /* downlink PDU's = Aircraft PDU's */
199 dissect_AircraftPDUs_PDU(
208 return tvb_reported_length_remaining(tvb, 0);
212 dissect_atn_cpdlc_heur(
218 atn_conversation_t *atn_cv = NULL;
219 volatile gboolean is_atn_cpdlc = FALSE;
220 volatile gboolean is_pm = FALSE;
223 type = check_heur_msg_type(pinfo);
228 dissect_ProtectedGroundPDUs_PDU(tvb, pinfo, NULL);
233 is_atn_cpdlc = FALSE;
237 dissect_GroundPDUs_PDU(tvb, pinfo, NULL);
242 is_atn_cpdlc = FALSE;
248 dissect_ProtectedAircraftPDUs_PDU(tvb, pinfo, NULL);
253 is_atn_cpdlc = FALSE;
257 dissect_AircraftPDUs_PDU(tvb, pinfo, NULL);
262 is_atn_cpdlc = FALSE;
272 /* all subsequent PDU's belonging to this conversation */
273 /* are considered CPDLC */
274 /* if the first CPDLC PDU has been decoded succesfully */
275 /* (This is done in "atn-ulcs" by using "call_dissector_with_data()") */
277 /* DT: dstref present, srcref is always zero */
278 if((pinfo->clnp_dstref) && (!pinfo->clnp_srcref)){
279 atn_cv = find_atn_conversation(&pinfo->dst,
283 /* CR: srcref present, dstref is always zero */
284 if((!pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
285 atn_cv = find_atn_conversation(&pinfo->src,
289 /* CC: srcref and dstref present, always use src/srcref & dst */
290 if((pinfo->clnp_dstref) && (pinfo->clnp_srcref)){
291 atn_cv = find_atn_conversation(&pinfo->src,
296 if(atn_cv){ /* atn conversation found */
298 atn_cv->ae_qualifier = pmcpdlc; }
300 atn_cv->ae_qualifier = cpdlc; }
301 dissect_atn_cpdlc(tvb, pinfo, tree, NULL);
303 }else { /* there should *always* be an atn conversation */
304 is_atn_cpdlc = FALSE;
312 void proto_register_atn_cpdlc (void)
314 static hf_register_info hf_atn_cpdlc[] = {
315 #include "packet-atn-cpdlc-hfarr.c"
318 static gint *ett[] = {
319 #include "packet-atn-cpdlc-ettarr.c"
324 proto_atn_cpdlc = proto_register_protocol(
329 proto_register_field_array(
332 array_length(hf_atn_cpdlc));
334 proto_register_subtree_array(
338 new_register_dissector(
344 void proto_reg_handoff_atn_cpdlc(void)
346 /* add session dissector to atn dissector list dissector list*/
349 dissect_atn_cpdlc_heur,
355 * Editor modelines - http://www.wireshark.org/tools/modelines.html
360 * indent-tabs-mode: t
363 * vi: set shiftwidth=2 tabstop=2 noexpandtab:
364 * :indentSize=2:tabSize=2:noTabs=false: