Coverage Report

Created: 2026-09-28 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-ua.c
Line
Count
Source
1
/* packet-ua.c
2
 * Routines for UA/UDP (Universal Alcatel over UDP) packet dissection.
3
 * Copyright 2012, Alcatel-Lucent Enterprise <lars.ruoff@alcatel-lucent.com>
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
#include "config.h"
13
14
#include <epan/packet.h>
15
16
#include "packet-uaudp.h"
17
18
void proto_register_ua_msg(void);
19
void proto_reg_handoff_ua_msg(void);
20
/*-----------------------------------------------------------------------------
21
  GLOBALS
22
  ---------------------------------------------------------------------------*/
23
24
#if 0
25
static dissector_table_t ua_opcode_dissector_table;
26
#endif
27
28
static int  proto_ua_msg;
29
static int ett_ua_msg;
30
31
static dissector_handle_t noe_handle;
32
static dissector_handle_t ua3g_handle;
33
34
static void uadecode(e_ua_direction  direction,
35
                     proto_tree     *tree,
36
                     packet_info    *pinfo,
37
                     tvbuff_t       *tvb,
38
                     int             offset,
39
                     int             opcode,
40
                     int             length)
41
598
{
42
598
    switch (opcode & 0x7f) /* suppression of the CP bit */
43
598
    {
44
26
    case 0x15:
45
45
    case 0x16:
46
45
        {
47
45
            call_dissector(noe_handle,
48
45
                           tvb_new_subset_length(tvb, offset, length),
49
45
                           pinfo,
50
45
                           tree);
51
45
            break;
52
26
        }
53
28
    case 0x00:
54
38
    case 0x01:
55
40
    case 0x02:
56
49
    case 0x03:
57
51
    case 0x04:
58
53
    case 0x05:
59
55
    case 0x06:
60
60
    case 0x07:  /* Only UA NOE */
61
61
    case 0x08:  /* Only UA NOE */
62
62
    case 0x09:
63
63
    case 0x0A:
64
77
    case 0x0B:
65
80
    case 0x0C:
66
85
    case 0x0D:
67
85
    case 0x0E:
68
88
    case 0x0F:
69
89
    case 0x11:
70
90
    case 0x12:
71
361
    case 0x13:
72
361
    case 0x14:
73
366
    case 0x17:
74
368
    case 0x18:
75
372
    case 0x1F:  /* case 0x9F */
76
374
    case 0x20:
77
376
    case 0x21:
78
378
    case 0x22:
79
378
    case 0x23:
80
379
    case 0x24:  /* Only IP NOE */
81
380
    case 0x25:  /* Only IP NOE */
82
382
    case 0x26:
83
392
    case 0x27:
84
392
    case 0x28:
85
394
    case 0x29:
86
397
    case 0x2A:
87
402
    case 0x2B:  /* Only UA NOE */
88
406
    case 0x2C:
89
408
    case 0x2D:
90
408
    case 0x2E:
91
410
    case 0x30:
92
412
    case 0x31:
93
414
    case 0x32:  /* Only UA NOE */
94
417
    case 0x33:
95
419
    case 0x35:
96
425
    case 0x36:  /* IP Phone */
97
426
    case 0x38:
98
427
    case 0x39:
99
428
    case 0x3A:
100
429
    case 0x3B:
101
449
    case 0x3C:
102
451
    case 0x3D:
103
455
    case 0x3E:
104
455
    case 0x3F:
105
457
    case 0x40:
106
459
    case 0x41:
107
460
    case 0x42:
108
461
    case 0x43:
109
462
    case 0x44:
110
462
    case 0x45:
111
463
    case 0x46:
112
464
    case 0x47:
113
465
    case 0x48:
114
507
    case 0x49:
115
508
    case 0x4A:
116
509
    case 0x4B:
117
510
    case 0x4C:
118
511
    case 0x4D:
119
512
    case 0x4E:
120
516
    case 0x4F:
121
526
    case 0x50:  /* Only UA NOE */
122
526
        {
123
526
            call_dissector_with_data(ua3g_handle,
124
526
                       tvb_new_subset_length(tvb, offset, length),
125
526
                       pinfo,
126
526
                       tree, &direction);
127
526
            break;
128
516
        }
129
27
    default:
130
27
        {
131
            /* add text to the frame "INFO" column */
132
27
            col_append_fstr(pinfo->cinfo, COL_INFO, " - UA3G Message ERR: Opcode (0x%02x) Unknown", tvb_get_uint8(tvb, (offset + 2)));
133
134
27
            call_data_dissector(tvb_new_subset_length(tvb, offset, length),
135
27
                           pinfo,
136
27
                           tree);
137
27
            break;
138
516
        }
139
598
    }
140
598
}
141
142
143
144
/*-----------------------------------------------------------------------------
145
  UA DISSECTOR
146
  ---------------------------------------------------------------------------*/
