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 /* Use tabstops = 4 */
28 /* NOTE: This should be rewritten to be more in line with how packet-uts.c is
29 * written so that there are filterable fields available for IPARS too.
37 #include <epan/packet.h>
38 #include <epan/emem.h>
40 static int proto_ipars = -1;
41 static guint8 ipars_eomtype = -1;
42 static gint ett_ipars = -1;
52 #define MAX_EOM_MSG_SIZE (16) /* max size of an EOMx indicator string */
55 dissect_ipars(tvbuff_t *tvb, packet_info *pinfo _U_ , proto_tree *tree)
57 proto_tree *ipars_tree = NULL;
60 guint8 ia = 0, ta = 0, cmd = 0, la = 0;
65 eom_msg = ep_alloc(MAX_EOM_MSG_SIZE);
68 if (check_col(pinfo->cinfo, COL_INFO))
69 col_clear(pinfo->cinfo, COL_INFO);
71 if (check_col(pinfo->cinfo, COL_PROTOCOL)) /* set the protocol column on summary display */
72 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPARS");
74 if (tvb_length_remaining(tvb, 0) >= 2 ) {
75 ia = tvb_get_guint8(tvb, 0) & 0x3f;
76 ta = tvb_get_guint8(tvb, 1) & 0x3f;
77 if (ia == S1 && ta == S2) { /* if the first two bytes are S1/S2 skip over them */
81 if (tvb_length_remaining(tvb, offset) >= 1) ia = tvb_get_guint8(tvb, offset + 0);
82 if (tvb_length_remaining(tvb, offset) >= 2) ta = tvb_get_guint8(tvb, offset + 1);
84 if (ia == 0x83 || ia == 0x43 || ia == GA) { /* if its an FPGA or 'corresponsdance code' 'go ahead'... */
85 if (tvb_length_remaining(tvb, offset) > 2) { /* if the msg is long, it must have been a 'poll' */
86 if (check_col(pinfo->cinfo, COL_INFO))
87 col_add_fstr(pinfo->cinfo, COL_INFO, "Poll IA: %2.2X", ta);
88 } else { /* if its short, then it was a 'no traffic' response */
89 if (tvb_length_remaining(tvb, offset) >= 2 ) {
90 if (check_col(pinfo->cinfo, COL_INFO))
91 col_add_fstr(pinfo->cinfo, COL_INFO, "GoAhead NextIA (0x%2.2X)", ta);
93 if (check_col(pinfo->cinfo, COL_INFO))
94 col_add_str(pinfo->cinfo, COL_INFO, "GoAhead NextIA");
97 } else { /* if its not a 'go ahead'... it must be some kind of data message */
101 if (check_col(pinfo->cinfo, COL_INFO))
102 col_add_fstr(pinfo->cinfo, COL_INFO, "Reset IA: %2.2X", ia); /* the TA character was the 'reset' command */
104 if (tvb_length_remaining(tvb, offset) >= 3) cmd = tvb_get_guint8(tvb, offset + 2) & 0x3f; /* get the first two bytes of the data message */
105 if (tvb_length_remaining(tvb, offset) >= 4) la = tvb_get_guint8(tvb, offset + 3) & 0x3f;
106 if (cmd == 0x1f && la == 0x38) {
107 if (check_col(pinfo->cinfo, COL_INFO))
108 col_add_fstr(pinfo->cinfo, COL_INFO, "Please Resend - IA: %2.2X TA: %2.2X", ia, ta); /* light the resend indicator */
109 } else if (cmd == 0x2a && la == 0x05) {
110 if (check_col(pinfo->cinfo, COL_INFO))
111 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsolicited Msg Indicator - IA: %2.2X TA: %2.2X", ia, ta); /* light the unsolicited msg indicator */
113 if (check_col(pinfo->cinfo, COL_INFO))
114 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 */
119 bytes = tvb_length_remaining(tvb, 0);
121 ia = tvb_get_guint8(tvb, 0) & 0x3f;
123 ti = proto_tree_add_protocol_format(tree, proto_ipars, tvb, 0, -1, "Ipars");
124 ipars_tree = proto_item_add_subtree(ti, ett_ipars);
127 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "GoAhead Next IA");
128 if (check_col(pinfo->cinfo, COL_INFO))
129 col_add_str(pinfo->cinfo, COL_INFO, "GoAhead");
131 } else if (ia != S1) {
132 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
134 bytes, "Unknown format - Data (%d byte%s)", bytes,
135 plurality(bytes, "", "s"));
138 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "S1");
139 ia = tvb_get_guint8(tvb, 1) & 0x3f;
141 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
143 bytes, "Unknown format - Data (%d byte%s)", bytes,
144 plurality(bytes, "", "s"));
147 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 1, 1, "S2");
148 ia = tvb_get_guint8(tvb, 2) & 0x3f;
150 ia = tvb_get_guint8(tvb, 3) & 0x3f;
151 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 2, 2, "GoAhead IA: %2.2X", ia);
152 ipars_eomtype = tvb_get_guint8(tvb, 4) & 0x3f;
153 switch (ipars_eomtype) {
154 case EOMc: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMc"); break;
155 case EOMi: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMi"); break;
156 case EOMu: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMu"); break;
157 case EOMpb: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMpb"); break;
158 default: g_snprintf(eom_msg, MAX_EOM_MSG_SIZE, "Unknown EOM type (0x%2.2X)", ia); break;
160 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 4, 1, "%s", eom_msg);
161 ia = tvb_get_guint8(tvb, 5) & 0x3f;
162 proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 5, 1, "Good BCC");
164 next_tvb = tvb_new_subset(tvb, 3, -1, -1);
165 proto_tree_add_protocol_format(ipars_tree, proto_ipars, next_tvb,
167 bytes, "Data (%d byte%s)", bytes,
168 plurality(bytes, "", "s"));
169 /* tvb_free(next_tvb); */ /* having this uncommented seems to cause a segfault (Fulko Hew, Nov 6/07) */
178 proto_register_ipars(void)
180 static gint *ett[] = {
184 proto_ipars = proto_register_protocol("International Passenger Airline Reservation System ", "IPARS", "ipars"); /* name, short name, abbrev */
185 proto_register_subtree_array(ett, array_length(ett));
187 register_dissector("ipars", dissect_ipars, proto_ipars);