Coverage Report

Created: 2026-11-12 07:01

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ipars.c
Line
Count
Source
1
/* packet-ipars.c
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.
4
 *
5
 * Wireshark - Network traffic analyzer
6
 * By Gerald Combs <gerald@wireshark.org>
7
 * Copyright 1998 Gerald Combs
8
 *
9
 * SPDX-License-Identifier: GPL-2.0-or-later
10
 */
11
12
/* NOTE:    This should be rewritten to be more in line with how packet-uts.c is
13
 *          written so that there are filterable fields available for IPARS too.
14
 */
15
16
#include "config.h"
17
18
#include <epan/packet.h>
19
#include <wsutil/str_util.h>
20
void proto_register_ipars(void);
21
22
static int      proto_ipars;
23
static int      ett_ipars;
24
25
0
#define S1      (0x00)
26
0
#define S2      (0x20)
27
0
#define GA      (0x03)
28
0
#define EOMpb   (0x10)
29
0
#define EOMc    (0x11)
30
0
#define EOMu    (0x12)
31
0
#define EOMi    (0x13)
32
33
0
#define MAX_EOM_MSG_SIZE    (24)            /* max size of an EOMx indicator string */
34
35
static int
36
dissect_ipars(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
37
0
{
38
0
    int       bytes;
39
0
    uint8_t   ia     = 0, ta = 0, cmd = 0, la = 0;
40
0
    tvbuff_t *next_tvb;
41
0
    int       offset = 0;
42
0
    char     *eom_msg;
43
0
    uint8_t   ipars_eomtype;
44
45
0
    eom_msg    = (char *)wmem_alloc(pinfo->pool, MAX_EOM_MSG_SIZE);
46
0
    eom_msg[0] = 0;
47
48
0
    col_clear(pinfo->cinfo, COL_INFO);
49
50
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPARS");
51
52
0
    if (tvb_captured_length_remaining(tvb, 0) >= 2 ) {
53
0
        ia = tvb_get_uint8(tvb, 0) & 0x3f;
54
0
        ta = tvb_get_uint8(tvb, 1) & 0x3f;
55
0
        if (ia == S1 && ta == S2) { /* if the first two bytes are S1/S2 skip over them */
56
0
            offset = 2;
57
0
        }
58
0
    }
59
0
    if (tvb_captured_length_remaining(tvb, offset) >= 1) ia = tvb_get_uint8(tvb, offset + 0);
60
0
    if (tvb_captured_length_remaining(tvb, offset) >= 2) ta = tvb_get_uint8(tvb, offset + 1);
61
62
0
    if (ia == 0x83 || ia == 0x43 || ia == GA) { /* if it's an FPGA or 'corresponsdance code' 'go ahead'... */
63
0
        if (tvb_captured_length_remaining(tvb, offset) > 2) { /* if the msg is long, it must have been a 'poll' */
64
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "Poll IA: %2.2X", ta);
65
0
        } else { /* if it's short, then it was a 'no traffic' response */
66
0
            if (tvb_captured_length_remaining(tvb, offset) >= 2 ) {
67
0
                col_add_fstr(pinfo->cinfo, COL_INFO, "GoAhead NextIA (0x%2.2X)", ta);
68
0
            } else {
69
0
                col_set_str(pinfo->cinfo, COL_INFO, "GoAhead NextIA");
70
0
            }
71
0
        }
72
0
    } else { /* if it's not a 'go ahead'... it must be some kind of data message */
73
0
        ia &= 0x3f;
74
0
        ta &= 0x3f;
75
0
        if (ta == 0x20) {
76
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "Reset IA: %2.2X", ia); /* the TA character was the 'reset' command */
77
0
        }
78
0
        if (tvb_captured_length_remaining(tvb, offset) >= 3) cmd = tvb_get_uint8(tvb, offset + 2) & 0x3f;   /* get the first two bytes of the data message */
79
0
        if (tvb_captured_length_remaining(tvb, offset) >= 4) la  = tvb_get_uint8(tvb, offset + 3) & 0x3f;
80
0
        if (cmd == 0x1f && la == 0x38) {
81
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "Please Resend - IA: %2.2X TA: %2.2X", ia, ta); /* light the resend indicator */
82
0
        } else if (cmd == 0x2a && la == 0x05) {
83
0
            col_add_fstr(pinfo->cinfo, COL_INFO, "Unsolicited Msg Indicator - IA: %2.2X TA: %2.2X", ia, ta);    /* light the unsolicited msg indicator */
84
0
        } else {
85
0
            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 */
86
0
        }
