Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-cisco-sm.c
Line
Count
Source
1
/* packet-sm.c
2
 * Routines for Cisco Session Management Protocol dissection
3
 * Copyright 2004, Duncan Sargeant <dunc-ethereal@rcpt.to>
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
/*
13
 * This is basically a glue dissector for the Cisco SM protocol.  It sits
14
 * between the RUDP and MTP3 layers between SLTs and MGCs.
15
 *
16
 * A link to an overview of the technology :
17
 * http://www.cisco.com/en/US/products/sw/netmgtsw/ps4883/products_installation_and_configuration_guide_chapter09186a008010950a.html
18
 * Link showing debugs of the protocol:
19
 * http://www.cisco.com/univercd/cc/td/doc/product/access/sc/rel7/omts/omts_apb.htm#30052
20
 * Scroll down to Backhaul Debug Event/Cause/Reason Codes:
21
 * http://www.cisco.com/en/US/docs/ios-xml/ios/debug/command/s1/db-s2.html#GUID-83B6671D-B86F-4B41-819C-85D14F4AACAE
22
 * Free/Opensource implementation:
23
 * http://yate.null.ro/websvn/filedetails.php?repname=yate&path=%2Ftrunk%2Fmodules%2Fserver%2Fciscosm.cpp
24
 */
25
26
#include "config.h"
27
28
#include <epan/packet.h>
29
30
#define MESSAGE_TYPE_START              0
31
#define MESSAGE_TYPE_STOP               1
32
#define MESSAGE_TYPE_ACTIVE             2
33
#define MESSAGE_TYPE_STANDBY            3
34
#define MESSAGE_TYPE_Q_HOLD_INVOKE      4
35
#define MESSAGE_TYPE_Q_HOLD_RESPONSE    5
36
#define MESSAGE_TYPE_Q_RESUME_INVOKE    6
37
#define MESSAGE_TYPE_Q_RESUME_RESPONSE  7
38
#define MESSAGE_TYPE_Q_RESET_INVOKE     8
39
#define MESSAGE_TYPE_Q_RESET_RESPONSE   9
40
0
#define MESSAGE_TYPE_PDU                0x8000
41
42
void proto_register_sm(void);
43
void proto_reg_handoff_sm(void);
44
45
static const value_string sm_message_type_value[] = {
46
    { MESSAGE_TYPE_START,             "Start Message" },
47
    { MESSAGE_TYPE_STOP,              "Stop Message" },
48
    { MESSAGE_TYPE_ACTIVE,            "Active Message" },
49
    { MESSAGE_TYPE_STANDBY,           "Standby Message" },
50
    { MESSAGE_TYPE_Q_HOLD_INVOKE,     "Q_HOLD Invoke Message" },
51
    { MESSAGE_TYPE_Q_HOLD_RESPONSE,   "Q_HOLD Response Message" },
52
    { MESSAGE_TYPE_Q_RESUME_INVOKE,   "Q_RESUME Invoke Message" },
53
    { MESSAGE_TYPE_Q_RESUME_RESPONSE, "Q_RESUME Response Message" },
54
    { MESSAGE_TYPE_Q_RESET_INVOKE,    "Q_RESET Invoke Message" },
55
    { MESSAGE_TYPE_Q_RESET_RESPONSE,  "Q_RESET Response Message" },
56
    { MESSAGE_TYPE_PDU,               "PDU Message" },
57
    { 0, NULL }
58
};
59
60
static const value_string sm_message_type_value_info[] = {
61
    { MESSAGE_TYPE_START,             "Start" },
62
    { MESSAGE_TYPE_STOP,              "Stop" },
63
    { MESSAGE_TYPE_ACTIVE,            "Active" },
64
    { MESSAGE_TYPE_STANDBY,           "Standby" },
65
    { MESSAGE_TYPE_Q_HOLD_INVOKE,     "Q_HOLD Invoke" },
66
    { MESSAGE_TYPE_Q_HOLD_RESPONSE,   "Q_HOLD Response" },
67
    { MESSAGE_TYPE_Q_RESUME_INVOKE,   "Q_RESUME Invoke" },
68
    { MESSAGE_TYPE_Q_RESUME_RESPONSE, "Q_RESUME Response" },
69
    { MESSAGE_TYPE_Q_RESET_INVOKE,    "Q_RESET Invoke" },
70
    { MESSAGE_TYPE_Q_RESET_RESPONSE,  "Q_RESET Response" },
71
    { MESSAGE_TYPE_PDU,               "PDU" },
72
    { 0, NULL }
73
};
74
75
static const value_string sm_alignment_type[] = {
76
    { 0x00, "Unknown (probably linkset was already up)"},
77
    { 0x03, "Emergency alignment"},
78
    { 0x04, "Normal alignment"},
79
    { 0x05, "Power On MTP2"},
80
    { 0x06, "Start MTP2"},
81
    { 0, NULL}
82
};
83
84
static const value_string sm_backhaul_reason_code[] = {
85
    { 0x00, "Layer management request"},
86
    { 0x01, "SUERM (Signal Unit Error Monitor) failure"},
87
    { 0x02, "Excessively long alignment period"},
88
    { 0x03, "T7 timer expired"},
89
    { 0x04, "Physical interface failure"},
90
    { 0x05, "Two or three invalid BSNs"},
91
    { 0x06, "Two or three invalid FIBs"},
92
    { 0x07, "LSSU (Link Status Signal Unit) condition"},
93
    { 0x13, "SIOs (Service Information Octets) received "
94
            "in Link State Control (LSC)"},
95
    { 0x14, "Timer T2 expired waiting for SIO"},
96
    { 0x15, "Timer T3 expired waiting for SIE/SIN "},
97
    { 0x16, "SIO received in initial alignment control (IAC)"},
98
    { 0x17, "Proving period failure"},
99
    { 0x18, "Timer T1 expired waiting for FISU (Fill-In Signal Unit)"},
100
    { 0x19, "SIN received in the in-service state"},
101
    { 0x20, "CTS lost"},
102
    { 0x25, "No resources"},
103
    {    0, NULL}
104
};
105
106
static const value_string sm_backhaul_event_code[] = {
107
    { 0x00, "Local processor outage"},
108
    { 0x01, "Local processor outage recovered"},
109
    { 0x02, "Entered a congested state"},
110
    { 0x03, "Exited a congested state"},
111
    { 0x04, "Physical layer up"},
112
    { 0x05, "Physical layer down"},
113
    { 0x06, "Protocol error"},
114
    { 0x07, "Link is aligned"},
115
    { 0x08, "Link alignment lost"},
116
    { 0x09, "Retransmit buffer full"},
117
    { 0x0a, "Retransmit buffer no longer full"},
118
    { 0x0b, "Negative acknowledgment"},
119
    { 0x0c, "Remote entered congestion"},
120
    { 0x0d, "Remote exited congestion"},
121
    { 0x0e, "Remote entered processor outage"},
122
    { 0x0f, "Remote exited processor outage"},
123
    {    0, NULL}
124
};
125
126
static const value_string sm_backhaul_cause_code[] = {
127
    { 0x00, "Unknown (default)"},
128
    { 0x01, "Management initiated"},
129
    { 0x02, "Abnormal BSN (backward sequence number)"},
130
    { 0x03, "Abnormal FIB (Forward Indicator Bit)"},
131
    { 0x04, "Congestion discard"},
132
    {    0, NULL}
133
};
134
135
static const value_string sm_linkdown_cause_code[] = {
136
    { 0x00, "Unknown (default)"},
137
    { 0x01, "Management initiated"},
138
    { 0x03, "Congestion ended"},
139
    {    0, NULL}
140
};
141
142
static const value_string sm_retrieval_type[] = {
143
    { 0x01, "Request for BSN"},
144
    { 0x02, "Request for MSUs"},
145
    { 0x03, "Request to drop MSUs"},
146
    {    0, NULL}
147
};
148
149
static const value_string sm_lsc_state_type[] = {
150
    { 0x00, "Set LPO"},
151
    { 0x01, "Clear LPO"},
152
    { 0x02, "Set Emergency"},
153
    { 0x03, "Clear Emergency"},
154
    { 0x04, "Clear Buffers"},
155
    { 0x05, "Clear Transmit Buffer"},
156
    { 0x06, "Clear ReTransmission Buffer"},
157
    { 0x07, "Clear Receive Buffer"},
158
    { 0x08, "Continue"},
159
    { 0x09, "Power On"},
160
    { 0x0a, "Start"},
161
    { 0x0b, "Stop"},
162
    {    0, NULL}
163
};
164
165
static const value_string sm_stat_request_type[] = {
166
    { 0x00, "Reset"},
167
    { 0x01, "Send & Reset"},
168
    { 0x02, "Send"},
169
    {    0, NULL}
170
};
171
172
0
#define PDU_CONNECT_REQUEST       0x06
173
0
#define PDU_CONNECT_CONFIRM       0x07
174
0
#define PDU_DISCONNECT_CONFIRM    0x0b
175
0
#define PDU_DISCONNECT_INDICATION 0x0c
176
0
#define PDU_MTP3_TO_SLT           0x10
177
0
#define PDU_MTP3_FROM_SLT         0x11
178
0
#define PDU_RETRIEVAL_REQUEST     0x12
179
0
#define PDU_RETRIEVAL_CONFIRM     0x13
180
0
#define PDU_LSC_REQUEST           0x20
181
0
#define PDU_LSC_CONFIRM           0x21
182
0
#define PDU_LSC_INDICATION        0x22
183
0
#define PDU_STAT_REQUEST          0x44
184
185
static const value_string sm_pdu_type_value[] = {
186
    { PDU_CONNECT_REQUEST,       "Connect Request"},
187
    { PDU_CONNECT_CONFIRM,       "Connect Confirm"},
188
    { 0x0a,                      "Disconnect Request"},
189
    { PDU_DISCONNECT_CONFIRM,    "Disconnect Confirm"},
190
    { PDU_DISCONNECT_INDICATION, "Disconnect Indication Message"},
191
    { PDU_MTP3_TO_SLT,           "MSU Request (message to MTP2 link)"},
192
    { PDU_MTP3_FROM_SLT,         "MSU Indication (message from MTP2 link)"},
193
    { PDU_RETRIEVAL_REQUEST,     "Retrieval Request"},
194
    { PDU_RETRIEVAL_CONFIRM,     "Retrieval Confirm"},
195
    { 0x14,                      "Retrieval Indication"},
196
    { 0x15,                      "Retrieval Message"},
197
    { PDU_LSC_REQUEST,           "Link State Controller Request"},
198
    { PDU_LSC_CONFIRM,           "Link State Controller Confirm"},
199
    { PDU_LSC_INDICATION,        "Link State Controller Indication"},
200
    { 0x40,                      "Configuration Request"},
201
    { 0x41,                      "Configuration Confirm"},
202
    { 0x42,                      "Status Request"},
203
    { 0x43,                      "Status Confirm"},
204
    { PDU_STAT_REQUEST,          "Statistic Request"},
205
    { 0x45,                      "Statistic Confirm"},
206
    { 0x46,                      "Control Request"},
207
    { 0x47,                      "Control Confirm"},
208
    { 0x50,                      "Flow Control Request"},
209
    { 0x51,                      "Flow Control Indication"},
210
    { 0,                    NULL }
211
};
212
213
/* TODO: Change to useful name once known */
214
0
#define SM_PROTOCOL_X004 0x0004 /* https://gitlab.com/wireshark/wireshark/-/issues/7188 */
215
/* RUDP/SM stack called BSM V1 (version 1 versus Version 0 used for SS7). */
216
0
#define SM_PROTOCOL_X100 0x0100
217
0
#define SM_PROTOCOL_X101 0x0101
218
0
#define SM_PROTOCOL_X114 0x0114
219
0
#define SM_PROTOCOL_X122 0x0122
220
221
222
/* Initialize the protocol and registered fields */
223
static int proto_sm;
224
225
static int hf_sm_sm_msg_type;
226
static int hf_sm_protocol;
227
static int hf_sm_msg_id;
228
static int hf_sm_msg_type;
229
static int hf_sm_channel;
230
static int hf_sm_bearer;
231
static int hf_sm_len;
232
static int hf_sm_ip_addr;
233
static int hf_sm_context;
234
static int hf_sm_eisup_msg_id;
235
static int hf_sm_tag;
236
static int hf_sm_alignment_type;
237
static int hf_sm_backhaul_reason_code;
238
static int hf_sm_backhaul_event_code;
239
static int hf_sm_backhaul_cause_code;
240
static int hf_sm_linkdown_cause_code;
241
static int hf_sm_retrieval_type;
242
static int hf_sm_lsc_state_type;
243
static int hf_sm_stat_request_type;
244
static int hf_sm_bsn_num;
245
246
/* Initialize the subtree pointers */
247
static int ett_sm;
248
249
static dissector_handle_t sdp_handle;
250
static dissector_handle_t mtp3_handle;
251
static dissector_handle_t q931_handle;
252
253
/* Code to actually dissect the packets */
254
static int
255
dissect_sm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
256
0
{
257
0
    proto_item *ti;
258
0
    proto_tree *sm_tree;
259
0
    tvbuff_t   *next_tvb      = NULL;
260
0
    uint32_t    sm_message_type;
261
0
    uint32_t    bh_event_code = 0;
262
0
    uint16_t    protocol;
263
0
    uint16_t    msg_type      = 0;
264
0
    uint16_t    length;
265
0
    uint16_t    tag;
266
0
    int         offset        = 0;
267
268
0
    sm_message_type = tvb_get_ntohl(tvb,offset);
269
270
0
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "SM");
271
272
0
    col_add_fstr(pinfo->cinfo, COL_INFO, "Cisco SM Packet (%s)",
273
0
        val_to_str_const(sm_message_type, sm_message_type_value_info,"reserved"));
