2 * Routines for IPARS/ALC (International Passenger Airline Reservation System/Airline Link Control) WAN protocol dissection
3 * Copyright 2007, Fulko Hew, SITA INC Canada, Inc.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 /* NOTE: This should be rewritten to be more in line with how packet-uts.c is
27 * written so that there are filterable fields available for IPARS too.
35 #include <epan/packet.h>
36 #include <epan/emem.h>
38 static int proto_ipars = -1;
39 static guint8 ipars_eomtype = G_MAXUINT8;
40 static gint ett_ipars = -1;
50 #define MAX_EOM_MSG_SIZE (16) /* max size of an EOMx indicator string */
53 dissect_ipars(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
55 proto_tree *ipars_tree = NULL;
58 guint8 ia = 0, ta = 0, cmd = 0, la = 0;
63 eom_msg = ep_alloc(MAX_EOM_MSG_SIZE);
66 col_clear(pinfo->cinfo, COL_INFO);
68 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPARS");
70 if (tvb_length_remaining(tvb, 0) >= 2 ) {
71 ia = tvb_get_guint8(tvb, 0) & 0x3f;
72 ta = tvb_get_guint8(tvb, 1) & 0x3f;
73 if (ia == S1 && ta == S2) { /* if the first two bytes are S1/S2 skip over them */
77 if (tvb_length_remaining(tvb, offset) >= 1) ia = tvb_get_guint8(tvb, offset + 0);
78 if (tvb_length_remaining(tvb, offset) >= 2) ta = tvb_get_guint8(tvb, offset + 1);
80 if (ia == 0x83 || ia == 0x43 || ia == GA) { /* if its an FPGA or 'corresponsdance code' 'go ahead'... */
81 if (tvb_length_remaining(tvb, offset) > 2) { /* if the msg is long, it must have been a 'poll' */
82 if (check_col(pinfo->cinfo, COL_INFO))
83 col_add_fstr(pinfo->cinfo, COL_INFO, "Poll IA: %2.2X", ta);
84 } else { /* if its short, then it was a 'no traffic' response */
85 if (tvb_length_remaining(tvb, offset) >= 2 ) {
86 if (check_col(pinfo->cinfo, COL_INFO))
87 col_add_fstr(pinfo->cinfo, COL_INFO, "GoAhead NextIA (0x%2.2X)", ta);
89 if (check_col(pinfo->cinfo, COL_INFO))
90 col_set_str(pinfo->cinfo, COL_INFO, "GoAhead NextIA");
93 } else { /* if its not a 'go ahead'... it must be some kind of data message */
97 if (check_col(pinfo->cinfo, COL_INFO))
98 col_add_fstr(pinfo->cinfo, COL_INFO, "Reset IA: %2.2X", ia); /* the TA character was the 'reset' command */
100 if (tvb_length_remaining(tvb, offset) >= 3) cmd = tvb_get_guint8(tvb, offset + 2) & 0x3f; /* get the first two bytes of the data message */
101 if (tvb_length_remaining(tvb, offset) >= 4) la = tvb_get_guint8(tvb, offset + 3) & 0x3f;
102 if (cmd == 0x1f && la == 0x38) {
103 if (check_col(pinfo->cinfo, COL_INFO))
104 col_add_fstr(pinfo->cinfo, COL_INFO, "Please Resend - IA: %2.2X TA: %2.2X", ia, ta); /* light the resend indicator */
105 } else if (cmd == 0x2a && la == 0x05) {
106 if (check_col(pinfo->cinfo, COL_INFO))
107 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsolicited Msg Indicator - IA: %2.2X TA: %2.2X", ia, ta); /* light the unsolicited msg indicator */
109 if (check_col(pinfo->cinfo, COL_INFO))
110 col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg - IA: %2.2X TA: %2.2X", ia, ta); /* it was a data message (display or printer */
115 bytes = tvb_length_remaining(tvb, 0);
117 ia = tvb_get_guint8(tvb, 0) & 0x3f;
119 ti = proto_tree_add_protocol_format(tree, proto_ipars, tvb, 0, -1, "Ipars");
120 ipars_tree = proto_item_add_subtree(ti, ett_ipars);
123 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "GoAhead Next IA");
124 if (check_col(pinfo->cinfo, COL_INFO))
125 col_set_str(pinfo->cinfo, COL_INFO, "GoAhead");
127 } else if (ia != S1) {
128 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
130 bytes, "Unknown format - Data (%d byte%s)", bytes,
131 plurality(bytes, "", "s"));
134 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "S1");
135 ia = tvb_get_guint8(tvb, 1) & 0x3f;
137 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
139 bytes, "Unknown format - Data (%d byte%s)", bytes,
140 plurality(bytes, "", "s"));
143 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 1, 1, "S2");
144 ia = tvb_get_guint8(tvb, 2) & 0x3f;
146 ia = tvb_get_guint8(tvb, 3) & 0x3f;
147 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 2, 2, "GoAhead IA: %2.2X", ia);
148 ipars_eomtype = tvb_get_guint8(tvb, 4) & 0x3f;
149 switch (ipars_eomtype) {
150 case EOMc: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMc"); break;
151 case EOMi: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMi"); break;
152 case EOMu: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMu"); break;
153 case EOMpb: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMpb"); break;
154 default: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "Unknown EOM type (0x%2.2X)", ia); break;
156 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 4, 1, "%s", eom_msg);
157 ia = tvb_get_guint8(tvb, 5) & 0x3f;
158 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 5, 1, "Good BCC");
160 next_tvb = tvb_new_subset_remaining(tvb, 3);
161 proto_tree_add_protocol_format(ipars_tree, proto_ipars, next_tvb,
163 bytes, "Data (%d byte%s)", bytes,
164 plurality(bytes, "", "s"));
173 proto_register_ipars(void)
175 static gint *ett[] = {
179 proto_ipars = proto_register_protocol("International Passenger Airline Reservation System", "IPARS", "ipars");
180 proto_register_subtree_array(ett, array_length(ett));
182 register_dissector("ipars", dissect_ipars, proto_ipars);