87
0
    }
88
89
0
    bytes = tvb_captured_length_remaining(tvb, 0);
90
0
    if (bytes > 0) {
91
0
        proto_tree  *ipars_tree;
92
0
        proto_item  *ti;
93
94
0
        ia = tvb_get_uint8(tvb, 0) & 0x3f;
95
96
0
        ti = proto_tree_add_protocol_format(tree, proto_ipars, tvb, 0, -1, "Ipars");
97
0
        ipars_tree = proto_item_add_subtree(ti, ett_ipars);
98
99
0
        if (ia == 0x03) {
100
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "GoAhead Next IA");
101
0
            col_set_str(pinfo->cinfo, COL_INFO, "GoAhead");
102
0
            return tvb_captured_length(tvb);
103
0
        } else if (ia != S1) {
104
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
105
0
                0,
106
0
                bytes, "Unknown format - Data (%d byte%s)", bytes,
107
0
                plurality(bytes, "", "s"));
108
0
            return tvb_captured_length(tvb);
109
0
        }
110
0
        proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 0, 1, "S1");
111
0
        ia = tvb_get_uint8(tvb, 1) & 0x3f;
112
0
        if (ia != S2) {
113
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb,
114
0
                0,
115
0
                bytes, "Unknown format - Data (%d byte%s)", bytes,
116
0
                plurality(bytes, "", "s"));
117
0
                return tvb_captured_length(tvb);
118
0
        }
119
0
        proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 1, 1, "S2");
120
0
        ia = tvb_get_uint8(tvb, 2) & 0x3f;
121
0
        if (ia == GA) {
122
0
            ia = tvb_get_uint8(tvb, 3) & 0x3f;
123
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 2, 2, "GoAhead IA: %2.2X", ia);
124
0
            ipars_eomtype = tvb_get_uint8(tvb, 4) & 0x3f;
125
0
            switch (ipars_eomtype) {
126
0
                case EOMc:  snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMc");                              break;
127
0
                case EOMi:  snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMi");                              break;
128
0
                case EOMu:  snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMu");                              break;
129
0
                case EOMpb: snprintf(eom_msg, MAX_EOM_MSG_SIZE, "EOMpb");                             break;
130
0
                default:    snprintf(eom_msg, MAX_EOM_MSG_SIZE, "Unknown EOM type (0x%2.2X)", ipars_eomtype);    break;
131
0
            }
132
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 4, 1, "%s", eom_msg);
133
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, tvb, 5, 1, "Good BCC");
134
0
        } else {
135
0
            next_tvb = tvb_new_subset_remaining(tvb, 3);
136
0
            bytes = tvb_captured_length(next_tvb);
137
0
            proto_tree_add_protocol_format(ipars_tree, proto_ipars, next_tvb,
138
0
                0,
139
0
                bytes, "Data (%d byte%s)", bytes,
140
0
                plurality(bytes, "", "s"));
141
0
            return tvb_captured_length(tvb);
142
0
        }
143
0
    }
144
0
    return tvb_captured_length(tvb);
145
0
}
146
147
void
148
proto_register_ipars(void)
149
16
{
150
16
    static int *ett[] = {
151
16
        &ett_ipars,
152
16
    };
153
154
16
    proto_ipars = proto_register_protocol("International Passenger Airline Reservation System", "IPARS", "ipars");
155
16
    proto_register_subtree_array(ett, array_length(ett));
156
157
16
    register_dissector("ipars", dissect_ipars, proto_ipars);
158
16
}
159
160
/*
161
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
162
 *
163
 * Local variables:
164
 * c-basic-offset: 4
165
 * tab-width: 8
166
 * indent-tabs-mode: nil
167
 * End:
168
 *
169
 * vi: set shiftwidth=4 tabstop=8 expandtab:
170
 * :indentSize=4:tabSize=8:noTabs=true:
171
 */