274
275
0
    ti = proto_tree_add_item(tree, proto_sm, tvb, offset, -1, ENC_NA);
276
0
    sm_tree = proto_item_add_subtree(ti, ett_sm);
277
278
0
    proto_tree_add_uint_format_value(sm_tree, hf_sm_sm_msg_type, tvb, offset, 4, sm_message_type,
279
0
        "%s (0x%0x)", val_to_str_const(sm_message_type, sm_message_type_value, "reserved"), sm_message_type);
280
281
0
    offset = offset + 4;
282
0
    if (sm_message_type ==  MESSAGE_TYPE_PDU) {
283
0
        proto_tree_add_item(sm_tree, hf_sm_protocol, tvb, offset, 2, ENC_BIG_ENDIAN);
284
0
        protocol = tvb_get_ntohs(tvb,offset);
285
0
        offset = offset + 2;
286
0
        switch(protocol){
287
        /* start case RUDP BSM v.1  ---------------------------------------------------------- */
288
0
        case SM_PROTOCOL_X004:
289
0
            proto_tree_add_item(sm_tree, hf_sm_msg_id, tvb, offset, 2, ENC_BIG_ENDIAN);
290
0
            offset = offset +2;
291
0
            msg_type = tvb_get_ntohs(tvb,offset);
292
0
            proto_tree_add_uint_format_value(sm_tree, hf_sm_msg_type, tvb, offset, 2, msg_type,
293
0
                "%s (0x%0x)", val_to_str_const(msg_type, sm_pdu_type_value, "reserved"),
294
0
                msg_type);
295
0
            msg_type = tvb_get_ntohs(tvb,offset);
296
0
            offset = offset + 2;
297
0
            proto_tree_add_item(sm_tree, hf_sm_channel, tvb, offset, 2, ENC_BIG_ENDIAN);
298
0
            offset = offset + 2;
299
0
            proto_tree_add_item(sm_tree, hf_sm_bearer, tvb, offset, 2, ENC_BIG_ENDIAN);
300
0
            offset = offset +2;
301
0
            proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
302
0
            length = tvb_get_ntohs(tvb,offset);
303
0
            offset = offset +2;
304
0
            proto_item_set_len(ti, 16);
305
306
0
            if (length > 0) {
307
0
                next_tvb = tvb_new_subset_length(tvb, offset, length);
308
309
0
                if ((msg_type == PDU_MTP3_TO_SLT || msg_type == PDU_MTP3_FROM_SLT)) {
310
0
                    call_dissector(q931_handle, next_tvb, pinfo, tree);
311
0
                } else {
312
0
                    call_data_dissector(next_tvb, pinfo, tree);
313
0
                }
314
0
            }
315
316
0
            break;
317
            /* end case RUDP BSM v.1 ---------------------------------------------------------- */
318
319
0
        case SM_PROTOCOL_X100:
320
0
        case SM_PROTOCOL_X122:
321
            /* Protocol 0x100/0x122 only contains a length and then an EISUP packet */
322
0
            proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
323
0
            length = tvb_get_ntohs(tvb,offset);
324
0
            offset = offset + 2;
325
0
            proto_item_set_len(ti, 8);
326
327
            /* This should be the EISUP dissector but we haven't got one
328
             * right now - so decode it as data for now ... */
329
0
            next_tvb = tvb_new_subset_length(tvb, offset, length);
330
0
            call_data_dissector(next_tvb, pinfo, sm_tree);
331
332
0
            break;
333
0
        case SM_PROTOCOL_X101:
334
            /* XXX Reverse engineered so this may not be correct!!!
335
             * EISUP - used between Cisco HSI and Cisco PGW devices,
336
             * uses RUDP with default port number 8003.
337
             * Protocol stack is RUDP->Cisco SM->SDP.
338
             * This implementation is PROPRIETARY
339
             */
340
0
            proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
341
0
            length = tvb_get_ntohs(tvb,offset);
342
0
            offset = offset + 2;
343
0
            proto_item_set_len(ti, length + offset);
344
            /* The next stuff seems to be IP addr */
345
0
            proto_tree_add_item(sm_tree, hf_sm_ip_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
346
0
            offset = offset + 4;
347
            /* This part looks to be the same per session */
348
0
            proto_tree_add_item(sm_tree, hf_sm_context, tvb, offset, 4, ENC_BIG_ENDIAN);
349
0
            offset = offset +4;
350
            /* Some sort of message type? */
351
0
            proto_tree_add_item(sm_tree, hf_sm_eisup_msg_id, tvb, offset, 1, ENC_BIG_ENDIAN);
352
0
            offset = offset + 1;
353
            /* XXX Problem are tags 1 or two bytes???*/
354
0
            proto_tree_add_item(sm_tree, hf_sm_tag, tvb, offset, 2, ENC_BIG_ENDIAN);
355
356
0
            tag = tvb_get_ntohs(tvb,offset);
357
0
            offset = offset +2;
358
0
            if (tag== 0x01ac) {
359
0
                proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
360
0
                length = tvb_get_ntohs(tvb,offset);
361
0
                offset = offset +2;
362
0
                next_tvb = tvb_new_subset_length(tvb, offset, length);
363
0
                call_dissector(sdp_handle, next_tvb, pinfo, sm_tree);
364
                /*offset = offset+length;*/
365
366
0
            }
367
            /*return;*/
368
0
            break;
369
0
        case SM_PROTOCOL_X114:
370
            /* XXX Reverse enginered so this may not be correct!!! */
371
0
            proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
372
0
            length = tvb_get_ntohs(tvb,offset);
373
0
            offset = offset + 2;
374
0
            proto_item_set_len(ti, length + offset);
375
            /* The next stuff seems to be IP addr */
376
0
            proto_tree_add_item(sm_tree, hf_sm_ip_addr, tvb, offset, 4, ENC_BIG_ENDIAN);
377
0
            offset = offset + 4;
378
0
            proto_tree_add_item(sm_tree, hf_sm_context, tvb, offset, 4, ENC_BIG_ENDIAN);
379
0
            offset = offset +4;
380
            /* Some sort of message type? */
381
0
            proto_tree_add_item(sm_tree, hf_sm_eisup_msg_id, tvb, offset, 1, ENC_BIG_ENDIAN);
382
0
            offset = offset + 1;
383
            /* XXX Problem are tags 1 or two bytes???*/
384
0
            proto_tree_add_item(sm_tree, hf_sm_tag, tvb, offset, 2, ENC_BIG_ENDIAN);
385
386
0
            tag = tvb_get_ntohs(tvb,offset);
387
0
            offset = offset +2;
388
0
            if (tag== 0x01ac) {
389
0
                proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
390
0
                length = tvb_get_ntohs(tvb,offset);
391
0
                offset = offset +2;
392
0
                next_tvb = tvb_new_subset_length(tvb, offset, length);
393
0
                call_dissector(sdp_handle, next_tvb, pinfo, sm_tree);
394
                /*offset = offset+length;*/
395
396
0
            }
397
0
            break;
398
0
        default:
399
0
            proto_tree_add_item(sm_tree, hf_sm_msg_id, tvb, offset, 2, ENC_BIG_ENDIAN);
400
0
            offset = offset +2;
401
0
            msg_type = tvb_get_ntohs(tvb,offset);
402
0
            proto_tree_add_uint_format_value(sm_tree, hf_sm_msg_type, tvb, offset, 2, msg_type,
403
0
                "%s (0x%0x)", val_to_str_const(msg_type, sm_pdu_type_value, "reserved"),
404
0
                msg_type);
405
0
            msg_type = tvb_get_ntohs(tvb,offset);
406
0
            offset = offset + 2;
407
0
            proto_tree_add_item(sm_tree, hf_sm_channel, tvb, offset, 2, ENC_BIG_ENDIAN);
408
0
            offset = offset + 2;
409
0
            proto_tree_add_item(sm_tree, hf_sm_bearer, tvb, offset, 2, ENC_BIG_ENDIAN);
410
0
            offset = offset +2;
411
0
            proto_tree_add_item(sm_tree, hf_sm_len, tvb, offset, 2, ENC_BIG_ENDIAN);
412
0
            length = tvb_get_ntohs(tvb,offset);
413
0
            offset = offset +2;
414
0
            proto_item_set_len(ti, 16);
415
416
0
            if (length > 0) {
417
0
                next_tvb = tvb_new_subset_length(tvb, offset, length);
418
419
0
                switch (msg_type) {
420
0
                case PDU_MTP3_TO_SLT:
421
0
                case PDU_MTP3_FROM_SLT:
422
0
                    call_dissector(mtp3_handle, next_tvb, pinfo, tree);
423
0
                    break;
424
0
                case PDU_CONNECT_REQUEST:
425
0
                case PDU_CONNECT_CONFIRM:
426
0
                    proto_tree_add_item(sm_tree, hf_sm_alignment_type, tvb, offset, 4, ENC_BIG_ENDIAN);
427
0
                    break;
428
0
                case PDU_DISCONNECT_CONFIRM:
429
0
                case PDU_DISCONNECT_INDICATION:
430
0
                    proto_tree_add_item(sm_tree, hf_sm_backhaul_reason_code, tvb, offset, 4, ENC_BIG_ENDIAN);
431
0
                    break;
432
0
                case PDU_RETRIEVAL_REQUEST:
433
0
                case PDU_RETRIEVAL_CONFIRM:
434
0
                    proto_tree_add_item(sm_tree, hf_sm_retrieval_type, tvb, offset, 4, ENC_BIG_ENDIAN);
435
0
                    if (msg_type == PDU_RETRIEVAL_CONFIRM && tvb_get_ntohl(tvb,offset) == 0x01) {
436
0
                        offset += 4;
437
0
                        proto_tree_add_item(sm_tree, hf_sm_bsn_num, tvb, offset, 4, ENC_BIG_ENDIAN);
438
0
                    }
439
0
                    break;
440
0
                case PDU_LSC_REQUEST:
441
0
                case PDU_LSC_CONFIRM:
442
0
                    proto_tree_add_item(sm_tree, hf_sm_lsc_state_type, tvb, offset, 4, ENC_BIG_ENDIAN);
443
0
                    break;
444
0
                case PDU_LSC_INDICATION:
445
0
                    proto_tree_add_item(sm_tree, hf_sm_backhaul_event_code, tvb, offset, 4, ENC_BIG_ENDIAN);
446
0
                    bh_event_code = tvb_get_ntohl(tvb,offset);
447
0
                    if (bh_event_code == 0x02 || bh_event_code == 0x04) {
448
0
                        offset += 4;
449
0
                        proto_tree_add_item(sm_tree, hf_sm_linkdown_cause_code, tvb, offset, 4, ENC_BIG_ENDIAN);
450
0
                    } else if (bh_event_code == 0x06) {
451
0
                        offset += 4;
452
0
                        proto_tree_add_item(sm_tree, hf_sm_backhaul_cause_code, tvb, offset, 4, ENC_BIG_ENDIAN);
453
0
                    }
454
0
                    break;
455
0
                case PDU_STAT_REQUEST:
456
0
                    proto_tree_add_item(sm_tree, hf_sm_stat_request_type, tvb, offset, 4, ENC_BIG_ENDIAN);
457
0
                    break;
458
0
                default:
459
0
                    call_data_dissector(next_tvb, pinfo, tree);
460
0
                }
461
0
            }
462
0
        }
463
0
    }
464
465
0
    return tvb_captured_length(tvb);
466
0
}
467
468
void
469
proto_register_sm(void)
470
14
{
471
14
    static hf_register_info hf[] = {
472
14
        { &hf_sm_sm_msg_type,
473
14
            { "SM Message Type",           "sm.sm_msg_type",
474
14
            FT_UINT32, BASE_HEX, NULL, 0x0,
475
14
            NULL, HFILL }
476
14
        },
477
14
        { &hf_sm_protocol,
478
14
            { "Protocol Type",           "sm.protocol",
479
14
            FT_UINT16, BASE_HEX, NULL, 0x0,
480
14
            NULL, HFILL }
481
14
        },
482
14
        { &hf_sm_msg_id,
483
14
            { "Message ID",           "sm.msgid",
484
14
            FT_UINT16, BASE_HEX, NULL, 0x0,
485
14
            NULL, HFILL }
486
14
        },
487
14
        { &hf_sm_msg_type,
488
14
            { "Message Type",           "sm.msg_type",
489
14
            FT_UINT16, BASE_HEX, NULL, 0x0,
490
14
            NULL, HFILL }
491
14
        },
492
14
        { &hf_sm_channel,
493
14
            { "Channel ID",           "sm.channel",
494
14
            FT_UINT16, BASE_HEX, NULL, 0x0,
495
14
            NULL, HFILL }
496
14
        },
497
14
        { &hf_sm_bearer,
498
14
            { "Bearer ID",           "sm.bearer",
499
14
            FT_UINT16, BASE_HEX, NULL, 0x0,
500
14
            NULL, HFILL }
501
14
        },
502
14
        { &hf_sm_len,
503
14
            { "Length",           "sm.len",
504
14
            FT_UINT16, BASE_DEC, NULL, 0x0,
505
14
            NULL, HFILL }
506
14
        },
507
14
        { &hf_sm_ip_addr,
508
14
            { "IPv4 address","sm.ip_addr",
509
14
            FT_IPv4,BASE_NONE,  NULL, 0x0,
510
14
            NULL, HFILL }
511
14
        },
512
14
        { &hf_sm_context,
513
14
            { "Context","sm.context",
514
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
515
14
            "Context(guesswork!)", HFILL }
516
14
        },
517
14
        { &hf_sm_eisup_msg_id,
518
14
            { "Message id","sm.eisup_message_id",
519
14
            FT_UINT8, BASE_DEC, NULL, 0x0,
520
14
            "Message id(guesswork!)", HFILL }
521
14
        },
522
14
        { &hf_sm_tag,
523
14
            { "Tag","sm.tag",
524
14
            FT_UINT16, BASE_DEC, NULL, 0x0,
525
14
            "Tag(guesswork!)", HFILL }
526
14
        },
527
14
        { &hf_sm_alignment_type,
528
14
          { "Alignment type","sm.connect_type",
529
14
            FT_UINT32, BASE_HEX, VALS(sm_alignment_type), 0x0,
530
14
            NULL, HFILL }
531
14
        },
532
14
        { &hf_sm_backhaul_reason_code,
533
14
          { "Backhaul reason code","sm.backhaul_reason",
534
14
            FT_UINT32, BASE_HEX, VALS(sm_backhaul_reason_code), 0x0,
535
14
            NULL, HFILL }
536
14
        },
537
14
        { &hf_sm_backhaul_event_code,
538
14
          { "Backhaul event code","sm.backhaul_event",
539
14
            FT_UINT32, BASE_HEX, VALS(sm_backhaul_event_code), 0x0,
540
14
                        NULL, HFILL }
541
14
        },
542
14
        { &hf_sm_backhaul_cause_code,
543
14
          { "Backhaul cause code","sm.backhaul_cause",
544
14
            FT_UINT32, BASE_HEX, VALS(sm_backhaul_cause_code), 0x0,
545
14
            NULL, HFILL }
546
14
        },
547
14
        { &hf_sm_linkdown_cause_code,
548
14
          { "Link down cause","sm.linkdown_reason",
549
14
            FT_UINT32, BASE_HEX, VALS(sm_linkdown_cause_code), 0x0,
550
14
            NULL, HFILL }
551
14
        },
552
553
14
        { &hf_sm_retrieval_type,
554
14
          { "Retrieval type","sm.retrieval_type",
555
14
            FT_UINT32, BASE_HEX, VALS(sm_retrieval_type), 0x0,
556
14
            NULL, HFILL }
557
14
        },
558
14
        { &hf_sm_lsc_state_type,
559
14
          { "LSC Request type","sm.lsc_state_type",
560
14
            FT_UINT32, BASE_HEX, VALS(sm_lsc_state_type), 0x0,
561
14
            NULL, HFILL }
562
14
        },
563
14
        { &hf_sm_stat_request_type,
564
14
          { "Statistic request type","sm.stat_request_type",
565
14
            FT_UINT32, BASE_HEX, VALS(sm_stat_request_type), 0x0,
566
14
            NULL, HFILL }
567
14
        },
568
14
        { &hf_sm_bsn_num,
569
14
          { "BSN","sm.bsn_num",
570
14
            FT_UINT32, BASE_DEC, NULL, 0x0,
571
14
            NULL, HFILL }
572
14
        },
573
574
14
    };
575
576
/* Setup protocol subtree array */
577
14
    static int *ett[] = {
578
14
        &ett_sm,
579
14
    };
580
581
/* Register the protocol name and description */
582
14
    proto_sm = proto_register_protocol("Cisco Session Management",
583
14
        "SM", "sm");
584
585
14
    register_dissector("sm", dissect_sm, proto_sm);
586
587
/* Required function calls to register the header fields and subtrees used */
588
14
    proto_register_field_array(proto_sm, hf, array_length(hf));
589
14
    proto_register_subtree_array(ett, array_length(ett));
590
14
}
591
592
void
593
proto_reg_handoff_sm(void)
594
14
{
595
14
    sdp_handle  = find_dissector_add_dependency("sdp", proto_sm);
596
14
    mtp3_handle = find_dissector_add_dependency("mtp3", proto_sm);
597
14
    q931_handle = find_dissector_add_dependency("q931", proto_sm);
598
14
}
599
600
/*
601
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
602
 *
603
 * Local variables:
604
 * c-basic-offset: 4
605
 * tab-width: 8
606
 * indent-tabs-mode: nil
607
 * End:
608
 *
609
 * vi: set shiftwidth=4 tabstop=8 expandtab:
610
 * :indentSize=4:tabSize=8:noTabs=true:
611
 */