147
static void _dissect_ua_msg(tvbuff_t       *tvb,
148
                            packet_info    *pinfo,
149
                            proto_tree     *tree,
150
                            e_ua_direction  direction)
151
498
{
152
498
    int         offset = 0;
153
498
    proto_item *ua_msg_item;
154
498
    proto_tree *ua_msg_tree;
155
156
498
    ua_msg_item = proto_tree_add_protocol_format(tree, proto_ua_msg, tvb, 0, -1,
157
498
        "Universal Alcatel Protocol, %s",
158
498
        ((direction == SYS_TO_TERM) ?
159
390
        "System -> Terminal" : "Terminal -> System"));
160
161
498
    ua_msg_tree = proto_item_add_subtree(ua_msg_item, ett_ua_msg);
162
163
1.09k
    while (tvb_offset_exists(tvb, offset))
164
601
    {
165
601
        int length = tvb_get_letohs(tvb, offset) + 2;
166
601
        int opcode = tvb_get_uint8(tvb, offset+2);
167
168
601
        uadecode(direction, ua_msg_tree, pinfo, tvb, offset, opcode, length);
169
170
601
        offset += length;
171
601
    }
172
498
}
173
174
175
static int dissect_ua_sys_to_term(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
176
390
{
177
390
    _dissect_ua_msg(tvb, pinfo, tree, SYS_TO_TERM);
178
390
    return tvb_captured_length(tvb);
179
390
}
180
181
static int dissect_ua_term_to_sys(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
182
108
{
183
108
    _dissect_ua_msg(tvb, pinfo, tree, TERM_TO_SYS);
184
108
    return tvb_captured_length(tvb);
185
108
}
186
187
188
/*-----------------------------------------------------------------------------
189
  DISSECTORS REGISTRATION FUNCTIONS
190
  ---------------------------------------------------------------------------*/
191
192
void proto_register_ua_msg(void)
193
16
{
194
16
    static int *ett[] =
195
16
    {
196
16
        &ett_ua_msg,
197
16
    };
198
199
    /* UA dissector registration */
200
16
    proto_ua_msg = proto_register_protocol("Universal Alcatel Protocol", "UA", "ua");
201
202
16
    register_dissector("ua_sys_to_term", dissect_ua_sys_to_term, proto_ua_msg);
203
16
    register_dissector("ua_term_to_sys", dissect_ua_term_to_sys, proto_ua_msg);
204
205
    /* Common subtree array registration */
206
16
    proto_register_subtree_array(ett, array_length(ett));
207
16
}
208
209
void proto_reg_handoff_ua_msg(void)
210
16
{
211
#if 0  /* Future */
212
    dissector_handle_t handle_ua_msg;
213
214
    /* hooking of UA on UAUDP */
215
    /* XXX: The following is NG since the same 'pattern' is added twice */
216
    handle_ua_msg = find_dissector("ua_sys_to_term");
217
    dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
218
219
    handle_ua_msg = find_dissector("ua_term_to_sys");
220
    dissector_add_uint("uaudp.opcode", UAUDP_DATA, handle_ua_msg);
221
222
    /* For hooking dissectors to UA */
223
    ua_opcode_dissector_table =
224
        register_dissector_table("ua.opcode",
225
                                 "ua.opcode",
226
                                 FT_UINT8,
227
                                 BASE_HEX);
228
229
230
#endif
231
16
    noe_handle  = find_dissector_add_dependency("noe", proto_ua_msg);
232
16
    ua3g_handle = find_dissector_add_dependency("ua3g", proto_ua_msg);
233
234
16
}
235
236
/*
237
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
238
 *
239
 * Local variables:
240
 * c-basic-offset: 4
241
 * tab-width: 8
242
 * indent-tabs-mode: nil
243
 * End:
244
 *
245
 * vi: set shiftwidth=4 tabstop=8 expandtab:
246
 * :indentSize=4:tabSize=8:noTabs=true:
247
 */