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-smpp.c
Line
Count
Source
1
/* packet-smpp.c
2
 * Routines for Short Message Peer to Peer dissection
3
 * Copyright 2001, Tom Uijldert.
4
 *
5
 * Data Coding Scheme decoding for GSM (SMS and CBS),
6
 * provided by Olivier Biot.
7
 *
8
 * Dissection of multiple SMPP PDUs within one packet
9
 * provided by Chris Wilson.
10
 *
11
 * Statistics support using Stats Tree API
12
 * provided by Abhik Sarkar
13
 *
14
 * Support for SMPP 5.0
15
 * introduced by Abhik Sarkar
16
 *
17
 * Support for Huawei SMPP+ extensions
18
 * introduced by Xu Bo and enhanced by Abhik Sarkar
19
 *
20
 * Enhanced error code handling
21
 * provided by Stipe Tolj from Kannel.
22
 *
23
 * Refer to the AUTHORS file or the AUTHORS section in the man page
24
 * for contacting the author(s) of this file.
25
 *
26
 * Wireshark - Network traffic analyzer
27
 * By Gerald Combs <gerald@wireshark.org>
28
 * Copyright 1998 Gerald Combs
29
 *
30
 * SPDX-License-Identifier: GPL-2.0-or-later
31
 *
32
 * ----------
33
 *
34
 * Dissector of an SMPP (Short Message Peer to Peer) PDU, as defined by the
35
 * SMS forum (www.smsforum.net) in "SMPP protocol specification v3.4"
36
 * (document version: 12-Oct-1999 Issue 1.2)
37
 */
38
39
#include "config.h"
40
41
#include <errno.h>
42
43
#include <epan/packet.h>
44
#include <epan/expert.h>
45
#include <epan/exceptions.h>
46
#include <epan/stats_tree.h>
47
#include <epan/prefs.h>
48
#include <epan/exported_pdu.h>
49
#include <epan/conversation.h>
50
#include <epan/proto_data.h>
51
#include <wsutil/time_util.h>
52
#include "packet-tcp.h"
53
#include "packet-tls.h"
54
#include "packet-smpp.h"
55
#include <epan/strutil.h>
56
57
8.82k
#define SMPP_FIXED_HEADER_LENGTH  16
58
4.65k
#define SMPP_MIN_LENGTH SMPP_FIXED_HEADER_LENGTH
59
60
/* Forward declarations         */
61
void proto_register_smpp(void);
62
void proto_reg_handoff_smpp(void);
63
64
static int exported_pdu_tap = -1;
65
66
/*
67
 * Initialize the protocol and registered fields
68
 *
69
 * Fixed header section
70
 */
71
static int proto_smpp;
72
73
static int st_smpp_ops                                = -1;
74
static int st_smpp_req                                = -1;
75
static int st_smpp_res                                = -1;
76
static int st_smpp_res_status                         = -1;
77
78
static int hf_smpp_command_id;
79
static int hf_smpp_command_request;
80
static int hf_smpp_command_response;
81
static int hf_smpp_command_length;
82
static int hf_smpp_command_status;
83
static int hf_smpp_sequence_number;
84
85
/*
86
 * Fixed body section
87
 */
88
static int hf_smpp_system_id;
89
static int hf_smpp_password;
90
static int hf_smpp_system_type;
91
static int hf_smpp_interface_version;
92
static int hf_smpp_addr_ton;
93
static int hf_smpp_addr_npi;
94
static int hf_smpp_address_range;
95
static int hf_smpp_service_type;
96
static int hf_smpp_source_addr_ton;
97
static int hf_smpp_source_addr_npi;
98
static int hf_smpp_source_addr;
99
static int hf_smpp_dest_addr_ton;
100
static int hf_smpp_dest_addr_npi;
101
static int hf_smpp_destination_addr;
102
static int hf_smpp_esm_submit_msg_mode;
103
static int hf_smpp_esm_submit_msg_type;
104
static int hf_smpp_esm_submit_features;
105
static int hf_smpp_protocol_id;
106
static int hf_smpp_priority_flag;
107
static int hf_smpp_schedule_delivery_time;
108
static int hf_smpp_schedule_delivery_time_r;
109
static int hf_smpp_validity_period;
110
static int hf_smpp_validity_period_r;
111
static int hf_smpp_regdel_receipt;
112
static int hf_smpp_regdel_acks;
113
static int hf_smpp_regdel_notif;
114
static int hf_smpp_replace_if_present_flag;
115
static int hf_smpp_data_coding;
116
static int hf_smpp_sm_default_msg_id;
117
static int hf_smpp_sm_length;
118
static int hf_smpp_short_message;
119
static int hf_smpp_short_message_bin;
120
static int hf_smpp_message_id;
121
static int hf_smpp_dlist;
122
static int hf_smpp_dlist_resp;
123
static int hf_smpp_dl_name;
124
static int hf_smpp_final_date;
125
static int hf_smpp_final_date_r;
126
static int hf_smpp_message_state;
127
static int hf_smpp_error_code;
128
static int hf_smpp_error_status_code;
129
static int hf_smpp_esme_addr_ton;
130
static int hf_smpp_esme_addr_npi;
131
static int hf_smpp_esme_addr;
132
133
/*
134
 * Optional parameter section
135
 */
136
static int hf_smpp_opt_params;
137
static int hf_smpp_opt_param;
138
static int hf_smpp_opt_param_tag;
139
static int hf_smpp_opt_param_len;
140
static int hf_smpp_vendor_op;
141
static int hf_smpp_reserved_op;
142
143
static int hf_smpp_dest_addr_subunit;
144
static int hf_smpp_dest_network_type;
145
static int hf_smpp_dest_bearer_type;
146
static int hf_smpp_dest_telematics_id;
147
static int hf_smpp_source_addr_subunit;
148
static int hf_smpp_source_network_type;
149
static int hf_smpp_source_bearer_type;
150
static int hf_smpp_source_telematics_id;
151
static int hf_smpp_qos_time_to_live;
152
static int hf_smpp_payload_type;
153
static int hf_smpp_additional_status_info_text;
154
static int hf_smpp_receipted_message_id;
155
static int hf_smpp_msg_wait_ind;
156
static int hf_smpp_msg_wait_type;
157
static int hf_smpp_privacy_indicator;
158
static int hf_smpp_source_subaddress;
159
static int hf_smpp_dest_subaddress;
160
static int hf_smpp_user_message_reference;
161
static int hf_smpp_user_response_code;
162
static int hf_smpp_source_port;
163
static int hf_smpp_destination_port;
164
static int hf_smpp_sar_msg_ref_num;
165
static int hf_smpp_language_indicator;
166
static int hf_smpp_sar_total_segments;
167
static int hf_smpp_sar_segment_seqnum;
168
static int hf_smpp_SC_interface_version;
169
static int hf_smpp_callback_num_pres;
170
static int hf_smpp_callback_num_scrn;
171
static int hf_smpp_callback_num_atag;
172
static int hf_smpp_number_of_messages;
173
static int hf_smpp_callback_num;
174
static int hf_smpp_dpf_result;
175
static int hf_smpp_set_dpf;
176
static int hf_smpp_ms_availability_status;
177
static int hf_smpp_network_error_type;
178
static int hf_smpp_network_error_code;
179
static int hf_smpp_message_payload;
180
static int hf_smpp_delivery_failure_reason;
181
static int hf_smpp_more_messages_to_send;
182
static int hf_smpp_ussd_service_op;
183
static int hf_smpp_display_time;
184
static int hf_smpp_sms_signal;
185
static int hf_smpp_ms_validity;
186
static int hf_smpp_alert_on_message_delivery_null;
187
static int hf_smpp_alert_on_message_delivery_type;
188
static int hf_smpp_its_reply_type;
189
static int hf_smpp_its_session_number;
190
static int hf_smpp_its_session_sequence;
191
static int hf_smpp_its_session_ind;
192
193
/* Optional Parameters introduced in SMPP 5.0   */
194
static int hf_smpp_congestion_state;
195
static int hf_smpp_billing_identification;
196
static int hf_smpp_dest_addr_np_country;
197
static int hf_smpp_dest_addr_np_information;
198
static int hf_smpp_dest_addr_np_resolution;
199
static int hf_smpp_source_network_id;
200
static int hf_smpp_source_node_id;
201
static int hf_smpp_dest_network_id;
202
static int hf_smpp_dest_node_id;
203
/* Optional Parameters for Cell Broadcast Operations */
204
static int hf_smpp_broadcast_channel_indicator;
205
static int hf_smpp_broadcast_content_type_nw;
206
static int hf_smpp_broadcast_content_type_type;
207
static int hf_smpp_broadcast_content_type_info;
208
static int hf_smpp_broadcast_message_class;
209
static int hf_smpp_broadcast_rep_num;
210
static int hf_smpp_broadcast_frequency_interval_unit;
211
static int hf_smpp_broadcast_frequency_interval_value;
212
static int hf_smpp_broadcast_area_identifier;
213
static int hf_smpp_broadcast_area_identifier_format;
214
static int hf_smpp_broadcast_error_status;
215
static int hf_smpp_broadcast_area_success;
216
static int hf_smpp_broadcast_end_time;
217
static int hf_smpp_broadcast_end_time_r;
218
static int hf_smpp_broadcast_service_group;
219
220
/*
221
 * Data Coding Scheme section
222
 */
223
static int hf_smpp_dcs_sms_coding_group;
224
static int hf_smpp_dcs_reserved;
225
static int hf_smpp_dcs_charset;
226
static int hf_smpp_dcs_class;
227
static int hf_smpp_dcs_wait_ind;
228
static int hf_smpp_dcs_reserved2;
229
static int hf_smpp_dcs_wait_type;
230
231
/*
232
 * Huawei SMPP+ extensions
233
 */
234
static int hf_huawei_smpp_smsc_addr;
235
static int hf_huawei_smpp_msc_addr_noa;
236
static int hf_huawei_smpp_msc_addr_npi;
237
static int hf_huawei_smpp_msc_addr;
238
static int hf_huawei_smpp_mo_mt_flag;
239
static int hf_huawei_smpp_length_auth;
240
static int hf_huawei_smpp_sm_id;
241
static int hf_huawei_smpp_service_id;
242
static int hf_huawei_smpp_operation_result;
243
static int hf_huawei_smpp_notify_mode;
244
static int hf_huawei_smpp_delivery_result;
245
246
/*
247
 * Request/response tracking
248
 */
249
static int hf_smpp_response_in;
250
static int hf_smpp_request_in;
251
static int hf_smpp_response_time;
252
253
static expert_field ei_smpp_message_payload_duplicate;
254
static expert_field ei_smpp_date_time_decoding_failed;
255
256
/* Initialize the subtree pointers */
257
static int ett_smpp;
258
static int ett_dlist;
259
static int ett_dlist_resp;
260
static int ett_opt_params;
261
static int ett_opt_param;
262
static int ett_dcs;
263
264
static dissector_handle_t smpp_handle;
265
266
/* Reassemble SMPP TCP segments */
267
static bool reassemble_over_tcp = true;
268
static bool smpp_gsm7_unpacked = true;
269
270
typedef enum {
271
  DECODE_AS_DEFAULT    =   0,
272
  DECODE_AS_ASCII      =   1,
273
  DECODE_AS_OCTET      =   2, /* 8-bit binary */
274
  DECODE_AS_ISO_8859_1 =   3,
275
  DECODE_AS_ISO_8859_5 =   6,
276
  DECODE_AS_ISO_8859_8 =   7,
277
  DECODE_AS_UCS2       =   8,
278
  DECODE_AS_KSC5601    =  14, /* Korean, EUC-KR as in ANSI 637 */
279
  DECODE_AS_GSM7       = 241, /* One of many GSM DCS values that means GSM7 */
280
} SMPP_DCS_Type;
281
282
/* ENC_NA is the same as ENC_ASCII, so use an artificial value to mean
283
 * "treat this as 8-bit binary / FT_BYTES, not a string."
284
 */
285
32
#define DO_NOT_DECODE UINT_MAX
286
287
/* Default preference whether to decode the SMS over SMPP when DCS = 0 */
288
static int smpp_decode_dcs_0_sms = DO_NOT_DECODE;
289
290
/* Tap */
291
static int smpp_tap;
292
293
3
#define SMPP_COMMAND_ID_GENERIC_NACK        0x00000000
294
53
#define SMPP_COMMAND_ID_BIND_RECEIVER       0x00000001
295
61
#define SMPP_COMMAND_ID_BIND_TRANSMITTER    0x00000002
296
8
#define SMPP_COMMAND_ID_QUERY_SM            0x00000003
297
32
#define SMPP_COMMAND_ID_SUBMIT_SM           0x00000004
298
46
#define SMPP_COMMAND_ID_DELIVER_SM          0x00000005
299
5
#define SMPP_COMMAND_ID_UNBIND              0x00000006
300
10
#define SMPP_COMMAND_ID_REPLACE_SM          0x00000007
301
13
#define SMPP_COMMAND_ID_CANCEL_SM           0x00000008
302
67
#define SMPP_COMMAND_ID_BIND_TRANSCEIVER    0x00000009
303
7
#define SMPP_COMMAND_ID_OUTBIND             0x0000000B
304
5
#define SMPP_COMMAND_ID_ENQUIRE_LINK        0x00000015
305
50
#define SMPP_COMMAND_ID_SUBMIT_MULTI        0x00000021
306
7
#define SMPP_COMMAND_ID_ALERT_NOTIFICATION  0x00000102
307
1
#define SMPP_COMMAND_ID_DATA_SM             0x00000103
308
/* Introduced in SMPP 5.0 */
309
4
#define SMPP_COMMAND_ID_BROADCAST_SM        0x00000111
310
1
#define SMPP_COMMAND_ID_QUERY_BROADCAST_SM  0x00000112
311
7
#define SMPP_COMMAND_ID_CANCEL_BROADCAST_SM 0x00000113
312
/* Huawei SMPP+ extensions */
313
5
#define SMPP_COMMAND_ID_HUAWEI_AUTH_ACC     0x01000001
314
2
#define SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY 0X01000002
315
316
317
2.47k
#define SMPP_COMMAND_ID_RESPONSE_MASK       0x80000000
318
319
86
#define SMPP_UDHI_MASK 0x40
320
321
/*
322
 * Value-arrays for field-contents
323
 */
324
static const value_string vals_command_id[] = {         /* Operation    */
325
    { SMPP_COMMAND_ID_BIND_RECEIVER, "Bind_receiver" },
326
    { SMPP_COMMAND_ID_BIND_TRANSMITTER, "Bind_transmitter" },
327
    { SMPP_COMMAND_ID_QUERY_SM, "Query_sm" },
328
    { SMPP_COMMAND_ID_SUBMIT_SM, "Submit_sm" },
329
    { SMPP_COMMAND_ID_DELIVER_SM, "Deliver_sm" },
330
    { SMPP_COMMAND_ID_UNBIND, "Unbind" },
331
    { SMPP_COMMAND_ID_REPLACE_SM, "Replace_sm" },
332
    { SMPP_COMMAND_ID_CANCEL_SM, "Cancel_sm" },
333
    { SMPP_COMMAND_ID_BIND_TRANSCEIVER, "Bind_transceiver" },
334
    { SMPP_COMMAND_ID_OUTBIND, "Outbind" },
335
    { SMPP_COMMAND_ID_ENQUIRE_LINK, "Enquire_link" },
336
    { SMPP_COMMAND_ID_SUBMIT_MULTI, "Submit_multi" },
337
    { SMPP_COMMAND_ID_ALERT_NOTIFICATION, "Alert_notification" },
338
    { SMPP_COMMAND_ID_DATA_SM, "Data_sm" },
339
    { SMPP_COMMAND_ID_BROADCAST_SM, "Broadcast_sm" },
340
    { SMPP_COMMAND_ID_QUERY_BROADCAST_SM, "Query_broadcast_sm" },
341
    { SMPP_COMMAND_ID_CANCEL_BROADCAST_SM, "Cancel_broadcast_sm" },
342
    { SMPP_COMMAND_ID_HUAWEI_AUTH_ACC, "Auth_acc" },
343
    { SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY, "Sm_result_notify" },
344
345
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_GENERIC_NACK, "Generic_nack" },
346
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_RECEIVER, "Bind_receiver - resp" },
347
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_TRANSMITTER, "Bind_transmitter - resp" },
348
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_QUERY_SM, "Query_sm - resp" },
349
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_SUBMIT_SM, "Submit_sm - resp" },
350
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_DELIVER_SM, "Deliver_sm - resp" },
351
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_UNBIND, "Unbind - resp" },
352
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_REPLACE_SM, "Replace_sm - resp" },
353
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_CANCEL_SM, "Cancel_sm - resp" },
354
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BIND_TRANSCEIVER, "Bind_transceiver - resp" },
355
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_ENQUIRE_LINK, "Enquire_link - resp" },
356
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_SUBMIT_MULTI, "Submit_multi - resp" },
357
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_DATA_SM, "Data_sm - resp" },
358
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_BROADCAST_SM, "Broadcast_sm - resp" },
359
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_QUERY_BROADCAST_SM, "Query_broadcast_sm - resp" },
360
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_CANCEL_BROADCAST_SM, "Cancel_broadcast_sm - resp" },
361
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_HUAWEI_AUTH_ACC, "Auth_acc - resp" },
362
    { SMPP_COMMAND_ID_RESPONSE_MASK|SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY, "Sm_result_notify - resp" },
363
    { 0, NULL }
364
};
365
366
static const range_string rvals_command_status[] = {     /* Status       */
367
    { 0x00000000, 0x00000000, "Ok" },
368
    { 0x00000001, 0x00000001, "Message length is invalid" },
369
    { 0x00000002, 0x00000002, "Command length is invalid" },
370
    { 0x00000003, 0x00000003, "Invalid command ID" },
371
    { 0x00000004, 0x00000004, "Incorrect BIND status for given command" },
372
    { 0x00000005, 0x00000005, "ESME already in bound state" },
373
    { 0x00000006, 0x00000006, "Invalid priority flag" },
374
    { 0x00000007, 0x00000007, "Invalid registered delivery flag" },
375
    { 0x00000008, 0x00000008, "System error" },
376
    { 0x00000009, 0x00000009, "[Reserved]" },
377
    { 0x0000000A, 0x0000000A, "Invalid source address" },
378
    { 0x0000000B, 0x0000000B, "Invalid destination address" },
379
    { 0x0000000C, 0x0000000C, "Message ID is invalid" },
380
    { 0x0000000D, 0x0000000D, "Bind failed" },
381
    { 0x0000000E, 0x0000000E, "Invalid password" },
382
    { 0x0000000F, 0x0000000F, "Invalid system ID" },
383
    { 0x00000010, 0x00000010, "[Reserved]" },
384
    { 0x00000011, 0x00000011, "Cancel SM failed" },
385
    { 0x00000012, 0x00000012, "[Reserved]" },
386
    { 0x00000013, 0x00000013, "Replace SM failed" },
387
    { 0x00000014, 0x00000014, "Message queue full" },
388
    { 0x00000015, 0x00000015, "Invalid service type" },
389
    { 0x00000016, 0x00000032, "[Reserved]" },
390
    { 0x00000033, 0x00000033, "Invalid number of destinations" },
391
    { 0x00000034, 0x00000034, "Invalid distribution list name" },
392
    { 0x00000035, 0x0000003F, "[Reserved]" },
393
    { 0x00000040, 0x00000040, "Destination flag is invalid (submit_multi)" },
394
    { 0x00000041, 0x00000041, "[Reserved]" },
395
    { 0x00000042, 0x00000042, "Invalid 'submit with replace' request" },
396
    { 0x00000043, 0x00000043, "Invalid esm_class field data" },
397
    { 0x00000044, 0x00000044, "Cannot submit to distribution list" },
398
    { 0x00000045, 0x00000045, "submit_sm or submit_multi failed" },
399
    { 0x00000046, 0x00000047, "[Reserved]" },
400
    { 0x00000048, 0x00000048, "Invalid source address TON" },
401
    { 0x00000049, 0x00000049, "Invalid source address NPI" },
402
    { 0x00000050, 0x00000050, "Invalid destination address TON" },
403
    { 0x00000051, 0x00000051, "Invalid destination address NPI" },
404
    { 0x00000052, 0x00000052, "[Reserved]" },
405
    { 0x00000053, 0x00000053, "Invalid system_type field" },
406
    { 0x00000054, 0x00000054, "Invalid replace_if_present flag" },
407
    { 0x00000055, 0x00000055, "Invalid number of messages" },
408
    { 0x00000056, 0x00000057, "[Reserved]" },
409
    { 0x00000058, 0x00000058, "Throttling error (ESME exceeded allowed message limits)" },
410
    { 0x00000059, 0x00000060, "[Reserved]" },
411
    { 0x00000061, 0x00000061, "Invalid scheduled delivery time" },
412
    { 0x00000062, 0x00000062, "Invalid message validity period (expiry time)" },
413
    { 0x00000063, 0x00000063, "Predefined message invalid or not found" },
414
    { 0x00000064, 0x00000064, "ESME receiver temporary app error code" },
415
    { 0x00000065, 0x00000065, "ESME receiver permanent app error code" },
416
    { 0x00000066, 0x00000066, "ESME receiver reject message error code" },
417
    { 0x00000067, 0x00000067, "query_sm request failed" },
418
    { 0x00000068, 0x000000BF, "[Reserved]" },
419
    { 0x000000C0, 0x000000C0, "Error in the optional part of the PDU body" },
420
    { 0x000000C1, 0x000000C1, "Optional parameter not allowed" },
421
    { 0x000000C2, 0x000000C2, "Invalid parameter length" },
422
    { 0x000000C3, 0x000000C3, "Expected optional parameter missing" },
423
    { 0x000000C4, 0x000000C4, "Invalid optional parameter  value" },
424
    { 0x000000C5, 0x000000FD, "[Reserved]" },
425
    { 0x000000FE, 0x000000FE, "(Transaction) Delivery failure (used for data_sm_resp)" },
426
    { 0x000000FF, 0x000000FF, "Unknown error" },
427
    /* Introduced in SMPP 5.0 */
428
    { 0x00000100, 0x00000100, "ESME Not authorised to use specified service_type." },
429
    { 0x00000101, 0x00000101, "ESME Prohibited from using specified operation."},
430
    { 0x00000102, 0x00000102, "Specified service_type is unavailable." },
431
    { 0x00000103, 0x00000103, "Specified service_type is denied." },
432
    { 0x00000104, 0x00000104, "Invalid Data Coding Scheme." },
433
    { 0x00000105, 0x00000105, "Source Address Sub unit is Invalid." },
434
    { 0x00000106, 0x00000106, "Destination Address Sub unit is Invalid." },
435
    { 0x00000107, 0x00000107, "Broadcast Frequency Interval is invalid." },
436
    { 0x00000108, 0x00000108, "Broadcast Alias Name is invalid." },
437
    { 0x00000109, 0x00000109, "Broadcast Area Format is invalid." },
438
    { 0x0000010A, 0x0000010A, "Number of Broadcast Areas is invalid." },
439
    { 0x0000010B, 0x0000010B, "Broadcast Content Type is invalid." },
440
    { 0x0000010C, 0x0000010C, "Broadcast Message Class is invalid." },
441
    { 0x0000010D, 0x0000010D, "broadcast_sm operation failed." },
442
    { 0x0000010E, 0x0000010E, "query_broadcast_sm operation failed." },
443
    { 0x0000010F, 0x0000010F, "cancel_broadcast_sm operation failed." },
444
    { 0x00000110, 0x00000110, "Number of Repeated Broadcasts is invalid." },
445
    { 0x00000111, 0x00000111, "Broadcast Service Group is invalid." },
446
    { 0x00000112, 0x00000112, "Broadcast Channel Indicator is invalid." },
447
    { 0x00000400, 0x000004FF, "[Vendor-specific Error]" },
448
    { 0x00000500, 0xFFFFFFFF, "[Reserved]" },
449
    { 0, 0, NULL }
450
};
451
452
static const value_string vals_tlv_tags[] = {
453
    { 0x0005, "dest_addr_subunit" },
454
    { 0x0006, "dest_network_type" },
455
    { 0x0007, "dest_bearer_type" },
456
    { 0x0008, "dest_telematics_id" },
457
    { 0x000D, "source_addr_subunit" },
458
    { 0x000E, "source_network_type" },
459
    { 0x000F, "source_bearer_type" },
460
    { 0x0010, "source_telematics_id" },
461
    { 0x0017, "qos_time_to_live" },
462
    { 0x0019, "payload_type" },
463
    { 0x001D, "additional_status_info_text" },
464
    { 0x001E, "receipted_message_id" },
465
    { 0x0030, "ms_msg_wait_facilities" },
466
    { 0x0201, "privacy_indicator" },
467
    { 0x0202, "source_subaddress" },
468
    { 0x0203, "dest_subaddress" },
469
    { 0x0204, "user_message_reference" },
470
    { 0x0205, "user_response_code" },
471
    { 0x020A, "source_port" },
472
    { 0x020B, "dest_port" },
473
    { 0x020C, "sar_msg_ref_num" },
474
    { 0x020D, "language_indicator" },
475
    { 0x020E, "sar_total_segments" },
476
    { 0x020F, "sar_segment_seqnum" },
477
    { 0x0210, "sc_interface_version" },
478
    { 0x0302, "callback_num_pres_ind" },
479
    { 0x0303, "callback_num_atag" },
480
    { 0x0304, "number_of_messages" },
481
    { 0x0381, "callback_num" },
482
    { 0x0420, "dpf_result" },
483
    { 0x0421, "set_dpf" },
484
    { 0x0422, "ms_availability_status" },
485
    { 0x0423, "network_error_code" },
486
    { 0x0424, "message_payload" },
487
    { 0x0425, "delivery_failure_reason" },
488
    { 0x0426, "more_messages_to_send" },
489
    { 0x0427, "message_state" },
490
    { 0x0428, "congestion_state" },
491
    { 0x0501, "ussd_service_op" },
492
    { 0x0600, "broadcast_channel_indicator" },
493
    { 0x0601, "broadcast_content_type" },
494
    { 0x0602, "broadcast_content_type_info" },
495
    { 0x0603, "broadcast_message_class" },
496
    { 0x0604, "broadcast_rep_num" },
497
    { 0x0605, "broadcast_frequency_interval" },
498
    { 0x0606, "broadcast_area_identifier" },
499
    { 0x0607, "broadcast_error_status" },
500
    { 0x0608, "broadcast_area_success" },
501
    { 0x0609, "broadcast_end_time" },
502
    { 0x060A, "broadcast_service_group" },
503
    { 0x060B, "billing_identification" },
504
    { 0x060D, "source_network_id" },
505
    { 0x060E, "dest_network_id" },
506
    { 0x060F, "source_node_id" },
507
    { 0x0610, "dest_node_id" },
508
    { 0x0611, "dest_addr_np_resolution" },
509
    { 0x0612, "dest_addr_np_information" },
510
    { 0x0613, "dest_addr_np_country" },
511
    { 0x1201, "display_time" },
512
    { 0x1203, "sms_signal" },
513
    { 0x1204, "ms_validity" },
514
    { 0x130C, "alert_on_message_delivery" },
515
    { 0x1380, "its_reply_type" },
516
    { 0x1383, "its_session_info" },
517
    { 0, NULL }
518
};
519
520
static const value_string vals_addr_ton[] = {
521
    { 0, "Unknown" },
522
    { 1, "International" },
523
    { 2, "National" },
524
    { 3, "Network specific" },
525
    { 4, "Subscriber number" },
526
    { 5, "Alphanumeric" },
527
    { 6, "Abbreviated" },
528
    { 0, NULL }
529
};
530
531
static const value_string vals_addr_npi[] = {
532
    {  0, "Unknown" },
533
    {  1, "ISDN (E163/E164)" },
534
    {  3, "Data (X.121)" },
535
    {  4, "Telex (F.69)" },
536
    {  6, "Land mobile (E.212)" },
537
    {  8, "National" },
538
    {  9, "Private" },
539
    { 10, "ERMES" },
540
    { 14, "Internet (IP)" },
541
    { 18, "WAP client Id" },
542
    {  0, NULL }
543
};
544
545
static const value_string vals_esm_submit_msg_mode[] = {
546
    {  0x0, "Default SMSC mode" },
547
    {  0x1, "Datagram mode" },
548
    {  0x2, "Forward mode" },
549
    {  0x3, "Store and forward mode" },
550
    {  0, NULL }
551
};
552
553
static const value_string vals_esm_submit_msg_type[] = {
554
    {  0x0, "Default message type" },
555
    {  0x1, "Short message contains SMSC Delivery Receipt" },
556
    {  0x2, "Short message contains (E)SME delivery acknowledgement" },
557
    {  0x3, "Reserved" },
558
    {  0x4, "Short message contains (E)SME manual/user acknowledgement" },
559
    {  0x5, "Reserved" },
560
    {  0x6, "Short message contains conversation abort" },
561
    {  0x7, "Reserved" },
562
    {  0x8, "Short message contains intermediate delivery notification" },
563
    {  0, NULL }
564
};
565
566
static const value_string vals_esm_submit_features[] = {
567
    {  0x0, "No specific features selected" },
568
    {  0x1, "UDHI indicator" },
569
    {  0x2, "Reply path" },
570
    {  0x3, "UDHI and reply path" },
571
    {  0, NULL }
572
};
573
574
static const value_string vals_priority_flag[] = {
575
    {  0, "GSM: None      ANSI-136: Bulk         IS-95: Normal" },
576
    {  1, "GSM: priority  ANSI-136: Normal       IS-95: Interactive" },
577
    {  2, "GSM: priority  ANSI-136: Urgent       IS-95: Urgent" },
578
    {  3, "GSM: priority  ANSI-136: Very Urgent  IS-95: Emergency" },
579
    {  0, NULL }
580
};
581
582
static const value_string vals_regdel_receipt[] = {
583
    {  0x0, "No SMSC delivery receipt requested" },
584
    {  0x1, "Delivery receipt requested (for success or failure)" },
585
    {  0x2, "Delivery receipt requested (for failure)" },
586
    {  0x3, "Reserved in version <= 3.4; Delivery receipt requested (for success) in 5.0" },
587
    {  0, NULL }
588
};
589
590
static const value_string vals_regdel_acks[] = {
591
    {  0x0, "No recipient SME acknowledgement requested" },
592
    {  0x1, "SME delivery acknowledgement requested" },
593
    {  0x2, "SME manual/user acknowledgement requested" },
594
    {  0x3, "Both delivery and manual/user acknowledgement requested" },
595
    {  0, NULL }
596
};
597
598
static const value_string vals_regdel_notif[] = {
599
    {  0x0, "No intermediate notification requested" },
600
    {  0x1, "Intermediate notification requested" },
601
    {  0, NULL }
602
};
603
604
static const value_string vals_replace_if_present_flag[] = {
605
    {  0x0, "Don't replace" },
606
    {  0x1, "Replace" },
607
    {  0, NULL }
608
};
609
610
static const range_string rvals_data_coding[] = {
611
    {    0,    0, "SMSC default alphabet" },
612
    {    1,    1, "IA5 (CCITT T.50)/ASCII (ANSI X3.4)" },
613
    {    2,    2, "Octet unspecified (8-bit binary)" },
614
    {    3,    3, "Latin 1 (ISO-8859-1)" },
615
    {    4,    4, "Octet unspecified (8-bit binary)" },
616
    {    5,    5, "JIS (X 0208-1990)" },
617
    {    6,    6, "Cyrillic (ISO-8859-5)" },
618
    {    7,    7, "Latin/Hebrew (ISO-8859-8)" },
619
    {    8,    8, "UCS2 (ISO/IEC-10646)" },
620
    {    9,    9, "Pictogram Encoding" },
621
    {   10,   10, "ISO-2022-JP (Music codes)" },
622
    {   11,   12, "Reserved" },
623
    {   13,   13, "Extended Kanji JIS (X 0212-1990)" },
624
    {   14,   14, "KS C 5601" },
625
    {   15, 0xBF, "Reserved" },
626
    { 0xC0, 0xEF, "GSM MWI control - see [GSM 03.38]" },
627
    { 0xF0, 0xFF, "GSM message class control - see [GSM 03.38]" },
628
    {    0,    0, NULL }
629
};
630
631
static const value_string vals_message_state[] = {
632
    {  1, "ENROUTE" },
633
    {  2, "DELIVERED" },
634
    {  3, "EXPIRED" },
635
    {  4, "DELETED" },
636
    {  5, "UNDELIVERABLE" },
637
    {  6, "ACCEPTED" },
638
    {  7, "UNKNOWN" },
639
    {  8, "REJECTED" },
640
    {  0, NULL }
641
};
642
643
static const value_string vals_addr_subunit[] = {
644
    {  0, "Unknown -default-" },
645
    {  1, "MS Display" },
646
    {  2, "Mobile equipment" },
647
    {  3, "Smart card 1" },
648
    {  4, "External unit 1" },
649
    {  0, NULL }
650
};
651
652
static const value_string vals_network_type[] = {
653
    {  0, "Unknown" },
654
    {  1, "GSM" },
655
    {  2, "ANSI-136/TDMA" },
656
    {  3, "IS-95/CDMA" },
657
    {  4, "PDC" },
658
    {  5, "PHS" },
659
    {  6, "iDEN" },
660
    {  7, "AMPS" },
661
    {  8, "Paging network" },
662
    {  0, NULL }
663
};
664
665
static const value_string vals_bearer_type[] = {
666
    {  0, "Unknown" },
667
    {  1, "SMS" },
668
    {  2, "Circuit Switched Data (CSD)" },
669
    {  3, "Packet data" },
670
    {  4, "USSD" },
671
    {  5, "CDPD" },
672
    {  6, "DataTAC" },
673
    {  7, "FLEX/ReFLEX" },
674
    {  8, "Cell Broadcast" },
675
    {  0, NULL }
676
};
677
678
static const value_string vals_payload_type[] = {
679
    {  0, "Default" },
680
    {  1, "WCMP message" },
681
    {  0, NULL }
682
};
683
684
static const value_string vals_privacy_indicator[] = {
685
    {  0, "Not restricted -default-" },
686
    {  1, "Restricted" },
687
    {  2, "Confidential" },
688
    {  3, "Secret" },
689
    {  0, NULL }
690
};
691
692
static const value_string vals_language_indicator[] = {
693
    {  0, "Unspecified -default-" },
694
    {  1, "english" },
695
    {  2, "french" },
696
    {  3, "spanish" },
697
    {  4, "german" },
698
    {  5, "portuguese" },
699
    {  0, NULL }
700
};
701
702
static const value_string vals_display_time[] = {
703
    {  0, "Temporary" },
704
    {  1, "Default -default-" },
705
    {  2, "Invoke" },
706
    {  0, NULL }
707
};
708
709
static const value_string vals_ms_validity[] = {
710
    {  0, "Store indefinitely -default-" },
711
    {  1, "Power down" },
712
    {  2, "SID based registration area" },
713
    {  3, "Display only" },
714
    {  0, NULL }
715
};
716
717
static const value_string vals_dpf_result[] = {
718
    {  0, "DPF not set" },
719
    {  1, "DPF set" },
720
    {  0, NULL }
721
};
722
723
static const value_string vals_set_dpf[] = {
724
    {  0, "Not requested (Set DPF for delivery failure)" },
725
    {  1, "Requested (Set DPF for delivery failure)" },
726
    {  0, NULL }
727
};
728
729
static const value_string vals_ms_availability_status[] = {
730
    {  0, "Available -default-" },
731
    {  1, "Denied" },
732
    {  2, "Unavailable" },
733
    {  0, NULL }
734
};
735
736
static const value_string vals_delivery_failure_reason[] = {
737
    {  0, "Destination unavailable" },
738
    {  1, "Destination address invalid" },
739
    {  2, "Permanent network error" },
740
    {  3, "Temporary network error" },
741
    {  0, NULL }
742
};
743
744
static const value_string vals_more_messages_to_send[] = {
745
    {  0, "No more messages" },
746
    {  1, "More messages -default-" },
747
    {  0, NULL }
748
};
749
750
static const value_string vals_its_reply_type[] = {
751
    {  0, "Digit" },
752
    {  1, "Number" },
753
    {  2, "Telephone no." },
754
    {  3, "Password" },
755
    {  4, "Character line" },
756
    {  5, "Menu" },
757
    {  6, "Date" },
758
    {  7, "Time" },
759
    {  8, "Continue" },
760
    {  0, NULL }
761
};
762
763
static const value_string vals_ussd_service_op[] = {
764
    {  0, "PSSD indication" },
765
    {  1, "PSSR indication" },
766
    {  2, "USSR request" },
767
    {  3, "USSN request" },
768
    { 16, "PSSD response" },
769
    { 17, "PSSR response" },
770
    { 18, "USSR confirm" },
771
    { 19, "USSN confirm" },
772
    {  0, NULL }
773
};
774
775
static const value_string vals_msg_wait_ind[] = {
776
    {  0, "Set indication inactive" },
777
    {  1, "Set indication active" },
778
    {  0, NULL }
779
};
780
781
static const value_string vals_msg_wait_type[] = {
782
    {  0, "Voicemail message waiting" },
783
    {  1, "Fax message waiting" },
784
    {  2, "Electronic mail message waiting" },
785
    {  3, "Other message waiting" },
786
    {  0, NULL }
787
};
788
789
static const value_string vals_callback_num_pres[] = {
790
    {  0, "Presentation allowed" },
791
    {  1, "Presentation restricted" },
792
    {  2, "Number not available" },
793
    {  3, "[Reserved]" },
794
    {  0, NULL }
795
};
796
797
static const value_string vals_callback_num_scrn[] = {
798
    {  0, "User provided, not screened" },
799
    {  1, "User provided, verified and passed" },
800
    {  2, "User provided, verified and failed" },
801
    {  3, "Network provided" },
802
    {  0, NULL }
803
};
804
805
static const value_string vals_network_error_type[] = {
806
    {  1, "ANSI-136 (Access Denied Reason)" },
807
    {  2, "IS-95 (Access Denied Reason)" },
808
    {  3, "GSM" },
809
    {  4, "[Reserved] in <= 3.4; ANSI 136 Cause Code in 5.0" },
810
    {  5, "[Reserved] in <= 3.4; IS 95 Cause Code in 5.0" },
811
    {  6, "[Reserved] in <= 3.4; ANSI-41 Error in 5.0" },
812
    {  7, "[Reserved] in <= 3.4; SMPP Error in 5.0" },
813
    {  8, "[Reserved] in <= 3.4; Message Center Specific in 5.0" },
814
    {  0, NULL }
815
};
816
817
static const value_string vals_its_session_ind[] = {
818
    {  0, "End of session indicator inactive" },
819
    {  1, "End of session indicator active" },
820
    {  0, NULL }
821
};
822
823
/* Data Coding Scheme: see 3GPP TS 23.040 and 3GPP TS 23.038.
824
 * Note values below 0x0C are not used in SMPP. */
825
static const value_string vals_dcs_sms_coding_group[] = {
826
#if 0
827
    { 0x00, "SMS DCS: General Data Coding indication - Uncompressed text, no message class" },
828
    { 0x01, "SMS DCS: General Data Coding indication - Uncompressed text" },
829
    { 0x02, "SMS DCS: General Data Coding indication - Compressed text, no message class" },
830
    { 0x03, "SMS DCS: General Data Coding indication - Compressed text" },
831
    { 0x04, "SMS DCS: Message Marked for Automatic Deletion - Uncompressed text, no message class" },
832
    { 0x05, "SMS DCS: Message Marked for Automatic Deletion - Uncompressed text" },
833
    { 0x06, "SMS DCS: Message Marked for Automatic Deletion - Compressed text, no message class" },
834
    { 0x07, "SMS DCS: Message Marked for Automatic Deletion - Compressed text" },
835
    { 0x08, "SMS DCS: Reserved" },
836
    { 0x09, "SMS DCS: Reserved" },
837
    { 0x0A, "SMS DCS: Reserved" },
838
    { 0x0B, "SMS DCS: Reserved" },
839
#endif
840
    { 0x0C, "SMS DCS: Message Waiting Indication - Discard Message" },
841
    { 0x0D, "SMS DCS: Message Waiting Indication - Store Message (GSM 7-bit default alphabet)" },
842
    { 0x0E, "SMS DCS: Message Waiting Indication - Store Message (UCS-2 character set)" },
843
    { 0x0F, "SMS DCS: Data coding / message class" },
844
    { 0x00, NULL }
845
};
846
847
static const value_string vals_dcs_charset[] = {
848
    { 0x00, "GSM 7-bit default alphabet" },
849
    { 0x01, "8-bit data" },
850
    { 0x00, NULL }
851
};
852
853
static const value_string vals_dcs_class[] = {
854
    { 0x00, "Class 0" },
855
    { 0x01, "Class 1 - ME specific" },
856
    { 0x02, "Class 2 - (U)SIM specific" },
857
    { 0x03, "Class 3 - TE specific" },
858
    { 0x00, NULL }
859
};
860
861
static const value_string vals_alert_on_message_delivery[] = {
862
    { 0x00, "Use mobile default alert (Default)" },
863
    { 0x01, "Use low-priority alert" },
864
    { 0x02, "Use medium-priority alert" },
865
    { 0x03, "Use high-priority alert" },
866
    { 0x00, NULL }
867
};
868
869
static const range_string vals_congestion_state[] = {
870
    {0,     0,      "Idle"},
871
    {1,     29,     "Low Load"},
872
    {30,    49,     "Medium Load"},
873
    {50,    79,     "High Load"},
874
    {80,    89,     "Optimum Load"}, /*Specs says 80-90, but that is probably a mistake */
875
    {90,    99,     "Nearing Congestion"},
876
    {100,   100,    "Congested / Maximum Load"},
877
    { 0,    0,      NULL }
878
};
879
880
static const range_string vals_broadcast_channel_indicator[] = {
881
    {0,     0,      "Basic Broadcast Channel (Default)"},
882
    {1,     1,      "Extended Broadcast Channel"},
883
    {2,     255,    "[Reserved]"},
884
    { 0,    0,      NULL }
885
};
886
887
static const value_string vals_broadcast_message_class[] = {
888
    {0, "No Class Specified (default)"},
889
    {1, "Class 1 (User Defined)"},
890
    {2, "Class 2 (User Defined)"},
891
    {3, "Class 3 (Terminal Equipment)"},
892
    {0, NULL }
893
};
894
895
static const range_string vals_broadcast_area_success[] = {
896
    {0,     100,    "%"},
897
    {101,   254,    "[Reserved]"},
898
    {255,   255,    "Information not available"},
899
    { 0,    0,      NULL }
900
};
901
902
static const value_string vals_broadcast_content_type_nw[] = {
903
    {0,     "Generic"},
904
    {1,     "GSM [23041]"},
905
    {2,     "TDMA [IS824][ANSI-41]"},
906
    {3,     "CDMA [IS824][IS637]"},
907
    {0,     NULL }
908
};
909
910
static const value_string vals_broadcast_content_type_type[] = {
911
    {0x0000,        "[System Service] Index"},
912
    {0x0001,        "[System Service] Emergency Broadcasts"},
913
    {0x0002,        "[System Service] IRDB Download"},
914
    {0x0010,        "[News Service] News Flashes"},
915
    {0x0011,        "[News Service] General News (Local)"},
916
    {0x0012,        "[News Service] General News (Regional)"},
917
    {0x0013,        "[News Service] General News (National)"},
918
    {0x0014,        "[News Service] General News (International)"},
919
    {0x0015,        "[News Service] Business/Financial News (Local)"},
920
    {0x0016,        "[News Service] Business/Financial News (Regional)"},
921
    {0x0017,        "[News Service] Business/Financial News (National)"},
922
    {0x0018,        "[News Service] Business/Financial News (International)"},
923
    {0x0019,        "[News Service] Sports News (Local)"},
924
    {0x001A,        "[News Service] Sports News (Regional)"},
925
    {0x001B,        "[News Service] Sports News (National)"},
926
    {0x001C,        "[News Service] Sports News (International)"},
927
    {0x001D,        "[News Service] Entertainment News (Local)"},
928
    {0x001E,        "[News Service] Entertainment News (Regional)"},
929
    {0x001F,        "[News Service] Entertainment News (National)"},
930
    {0x0020,        "[News Service] Entertainment News (International)"},
931
    {0x0021,        "[Subscriber Information Services] Medical/Health/Hospitals"},
932
    {0x0022,        "[Subscriber Information Services] Doctors"},
933
    {0x0023,        "[Subscriber Information Services] Pharmacy"},
934
    {0x0030,        "[Subscriber Information Services] Local Traffic/Road Reports"},
935
    {0x0031,        "[Subscriber Information Services] Long Distance Traffic/Road Reports"},
936
    {0x0032,        "[Subscriber Information Services] Taxis"},
937
    {0x0033,        "[Subscriber Information Services] Weather"},
938
    {0x0034,        "[Subscriber Information Services] Local Airport Flight Schedules"},
939
    {0x0035,        "[Subscriber Information Services] Restaurants"},
940
    {0x0036,        "[Subscriber Information Services] Lodgings"},
941
    {0x0037,        "[Subscriber Information Services] Retail Directory"},
942
    {0x0038,        "[Subscriber Information Services] Advertisements"},
943
    {0x0039,        "[Subscriber Information Services] Stock Quotes"},
944
    {0x0040,        "[Subscriber Information Services] Employment Opportunities"},
945
    {0x0041,        "[Subscriber Information Services] Technology News"},
946
    {0x0070,        "[Carrier Information Services] District (Base Station Info)"},
947
    {0x0071,        "[Carrier Information Services] Network Information"},
948
    {0x0080,        "[Subscriber Care Services] Operator Services"},
949
    {0x0081,        "[Subscriber Care Services] Directory Enquiries (National)"},
950
    {0x0082,        "[Subscriber Care Services] Directory Enquiries (International)"},
951
    {0x0083,        "[Subscriber Care Services] Customer Care (National)"},
952
    {0x0084,        "[Subscriber Care Services] Customer Care (International)"},
953
    {0x0085,        "[Subscriber Care Services] Local Date/Time/Time Zone"},
954
    {0x0100,        "[Multi Category Services] Multi Category Services"},
955
    {0x0000,        NULL }
956
};
957
958
static const value_string vals_broadcast_frequency_interval_unit[] = {
959
    {0x00,  "As frequently as possible"},
960
    {0x08,  "seconds"},
961
    {0x09,  "minutes"},
962
    {0x0A,  "hours"},
963
    {0x0B,  "days"},
964
    {0x0C,  "weeks"},
965
    {0x0D,  "months"},
966
    {0x0E,  "years"},
967
    {0x00,  NULL }
968
};
969
970
static const value_string vals_dest_addr_np_resolution[] = {
971
    {0x00,  "query has not been performed (default)"},
972
    {0x01,  "query has been performed, number not ported"},
973
    {0x02,  "query has been performed, number ported"},
974
    {0x00,  NULL }
975
};
976
977
static const range_string vals_broadcast_area_identifier_format[] = {
978
    {0,   0, "Alias / Name"},
979
    {1,   1, "Ellipsoid Arc"},
980
    {2,   2, "Polygon"},
981
    {3, 255, "[Reserved]"},
982
    {0, 0,  NULL }
983
};
984
985
/* Huawei SMPP+ extensions */
986
static const value_string vals_mo_mt_flag[] = {
987
    { 0x01, "MO" },
988
    { 0x02, "MT" },
989
    { 0x03, "Reserved" },
990
    { 0x00, NULL }
991
};
992
993
static const value_string vals_operation_result[] = {
994
    { 0x00, "Successful" },
995
    { 0x01, "Protocol is not supported" },
996
    { 0x0a, "Others" },
997
    { 0x0b, "MO account does not exist" },
998
    { 0x0c, "MT account does not exist" },
999
    { 0x0d, "MO account state is abnormal" },
1000
    { 0x0e, "MT account state is abnormal" },
1001
    { 0x0f, "MO account balance is not enough" },
1002
    { 0x10, "MT account balance is not enough" },
1003
    { 0x11, "MO VAS is not supported" },
1004
    { 0x12, "MT VAS is not supported" },
1005
    { 0x13, "MO user is post-paid user and checked success" },
1006
    { 0x14, "MT user is post-paid user and checked success" },
1007
    { 0x15, "MO post-paid user status is incorrect" },
1008
    { 0x16, "MT post-paid user status is incorrect" },
1009
    { 0x17, "MO post-paid user account balance is not sufficient" },
1010
    { 0x18, "MT post-paid user account balance is not sufficient" },
1011
    { 0x19, "MO post-paid user value-added services are not supported" },
1012
    { 0x1a, "MT post-paid user value-added services are not supported" },
1013
    { 0x00, NULL }
1014
};
1015
1016
static const value_string vals_notify_mode[] = {
1017
    { 0x01, "Deliver the report when it's successful or failed" },
1018
    { 0x02, "Deliver the report only when it's failed" },
1019
    { 0x03, "Deliver the report only when it's successful" },
1020
    { 0x04, "Never deliver the report" },
1021
    { 0x00, NULL }
1022
};
1023
1024
static const value_string vals_delivery_result[] = {
1025
    { 0x00, "Successful" },
1026
    { 0x01, "Unsuccessful" },
1027
    { 0x00, NULL }
1028
};
1029
1030
static const value_string vals_msc_addr_noa    [] = {
1031
    { 0x00, "Spare" },
1032
    { 0x01, "Subscriber number" },
1033
    { 0x02, "Unknown" },
1034
    { 0x03, "National number" },
1035
    { 0x04, "International" },
1036
    { 0x00, NULL }
1037
};
1038
1039
static const value_string vals_msc_addr_npi    [] = {
1040
    { 0x00, "Spare" },
1041
    { 0x01, "ISDN (Telephony) numbering plan (Recommendation E.164)" },
1042
    { 0x02, "Spare" },
1043
    { 0x03, "Data numbering plan (Recommendation X.121) (national use)" },
1044
    { 0x04, "Telex numbering plan (Recommendation F.69) (national use)" },
1045
    { 0x05, "Reserved for national use" },
1046
    { 0x06, "Reserved for national use" },
1047
    { 0x07, "Spare" },
1048
    { 0x00, NULL }
1049
};
1050
1051
static int * const regdel_fields[] = {
1052
    &hf_smpp_regdel_receipt,
1053
    &hf_smpp_regdel_acks,
1054
    &hf_smpp_regdel_notif,
1055
    NULL
1056
};
1057
1058
static int * const submit_msg_fields[] = {
1059
    &hf_smpp_esm_submit_msg_mode,
1060
    &hf_smpp_esm_submit_msg_type,
1061
    &hf_smpp_esm_submit_features,
1062
    NULL
1063
};
1064
1065
/* Structures for request/response tracking */
1066
typedef struct _smpp_session_t {
1067
        wmem_multimap_t *rr_map;    /* Multimap to track request/response pairs
1068
                                       as sequence numbers _might_ be reused
1069
                                       according to SMPP 5.0 section 2.6.2 */
1070
} smpp_session_t;
1071
1072
/*
1073
 * A data structure to track a SMPP request/response pair.
1074
 * Note: The protocol spec doesn't use the term "transaction", but we are using
1075
 * it here anyway...
1076
 */
1077
typedef struct _smpp_txn_t {
1078
        uint32_t req_frame;       /* Frame number in which request was seen */
1079
        uint32_t res_frame;       /* Frame number in which response was seen */
1080
        nstime_t req_time;        /* Time when request was seen */
1081
        nstime_t res_time;        /* Time when response was seen */
1082
} smpp_txn_t;
1083
1084
/* The same sequence number might be used in either direction in the same
1085
 * session. So, we need to track the sequence numbers by direction.
1086
 */
1087
typedef struct _smpp_txn_key_t {
1088
        address src_addr;
1089
        address dst_addr;
1090
        unsigned sequence_number;
1091
} smpp_txn_key_t;
1092
1093
static dissector_handle_t gsm_sms_handle;
1094
1095
static smpp_data_t *
1096
get_smpp_data(packet_info *pinfo)
1097
100
{
1098
100
    smpp_data_t *smpp_data = NULL;
1099
1100
100
    smpp_data = (smpp_data_t*)p_get_proto_data(pinfo->pool, pinfo, proto_smpp, 0);
1101
100
    if (!smpp_data) {
1102
93
        smpp_data = wmem_new0(pinfo->pool, smpp_data_t);
1103
93
        p_add_proto_data(pinfo->pool, pinfo, proto_smpp, 0, smpp_data);
1104
93
    }
1105
1106
100
    return smpp_data;
1107
100
}
1108
1109
/*
1110
 * For Stats Tree
1111
 */
1112
static void
1113
smpp_stats_tree_init(stats_tree* st)
1114
0
{
1115
0
    st_smpp_ops = stats_tree_create_node(st, "SMPP Operations", 0, STAT_DT_INT, true);
1116
0
    st_smpp_req = stats_tree_create_node(st, "SMPP Requests", st_smpp_ops, STAT_DT_INT, true);
1117
0
    st_smpp_res = stats_tree_create_node(st, "SMPP Responses", st_smpp_ops, STAT_DT_INT, true);
1118
0
    st_smpp_res_status = stats_tree_create_node(st, "SMPP Response Status", 0, STAT_DT_INT, true);
1119
1120
0
}
1121
1122
static tap_packet_status
1123
smpp_stats_tree_per_packet(stats_tree *st, /* st as it was passed to us */
1124
                           packet_info *pinfo,
1125
                           epan_dissect_t *edt _U_,
1126
                           const void *p,
1127
                           tap_flags_t flags _U_) /* Used for getting SMPP command_id values */
1128
0
{
1129
0
    const smpp_tap_rec_t* tap_rec = (const smpp_tap_rec_t*)p;
1130
1131
0
    tick_stat_node(st, "SMPP Operations", 0, true);
1132
1133
0
    if ((tap_rec->command_id & SMPP_COMMAND_ID_RESPONSE_MASK) == SMPP_COMMAND_ID_RESPONSE_MASK) /* Response */
1134
0
    {
1135
0
        tick_stat_node(st, "SMPP Responses", st_smpp_ops, true);
1136
0
        tick_stat_node(st, val_to_str(pinfo->pool, tap_rec->command_id, vals_command_id, "Unknown 0x%08x"), st_smpp_res, false);
1137
1138
0
        tick_stat_node(st, "SMPP Response Status", 0, true);
1139
0
        tick_stat_node(st, rval_to_str_wmem(pinfo->pool, tap_rec->command_status, rvals_command_status, "Unknown 0x%08x"), st_smpp_res_status, false);
1140
1141
0
    }
1142
0
    else  /* Request */
1143
0
    {
1144
0
        tick_stat_node(st, "SMPP Requests", st_smpp_ops, true);
1145
0
        tick_stat_node(st, val_to_str(pinfo->pool, tap_rec->command_id, vals_command_id, "Unknown 0x%08x"), st_smpp_req, false);
1146
0
    }
1147
1148
0
    return TAP_PACKET_REDRAW;
1149
0
}
1150
1151
/*!
1152
 * SMPP equivalent of mktime() (3). Convert date to standard 'time_t' format
1153
 *
1154
 * \param      datestr  The SMPP-formatted date to convert
1155
 * \param      nstime   Returns the 'nstime_t' equivalent
1156
 * \param      relative Returns whether time is specified relative or absolute
1157
 *
1158
 * \return              Whether the time parsed validly.
1159
 */
1160
1161
static bool
1162
smpp_mktime(const char *datestr, nstime_t *nstime, bool *relative)
1163
14
{
1164
14
    struct tm    r_time;
1165
14
    time_t       t_diff;
1166
1167
24
    for (int i = 0; i < 15; ++i) {
1168
24
        if (!g_ascii_isdigit(datestr[i])) {
1169
14
            return false;
1170
14
        }
1171
24
    }
1172
1173
0
    switch (datestr[15]) {
1174
0
    case 'R':
1175
0
        *relative = true;
1176
0
        break;
1177
0
    case '+':
1178
0
    case '-':
1179
0
        *relative = false;
1180
0
        break;
1181
0
    default:
1182
0
        return false;
1183
0
    }
1184
1185
0
    r_time.tm_year = 10 * (datestr[0] - '0') + (datestr[1] - '0');
1186
    /*
1187
     * Y2K rollover date as recommended in appendix C
1188
     */
1189
0
    if (r_time.tm_year < 38)
1190
0
        r_time.tm_year += 100;
1191
0
    r_time.tm_mon  = 10 * (datestr[2] - '0') + (datestr[3] - '0');
1192
0
    r_time.tm_mon--;
1193
0
    r_time.tm_mday = 10 * (datestr[4] - '0') + (datestr[5] - '0');
1194
0
    r_time.tm_hour = 10 * (datestr[6] - '0') + (datestr[7] - '0');
1195
0
    r_time.tm_min  = 10 * (datestr[8] - '0') + (datestr[9] - '0');
1196
0
    r_time.tm_sec  = 10 * (datestr[10] - '0') + (datestr[11] - '0');
1197
0
    r_time.tm_isdst = -1;
1198
1199
    /* Some implementations of timegm, mktime, etc. happily convert
1200
     * October 40 to November 9, etc. Don't allow that. */
1201
0
    if (!tm_is_valid(&r_time)) {
1202
0
        return false;
1203
0
    }
1204
1205
0
    if (*relative == false) {
1206
0
        nstime->secs = mktime_utc(&r_time);
1207
0
        if (errno == EINVAL) {
1208
0
            return false;
1209
0
        }
1210
0
        nstime->nsecs = (datestr[12] - '0') * 100000000;
1211
1212
0
        t_diff = (10 * (datestr[13] - '0') + (datestr[14] - '0')) * 900;
1213
0
        if (datestr[15] == '-')
1214
            /* Represented time is behind UTC, shift it forward to UTC */
1215
0
            nstime->secs += t_diff;
1216
0
        else if (datestr[15] == '+')
1217
            /* Represented time is ahead of UTC, shift it backward to UTC */
1218
0
            nstime->secs -= t_diff;
1219
0
    } else {
1220
        /* The SMPP standard gives examples of a relative time using years
1221
         * and months, but that can't be converted into a FT_RELATIVE_TIME
1222
         * without knowing the start time. In practice it shouldn't happen.
1223
         * XXX - Either fail or use some kind of contractual average month?
1224
         */
1225
0
        nstime->secs = r_time.tm_sec + 60 *
1226
0
            (r_time.tm_min + 60 *
1227
0
             (r_time.tm_hour + 24 *
1228
0
              r_time.tm_mday));
1229
0
        nstime->nsecs = 0;
1230
0
    }
1231
1232
0
    return true;
1233
0
}
1234
1235
/*!
1236
 * Scanning routines to add standard types (byte, int, string...) to the
1237
 * protocol tree.
1238
 *
1239
 * \param       tree    The protocol tree to add to
1240
 * \param       tvb     Buffer containing the data
1241
 * \param       field   Actual field whose value needs displaying
1242
 * \param       offset  Location of field in buffer, returns location of
1243
 *                      next field
1244
 */
1245
static void
1246
smpp_handle_string(proto_tree *tree, tvbuff_t *tvb, int field, int *offset)
1247
1.36k
{
1248
1.36k
    unsigned     len;
1249
1250
1.36k
    len = tvb_strsize(tvb, *offset);
1251
1.36k
    if (len > 1) {
1252
634
        proto_tree_add_item(tree, field, tvb, *offset, len, ENC_NA);
1253
634
    }
1254
1.36k
    (*offset) += len;
1255
1.36k
}
1256
1257
static const char *
1258
smpp_handle_string_return(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int field, int *offset)
1259
140
{
1260
140
    unsigned     len;
1261
140
    const char* str = (const char *)tvb_get_stringz_enc(pinfo->pool, tvb, *offset, &len, ENC_ASCII);
1262
1263
140
    if (len > 0)
1264
137
        proto_tree_add_string(tree, field, tvb, *offset, len, str);
1265
1266
140
    (*offset) += len;
1267
140
    return str;
1268
140
}
1269
1270
static void
1271
smpp_handle_string_z(proto_tree *tree, tvbuff_t *tvb, int field, int *offset,
1272
                const char *null_string)
1273
158
{
1274
158
    int          len;
1275
1276
158
    len = tvb_strsize(tvb, *offset);
1277
158
    if (len > 1) {
1278
90
        proto_tree_add_item(tree, field, tvb, *offset, len, ENC_NA);
1279
90
    } else {
1280
68
        proto_tree_add_string(tree, field, tvb, *offset, len, null_string);
1281
68
    }
1282
158
    (*offset) += len;
1283
158
}
1284
1285
static void
1286
smpp_handle_time(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo,
1287
                 int field, int field_R, int *offset)
1288
70
{
1289
70
    proto_item *ti;
1290
70
    char     *strval;
1291
70
    unsigned  len;
1292
70
    nstime_t  tmptime = NSTIME_INIT_ZERO;
1293
70
    bool relative;
1294
1295
70
    strval = (char *) tvb_get_stringz_enc(pinfo->pool, tvb, *offset, &len, ENC_ASCII);
1296
70
    if (*strval)
1297
69
    {
1298
69
        if (len >= 16 && smpp_mktime(strval, &tmptime, &relative))
1299
0
        {
1300
0
            if (relative) {
1301
0
                proto_tree_add_time(tree, field_R, tvb, *offset, len, &tmptime);
1302
0
            } else {
1303
0
                proto_tree_add_time(tree, field, tvb, *offset, len, &tmptime);
1304
0
            }
1305
0
        }
1306
69
        else
1307
69
        {
1308
69
            ti = proto_tree_add_time_format_value(tree, field_R, tvb, *offset, len, &tmptime, "%s", strval);
1309
69
            expert_add_info(pinfo, ti, &ei_smpp_date_time_decoding_failed);
1310
69
        }
1311
69
    }
1312
70
    *offset += len;
1313
70
}
1314
1315
/*!
1316
 * Scanning routine to handle the destination-list of 'submit_multi'
1317
 *
1318
 * \param       tree    The protocol tree to add to
1319
 * \param       tvb     Buffer containing the data
1320
 * \param       offset  Location of field in buffer, returns location of
1321
 *                      next field
1322
 */
1323
static void
1324
smpp_handle_dlist(proto_tree *tree, tvbuff_t *tvb, int *offset)
1325
39
{
1326
39
    uint8_t      entries;
1327
39
    int          tmpoff = *offset;
1328
39
    proto_tree  *sub_tree = NULL;
1329
39
    uint8_t      dest_flag;
1330
1331
39
    if ((entries = tvb_get_uint8(tvb, tmpoff++))) {
1332
27
        proto_item  *pi;
1333
27
        pi = proto_tree_add_item(tree, hf_smpp_dlist, tvb, *offset, 1, ENC_NA);
1334
27
        sub_tree = proto_item_add_subtree(pi, ett_dlist);
1335
27
    }
1336
886
    while (entries--)
1337
847
    {
1338
847
        dest_flag = tvb_get_uint8(tvb, tmpoff++);
1339
847
        if (dest_flag == 1)                     /* SME address  */
1340
77
        {
1341
77
            proto_tree_add_item(sub_tree, hf_smpp_dest_addr_ton, tvb, tmpoff, 1, ENC_NA);
1342
77
            tmpoff += 1;
1343
77
            proto_tree_add_item(sub_tree, hf_smpp_dest_addr_npi, tvb, tmpoff, 1, ENC_NA);
1344
77
            tmpoff += 1;
1345
77
            smpp_handle_string(sub_tree,tvb,hf_smpp_destination_addr,&tmpoff);
1346
77
        }
1347
770
        else                                    /* Distribution list    */
1348
770
        {
1349
770
            smpp_handle_string(sub_tree, tvb, hf_smpp_dl_name, &tmpoff);
1350
770
        }
1351
847
    }
1352
39
    *offset = tmpoff;
1353
39
}
1354
1355
/*!
1356
 * Scanning routine to handle the destination result list
1357
 * of 'submit_multi_resp'
1358
 *
1359
 * \param       tree    The protocol tree to add to
1360
 * \param       tvb     Buffer containing the data
1361
 * \param       offset  Location of field in buffer, returns location of
1362
 *                      next field
1363
 */
1364
static void
1365
smpp_handle_dlist_resp(proto_tree *tree, tvbuff_t *tvb, int *offset)
1366
10
{
1367
10
    uint8_t      entries;
1368
10
    int          tmpoff = *offset;
1369
10
    proto_tree  *sub_tree = NULL;
1370
1371
10
    if ((entries = tvb_get_uint8(tvb, tmpoff++))) {
1372
8
        proto_item  *pi;
1373
8
        pi = proto_tree_add_item(tree, hf_smpp_dlist_resp,
1374
8
                                  tvb, *offset, 1, ENC_NA);
1375
8
        sub_tree = proto_item_add_subtree(pi, ett_dlist_resp);
1376
8
    }
1377
238
    while (entries--)
1378
228
    {
1379
228
        proto_tree_add_item(sub_tree, hf_smpp_dest_addr_ton, tvb, tmpoff, 1, ENC_NA);
1380
228
        tmpoff += 1;
1381
228
        proto_tree_add_item(sub_tree, hf_smpp_dest_addr_npi, tvb, tmpoff, 1, ENC_NA);
1382
228
        tmpoff += 1;
1383
228
        smpp_handle_string(sub_tree,tvb,hf_smpp_destination_addr,&tmpoff);
1384
228
        proto_tree_add_item(sub_tree, hf_smpp_error_status_code, tvb, tmpoff, 4, ENC_BIG_ENDIAN);
1385
228
        tmpoff += 4;
1386
228
    }
1387
10
    *offset = tmpoff;
1388
10
}
1389
1390
/*!
1391
 * Scanning routine to handle all optional parameters of SMPP-operations.
1392
 * The parameters have the format Tag Length Value (TLV), with a 2-byte tag
1393
 * and 2-byte length.
1394
 *
1395
 * \param       tree    The protocol tree to add to
1396
 * \param       tvb     Buffer containing the data
1397
 * \param       offset  Location of field in buffer, returns location of
1398
 *                      next field
1399
 */
1400
static void
1401
smpp_handle_tlv(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int *offset, tvbuff_t **tvb_msg)
1402
83
{
1403
83
    proto_tree *tlvs_tree = NULL;
1404
83
    proto_item *pi;
1405
83
    smpp_data_t *smpp_data;
1406
83
    uint16_t source_port = 0, dest_port = 0, sm_id = 0;
1407
83
    uint8_t frags = 0, frag = 0;
1408
83
    bool source_port_found = false, dest_port_found = false;
1409
83
    bool sm_id_found = false;
1410
1411
83
    if (tvb_reported_length_remaining(tvb, *offset) >= 1) {
1412
82
        pi = proto_tree_add_item(tree, hf_smpp_opt_params,
1413
82
                                 tvb, *offset, -1, ENC_NA);
1414
82
        tlvs_tree = proto_item_add_subtree(pi, ett_opt_params);
1415
82
    }
1416
1417
410
    while (tvb_reported_length_remaining(tvb, *offset) >= 1)
1418
403
    {
1419
403
        proto_item *sub_tree;
1420
403
        uint16_t tag;
1421
403
        uint16_t length;
1422
1423
403
        tag = tvb_get_ntohs(tvb, *offset);
1424
403
        length = tvb_get_ntohs(tvb, (*offset+2));
1425
1426
403
        pi = proto_tree_add_none_format(tlvs_tree, hf_smpp_opt_param, tvb,
1427
403
                                        *offset, length+4,
1428
403
                                        "Optional parameter: %s (0x%04x)",
1429
403
                                        val_to_str(pinfo->pool, tag, vals_tlv_tags, "0x%04x"), tag);
1430
403
        sub_tree = proto_item_add_subtree(pi, ett_opt_param);
1431
403
        proto_tree_add_uint(sub_tree,hf_smpp_opt_param_tag,tvb,*offset,2,tag);
1432
403
        proto_tree_add_uint(sub_tree,hf_smpp_opt_param_len,tvb,*offset+2,2,length);
1433
1434
403
        *offset += 4;
1435
1436
403
        switch (tag) {
1437
0
            case  0x0005:       /* dest_addr_subunit    */
1438
0
                proto_tree_add_item(sub_tree, hf_smpp_dest_addr_subunit, tvb, *offset, 1, ENC_NA);
1439
0
                (*offset) += 1;
1440
0
                break;
1441
4
            case  0x0006:       /* dest_network_type    */
1442
4
                proto_tree_add_item(sub_tree, hf_smpp_dest_network_type, tvb, *offset, 1, ENC_NA);
1443
4
                (*offset) += 1;
1444
4
                break;
1445
0
            case  0x0007:       /* dest_bearer_type     */
1446
0
                proto_tree_add_item(sub_tree, hf_smpp_dest_bearer_type, tvb, *offset, 1, ENC_NA);
1447
0
                (*offset) += 1;
1448
0
                break;
1449
4
            case  0x0008:       /* dest_telematics_id   */
1450
4
                proto_tree_add_item(sub_tree, hf_smpp_dest_telematics_id, tvb, *offset, 2, ENC_BIG_ENDIAN);
1451
4
                (*offset) += 2;
1452
4
                break;
1453
1
            case  0x000D:       /* source_addr_subunit  */
1454
1
                proto_tree_add_item(sub_tree, hf_smpp_source_addr_subunit, tvb, *offset, 1, ENC_NA);
1455
1
                (*offset) += 1;
1456
1
                break;
1457
1
            case  0x000E:       /* source_network_type  */
1458
1
                proto_tree_add_item(sub_tree, hf_smpp_source_network_type, tvb, *offset, 1, ENC_NA);
1459
1
                (*offset) += 1;
1460
1
                break;
1461
0
            case  0x000F:       /* source_bearer_type   */
1462
0
                proto_tree_add_item(sub_tree, hf_smpp_source_bearer_type, tvb, *offset, 1, ENC_NA);
1463
0
                (*offset) += 1;
1464
0
                break;
1465
2
            case  0x0010:       /* source_telematics_id */
1466
2
                proto_tree_add_item(sub_tree, hf_smpp_source_telematics_id, tvb, *offset, 1, ENC_NA);
1467
2
                (*offset) += 1;
1468
2
                break;
1469
2
            case  0x0017:       /* qos_time_to_live     */
1470
2
                proto_tree_add_item(sub_tree, hf_smpp_qos_time_to_live, tvb, *offset, 4, ENC_BIG_ENDIAN);
1471
2
                (*offset) += 4;
1472
2
                break;
1473
1
            case  0x0019:       /* payload_type */
1474
1
                proto_tree_add_item(sub_tree, hf_smpp_payload_type, tvb, *offset, 1, ENC_NA);
1475
1
                (*offset) += 1;
1476
1
                break;
1477
1
            case  0x001D:       /* additional_status_info_text  */
1478
1
                if (length)
1479
1
                    proto_tree_add_item(sub_tree, hf_smpp_additional_status_info_text,
1480
1
                        tvb, *offset, length, ENC_ASCII);
1481
1
                (*offset) += length;
1482
1
                break;
1483
1
            case  0x001E:       /* receipted_message_id */
1484
1
                if (length)
1485
1
                    proto_tree_add_item(sub_tree, hf_smpp_receipted_message_id,
1486
1
                        tvb, *offset, length, ENC_ASCII);
1487
1
                (*offset) += length;
1488
1
                break;
1489
0
            case  0x0030: {       /* ms_msg_wait_facilities       */
1490
0
                static int * const fields[] = {
1491
0
                    &hf_smpp_msg_wait_ind,
1492
0
                    &hf_smpp_msg_wait_type,
1493
0
                    NULL
1494
0
                };
1495
1496
1497
0
                proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
1498
0
                (*offset)++;
1499
0
                }
1500
0
                break;
1501
0
            case  0x0201:       /* privacy_indicator    */
1502
0
                proto_tree_add_item(sub_tree, hf_smpp_privacy_indicator, tvb, *offset, 1, ENC_NA);
1503
0
                (*offset) += 1;
1504
0
                break;
1505
1
            case  0x0202:       /* source_subaddress    */
1506
1
                if (length) {
1507
1
                    proto_tree_add_item(sub_tree, hf_smpp_source_subaddress,
1508
1
                                    tvb, *offset, length, ENC_NA);
1509
1
                    (*offset) += length;
1510
1
                }
1511
1
                break;
1512
1
            case  0x0203:       /* dest_subaddress      */
1513
1
                if (length) {
1514
1
                    proto_tree_add_item(sub_tree, hf_smpp_dest_subaddress,
1515
1
                                    tvb, *offset, length, ENC_NA);
1516
1
                    (*offset) += length;
1517
1
                }
1518
1
                break;
1519
0
            case  0x0204:       /* user_message_reference       */
1520
0
                proto_tree_add_item(sub_tree, hf_smpp_user_message_reference, tvb, *offset, 2, ENC_BIG_ENDIAN);
1521
0
                (*offset) += 2;
1522
0
                break;
1523
0
            case  0x0205:       /* user_response_code   */
1524
0
                proto_tree_add_item(sub_tree, hf_smpp_user_response_code, tvb, *offset, 1, ENC_NA);
1525
0
                (*offset) += 1;
1526
0
                break;
1527
0
            case  0x020A:       /* source_port  */
1528
0
                proto_tree_add_item_ret_uint16(sub_tree, hf_smpp_source_port, tvb, *offset, 2, ENC_BIG_ENDIAN, &source_port);
1529
0
                source_port_found = true;
1530
0
                (*offset) += 2;
1531
0
                break;
1532
0
            case  0x020B:       /* destination_port     */
1533
0
                proto_tree_add_item_ret_uint16(sub_tree, hf_smpp_destination_port, tvb, *offset, 2, ENC_BIG_ENDIAN, &dest_port);
1534
0
                dest_port_found = true;
1535
0
                (*offset) += 2;
1536
0
                break;
1537
0
            case  0x020C:       /* sar_msg_ref_num      */
1538
0
                proto_tree_add_item_ret_uint16(sub_tree, hf_smpp_sar_msg_ref_num, tvb, *offset, 2, ENC_BIG_ENDIAN, &sm_id);
1539
0
                sm_id_found = true;
1540
0
                (*offset) += 2;
1541
0
                break;
1542
0
            case  0x020D:       /* language_indicator   */
1543
0
                proto_tree_add_item(sub_tree, hf_smpp_language_indicator, tvb, *offset, 1, ENC_NA);
1544
0
                (*offset) += 1;
1545
0
                break;
1546
0
            case  0x020E:       /* sar_total_segments   */
1547
0
                proto_tree_add_item(sub_tree, hf_smpp_sar_total_segments, tvb, *offset, 1, ENC_NA);
1548
0
                frags = tvb_get_uint8(tvb, *offset);
1549
0
                (*offset) += 1;
1550
0
                break;
1551
0
            case  0x020F:       /* sar_segment_seqnum   */
1552
0
                proto_tree_add_item(sub_tree, hf_smpp_sar_segment_seqnum, tvb, *offset, 1, ENC_NA);
1553
0
                frag = tvb_get_uint8(tvb, *offset);
1554
0
                (*offset) += 1;
1555
0
                break;
1556
0
            case  0x0210:       /* SC_interface_version */
1557
0
                proto_tree_add_item(sub_tree, hf_smpp_SC_interface_version, tvb, *offset, 1, ENC_NA);
1558
0
                (*offset) += 1;
1559
0
                break;
1560
0
            case  0x0302: {      /* callback_num_pres_ind        */
1561
1562
0
                static int * const fields[] = {
1563
0
                    &hf_smpp_callback_num_pres,
1564
0
                    &hf_smpp_callback_num_scrn,
1565
0
                    NULL
1566
0
                };
1567
1568
0
                proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
1569
0
                (*offset)++;
1570
0
                }
1571
0
                break;
1572
5
            case  0x0303:       /* callback_num_atag    */
1573
5
                if (length)
1574
5
                    proto_tree_add_item(sub_tree, hf_smpp_callback_num_atag,
1575
5
                                        tvb, *offset, length, ENC_NA);
1576
5
                (*offset) += length;
1577
5
                break;
1578
0
            case  0x0304:       /* number_of_messages   */
1579
0
                proto_tree_add_item(sub_tree, hf_smpp_number_of_messages, tvb, *offset, 1, ENC_NA);
1580
0
                (*offset) += 1;
1581
0
                break;
1582
0
            case  0x0381:       /* callback_num */
1583
0
                if (length)
1584
0
                    proto_tree_add_item(sub_tree, hf_smpp_callback_num,
1585
0
                                        tvb, *offset, length, ENC_NA);
1586
0
                (*offset) += length;
1587
0
                break;
1588
0
            case  0x0420:       /* dpf_result   */
1589
0
                proto_tree_add_item(sub_tree, hf_smpp_dpf_result, tvb, *offset, 1, ENC_NA);
1590
0
                (*offset) += 1;
1591
0
                break;
1592
0
            case  0x0421:       /* set_dpf      */
1593
0
                proto_tree_add_item(sub_tree, hf_smpp_set_dpf, tvb, *offset, 1, ENC_NA);
1594
0
                (*offset) += 1;
1595
0
                break;
1596
0
            case  0x0422:       /* ms_availability_status       */
1597
0
                proto_tree_add_item(sub_tree, hf_smpp_ms_availability_status, tvb, *offset, 1, ENC_NA);
1598
0
                (*offset) += 1;
1599
0
                break;
1600
0
            case  0x0423:       /* network_error_code   */
1601
0
                proto_tree_add_item(sub_tree, hf_smpp_network_error_type, tvb, *offset, 1, ENC_NA);
1602
0
                (*offset) += 1;
1603
0
                proto_tree_add_item(sub_tree, hf_smpp_network_error_code, tvb, *offset, 2, ENC_BIG_ENDIAN);
1604
0
                (*offset) += 2;
1605
0
                break;
1606
0
            case  0x0424:       /* message_payload      */
1607
0
                if (length) {
1608
0
                    pi = proto_tree_add_item(sub_tree, hf_smpp_message_payload,
1609
0
                                             tvb, *offset, length, ENC_NA);
1610
0
                    if (tvb_msg) {
1611
0
                        if (*tvb_msg != NULL) {
1612
0
                            expert_add_info(pinfo, pi, &ei_smpp_message_payload_duplicate);
1613
0
                        }
1614
0
                        *tvb_msg = tvb_new_subset_length(tvb, *offset, length);
1615
0
                    }
1616
0
                }
1617
0
                (*offset) += length;
1618
0
                break;
1619
0
            case  0x0425:       /* delivery_failure_reason      */
1620
0
                proto_tree_add_item(sub_tree, hf_smpp_delivery_failure_reason, tvb, *offset, 1, ENC_NA);
1621
0
                (*offset) += 1;
1622
0
                break;
1623
0
            case  0x0426:       /* more_messages_to_send        */
1624
0
                proto_tree_add_item(sub_tree, hf_smpp_more_messages_to_send, tvb, *offset, 1, ENC_NA);
1625
0
                (*offset) += 1;
1626
0
                break;
1627
0
            case  0x0427:       /* message_state        */
1628
0
                proto_tree_add_item(sub_tree, hf_smpp_message_state, tvb, *offset, 1, ENC_NA);
1629
0
                (*offset) += 1;
1630
0
                break;
1631
0
            case        0x0428: /* congestion_state */
1632
0
                proto_tree_add_item(sub_tree, hf_smpp_congestion_state, tvb, *offset, 1, ENC_NA);
1633
0
                (*offset) += 1;
1634
0
                break;
1635
1
            case  0x0501:       /* ussd_service_op      */
1636
1
                proto_tree_add_item(sub_tree, hf_smpp_ussd_service_op, tvb, *offset, 1, ENC_NA);
1637
1
                (*offset) += 1;
1638
1
                break;
1639
2
            case 0x0600:        /* broadcast_channel_indicator */
1640
2
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_channel_indicator, tvb, *offset, 1, ENC_NA);
1641
2
                (*offset) += 1;
1642
2
                break;
1643
0
            case 0x0601:        /* broadcast_content_type */
1644
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_nw, tvb, *offset, 1, ENC_NA);
1645
0
                (*offset) += 1;
1646
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_type, tvb, *offset, 2, ENC_BIG_ENDIAN);
1647
0
                (*offset) += 2;
1648
0
                break;
1649
1
            case 0x0602:        /* broadcast_content_type_info */
1650
1
                if (length)
1651
0
                    proto_tree_add_item(sub_tree, hf_smpp_broadcast_content_type_info,
1652
0
                                        tvb, *offset, length, ENC_NA);
1653
1
                (*offset) += length;
1654
1
                break;
1655
0
            case 0x0603:        /* broadcast_message_class */
1656
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_message_class, tvb, *offset, 1, ENC_NA);
1657
0
                (*offset) += 1;
1658
0
                break;
1659
0
            case 0x0604:        /* broadcast_rep_num */
1660
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_rep_num, tvb, *offset, 1, ENC_NA);
1661
0
                (*offset) += 1;
1662
0
                break;
1663
0
            case 0x0605:        /* broadcast_frequency_interval */
1664
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_frequency_interval_unit, tvb, *offset, 1, ENC_NA);
1665
0
                (*offset) += 1;
1666
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_frequency_interval_value, tvb, *offset, 2, ENC_BIG_ENDIAN);
1667
0
                (*offset) += 2;
1668
0
                break;
1669
2
            case 0x0606:        /* broadcast_area_identifier */
1670
2
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_identifier_format, tvb, *offset, 1, ENC_NA);
1671
2
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_identifier,
1672
2
                                        tvb, *offset, length, ENC_NA);
1673
2
                (*offset) += length;
1674
2
                break;
1675
0
            case 0x0607:        /* broadcast_error_status */
1676
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_error_status, tvb, *offset, 4, ENC_BIG_ENDIAN);
1677
0
                (*offset) += 4;
1678
0
                break;
1679
0
            case 0x0608:        /* broadcast_area_success */
1680
0
                proto_tree_add_item(sub_tree, hf_smpp_broadcast_area_success, tvb, *offset, 1, ENC_NA);
1681
0
                (*offset) += 1;
1682
0
                break;
1683
0
            case 0x0609:        /* broadcast_end_time */
1684
0
                smpp_handle_time(sub_tree, tvb, pinfo, hf_smpp_broadcast_end_time,
1685
0
                                hf_smpp_broadcast_end_time_r, offset);
1686
0
                break;
1687
0
            case 0x060A:        /* broadcast_service_group */
1688
0
                if (length)
1689
0
                    proto_tree_add_item(sub_tree, hf_smpp_broadcast_service_group,
1690
0
                                        tvb, *offset, length, ENC_NA);
1691
0
                (*offset) += length;
1692
0
                break;
1693
0
            case 0x060B:        /* billing_identification */
1694
0
                if (length)
1695
0
                    proto_tree_add_item(sub_tree, hf_smpp_billing_identification,
1696
0
                                        tvb, *offset, length, ENC_NA);
1697
0
                (*offset) += length;
1698
0
                break;
1699
            /* 0x060C is skipped in the specs for some reason :-? */
1700
1
            case 0x060D:        /* source_network_id */
1701
1
                if (length)
1702
0
                    proto_tree_add_item(sub_tree, hf_smpp_source_network_id,
1703
0
                        tvb, *offset, length, ENC_ASCII);
1704
1
                (*offset) += length;
1705
1
                break;
1706
0
            case 0x060E:        /* dest_network_id */
1707
0
                if (length)
1708
0
                    proto_tree_add_item(sub_tree, hf_smpp_dest_network_id,
1709
0
                        tvb, *offset, length, ENC_ASCII);
1710
0
                (*offset) += length;
1711
0
                break;
1712
1
            case 0x060F:        /* source_node_id */
1713
1
                if (length)
1714
1
                    proto_tree_add_item(sub_tree, hf_smpp_source_node_id,
1715
1
                                        tvb, *offset, length, ENC_NA);
1716
1
                (*offset) += length;
1717
1
                break;
1718
0
            case 0x0610:        /* dest_node_id */
1719
0
                if (length)
1720
0
                    proto_tree_add_item(sub_tree, hf_smpp_dest_node_id,
1721
0
                                        tvb, *offset, length, ENC_NA);
1722
0
                (*offset) += length;
1723
0
                break;
1724
0
            case 0x0611:        /* dest_addr_np_resolution */
1725
0
                proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_resolution, tvb, *offset, 1, ENC_NA);
1726
0
                (*offset) += 1;
1727
0
                break;
1728
0
            case 0x0612:        /* dest_addr_np_information */
1729
0
                if (length)
1730
0
                    proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_information,
1731
0
                                        tvb, *offset, length, ENC_NA);
1732
0
                (*offset) += length;
1733
0
                break;
1734
0
            case 0x0613:        /* dest_addr_np_country */
1735
                /* TODO : Fetch values from packet-e164? */
1736
0
                if (length)
1737
0
                    proto_tree_add_item(sub_tree, hf_smpp_dest_addr_np_country,
1738
0
                                        tvb, *offset, length, ENC_NA);
1739
0
                (*offset) += length;
1740
0
                break;
1741
0
            case  0x1201:       /* display_time */
1742
0
                proto_tree_add_item(sub_tree, hf_smpp_display_time, tvb, *offset, 1, ENC_NA);
1743
0
                (*offset) += 1;
1744
0
                break;
1745
0
            case  0x1203:       /* sms_signal   */
1746
0
                proto_tree_add_item(sub_tree, hf_smpp_sms_signal, tvb, *offset, 2, ENC_BIG_ENDIAN);
1747
0
                (*offset) += 2;
1748
                /*! \todo Fill as per TIA/EIA-136-710-A         */
1749
0
                break;
1750
0
            case  0x1204:       /* ms_validity  */
1751
0
                proto_tree_add_item(sub_tree, hf_smpp_ms_validity, tvb, *offset, 1, ENC_NA);
1752
0
                (*offset) += 1;
1753
0
                break;
1754
0
            case  0x130C:       /* alert_on_message_delivery    */
1755
0
                if (length == 0) {
1756
0
                        proto_tree_add_item(sub_tree,
1757
0
                                    hf_smpp_alert_on_message_delivery_null,
1758
0
                                    tvb, *offset, length, ENC_NA);
1759
0
                } else {
1760
0
                    proto_tree_add_item(sub_tree, hf_smpp_alert_on_message_delivery_type, tvb, *offset, 1, ENC_NA);
1761
0
                    (*offset) += 1;
1762
0
                }
1763
0
                break;
1764
0
            case  0x1380:       /* its_reply_type       */
1765
0
                proto_tree_add_item(sub_tree, hf_smpp_its_reply_type, tvb, *offset, 1, ENC_NA);
1766
0
                (*offset) += 1;
1767
0
                break;
1768
0
            case  0x1383: {      /* its_session_info     */
1769
1770
0
                static int * const fields[] = {
1771
0
                    &hf_smpp_its_session_sequence,
1772
0
                    &hf_smpp_its_session_ind,
1773
0
                    NULL
1774
0
                };
1775
1776
0
                proto_tree_add_item(sub_tree, hf_smpp_its_session_number, tvb, *offset, 1, ENC_NA);
1777
0
                (*offset) += 1;
1778
0
                proto_tree_add_bitmask_list(sub_tree, tvb, *offset, 1, fields, ENC_NA);
1779
0
                (*offset) += 1;
1780
0
                }
1781
0
                break;
1782
1783
368
            default:
1784
                /* TODO : Hopefully to be implemented soon - handle vendor specific TLVs
1785
                 * from a dictionary before treating them as unknown! */
1786
368
                if ((tag >= 0x1400) && (tag <= 0x3FFF)) {
1787
25
                    proto_tree_add_item(sub_tree, hf_smpp_vendor_op, tvb,
1788
25
                                        *offset, length, ENC_NA);
1789
343
                } else {
1790
343
                    proto_tree_add_item(sub_tree, hf_smpp_reserved_op, tvb,
1791
343
                                        *offset, length, ENC_NA);
1792
343
                }
1793
1794
368
                if (length > 0) {
1795
23
                    char *str;
1796
23
                    str = tvb_bytes_to_str(NULL, tvb,*offset,length);
1797
23
                    proto_item_append_text(sub_tree,": %s", str);
1798
23
                    wmem_free(NULL, str);
1799
23
                }
1800
1801
368
                (*offset) += length;
1802
368
                break;
1803
403
        }
1804
403
    }
1805
1806
7
    if (source_port_found && dest_port_found) {
1807
0
        smpp_data = get_smpp_data(pinfo);
1808
0
        if (smpp_data->udh_fields == NULL) {
1809
0
            smpp_data->udh_fields = wmem_new0(pinfo->pool, gsm_sms_udh_fields_t);
1810
0
        }
1811
0
        smpp_data->udh_fields->port_src = source_port;
1812
0
        smpp_data->udh_fields->port_dst = dest_port;
1813
0
    }
1814
1815
7
    if (sm_id_found && frags && frag) {
1816
        /* frags and frag must be at least 1 */
1817
0
        smpp_data = get_smpp_data(pinfo);
1818
0
        if (smpp_data->udh_fields == NULL) {
1819
0
            smpp_data->udh_fields = wmem_new0(pinfo->pool, gsm_sms_udh_fields_t);
1820
0
        }
1821
0
        smpp_data->udh_fields->sm_id = sm_id;
1822
0
        smpp_data->udh_fields->frags = frags;
1823
0
        smpp_data->udh_fields->frag  = frag;
1824
0
    }
1825
7
}
1826
1827
void
1828
smpp_handle_dcs(proto_tree *tree, tvbuff_t *tvb, int *offset, unsigned *encoding)
1829
68
{
1830
68
    uint32_t    val;
1831
68
    uint8_t     dataCoding;
1832
68
    int         off     = *offset;
1833
68
    proto_tree *subtree;
1834
68
    proto_item *pi;
1835
1836
    /* SMPP Data Coding Scheme */
1837
68
    pi = proto_tree_add_item_ret_uint(tree, hf_smpp_data_coding, tvb, off, 1, ENC_NA, &val);
1838
1839
68
    if (val & 0xC0) {
1840
1841
        /* GSM SMS Data Coding Scheme */
1842
20
        subtree = proto_item_add_subtree(pi, ett_dcs);
1843
1844
20
        if ((val & 0xF0) == 0xF0) {
1845
4
            static int * const gsm_msg_control_fields[] = {
1846
4
                &hf_smpp_dcs_sms_coding_group,
1847
4
                &hf_smpp_dcs_reserved,
1848
4
                &hf_smpp_dcs_charset,
1849
4
                &hf_smpp_dcs_class,
1850
4
                NULL
1851
4
            };
1852
1853
4
            proto_tree_add_bitmask_list(subtree, tvb, off, 1, gsm_msg_control_fields, ENC_NA);
1854
4
            if ((val & 0x04) == 0x04) {
1855
2
                dataCoding = DECODE_AS_OCTET;
1856
2
            } else {
1857
2
                dataCoding = DECODE_AS_GSM7;
1858
2
            }
1859
16
        } else {
1860
16
            static int * const gsm_mwi_control_fields[] = {
1861
16
                &hf_smpp_dcs_sms_coding_group,
1862
16
                &hf_smpp_dcs_wait_ind,
1863
16
                &hf_smpp_dcs_reserved2,
1864
16
                &hf_smpp_dcs_wait_type,
1865
16
                NULL
1866
16
            };
1867
1868
16
            proto_tree_add_bitmask_list(subtree, tvb, off, 1, gsm_mwi_control_fields, ENC_NA);
1869
16
            if ((val & 0xF0) == 0xE0) {
1870
4
                dataCoding = DECODE_AS_UCS2;
1871
12
            } else {
1872
12
                dataCoding = DECODE_AS_GSM7;
1873
12
            }
1874
16
        }
1875
48
    } else {
1876
48
        dataCoding = val;
1877
48
    }
1878
68
    if (encoding != NULL) {
1879
66
        switch (dataCoding)
1880
66
        {
1881
27
        case DECODE_AS_DEFAULT:
1882
27
            *encoding = smpp_decode_dcs_0_sms;
1883
27
            break;
1884
3
        case DECODE_AS_ASCII:
1885
3
            *encoding = ENC_ASCII;
1886
3
            break;
1887
2
        case DECODE_AS_OCTET:
1888
2
            *encoding = DO_NOT_DECODE;
1889
2
            break;
1890
3
        case DECODE_AS_ISO_8859_1:
1891
3
            *encoding = ENC_ISO_8859_1;
1892
3
            break;
1893
2
        case DECODE_AS_ISO_8859_5:
1894
2
            *encoding = ENC_ISO_8859_5;
1895
2
            break;
1896
0
        case DECODE_AS_ISO_8859_8:
1897
0
            *encoding = ENC_ISO_8859_8;
1898
0
            break;
1899
4
        case DECODE_AS_UCS2:
1900
4
            *encoding = ENC_UCS_2|ENC_BIG_ENDIAN;
1901
4
            break;
1902
2
        case DECODE_AS_KSC5601:
1903
2
            *encoding = ENC_EUC_KR;
1904
2
            break;
1905
14
        case DECODE_AS_GSM7:
1906
14
            *encoding = smpp_gsm7_unpacked ? ENC_3GPP_TS_23_038_7BITS_UNPACKED :
1907
14
                ENC_3GPP_TS_23_038_7BITS_PACKED;
1908
14
            break;
1909
9
        default:
1910
            /* XXX: Support decoding unknown values according to the pref? */
1911
9
            *encoding = DO_NOT_DECODE;
1912
9
            break;
1913
66
        }
1914
66
    }
1915
1916
68
    (*offset)++;
1917
68
}
1918
1919
static void
1920
smpp_handle_msg(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, const char *src_str, const char *dst_str)
1921
5
{
1922
5
    smpp_data_t *smpp_data;
1923
5
    address      save_src, save_dst;
1924
5
    unsigned     encoding;
1925
5
    int          udh_offset = 0;
1926
5
    int          length;
1927
1928
5
    smpp_data = get_smpp_data(pinfo);
1929
5
    encoding = smpp_data->encoding;
1930
1931
5
    length = tvb_reported_length(tvb);
1932
1933
5
    if (smpp_data->udhi) /* UDHI indicator present */
1934
2
    {
1935
2
        udh_offset = tvb_get_uint8(tvb, 0) + 1;
1936
2
    }
1937
1938
5
    if (smpp_data->udhi || smpp_data->udh_fields) {
1939
        /* Save original addresses */
1940
2
        copy_address_shallow(&save_src, &pinfo->src);
1941
2
        copy_address_shallow(&save_dst, &pinfo->dst);
1942
        /* Set SMPP source and destination address */
1943
2
        set_address(&(pinfo->src), AT_STRINGZ, 1+(int)strlen(src_str), src_str);
1944
2
        set_address(&(pinfo->dst), AT_STRINGZ, 1+(int)strlen(dst_str), dst_str);
1945
2
        call_dissector_with_data(gsm_sms_handle, tvb, pinfo, proto_tree_get_parent_tree(tree), smpp_data);
1946
        /* Restore original addresses */
1947
2
        copy_address_shallow(&pinfo->src, &save_src);
1948
2
        copy_address_shallow(&pinfo->dst, &save_dst);
1949
2
    }
1950
1951
5
    if (smpp_data->encoding != DO_NOT_DECODE) {
1952
3
        if (smpp_data->encoding == ENC_3GPP_TS_23_038_7BITS_PACKED && smpp_data->udhi) {
1953
            /* SMPP only has the number of octets of the payload, but when
1954
             * packed 7-bit GSM alphabet is used with a UDH, there are fill
1955
             * bits after the UDH to align the SM start with a septet boundary.
1956
             * Calculate the fill bits after the UDH as well as the number of
1957
             * septets that could fit in the bytes. (In certain circumstances
1958
             * there are two possible numbers of septets that would require
1959
             * a certain number of octets. This is part of why packet 7-bit
1960
             * GSM alphabet is not usually used in SMPP, but there are reports
1961
             * of some servers out there.)
1962
             */
1963
0
            uint8_t fill_bits = 6 - ((udh_offset - 1) * 8) % 7;
1964
0
            int septets = ((length - udh_offset) * 8 - fill_bits) / 7;
1965
0
            proto_tree_add_ts_23_038_7bits_packed_item(tree, hf_smpp_short_message, tvb, udh_offset * 8 + fill_bits, septets);
1966
3
        } else {
1967
3
            proto_tree_add_item(tree, hf_smpp_short_message, tvb,
1968
3
                    udh_offset, length-udh_offset, encoding);
1969
3
        }
1970
3
    }
1971
5
}
1972
1973
/*!
1974
 * The next set of routines handle the different operations, associated
1975
 * with SMPP.
1976
 */
1977
static void
1978
bind_receiver(proto_tree *tree, tvbuff_t *tvb, int offset)
1979
61
{
1980
61
    smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
1981
61
    smpp_handle_string(tree, tvb, hf_smpp_password, &offset);
1982
61
    smpp_handle_string(tree, tvb, hf_smpp_system_type, &offset);
1983
61
    proto_tree_add_item(tree, hf_smpp_interface_version, tvb, offset, 1, ENC_NA);
1984
61
    offset += 1;
1985
61
    proto_tree_add_item(tree, hf_smpp_addr_ton, tvb, offset, 1, ENC_NA);
1986
61
    offset += 1;
1987
61
    proto_tree_add_item(tree, hf_smpp_addr_npi, tvb, offset, 1, ENC_NA);
1988
61
    offset += 1;
1989
61
    smpp_handle_string_z(tree, tvb, hf_smpp_address_range, &offset, "NULL");
1990
61
}
1991
1992
static void
1993
query_sm(proto_tree *tree, tvbuff_t *tvb, int offset)
1994
7
{
1995
7
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
1996
7
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
1997
7
    offset += 1;
1998
7
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
1999
7
    offset += 1;
2000
7
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2001
7
}
2002
2003
static void
2004
outbind(proto_tree *tree, tvbuff_t *tvb, int offset)
2005
7
{
2006
7
    smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
2007
7
    smpp_handle_string(tree, tvb, hf_smpp_password, &offset);
2008
7
}
2009
2010
static void
2011
submit_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2012
45
{
2013
45
    tvbuff_t    *tvb_msg = NULL;
2014
45
    smpp_data_t *smpp_data;
2015
45
    uint32_t     length;
2016
45
    const char  *src_str = NULL;
2017
45
    const char  *dst_str = NULL;
2018
45
    nstime_t     zero_time = NSTIME_INIT_ZERO;
2019
2020
45
    smpp_data = get_smpp_data(pinfo);
2021
2022
45
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2023
45
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2024
45
    offset += 1;
2025
45
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2026
45
    offset += 1;
2027
45
    src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
2028
45
    proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
2029
45
    offset += 1;
2030
45
    proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
2031
45
    offset += 1;
2032
45
    dst_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_destination_addr, &offset);
2033
2034
45
    smpp_data->udhi = tvb_get_uint8(tvb, offset) & SMPP_UDHI_MASK;
2035
45
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
2036
45
    offset++;
2037
2038
45
    proto_tree_add_item(tree, hf_smpp_protocol_id, tvb, offset, 1, ENC_NA);
2039
45
    offset += 1;
2040
45
    proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
2041
45
    offset += 1;
2042
45
    if (tvb_get_uint8(tvb,offset)) {
2043
19
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
2044
19
                         hf_smpp_schedule_delivery_time_r, &offset);
2045
26
    } else { /* Time = NULL means Immediate delivery */
2046
26
        proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
2047
26
    }
2048
45
    if (tvb_get_uint8(tvb,offset)) {
2049
15
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period,
2050
15
                         hf_smpp_validity_period_r, &offset);
2051
30
    } else { /* Time = NULL means SMSC default validity */
2052
30
        proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
2053
30
    }
2054
2055
45
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
2056
45
    offset++;
2057
45
    proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
2058
45
    offset += 1;
2059
45
    smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
2060
45
    proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
2061
45
    offset += 1;
2062
45
    proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
2063
45
    if (length)
2064
21
    {
2065
21
        proto_tree_add_item(tree, hf_smpp_short_message_bin,
2066
21
                            tvb, offset, length, ENC_NA);
2067
21
        tvb_msg = tvb_new_subset_length(tvb, offset, length);
2068
21
        offset += length;
2069
21
    }
2070
    /* Get rid of SMPP text string addresses */
2071
45
    smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
2072
2073
45
    if (tvb_msg) {
2074
4
        smpp_handle_msg(tree, tvb_msg, pinfo, src_str, dst_str);
2075
4
    }
2076
45
}
2077
2078
static void
2079
replace_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2080
7
{
2081
7
    tvbuff_t    *tvb_msg = NULL;
2082
7
    smpp_data_t *smpp_data;
2083
7
    uint32_t     length;
2084
7
    const char  *src_str = NULL;
2085
7
    nstime_t     zero_time = NSTIME_INIT_ZERO;
2086
2087
7
    smpp_data = get_smpp_data(pinfo);
2088
2089
7
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2090
7
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2091
7
    offset += 1;
2092
7
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2093
7
    offset += 1;
2094
7
    src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
2095
7
    if (tvb_get_uint8(tvb,offset)) {
2096
5
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
2097
5
                                hf_smpp_schedule_delivery_time_r, &offset);
2098
5
    } else { /* Time = NULL */
2099
2
        proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Keep initial delivery time setting");
2100
2
    }
2101
7
    if (tvb_get_uint8(tvb,offset)) {
2102
4
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period,
2103
4
                                hf_smpp_validity_period_r, &offset);
2104
4
    } else { /* Time = NULL */
2105
3
        proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1,&zero_time, "Keep initial validity period setting");
2106
3
    }
2107
7
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
2108
7
    offset++;
2109
7
    proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
2110
7
    offset += 1;
2111
7
    proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
2112
    /* XXX: replace_sm does not contain a DCS element, so theoretically
2113
     * the encoding must be the same as the previously submitted message
2114
     * with the same message ID. We don't track that, though, so just assume
2115
     * default.
2116
     */
2117
7
    smpp_data->encoding = smpp_decode_dcs_0_sms;
2118
7
    if (length) {
2119
2
        proto_tree_add_item(tree, hf_smpp_short_message_bin,
2120
2
                tvb, offset, length, ENC_NA);
2121
2
        tvb_msg = tvb_new_subset_length(tvb, offset, length);
2122
2
    }
2123
7
    offset += length;
2124
7
    smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
2125
7
    if (tvb_msg) {
2126
0
        smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
2127
0
    }
2128
7
}
2129
2130
static void
2131
cancel_sm(proto_tree *tree, tvbuff_t *tvb, int offset)
2132
10
{
2133
10
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2134
10
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2135
10
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2136
10
    offset += 1;
2137
10
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2138
10
    offset += 1;
2139
10
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2140
10
    proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
2141
10
    offset += 1;
2142
10
    proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
2143
10
    offset += 1;
2144
10
    smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
2145
10
}
2146
2147
static void
2148
submit_multi(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2149
40
{
2150
40
    tvbuff_t    *tvb_msg = NULL;
2151
40
    smpp_data_t *smpp_data;
2152
40
    uint32_t     length;
2153
40
    const char  *src_str = NULL;
2154
40
    nstime_t     zero_time = NSTIME_INIT_ZERO;
2155
2156
40
    smpp_data = get_smpp_data(pinfo);
2157
2158
40
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2159
40
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2160
40
    offset += 1;
2161
40
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2162
40
    offset += 1;
2163
40
    src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
2164
2165
40
    smpp_handle_dlist(tree, tvb, &offset);
2166
2167
40
    smpp_data->udhi = tvb_get_uint8(tvb, offset) & SMPP_UDHI_MASK;
2168
40
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
2169
40
    offset++;
2170
40
    proto_tree_add_item(tree, hf_smpp_protocol_id, tvb, offset, 1, ENC_NA);
2171
40
    offset += 1;
2172
40
    proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
2173
40
    offset += 1;
2174
40
    if (tvb_get_uint8(tvb,offset)) {
2175
14
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
2176
14
                hf_smpp_schedule_delivery_time_r, &offset);
2177
26
    } else { /* Time = NULL means Immediate delivery */
2178
26
        proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
2179
26
    }
2180
40
    if (tvb_get_uint8(tvb,offset)) {
2181
12
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period, hf_smpp_validity_period_r, &offset);
2182
28
    } else { /* Time = NULL means SMSC default validity */
2183
28
        proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
2184
28
    }
2185
40
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
2186
40
    offset++;
2187
40
    proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
2188
40
    offset += 1;
2189
40
    smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
2190
40
    proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
2191
40
    offset += 1;
2192
40
    proto_tree_add_item_ret_uint(tree, hf_smpp_sm_length, tvb, offset++, 1, ENC_NA, &length);
2193
40
    if (length) {
2194
10
        proto_tree_add_item(tree, hf_smpp_short_message_bin,
2195
10
                tvb, offset, length, ENC_NA);
2196
10
        tvb_msg = tvb_new_subset_length(tvb, offset, length);
2197
10
    }
2198
40
    offset += length;
2199
40
    smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
2200
40
    if (tvb_msg) {
2201
        /* submit_multi can have many destinations; for reassembly purposes
2202
         * use the null address, like a broadcast.
2203
         */
2204
1
        smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
2205
1
    }
2206
40
}
2207
2208
static void
2209
alert_notification(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2210
5
{
2211
5
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2212
5
    offset += 1;
2213
5
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2214
5
    offset += 1;
2215
5
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2216
5
    proto_tree_add_item(tree, hf_smpp_esme_addr_ton, tvb, offset, 1, ENC_NA);
2217
5
    offset += 1;
2218
5
    proto_tree_add_item(tree, hf_smpp_esme_addr_npi, tvb, offset, 1, ENC_NA);
2219
5
    offset += 1;
2220
5
    smpp_handle_string(tree, tvb, hf_smpp_esme_addr, &offset);
2221
5
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2222
5
}
2223
2224
static void
2225
data_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2226
1
{
2227
1
    tvbuff_t    *tvb_msg = NULL;
2228
1
    smpp_data_t *smpp_data;
2229
1
    const char  *src_str = NULL;
2230
1
    const char  *dst_str = NULL;
2231
2232
1
    smpp_data = get_smpp_data(pinfo);
2233
2234
1
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2235
1
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2236
1
    offset += 1;
2237
1
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2238
1
    offset += 1;
2239
1
    src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
2240
1
    proto_tree_add_item(tree, hf_smpp_dest_addr_ton, tvb, offset, 1, ENC_NA);
2241
1
    offset += 1;
2242
1
    proto_tree_add_item(tree, hf_smpp_dest_addr_npi, tvb, offset, 1, ENC_NA);
2243
1
    offset += 1;
2244
1
    dst_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_destination_addr, &offset);
2245
1
    smpp_data->udhi = tvb_get_uint8(tvb, offset) & SMPP_UDHI_MASK;
2246
1
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, submit_msg_fields, ENC_NA);
2247
1
    offset++;
2248
1
    proto_tree_add_bitmask_list(tree, tvb, offset, 1, regdel_fields, ENC_NA);
2249
1
    offset++;
2250
1
    smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
2251
1
    smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
2252
1
    if (tvb_msg) {
2253
0
        smpp_handle_msg(tree, tvb_msg, pinfo, src_str, dst_str);
2254
0
    }
2255
1
}
2256
2257
/*
2258
 * Request operations introduced in the SMPP 5.0
2259
 */
2260
static void
2261
broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2262
2
{
2263
2
    nstime_t     zero_time = NSTIME_INIT_ZERO;
2264
2
    tvbuff_t    *tvb_msg = NULL;
2265
2
    smpp_data_t *smpp_data;
2266
2
    const char  *src_str = NULL;
2267
2268
2
    smpp_data = get_smpp_data(pinfo);
2269
2270
2
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2271
2
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2272
2
    offset += 1;
2273
2
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2274
2
    offset += 1;
2275
2
    src_str = smpp_handle_string_return(tree, tvb, pinfo, hf_smpp_source_addr, &offset);
2276
2
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2277
2
    proto_tree_add_item(tree, hf_smpp_priority_flag, tvb, offset, 1, ENC_NA);
2278
2
    offset += 1;
2279
2
    if (tvb_get_uint8(tvb,offset)) {
2280
1
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_schedule_delivery_time,
2281
1
                hf_smpp_schedule_delivery_time_r, &offset);
2282
1
    } else { /* Time = NULL means Immediate delivery */
2283
1
        proto_tree_add_time_format_value(tree, hf_smpp_schedule_delivery_time_r, tvb, offset++, 1, &zero_time, "Immediate delivery");
2284
1
    }
2285
2
    if (tvb_get_uint8(tvb,offset)) {
2286
0
        smpp_handle_time(tree, tvb, pinfo, hf_smpp_validity_period, hf_smpp_validity_period_r, &offset);
2287
2
    } else { /* Time = NULL means SMSC default validity */
2288
2
        proto_tree_add_time_format_value(tree, hf_smpp_validity_period_r, tvb, offset++, 1, &zero_time, "SMSC default validity period");
2289
2
    }
2290
2
    proto_tree_add_item(tree, hf_smpp_replace_if_present_flag, tvb, offset, 1, ENC_NA);
2291
2
    offset += 1;
2292
2
    smpp_handle_dcs(tree, tvb, &offset, &smpp_data->encoding);
2293
2
    proto_tree_add_item(tree, hf_smpp_sm_default_msg_id, tvb, offset, 1, ENC_NA);
2294
2
    offset += 1;
2295
2
    smpp_handle_tlv(tree, tvb, pinfo, &offset, &tvb_msg);
2296
2
    if (tvb_msg) {
2297
0
        smpp_handle_msg(tree, tvb_msg, pinfo, src_str, "");
2298
0
    }
2299
2
}
2300
2301
static void
2302
query_broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2303
1
{
2304
1
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2305
1
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2306
1
    offset += 1;
2307
1
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2308
1
    offset += 1;
2309
1
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2310
1
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2311
1
}
2312
2313
static void
2314
cancel_broadcast_sm(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2315
4
{
2316
4
    smpp_handle_string_z(tree, tvb, hf_smpp_service_type, &offset, "(Default)");
2317
4
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2318
4
    proto_tree_add_item(tree, hf_smpp_source_addr_ton, tvb, offset, 1, ENC_NA);
2319
4
    offset += 1;
2320
4
    proto_tree_add_item(tree, hf_smpp_source_addr_npi, tvb, offset, 1, ENC_NA);
2321
4
    offset += 1;
2322
4
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2323
4
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2324
4
}
2325
2326
/*!
2327
 * The next set of routines handle the different operation-responses,
2328
 * associated with SMPP.
2329
 */
2330
static void
2331
bind_receiver_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2332
4
{
2333
4
    smpp_handle_string(tree, tvb, hf_smpp_system_id, &offset);
2334
4
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2335
4
}
2336
2337
static void
2338
query_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2339
0
{
2340
0
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2341
0
    smpp_handle_time(tree, tvb, pinfo, hf_smpp_final_date,
2342
0
                                hf_smpp_final_date_r, &offset);
2343
0
    proto_tree_add_item(tree, hf_smpp_message_state, tvb, offset, 1, ENC_NA);
2344
0
    offset += 1;
2345
0
    proto_tree_add_item(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA);
2346
0
    offset += 1;
2347
0
}
2348
2349
static void
2350
submit_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2351
0
{
2352
0
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2353
0
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2354
0
}
2355
2356
static void
2357
submit_multi_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2358
10
{
2359
10
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2360
10
    smpp_handle_dlist_resp(tree, tvb, &offset);
2361
10
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2362
10
}
2363
2364
static void
2365
data_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2366
0
{
2367
0
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2368
0
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2369
0
}
2370
2371
static void
2372
query_broadcast_sm_resp(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
2373
0
{
2374
0
    smpp_handle_string(tree, tvb, hf_smpp_message_id, &offset);
2375
0
    smpp_handle_tlv(tree, tvb, pinfo, &offset, NULL);
2376
0
}
2377
2378
/* Huawei SMPP+ extensions */
2379
static void
2380
huawei_auth_acc(proto_tree *tree, tvbuff_t *tvb, int offset)
2381
5
{
2382
5
    uint32_t version;
2383
2384
5
    proto_tree_add_item_ret_uint(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA, &version);
2385
5
    offset += 1;
2386
5
    smpp_handle_string(tree, tvb, hf_huawei_smpp_smsc_addr, &offset);
2387
5
    if ( version == '3' ) {
2388
0
        proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_noa, tvb, offset, 1, ENC_NA);
2389
0
        offset += 1;
2390
0
        proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_npi, tvb, offset, 1, ENC_NA);
2391
0
        offset += 1;
2392
0
        smpp_handle_string(tree, tvb, hf_huawei_smpp_msc_addr, &offset);
2393
0
    }
2394
5
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2395
5
    smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
2396
5
    proto_tree_add_item(tree, hf_huawei_smpp_mo_mt_flag, tvb, offset, 1, ENC_NA);
2397
5
    offset += 1;
2398
5
    smpp_handle_string(tree, tvb, hf_huawei_smpp_sm_id, &offset);
2399
5
    proto_tree_add_item(tree, hf_huawei_smpp_length_auth, tvb, offset, 4, ENC_BIG_ENDIAN);
2400
5
    offset += 4;
2401
5
    proto_tree_add_item(tree, hf_huawei_smpp_service_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2402
5
}
2403
2404
static void
2405
huawei_auth_acc_resp(proto_tree *tree, tvbuff_t *tvb, int offset)
2406
0
{
2407
0
    proto_tree_add_item(tree, hf_huawei_smpp_operation_result, tvb, offset, 4, ENC_BIG_ENDIAN);
2408
0
    offset += 4;
2409
0
    proto_tree_add_item(tree, hf_huawei_smpp_notify_mode, tvb, offset, 1, ENC_NA);
2410
0
}
2411
2412
static void
2413
huawei_sm_result_notify(proto_tree *tree, tvbuff_t *tvb, int offset)
2414
2
{
2415
2
    uint32_t version;
2416
2417
2
    proto_tree_add_item_ret_uint(tree, hf_smpp_error_code, tvb, offset, 1, ENC_NA, &version);
2418
2
    offset += 1;
2419
2
    smpp_handle_string(tree, tvb, hf_huawei_smpp_smsc_addr, &offset);
2420
2421
2
    if ( version == '3' ) {
2422
0
        proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_noa, tvb, offset, 1, ENC_NA);
2423
0
        offset += 1;
2424
0
        proto_tree_add_item(tree, hf_huawei_smpp_msc_addr_npi, tvb, offset, 1, ENC_NA);
2425
0
        offset += 1;
2426
0
        smpp_handle_string(tree, tvb, hf_huawei_smpp_msc_addr, &offset);
2427
0
    }
2428
2429
2
    smpp_handle_string(tree, tvb, hf_smpp_source_addr, &offset);
2430
2
    smpp_handle_string(tree, tvb, hf_smpp_destination_addr, &offset);
2431
2
    proto_tree_add_item(tree, hf_huawei_smpp_mo_mt_flag, tvb, offset, 1, ENC_NA);
2432
2
    offset += 1;
2433
2
    smpp_handle_string(tree, tvb, hf_huawei_smpp_sm_id, &offset);
2434
2
    proto_tree_add_item(tree, hf_huawei_smpp_length_auth, tvb, offset, 4, ENC_BIG_ENDIAN);
2435
2
    offset += 4;
2436
2
    proto_tree_add_item(tree, hf_huawei_smpp_delivery_result, tvb, offset, 4, ENC_BIG_ENDIAN);
2437
2
    offset += 4;
2438
2
    proto_tree_add_item(tree, hf_huawei_smpp_service_id, tvb, offset, 4, ENC_BIG_ENDIAN);
2439
2
}
2440
2441
static void
2442
huawei_sm_result_notify_resp(proto_tree *tree, tvbuff_t *tvb, int offset)
2443
0
{
2444
0
    proto_tree_add_item(tree, hf_huawei_smpp_delivery_result, tvb, offset, 4, ENC_BIG_ENDIAN);
2445
0
}
2446
2447
static bool
2448
test_smpp(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
2449
3.79k
{
2450
3.79k
    uint32_t     command_id;            /* SMPP command         */
2451
3.79k
    uint32_t     command_status;        /* Status code          */
2452
3.79k
    uint32_t     command_length;        /* length of PDU        */
2453
2454
3.79k
    if (tvb_reported_length_remaining(tvb, offset) < SMPP_MIN_LENGTH ||   /* Mandatory header     */
2455
3.16k
        tvb_captured_length_remaining(tvb, offset) < 12)
2456
656
        return false;
2457
3.14k
    command_length = tvb_get_ntohl(tvb, offset);
2458
3.14k
    if (command_length > 64 * 1024 || command_length < SMPP_MIN_LENGTH)
2459
2.69k
        return false;
2460
447
    command_id = tvb_get_ntohl(tvb, offset + 4);         /* Only known commands  */
2461
447
    if (try_val_to_str(command_id, vals_command_id) == NULL)
2462
159
        return false;
2463
288
    command_status = tvb_get_ntohl(tvb, offset + 8);     /* ..with known status  */
2464
288
    if (try_rval_to_str(command_status, rvals_command_status) == NULL)
2465
1
        return false;
2466
2467
287
    return true;
2468
288
}
2469
2470
static unsigned
2471
get_smpp_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb, int offset, void *data _U_)
2472
226
{
2473
226
    return tvb_get_ntohl(tvb, offset);
2474
226
}
2475
2476
static void
2477
export_smpp_pdu(packet_info *pinfo, tvbuff_t *tvb)
2478
0
{
2479
0
    exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, "smpp", EXP_PDU_TAG_DISSECTOR_NAME);
2480
2481
0
    exp_pdu_data->tvb_captured_length = tvb_captured_length(tvb);
2482
0
    exp_pdu_data->tvb_reported_length = tvb_reported_length(tvb);
2483
0
    exp_pdu_data->pdu_tvb = tvb;
2484
2485
0
    tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
2486
0
}
2487
2488
static unsigned
2489
smpp_txn_key_hash(const void *k)
2490
349
{
2491
349
    const smpp_txn_key_t *key = (const smpp_txn_key_t *)k;
2492
349
    unsigned hash_val = 0;
2493
2494
349
    hash_val = add_address_to_hash(hash_val, &key->src_addr);
2495
349
    hash_val = add_address_to_hash(hash_val, &key->dst_addr);
2496
349
    hash_val ^= key->sequence_number * 2654435761u;
2497
349
    return hash_val;
2498
349
}
2499
2500
static gboolean
2501
smpp_txn_key_equal(const void *a, const void *b)
2502
62
{
2503
62
    const smpp_txn_key_t *key_a = (const smpp_txn_key_t *)a;
2504
62
    const smpp_txn_key_t *key_b = (const smpp_txn_key_t *)b;
2505
2506
62
    return addresses_equal(&key_a->src_addr, &key_b->src_addr) &&
2507
62
           addresses_equal(&key_a->dst_addr, &key_b->dst_addr) &&
2508
62
           key_a->sequence_number == key_b->sequence_number;
2509
62
}
2510
2511
static smpp_txn_key_t*
2512
get_smpp_txn_key(packet_info *pinfo, unsigned command_id, unsigned sequence_number, wmem_allocator_t *wma)
2513
307
{
2514
307
    smpp_txn_key_t *txn_key = wmem_new0(wma, smpp_txn_key_t);
2515
307
    txn_key->sequence_number = sequence_number;
2516
307
    if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2517
        /* PDU is a response; key direction reversed */
2518
76
        copy_address_wmem(wma, &txn_key->src_addr, &pinfo->dst);
2519
76
        copy_address_wmem(wma, &txn_key->dst_addr, &pinfo->src);
2520
76
        return txn_key;
2521
231
    } else {
2522
231
        copy_address_wmem(wma, &txn_key->src_addr, &pinfo->src);
2523
231
        copy_address_wmem(wma, &txn_key->dst_addr, &pinfo->dst);
2524
231
        return txn_key;
2525
231
    }
2526
307
}
2527
2528
static smpp_session_t*
2529
find_or_create_smpp_session(packet_info *pinfo)
2530
307
{
2531
307
    conversation_t *conversation = find_or_create_conversation(pinfo);
2532
307
    smpp_session_t *smpp_session = conversation_get_proto_data(conversation, proto_smpp);
2533
307
    if (!smpp_session) {
2534
120
        smpp_session = wmem_new0(wmem_file_scope(), smpp_session_t);
2535
120
        smpp_session->rr_map = wmem_multimap_new(wmem_file_scope(), smpp_txn_key_hash, smpp_txn_key_equal);
2536
120
        conversation_add_proto_data(conversation, proto_smpp, smpp_session);
2537
120
    }
2538
307
    return smpp_session;
2539
307
}
2540
2541
/* Dissect a single SMPP PDU contained within "tvb". */
2542
static int
2543
dissect_smpp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
2544
313
{
2545
313
    int             offset      = 0; /* Offset within tvbuff */
2546
313
    unsigned        command_length;  /* length of PDU        */
2547
313
    unsigned        command_id;      /* SMPP command         */
2548
313
    unsigned        command_status;  /* Status code          */
2549
313
    unsigned        sequence_number; /* ...of command        */
2550
313
    smpp_tap_rec_t *tap_rec;         /* Tap record           */
2551
313
    const char     *command_str;
2552
313
    const char     *command_status_str = NULL;
2553
    /* Set up structures needed to add the protocol subtree and manage it */
2554
313
    proto_item     *ti;
2555
313
    proto_tree     *smpp_tree;
2556
2557
    /* Request/response tracking */
2558
313
    smpp_session_t *smpp_session = NULL;
2559
313
    smpp_txn_t     *smpp_txn = NULL;
2560
313
    smpp_txn_key_t *txn_key = NULL;
2561
313
    nstime_t       ns;
2562
2563
    /*
2564
     * Safety: don't even try to dissect the PDU
2565
     * when the mandatory header isn't present.
2566
     */
2567
313
    if (tvb_reported_length(tvb) < SMPP_MIN_LENGTH)
2568
1
        return 0;
2569
312
    command_length = tvb_get_ntohl(tvb, offset);
2570
312
    offset += 4;
2571
312
    command_id = tvb_get_ntohl(tvb, offset);
2572
312
    command_str = val_to_str(pinfo->pool, command_id, vals_command_id,
2573
312
            "(Unknown SMPP Operation 0x%08X)");
2574
312
    offset += 4;
2575
312
    command_status = tvb_get_ntohl(tvb, offset);
2576
312
    if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2577
        /* PDU is a response. */
2578
77
        command_status_str = rval_to_str_wmem(pinfo->pool, command_status, rvals_command_status, "Unknown (0x%08x)");
2579
77
    }
2580
312
    offset += 4;
2581
312
    sequence_number = tvb_get_ntohl(tvb, offset);
2582
2583
    /* Request/response tracking */
2584
312
    smpp_session = find_or_create_smpp_session(pinfo);
2585
312
    if (!PINFO_FD_VISITED(pinfo)) {
2586
307
        if ((command_id & SMPP_COMMAND_ID_RESPONSE_MASK) == 0) {
2587
            /* This is a request. We assume that it will always be seen before the response. */
2588
231
            txn_key = get_smpp_txn_key(pinfo, command_id, sequence_number, wmem_file_scope());
2589
231
            smpp_txn = wmem_new0(wmem_file_scope(), smpp_txn_t);
2590
231
            wmem_multimap_insert32(smpp_session->rr_map, txn_key, pinfo->num, smpp_txn);
2591
231
            smpp_txn->req_frame = pinfo->num;
2592
231
            smpp_txn->req_time = pinfo->fd->abs_ts;
2593
231
        } else {
2594
            /* This is a response. */
2595
76
            txn_key = get_smpp_txn_key(pinfo, command_id, sequence_number, pinfo->pool);
2596
76
            smpp_txn = (smpp_txn_t *)wmem_multimap_lookup32_le(smpp_session->rr_map, txn_key, pinfo->num);
2597
76
            if (smpp_txn) {
2598
0
                smpp_txn->res_frame = pinfo->num;
2599
0
                smpp_txn->res_time = pinfo->fd->abs_ts;
2600
0
            }
2601
76
        }
2602
307
    } else {
2603
5
        txn_key = get_smpp_txn_key(pinfo, command_id, sequence_number, pinfo->pool);
2604
5
        smpp_txn = (smpp_txn_t *)wmem_multimap_lookup32_le(smpp_session->rr_map, txn_key, pinfo->num);
2605
5
    }
2606
2607
312
    if (have_tap_listener(exported_pdu_tap)){
2608
0
        export_smpp_pdu(pinfo,tvb);
2609
0
    }
2610
2611
    /*
2612
     * Update the protocol column.
2613
     */
2614
312
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMPP");
2615
312
    col_clear(pinfo->cinfo, COL_INFO);
2616
2617
    /*
2618
     * Create display subtree for the protocol
2619
     */
2620
312
    ti = proto_tree_add_item (tree, proto_smpp, tvb, 0, tvb_captured_length(tvb), ENC_NA);
2621
312
    smpp_tree = proto_item_add_subtree (ti, ett_smpp);
2622
2623
    /*
2624
     * Make entries in the Info column on the summary display
2625
     */
2626
312
    col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", command_str);
2627
2628
    /*
2629
     * Display command status of responses in Info column
2630
     */
2631
312
    if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2632
76
        col_append_fstr(pinfo->cinfo, COL_INFO, ": \"%s\"", command_status_str);
2633
76
    }
2634
2635
    /*
2636
     * Set the fence before dissecting the PDU because if the PDU is invalid it
2637
     * may throw an exception and the next PDU will clear the info about the
2638
     * current PDU
2639
     */
2640
312
    col_set_fence(pinfo->cinfo, COL_INFO);
2641
2642
    /*
2643
     * Dissect the PDU
2644
     */
2645
2646
    /*
2647
     * Create display subtree for the PDU
2648
     */
2649
312
    proto_tree_add_uint(smpp_tree, hf_smpp_command_length, tvb, 0, 4, command_length);
2650
312
    if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2651
76
        ti = proto_tree_add_boolean(smpp_tree, hf_smpp_command_response, tvb, 4, 4, true);
2652
76
    }
2653
236
    else {
2654
236
        ti = proto_tree_add_boolean(smpp_tree, hf_smpp_command_request, tvb, 4, 4, true);
2655
236
    }
2656
312
    proto_item_set_generated(ti);
2657
312
    proto_tree_add_uint(smpp_tree, hf_smpp_command_id, tvb, 4, 4, command_id);
2658
312
    proto_item_append_text(smpp_tree, ", Command: %s", command_str);
2659
2660
    /*
2661
     * Status is only meaningful with responses
2662
     */
2663
312
    if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2664
76
        proto_tree_add_uint(smpp_tree, hf_smpp_command_status, tvb, 8, 4, command_status);
2665
76
        proto_item_append_text (smpp_tree, ", Status: \"%s\"", command_status_str);
2666
76
    }
2667
312
    proto_tree_add_uint(smpp_tree, hf_smpp_sequence_number, tvb, 12, 4, sequence_number);
2668
312
    proto_item_append_text(smpp_tree, ", Seq: %u, Len: %u", sequence_number, command_length);
2669
2670
    /* Set the conversation related fields */
2671
312
    if (smpp_txn) {
2672
231
        if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK) {
2673
            /* Fill info about request frame and response time, but only if both req/res seen */
2674
0
            if (smpp_txn->req_frame > 0 && smpp_txn->res_frame > 0) {
2675
0
                ti =  proto_tree_add_uint(smpp_tree, hf_smpp_request_in, tvb, 0, 0, smpp_txn->req_frame);
2676
0
                proto_item_set_generated(ti);
2677
2678
0
                nstime_delta(&ns, &smpp_txn->res_time, &smpp_txn->req_time);
2679
0
                ti = proto_tree_add_time(smpp_tree, hf_smpp_response_time, tvb, 0, 0, &ns);
2680
0
                proto_item_set_generated(ti);
2681
0
            }
2682
231
        } else {
2683
231
            if (smpp_txn->res_frame > 0) {
2684
0
                ti =  proto_tree_add_uint(smpp_tree, hf_smpp_response_in, tvb, 0, 0, smpp_txn->res_frame);
2685
0
                proto_item_set_generated(ti);
2686
0
            }
2687
231
        }
2688
231
    }
2689
2690
312
    if (command_length <= tvb_reported_length(tvb))
2691
307
    {
2692
307
        if (command_id & SMPP_COMMAND_ID_RESPONSE_MASK)
2693
76
        {
2694
76
            switch (command_id & (~SMPP_COMMAND_ID_RESPONSE_MASK)) {
2695
                /*
2696
                    * All of these only have a fixed header
2697
                    */
2698
3
                case SMPP_COMMAND_ID_GENERIC_NACK:
2699
3
                case SMPP_COMMAND_ID_UNBIND:
2700
3
                case SMPP_COMMAND_ID_REPLACE_SM:
2701
3
                case SMPP_COMMAND_ID_CANCEL_SM:
2702
3
                case SMPP_COMMAND_ID_ENQUIRE_LINK:
2703
3
                case SMPP_COMMAND_ID_CANCEL_BROADCAST_SM:
2704
3
                    break;
2705
                /* FIXME: The body of the response PDUs are only
2706
                    * only dissected if the request was successful.
2707
                    * However, in SMPP 5.0 some responses might
2708
                    * contain body to provide additional information
2709
                    * about the error. This needs to be handled.
2710
                    */
2711
1
                case SMPP_COMMAND_ID_BIND_RECEIVER:
2712
1
                case SMPP_COMMAND_ID_BIND_TRANSMITTER:
2713
6
                case SMPP_COMMAND_ID_BIND_TRANSCEIVER:
2714
6
                    if (!command_status)
2715
4
                        bind_receiver_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2716
6
                    break;
2717
1
                case SMPP_COMMAND_ID_QUERY_SM:
2718
1
                    if (!command_status)
2719
0
                        query_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2720
1
                    break;
2721
1
                case SMPP_COMMAND_ID_SUBMIT_SM:
2722
1
                case SMPP_COMMAND_ID_DELIVER_SM:
2723
2
                case SMPP_COMMAND_ID_BROADCAST_SM:
2724
2
                    if (!command_status)
2725
0
                        submit_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2726
2
                    break;
2727
10
                case SMPP_COMMAND_ID_SUBMIT_MULTI:
2728
10
                    if (!command_status)
2729
10
                        submit_multi_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2730
10
                    break;
2731
0
                case SMPP_COMMAND_ID_DATA_SM:
2732
0
                    if (!command_status)
2733
0
                        data_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2734
0
                    break;
2735
0
                case SMPP_COMMAND_ID_QUERY_BROADCAST_SM:
2736
0
                    if (!command_status)
2737
0
                        query_broadcast_sm_resp(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2738
0
                    break;
2739
0
                case SMPP_COMMAND_ID_HUAWEI_AUTH_ACC:
2740
0
                    if (!command_status)
2741
0
                        huawei_auth_acc_resp(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2742
0
                    break;
2743
0
                    case SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY:
2744
0
                    if (!command_status)
2745
0
                        huawei_sm_result_notify_resp(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2746
0
                    break;
2747
54
                default:
2748
54
                    break;
2749
76
            } /* switch (command_id & 0x7FFFFFFF) */
2750
76
        }
2751
231
        else
2752
231
        {
2753
231
            switch (command_id) {
2754
52
                case SMPP_COMMAND_ID_BIND_RECEIVER:
2755
60
                case SMPP_COMMAND_ID_BIND_TRANSMITTER:
2756
61
                case SMPP_COMMAND_ID_BIND_TRANSCEIVER:
2757
61
                    bind_receiver(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2758
61
                    break;
2759
7
                case SMPP_COMMAND_ID_QUERY_SM:
2760
7
                    query_sm(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2761
7
                    break;
2762
31
                case SMPP_COMMAND_ID_SUBMIT_SM:
2763
45
                case SMPP_COMMAND_ID_DELIVER_SM:
2764
45
                    submit_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2765
45
                    break;
2766
2
                case SMPP_COMMAND_ID_UNBIND:
2767
2
                case SMPP_COMMAND_ID_ENQUIRE_LINK:
2768
2
                    break;
2769
7
                case SMPP_COMMAND_ID_REPLACE_SM:
2770
7
                    replace_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2771
7
                    break;
2772
10
                case SMPP_COMMAND_ID_CANCEL_SM:
2773
10
                    cancel_sm(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2774
10
                    break;
2775
7
                case SMPP_COMMAND_ID_OUTBIND:
2776
7
                    outbind(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2777
7
                    break;
2778
40
                case SMPP_COMMAND_ID_SUBMIT_MULTI:
2779
40
                    submit_multi(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2780
40
                    break;
2781
5
                case SMPP_COMMAND_ID_ALERT_NOTIFICATION:
2782
5
                    alert_notification(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2783
5
                    break;
2784
1
                case SMPP_COMMAND_ID_DATA_SM:
2785
1
                    data_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2786
1
                    break;
2787
2
                case SMPP_COMMAND_ID_BROADCAST_SM:
2788
2
                    broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2789
2
                    break;
2790
1
                case SMPP_COMMAND_ID_QUERY_BROADCAST_SM:
2791
1
                    query_broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2792
1
                    break;
2793
4
                case SMPP_COMMAND_ID_CANCEL_BROADCAST_SM:
2794
4
                    cancel_broadcast_sm(smpp_tree, tvb, pinfo, SMPP_FIXED_HEADER_LENGTH);
2795
4
                    break;
2796
5
                case SMPP_COMMAND_ID_HUAWEI_AUTH_ACC:
2797
5
                    huawei_auth_acc(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2798
5
                    break;
2799
2
                case SMPP_COMMAND_ID_HUAWEI_SM_RESULT_NOTIFY:
2800
2
                    huawei_sm_result_notify(smpp_tree, tvb, SMPP_FIXED_HEADER_LENGTH);
2801
2
                    break;
2802
32
                default:
2803
32
                    break;
2804
231
            } /* switch (command_id) */
2805
231
        }
2806
2807
307
    }
2808
2809
    /* Queue packet for Tap */
2810
169
    tap_rec = wmem_new0(pinfo->pool, smpp_tap_rec_t);
2811
169
    tap_rec->command_id = command_id;
2812
169
    tap_rec->command_status = command_status;
2813
169
    tap_queue_packet(smpp_tap, pinfo, tap_rec);
2814
2815
169
    return tvb_captured_length(tvb);
2816
312
}
2817
2818
static int
2819
dissect_smpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
2820
248
{
2821
248
    if (pinfo->ptype == PT_TCP) {       /* are we running on top of TCP */
2822
194
        if (!test_smpp(pinfo, tvb, 0, data)) {
2823
27
            return 0;
2824
27
        }
2825
167
        tcp_dissect_pdus(tvb, pinfo, tree,
2826
167
            reassemble_over_tcp,    /* Do we try to reassemble      */
2827
167
            SMPP_FIXED_HEADER_LENGTH, /* Length of fixed header       */
2828
            /* XXX: We only use the first 4 bytes for the length, do we
2829
             * really need to pass in the entire fixed header? */
2830
167
            get_smpp_pdu_len,       /* Function returning PDU len   */
2831
167
            dissect_smpp_pdu, data);      /* PDU dissector                */
2832
167
    }
2833
54
    else {                            /* no? probably X.25            */
2834
54
        uint32_t offset = 0;
2835
144
        while (tvb_reported_length_remaining(tvb, offset) > 0) {
2836
90
            uint32_t pdu_len = tvb_get_ntohl(tvb, offset);
2837
90
            int pdu_real_len = tvb_captured_length_remaining(tvb, offset);
2838
90
            tvbuff_t *pdu_tvb;
2839
2840
90
            if (pdu_len < 1)
2841
0
                return offset;
2842
2843
90
            if (pdu_real_len <= 0)
2844
0
                return offset;
2845
90
            pdu_tvb = tvb_new_subset_length(tvb, offset, pdu_len);
2846
90
            dissect_smpp_pdu(pdu_tvb, pinfo, tree, data);
2847
90
            offset += pdu_len;
2848
90
        }
2849
54
    }
2850
2851
221
    return tvb_captured_length(tvb);
2852
248
}
2853
2854
/*
2855
* A 'heuristic dissector' that attemtps to establish whether we have
2856
* a genuine SMPP PDU here.
2857
* Only works when:
2858
*      at least the fixed header is there
2859
*      it has a correct overall PDU length
2860
*      it is a 'well-known' operation
2861
*      has a 'well-known' or 'reserved' status
2862
*/
2863
static bool
2864
dissect_smpp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2865
3.60k
{
2866
3.60k
    uint32_t     command_id;            /* SMPP command         */
2867
2868
3.60k
    conversation_t* conversation;
2869
2870
3.60k
    if (!test_smpp(pinfo, tvb, 0, data)) {
2871
3.48k
        return false;
2872
3.48k
    }
2873
2874
    // Test a few extra bytes in the heuristic dissector, past the
2875
    // minimum fixed header length, to reduce false positives.
2876
2877
120
    command_id = tvb_get_ntohl(tvb, 4);
2878
    //Check for specific values in commands (to avoid false positives)
2879
120
    switch (command_id)
2880
120
    {
2881
2
    case SMPP_COMMAND_ID_ALERT_NOTIFICATION:
2882
2
    {
2883
2
        uint8_t ton, npi;
2884
2885
2
        if (tvb_reported_length(tvb) < 19)
2886
0
            return false;
2887
2
        ton = tvb_get_uint8(tvb, 16);
2888
2
        if (try_val_to_str(ton, vals_addr_ton) == NULL)
2889
0
            return false;
2890
2891
2
        npi = tvb_get_uint8(tvb, 17);
2892
2
        if (try_val_to_str(npi, vals_addr_npi) == NULL)
2893
0
            return false;
2894
2895
        //address must be NULL-terminated string of up to 65 ascii characters
2896
2
        unsigned end;
2897
2
        bool found;
2898
2
        found = tvb_find_uint8_remaining(tvb, 18, 0, &end);
2899
2
        if ((found == false) ||(end == 0) || (end > 65))
2900
0
            return false;
2901
2902
2
        if (!tvb_ascii_isprint(tvb, 18, end - 18))
2903
0
            return false;
2904
2
    }
2905
2
    break;
2906
120
    }
2907
2908
    /* This is called on TCP or X.25, both of which are endpoint types.
2909
     * Set the conversation so we can handle TCP segmentation. */
2910
120
    conversation = find_or_create_conversation(pinfo);
2911
120
    conversation_set_dissector(conversation, smpp_handle);
2912
2913
120
    dissect_smpp(tvb, pinfo, tree, data);
2914
120
    return true;
2915
120
}
2916
2917
static void
2918
smpp_fmt_version(char *result, uint32_t revision)
2919
0
{
2920
0
    snprintf(result, ITEM_LABEL_LENGTH, "%u.%u", (uint8_t)((revision & 0xF0) >> 4), (uint8_t)(revision & 0x0F));
2921
0
}
2922
2923
/* Register the protocol with Wireshark */
2924
void
2925
proto_register_smpp(void)
2926
16
{
2927
16
    module_t *smpp_module; /* Preferences for SMPP */
2928
16
    expert_module_t *expert_smpp;
2929
2930
    /* Setup list of header fields      */
2931
16
    static hf_register_info hf[] = {
2932
16
        {   &hf_smpp_command_length,
2933
16
            {   "Length", "smpp.command_length",
2934
16
                FT_UINT32, BASE_DEC, NULL, 0x00,
2935
16
                "Total length of the SMPP PDU.",
2936
16
                HFILL
2937
16
            }
2938
16
        },
2939
16
        {   &hf_smpp_command_id,
2940
16
            {   "Operation", "smpp.command_id",
2941
16
                FT_UINT32, BASE_HEX, VALS(vals_command_id), 0x00,
2942
16
                "Defines the SMPP PDU.",
2943
16
                HFILL
2944
16
            }
2945
16
        },
2946
16
        {   &hf_smpp_command_request,
2947
16
            {   "Request", "smpp.request",
2948
16
                FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2949
16
                "true if this is a SMPP request.",
2950
16
                HFILL
2951
16
            }
2952
16
        },
2953
16
        {   &hf_smpp_command_response,
2954
16
            {   "Response", "smpp.response",
2955
16
                FT_BOOLEAN, BASE_NONE, NULL, 0x00,
2956
16
                "true if this is a SMPP response.",
2957
16
                HFILL
2958
16
            }
2959
16
        },
2960
16
        {   &hf_smpp_command_status,
2961
16
            {   "Result", "smpp.command_status",
2962
16
                FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
2963
16
                "Indicates success or failure of the SMPP request.",
2964
16
                HFILL
2965
16
            }
2966
16
        },
2967
16
        {   &hf_smpp_sequence_number,
2968
16
            {   "Sequence #", "smpp.sequence_number",
2969
16
                FT_UINT32, BASE_DEC, NULL, 0x00,
2970
16
                "A number to correlate requests with responses.",
2971
16
                HFILL
2972
16
            }
2973
16
        },
2974
16
        {   &hf_smpp_system_id,
2975
16
            {   "System ID", "smpp.system_id",
2976
16
                FT_STRING, BASE_NONE, NULL, 0x00,
2977
16
                "Identifies a system.",
2978
16
                HFILL
2979
16
            }
2980
16
        },
2981
16
        {   &hf_smpp_password,
2982
16
            {   "Password", "smpp.password",
2983
16
                FT_STRING, BASE_NONE, NULL, 0x00,
2984
16
                "Password used for authentication.",
2985
16
                HFILL
2986
16
            }
2987
16
        },
2988
16
        {   &hf_smpp_system_type,
2989
16
            {   "System type", "smpp.system_type",
2990
16
                FT_STRING, BASE_NONE, NULL, 0x00,
2991
16
                "Categorizes the system.",
2992
16
                HFILL
2993
16
            }
2994
16
        },
2995
16
        {   &hf_smpp_interface_version,
2996
16
            {   "Version (if)", "smpp.interface_version",
2997
16
                FT_UINT8, BASE_CUSTOM, CF_FUNC(smpp_fmt_version), 0x00,
2998
16
                "Version of SMPP interface supported.",
2999
16
                HFILL
3000
16
            }
3001
16
        },
3002
16
        {   &hf_smpp_service_type,
3003
16
            {   "Service type", "smpp.service_type",
3004
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3005
16
                "SMS application service associated with the message.",
3006
16
                HFILL
3007
16
            }
3008
16
        },
3009
16
        {   &hf_smpp_addr_ton,
3010
16
            {   "Type of number", "smpp.addr_ton",
3011
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
3012
16
                "Indicates the type of number, given in the address.",
3013
16
                HFILL
3014
16
            }
3015
16
        },
3016
16
        {   &hf_smpp_source_addr_ton,
3017
16
            {   "Type of number (originator)", "smpp.source_addr_ton",
3018
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
3019
16
                "Indicates originator type of number, given in the address.",
3020
16
                HFILL
3021
16
            }
3022
16
        },
3023
16
        {   &hf_smpp_dest_addr_ton,
3024
16
            {   "Type of number (recipient)", "smpp.dest_addr_ton",
3025
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
3026
16
                "Indicates recipient type of number, given in the address.",
3027
16
                HFILL
3028
16
            }
3029
16
        },
3030
16
        {   &hf_smpp_addr_npi,
3031
16
            {   "Numbering plan indicator", "smpp.addr_npi",
3032
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
3033
16
                "Gives the numbering plan this address belongs to.",
3034
16
                HFILL
3035
16
            }
3036
16
        },
3037
16
        {   &hf_smpp_source_addr_npi,
3038
16
            {   "Numbering plan indicator (originator)", "smpp.source_addr_npi",
3039
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
3040
16
                "Gives originator numbering plan this address belongs to.",
3041
16
                HFILL
3042
16
            }
3043
16
        },
3044
16
        {   &hf_smpp_dest_addr_npi,
3045
16
            {   "Numbering plan indicator (recipient)", "smpp.dest_addr_npi",
3046
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
3047
16
                "Gives recipient numbering plan this address belongs to.",
3048
16
                HFILL
3049
16
            }
3050
16
        },
3051
16
        {   &hf_smpp_address_range,
3052
16
            {   "Address", "smpp.address_range",
3053
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3054
16
                "Given address or address range.",
3055
16
                HFILL
3056
16
            }
3057
16
        },
3058
16
        {   &hf_smpp_source_addr,
3059
16
            {   "Originator address", "smpp.source_addr",
3060
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3061
16
                "Address of SME originating this message.",
3062
16
                HFILL
3063
16
            }
3064
16
        },
3065
16
        {   &hf_smpp_destination_addr,
3066
16
            {   "Recipient address", "smpp.destination_addr",
3067
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3068
16
                "Address of SME receiving this message.",
3069
16
                HFILL
3070
16
            }
3071
16
        },
3072
16
        {   &hf_smpp_esm_submit_msg_mode,
3073
16
            {   "Messaging mode", "smpp.esm.submit.msg_mode",
3074
16
                FT_UINT8, BASE_HEX, VALS(vals_esm_submit_msg_mode), 0x03,
3075
16
                "Mode attribute for this message.",
3076
16
                HFILL
3077
16
            }
3078
16
        },
3079
16
        {   &hf_smpp_esm_submit_msg_type,
3080
16
            {   "Message type", "smpp.esm.submit.msg_type",
3081
16
                FT_UINT8, BASE_HEX, VALS(vals_esm_submit_msg_type), 0x3C,
3082
16
                "Type attribute for this message.",
3083
16
                HFILL
3084
16
            }
3085
16
        },
3086
16
        {   &hf_smpp_esm_submit_features,
3087
16
            {   "GSM features", "smpp.esm.submit.features",
3088
16
                FT_UINT8, BASE_HEX, VALS(vals_esm_submit_features), 0xC0,
3089
16
                "GSM network specific features.",
3090
16
                HFILL
3091
16
            }
3092
16
        },
3093
        /*! \todo Get proper values from GSM-spec.      */
3094
16
        {   &hf_smpp_protocol_id,
3095
16
            {   "Protocol id.", "smpp.protocol_id",
3096
16
                FT_UINT8, BASE_HEX, NULL, 0x00,
3097
16
                "Protocol identifier according GSM 03.40.",
3098
16
                HFILL
3099
16
            }
3100
16
        },
3101
16
        {   &hf_smpp_priority_flag,
3102
16
            {   "Priority level", "smpp.priority_flag",
3103
16
                FT_UINT8, BASE_HEX, VALS(vals_priority_flag), 0x00,
3104
16
                "The priority level of the short message.",
3105
16
                HFILL
3106
16
            }
3107
16
        },
3108
16
        {   &hf_smpp_schedule_delivery_time,
3109
16
            {   "Scheduled delivery time", "smpp.schedule_delivery_time",
3110
16
                FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
3111
16
                "Scheduled time for delivery of short message.",
3112
16
                HFILL
3113
16
            }
3114
16
        },
3115
16
        {   &hf_smpp_schedule_delivery_time_r,
3116
16
            {   "Scheduled delivery time", "smpp.schedule_delivery_time_r",
3117
16
                FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3118
16
                "Scheduled time for delivery of short message.",
3119
16
                HFILL
3120
16
            }
3121
16
        },
3122
16
        {   &hf_smpp_validity_period,
3123
16
            {   "Validity period", "smpp.validity_period",
3124
16
                FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
3125
16
                "Validity period of this message.",
3126
16
                HFILL
3127
16
            }
3128
16
        },
3129
16
        {   &hf_smpp_validity_period_r,
3130
16
            {   "Validity period", "smpp.validity_period_r",
3131
16
                FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3132
16
                "Validity period of this message.",
3133
16
                HFILL
3134
16
            }
3135
16
        },
3136
16
        {   &hf_smpp_regdel_receipt,
3137
16
            {   "Delivery receipt", "smpp.regdel.receipt",
3138
16
                FT_UINT8, BASE_HEX, VALS(vals_regdel_receipt), 0x03,
3139
16
                "SMSC delivery receipt request.",
3140
16
                HFILL
3141
16
            }
3142
16
        },
3143
16
        {   &hf_smpp_regdel_acks,
3144
16
            {   "Message type", "smpp.regdel.acks",
3145
16
                FT_UINT8, BASE_HEX, VALS(vals_regdel_acks), 0x0C,
3146
16
                "SME acknowledgement request.",
3147
16
                HFILL
3148
16
            }
3149
16
        },
3150
16
        {   &hf_smpp_regdel_notif,
3151
16
            {   "Intermediate notif", "smpp.regdel.notif",
3152
16
                FT_UINT8, BASE_HEX, VALS(vals_regdel_notif), 0x10,
3153
16
                "Intermediate notification request.",
3154
16
                HFILL
3155
16
            }
3156
16
        },
3157
16
        {   &hf_smpp_replace_if_present_flag,
3158
16
            {   "Replace", "smpp.replace_if_present_flag",
3159
16
                FT_UINT8, BASE_HEX, VALS(vals_replace_if_present_flag), 0x01,
3160
16
                "Replace the short message with this one or not.",
3161
16
                HFILL
3162
16
            }
3163
16
        },
3164
16
        {   &hf_smpp_data_coding,
3165
16
            {   "Data coding", "smpp.data_coding",
3166
16
                FT_UINT8, BASE_HEX|BASE_RANGE_STRING, RVALS(rvals_data_coding), 0x00,
3167
16
                "Defines the encoding scheme of the message.",
3168
16
                HFILL
3169
16
            }
3170
16
        },
3171
16
        {   &hf_smpp_sm_default_msg_id,
3172
16
            {   "Predefined message", "smpp.sm_default_msg_id",
3173
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3174
16
                "Index of a predefined ('canned') short message.",
3175
16
                HFILL
3176
16
            }
3177
16
        },
3178
16
        {   &hf_smpp_sm_length,
3179
16
            {   "Message length", "smpp.sm_length",
3180
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3181
16
                "Length of the message content.",
3182
16
                HFILL
3183
16
            }
3184
16
        },
3185
16
        {   &hf_smpp_short_message,
3186
16
            {   "Message", "smpp.message_text",
3187
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3188
16
                "The actual message or data.",
3189
16
                HFILL
3190
16
            }
3191
16
        },
3192
16
        {   &hf_smpp_short_message_bin,
3193
16
            {   "Message bytes", "smpp.message",
3194
16
                FT_BYTES, BASE_NONE, NULL, 0x00,
3195
16
                "The actual message bytes.",
3196
16
                HFILL
3197
16
            }
3198
16
        },
3199
16
        {   &hf_smpp_message_id,
3200
16
            {   "Message id.", "smpp.message_id",
3201
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3202
16
                "Identifier of the submitted short message.",
3203
16
                HFILL
3204
16
            }
3205
16
        },
3206
16
        {   &hf_smpp_dlist,
3207
16
            {   "Destination list", "smpp.dlist",
3208
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3209
16
                "The list of destinations for a short message.",
3210
16
                HFILL
3211
16
            }
3212
16
        },
3213
16
        {   &hf_smpp_dlist_resp,
3214
16
            {   "Unsuccessful delivery list", "smpp.dlist_resp",
3215
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3216
16
                "The list of unsuccessful deliveries to destinations.",
3217
16
                HFILL
3218
16
            }
3219
16
        },
3220
16
        {   &hf_smpp_dl_name,
3221
16
            {   "Distr. list name", "smpp.dl_name",
3222
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3223
16
                "The name of the distribution list.",
3224
16
                HFILL
3225
16
            }
3226
16
        },
3227
16
        {   &hf_smpp_final_date,
3228
16
            {   "Final date", "smpp.final_date",
3229
16
                FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
3230
16
                "Date-time when the queried message reached a final state.",
3231
16
                HFILL
3232
16
            }
3233
16
        },
3234
16
        {   &hf_smpp_final_date_r,
3235
16
            {   "Final date", "smpp.final_date_r",
3236
16
                FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3237
16
                "Date-time when the queried message reached a final state.",
3238
16
                HFILL
3239
16
            }
3240
16
        },
3241
16
        {   &hf_smpp_message_state,
3242
16
            {   "Message state", "smpp.message_state",
3243
16
                FT_UINT8, BASE_DEC, VALS(vals_message_state), 0x00,
3244
16
                "Specifies the status of the queried short message.",
3245
16
                HFILL
3246
16
            }
3247
16
        },
3248
16
        {   &hf_smpp_error_code,
3249
16
            {   "Error code", "smpp.error_code",
3250
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3251
16
                "Network specific error code defining reason for failure.",
3252
16
                HFILL
3253
16
            }
3254
16
        },
3255
16
        {   &hf_smpp_error_status_code,
3256
16
            {   "Status", "smpp.error_status_code",
3257
16
                FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
3258
16
                "Indicates success/failure of request for this address.",
3259
16
                HFILL
3260
16
            }
3261
16
        },
3262
16
        {   &hf_smpp_esme_addr_ton,
3263
16
            {   "Type of number (ESME)", "smpp.esme_addr_ton",
3264
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_ton), 0x00,
3265
16
                "Indicates recipient type of number, given in the address.",
3266
16
                HFILL
3267
16
            }
3268
16
        },
3269
16
        {   &hf_smpp_esme_addr_npi,
3270
16
            {   "Numbering plan indicator (ESME)", "smpp.esme_addr_npi",
3271
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_npi), 0x00,
3272
16
                "Gives the numbering plan this address belongs to.",
3273
16
                HFILL
3274
16
            }
3275
16
        },
3276
16
        {   &hf_smpp_esme_addr,
3277
16
            {   "ESME address", "smpp.esme_addr",
3278
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3279
16
                "Address of ESME originating this message.",
3280
16
                HFILL
3281
16
            }
3282
16
        },
3283
16
        {   &hf_smpp_dest_addr_subunit,
3284
16
            {   "Subunit destination", "smpp.dest_addr_subunit",
3285
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_subunit), 0x00,
3286
16
                "Subunit address within mobile to route message to.",
3287
16
                HFILL
3288
16
            }
3289
16
        },
3290
16
        {   &hf_smpp_source_addr_subunit,
3291
16
            {   "Subunit origin", "smpp.source_addr_subunit",
3292
16
                FT_UINT8, BASE_HEX, VALS(vals_addr_subunit), 0x00,
3293
16
                "Subunit address within mobile that generated the message.",
3294
16
                HFILL
3295
16
            }
3296
16
        },
3297
16
        {   &hf_smpp_dest_network_type,
3298
16
            {   "Destination network", "smpp.dest_network_type",
3299
16
                FT_UINT8, BASE_HEX, VALS(vals_network_type), 0x00,
3300
16
                "Network associated with the destination address.",
3301
16
                HFILL
3302
16
            }
3303
16
        },
3304
16
        {   &hf_smpp_source_network_type,
3305
16
            {   "Originator network", "smpp.source_network_type",
3306
16
                FT_UINT8, BASE_HEX, VALS(vals_network_type), 0x00,
3307
16
                "Network associated with the originator address.",
3308
16
                HFILL
3309
16
            }
3310
16
        },
3311
16
        {   &hf_smpp_dest_bearer_type,
3312
16
            {   "Destination bearer", "smpp.dest_bearer_type",
3313
16
                FT_UINT8, BASE_HEX, VALS(vals_bearer_type), 0x00,
3314
16
                "Desired bearer for delivery of message.",
3315
16
                HFILL
3316
16
            }
3317
16
        },
3318
16
        {   &hf_smpp_source_bearer_type,
3319
16
            {   "Originator bearer", "smpp.source_bearer_type",
3320
16
                FT_UINT8, BASE_HEX, VALS(vals_bearer_type), 0x00,
3321
16
                "Bearer over which the message originated.",
3322
16
                HFILL
3323
16
            }
3324
16
        },
3325
16
        {   &hf_smpp_dest_telematics_id,
3326
16
            {   "Telematic interworking (dest)", "smpp.dest_telematics_id",
3327
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3328
16
                "Telematic interworking to be used for message delivery.",
3329
16
                HFILL
3330
16
            }
3331
16
        },
3332
16
        {   &hf_smpp_source_telematics_id,
3333
16
            {   "Telematic interworking (orig)", "smpp.source_telematics_id",
3334
16
                FT_UINT8, BASE_HEX, NULL, 0x00,
3335
16
                "Telematic interworking used for message submission.",
3336
16
                HFILL
3337
16
            }
3338
16
        },
3339
16
        {   &hf_smpp_qos_time_to_live,
3340
16
            {   "Validity period", "smpp.qos_time_to_live",
3341
16
                FT_UINT32, BASE_DEC, NULL, 0x00,
3342
16
                "Number of seconds to retain message before expiry.",
3343
16
                HFILL
3344
16
            }
3345
16
        },
3346
16
        {   &hf_smpp_payload_type,
3347
16
            {   "Payload", "smpp.payload_type",
3348
16
                FT_UINT8, BASE_DEC, VALS(vals_payload_type), 0x00,
3349
16
                "PDU type contained in the message payload.",
3350
16
                HFILL
3351
16
            }
3352
16
        },
3353
16
        {   &hf_smpp_additional_status_info_text,
3354
16
            {   "Information", "smpp.additional_status_info_text",
3355
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3356
16
                "Description of the meaning of a response PDU.",
3357
16
                HFILL
3358
16
            }
3359
16
        },
3360
16
        {   &hf_smpp_receipted_message_id,
3361
16
            {   "SMSC identifier", "smpp.receipted_message_id",
3362
16
                FT_STRING, BASE_NONE, NULL, 0x00,
3363
16
                "SMSC handle of the message being received.",
3364
16
                HFILL
3365
16
            }
3366
16
        },
3367
16
        {   &hf_smpp_privacy_indicator,
3368
16
            {   "Privacy indicator", "smpp.privacy_indicator",
3369
16
                FT_UINT8, BASE_DEC, VALS(vals_privacy_indicator), 0x00,
3370
16
                "Indicates the privacy level of the message.",
3371
16
                HFILL
3372
16
            }
3373
16
        },
3374
16
    {   &hf_smpp_source_subaddress,
3375
16
            {   "Source Subaddress", "smpp.source_subaddress",
3376
16
                FT_BYTES, BASE_NONE, NULL, 0x00,
3377
16
                NULL,
3378
16
                HFILL
3379
16
            }
3380
16
        },
3381
16
    {   &hf_smpp_dest_subaddress,
3382
16
            {   "Destination Subaddress", "smpp.dest_subaddress",
3383
16
                FT_BYTES, BASE_NONE, NULL, 0x00,
3384
16
                NULL,
3385
16
                HFILL
3386
16
            }
3387
16
        },
3388
16
    {   &hf_smpp_user_message_reference,
3389
16
            {   "Message reference", "smpp.user_message_reference",
3390
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3391
16
                "Reference to the message, assigned by the user.",
3392
16
                HFILL
3393
16
            }
3394
16
        },
3395
16
        {   &hf_smpp_user_response_code,
3396
16
            {   "Application response code", "smpp.user_response_code",
3397
16
                FT_UINT8, BASE_HEX, NULL, 0x00,
3398
16
                "A response code set by the user.",
3399
16
                HFILL
3400
16
            }
3401
16
        },
3402
16
        {   &hf_smpp_language_indicator,
3403
16
            {   "Language", "smpp.language_indicator",
3404
16
                FT_UINT8, BASE_DEC, VALS(vals_language_indicator), 0x00,
3405
16
                "Indicates the language of the short message.",
3406
16
                HFILL
3407
16
            }
3408
16
        },
3409
16
        {   &hf_smpp_source_port,
3410
16
            {   "Source port", "smpp.source_port",
3411
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3412
16
                "Application port associated with the source of the message.",
3413
16
                HFILL
3414
16
            }
3415
16
        },
3416
16
        {   &hf_smpp_destination_port,
3417
16
            {   "Destination port", "smpp.destination_port",
3418
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3419
16
                "Application port associated with the destination of the message.",
3420
16
                HFILL
3421
16
            }
3422
16
        },
3423
16
        {   &hf_smpp_sar_msg_ref_num,
3424
16
            {   "SAR reference number", "smpp.sar_msg_ref_num",
3425
16
                FT_UINT16, BASE_DEC, NULL, 0x00,
3426
16
                "Reference number for a concatenated short message.",
3427
16
                HFILL
3428
16
            }
3429
16
        },
3430
16
        {   &hf_smpp_sar_total_segments,
3431
16
            {   "SAR size", "smpp.sar_total_segments",
3432
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3433
16
                "Number of segments of a concatenated short message.",
3434
16
                HFILL
3435
16
            }
3436
16
        },
3437
16
        {   &hf_smpp_sar_segment_seqnum,
3438
16
            {   "SAR sequence number", "smpp.sar_segment_seqnum",
3439
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3440
16
                "Segment number within a concatenated short message.",
3441
16
                HFILL
3442
16
            }
3443
16
        },
3444
16
        {   &hf_smpp_display_time,
3445
16
            {   "Display time", "smpp.display_time",
3446
16
                FT_UINT8, BASE_DEC, VALS(vals_display_time), 0x00,
3447
16
                "Associates a display time with the message on the handset.",
3448
16
                HFILL
3449
16
            }
3450
16
        },
3451
16
        {   &hf_smpp_sms_signal,
3452
16
            {   "SMS signal", "smpp.sms_signal",
3453
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3454
16
                "Alert the user according to the information contained within this information element.",
3455
16
                HFILL
3456
16
            }
3457
16
        },
3458
16
        {   &hf_smpp_ms_validity,
3459
16
            {   "Validity info", "smpp.ms_validity",
3460
16
                FT_UINT8, BASE_DEC, VALS(vals_ms_validity), 0x00,
3461
16
                "Associates validity info with the message on the handset.",
3462
16
                HFILL
3463
16
            }
3464
16
        },
3465
16
        {   &hf_smpp_dpf_result,
3466
16
            {   "Delivery pending set?", "smpp.dpf_result",
3467
16
                FT_UINT8, BASE_DEC, VALS(vals_dpf_result), 0x00,
3468
16
                "Indicates whether Delivery Pending Flag was set.",
3469
16
                HFILL
3470
16
            }
3471
16
        },
3472
16
        {   &hf_smpp_set_dpf,
3473
16
            {   "Request DPF set", "smpp.set_dpf",
3474
16
                FT_UINT8, BASE_DEC, VALS(vals_set_dpf), 0x00,
3475
16
                "Request to set the DPF for certain failure scenario's.",
3476
16
                HFILL
3477
16
            }
3478
16
        },
3479
16
        {   &hf_smpp_ms_availability_status,
3480
16
            {   "Availability status", "smpp.ms_availability_status",
3481
16
                FT_UINT8, BASE_DEC, VALS(vals_ms_availability_status), 0x00,
3482
16
                "Indicates the availability state of the handset.",
3483
16
                HFILL
3484
16
            }
3485
16
        },
3486
16
        {   &hf_smpp_delivery_failure_reason,
3487
16
            {   "Delivery failure reason", "smpp.delivery_failure_reason",
3488
16
                FT_UINT8, BASE_DEC, VALS(vals_delivery_failure_reason), 0x00,
3489
16
                "Indicates the reason for a failed delivery attempt.",
3490
16
                HFILL
3491
16
            }
3492
16
        },
3493
16
        {   &hf_smpp_more_messages_to_send,
3494
16
            {   "More messages?", "smpp.more_messages_to_send",
3495
16
                FT_UINT8, BASE_DEC, VALS(vals_more_messages_to_send), 0x00,
3496
16
                "Indicates more messages pending for the same destination.",
3497
16
                HFILL
3498
16
            }
3499
16
        },
3500
16
        {   &hf_smpp_number_of_messages,
3501
16
            {   "Number of messages", "smpp.number_of_messages",
3502
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3503
16
                "Indicates number of messages stored in a mailbox.",
3504
16
                HFILL
3505
16
            }
3506
16
        },
3507
16
        {   &hf_smpp_its_reply_type,
3508
16
            {   "Reply method", "smpp.its_reply_type",
3509
16
                FT_UINT8, BASE_DEC, VALS(vals_its_reply_type), 0x00,
3510
16
                "Indicates the handset reply method on message receipt.",
3511
16
                HFILL
3512
16
            }
3513
16
        },
3514
16
        {   &hf_smpp_ussd_service_op,
3515
16
            {   "USSD service operation", "smpp.ussd_service_op",
3516
16
                FT_UINT8, BASE_DEC, VALS(vals_ussd_service_op), 0x00,
3517
16
                "Indicates the USSD service operation.",
3518
16
                HFILL
3519
16
            }
3520
16
        },
3521
16
        {   &hf_smpp_vendor_op,
3522
16
            {   "Value", "smpp.vendor_op",
3523
16
                FT_BYTES, BASE_NONE|BASE_ALLOW_ZERO, NULL, 0x00,
3524
16
                "A supplied optional parameter specific to an SMSC-vendor.",
3525
16
                HFILL
3526
16
            }
3527
16
        },
3528
16
        {   &hf_smpp_reserved_op,
3529
16
            {   "Value", "smpp.reserved_op",
3530
16
                FT_BYTES, BASE_NONE|BASE_ALLOW_ZERO, NULL, 0x00,
3531
16
                "An optional parameter that is reserved in this version.",
3532
16
                HFILL
3533
16
            }
3534
16
        },
3535
16
        {   &hf_smpp_msg_wait_ind,
3536
16
            {   "Indication", "smpp.msg_wait.ind",
3537
16
                FT_UINT8, BASE_HEX, VALS(vals_msg_wait_ind), 0x80,
3538
16
                "Indicates to the handset that a message is waiting.",
3539
16
                HFILL
3540
16
            }
3541
16
        },
3542
16
        {   &hf_smpp_msg_wait_type,
3543
16
            {   "Type", "smpp.msg_wait.type",
3544
16
                FT_UINT8, BASE_HEX, VALS(vals_msg_wait_type), 0x03,
3545
16
                "Indicates type of message that is waiting.",
3546
16
                HFILL
3547
16
            }
3548
16
        },
3549
16
        {   &hf_smpp_SC_interface_version,
3550
16
            {   "SMSC-supported version", "smpp.SC_interface_version",
3551
16
                FT_UINT8, BASE_CUSTOM, CF_FUNC(smpp_fmt_version), 0x00,
3552
16
                "Version of SMPP interface supported by the SMSC.",
3553
16
                HFILL
3554
16
            }
3555
16
        },
3556
16
        {   &hf_smpp_callback_num_pres,
3557
16
            {   "Presentation", "smpp.callback_num.pres",
3558
16
                FT_UINT8, BASE_HEX, VALS(vals_callback_num_pres), 0x0C,
3559
16
                "Controls the presentation indication.",
3560
16
                HFILL
3561
16
            }
3562
16
        },
3563
16
        {   &hf_smpp_callback_num_scrn,
3564
16
            {   "Screening", "smpp.callback_num.scrn",
3565
16
                FT_UINT8, BASE_HEX, VALS(vals_callback_num_scrn), 0x03,
3566
16
                "Controls screening of the callback-number.",
3567
16
                HFILL
3568
16
            }
3569
16
        },
3570
16
        {   &hf_smpp_callback_num_atag,
3571
16
            {   "Callback number - alphanumeric display tag",
3572
16
                "smpp.callback_num_atag",
3573
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3574
16
                "Associates an alphanumeric display with call back number.",
3575
16
                HFILL
3576
16
            }
3577
16
        },
3578
16
        {   &hf_smpp_callback_num,
3579
16
            {   "Callback number", "smpp.callback_num",
3580
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3581
16
                "Associates a call back number with the message.",
3582
16
                HFILL
3583
16
            }
3584
16
        },
3585
16
        {   &hf_smpp_network_error_type,
3586
16
            {   "Error type", "smpp.network_error.type",
3587
16
                FT_UINT8, BASE_DEC, VALS(vals_network_error_type), 0x00,
3588
16
                "Indicates the network type.",
3589
16
                HFILL
3590
16
            }
3591
16
        },
3592
16
        {   &hf_smpp_network_error_code,
3593
16
            {   "Error code", "smpp.network_error.code",
3594
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3595
16
                "Gives the actual network error code.",
3596
16
                HFILL
3597
16
            }
3598
16
        },
3599
16
        {   &hf_smpp_message_payload,
3600
16
            {   "Payload", "smpp.message_payload",
3601
16
                FT_BYTES, BASE_NONE, NULL, 0x00,
3602
16
                "Short message user data.",
3603
16
                HFILL
3604
16
            }
3605
16
        },
3606
16
        {   &hf_smpp_alert_on_message_delivery_null,
3607
16
            {   "Alert on delivery", "smpp.alert_on_message_delivery_null",
3608
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3609
16
                "Instructs the handset to alert user on message delivery.",
3610
16
                HFILL
3611
16
            }
3612
16
        },
3613
16
        {   &hf_smpp_alert_on_message_delivery_type,
3614
16
            {   "Alert on delivery", "smpp.alert_on_message_delivery_type",
3615
16
                FT_UINT8, BASE_DEC, VALS(vals_alert_on_message_delivery), 0x00,
3616
16
                "Instructs the handset to alert user on message delivery.",
3617
16
                HFILL
3618
16
            }
3619
16
        },
3620
16
        {   &hf_smpp_its_session_number,
3621
16
            {   "Session number", "smpp.its_session.number",
3622
16
                FT_UINT8, BASE_DEC, NULL, 0x00,
3623
16
                "Session number of interactive teleservice.",
3624
16
                HFILL
3625
16
            }
3626
16
        },
3627
16
        {   &hf_smpp_its_session_sequence,
3628
16
            {   "Sequence number", "smpp.its_session.sequence",
3629
16
                FT_UINT8, BASE_HEX, NULL, 0xFE,
3630
16
                "Sequence number of the dialogue unit.",
3631
16
                HFILL
3632
16
            }
3633
16
        },
3634
16
        {   &hf_smpp_its_session_ind,
3635
16
            {   "Session indicator", "smpp.its_session.ind",
3636
16
                FT_UINT8, BASE_HEX, VALS(vals_its_session_ind), 0x01,
3637
16
                "Indicates whether this message is end of conversation.",
3638
16
                HFILL
3639
16
            }
3640
16
        },
3641
16
        {   &hf_smpp_opt_params,
3642
16
            {   "Optional parameters", "smpp.opt_params",
3643
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3644
16
                "The list of optional parameters in this operation.",
3645
16
                HFILL
3646
16
            }
3647
16
        },
3648
16
        {   &hf_smpp_opt_param,
3649
16
            {   "Optional parameter", "smpp.opt_param",
3650
16
                FT_NONE, BASE_NONE, NULL, 0x00,
3651
16
                NULL,
3652
16
                HFILL
3653
16
            }
3654
16
        },
3655
16
        {   &hf_smpp_opt_param_tag,
3656
16
            {   "Tag", "smpp.opt_param_tag",
3657
16
                FT_UINT16, BASE_HEX, NULL, 0x00,
3658
16
                "Optional parameter identifier tag",
3659
16
                HFILL
3660
16
            }
3661
16
        },
3662
16
        {   &hf_smpp_opt_param_len,
3663
16
            {   "Length", "smpp.opt_param_len",
3664
16
                FT_UINT16, BASE_DEC, NULL, 0x00,
3665
16
                "Optional parameter length",
3666
16
                HFILL
3667
16
            }
3668
16
        },
3669
3670
        /*
3671
         * Data Coding Scheme
3672
         */
3673
16
        {   &hf_smpp_dcs_sms_coding_group,
3674
16
            {   "DCS Coding Group for SMS", "smpp.dcs.sms_coding_group",
3675
16
                FT_UINT8, BASE_HEX, VALS(vals_dcs_sms_coding_group), 0xF0,
3676
16
                "Data Coding Scheme coding group for GSM Short Message Service.",
3677
16
                HFILL
3678
16
            }
3679
16
        },
3680
16
        {   &hf_smpp_dcs_reserved,
3681
16
            {   "Reserved (should be zero)", "smpp.dcs.reserved",
3682
16
                FT_UINT8, BASE_DEC, NULL, 0x08,
3683
16
                NULL, HFILL
3684
16
            }
3685
16
        },
3686
16
        {   &hf_smpp_dcs_charset,
3687
16
            {   "DCS Character set", "smpp.dcs.charset",
3688
16
                FT_UINT8, BASE_HEX, VALS(vals_dcs_charset), 0x04,
3689
16
                "Specifies the character set used in the message.", HFILL
3690
16
            }
3691
16
        },
3692
16
        {   &hf_smpp_dcs_class,
3693
16
            {   "DCS Message class", "smpp.dcs.class",
3694
16
                FT_UINT8, BASE_HEX, VALS(vals_dcs_class), 0x03,
3695
16
                "Specifies the message class.", HFILL
3696
16
            }
3697
16
        },
3698
16
        {   &hf_smpp_dcs_wait_ind,
3699
16
            {   "Indication", "smpp.dcs.wait_ind",
3700
16
                FT_UINT8, BASE_HEX, VALS(vals_msg_wait_ind), 0x08,
3701
16
                "Indicates to the handset that a message is waiting.",
3702
16
                HFILL
3703
16
            }
3704
16
        },
3705
16
        {   &hf_smpp_dcs_reserved2,
3706
16
            {   "Reserved (should be zero)", "smpp.dcs.reserved",
3707
16
                FT_UINT8, BASE_DEC, NULL, 0x04,
3708
16
                NULL, HFILL
3709
16
            }
3710
16
        },
3711
16
        {   &hf_smpp_dcs_wait_type,
3712
16
            {   "Type", "smpp.dcs.wait_type",
3713
16
                FT_UINT8, BASE_HEX, VALS(vals_msg_wait_type), 0x03,
3714
16
                "Indicates type of message that is waiting.",
3715
16
                HFILL
3716
16
            }
3717
16
        },
3718
        /* Changes in SMPP 5.0 */
3719
16
        {       &hf_smpp_congestion_state,
3720
16
                {       "Congestion State", "smpp.congestion_state",
3721
16
                        FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_congestion_state), 0x00,
3722
16
                        "Congestion info between ESME and MC for flow control/cong. control", HFILL
3723
16
                }
3724
16
        },
3725
16
        {       &hf_smpp_billing_identification,
3726
16
                {       "Billing Identification", "smpp.billing_id",
3727
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3728
16
                        "Billing identification info", HFILL
3729
16
                }
3730
16
        },
3731
16
        {       &hf_smpp_dest_addr_np_country,
3732
16
                {       "Destination Country Code", "smpp.dest_addr_np_country",
3733
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3734
16
                        "Destination Country Code (E.164 Region Code)", HFILL
3735
16
                }
3736
16
        },
3737
16
        {       &hf_smpp_dest_addr_np_information,
3738
16
                {       "Number Portability information", "smpp.dest_addr_np_info",
3739
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3740
16
                        NULL, HFILL
3741
16
                }
3742
16
        },
3743
16
        {       &hf_smpp_dest_addr_np_resolution,
3744
16
                {       "Number Portability query information", "smpp.dest_addr_np_resolution",
3745
16
                        FT_UINT8, BASE_DEC, VALS(vals_dest_addr_np_resolution), 0x00,
3746
16
                        "Number Portability query information - method used to resolve number", HFILL
3747
16
                }
3748
16
        },
3749
16
        {       &hf_smpp_source_network_id,
3750
16
                {       "Source Network ID", "smpp.source_network_id",
3751
16
                        FT_STRING, BASE_NONE, NULL, 0x00,
3752
16
                        "Unique ID for a network or ESME operator", HFILL
3753
16
                }
3754
16
        },
3755
16
        {       &hf_smpp_source_node_id,
3756
16
                {       "Source Node ID", "smpp.source_node_id",
3757
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3758
16
                        "Unique ID for a ESME or MC node", HFILL
3759
16
                }
3760
16
        },
3761
16
        {       &hf_smpp_dest_network_id,
3762
16
                {       "Destination Network ID", "smpp.dest_network_id",
3763
16
                        FT_STRING, BASE_NONE, NULL, 0x00,
3764
16
                        "Unique ID for a network or ESME operator", HFILL
3765
16
                }
3766
16
        },
3767
16
        {       &hf_smpp_dest_node_id,
3768
16
                {       "Destination Node ID", "smpp.dest_node_id",
3769
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3770
16
                        "Unique ID for a ESME or MC node", HFILL
3771
16
                }
3772
16
        },
3773
16
        {       &hf_smpp_broadcast_channel_indicator,
3774
16
                {       "Cell Broadcast channel", "smpp.broadcast_channel_indicator",
3775
16
                        FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_broadcast_channel_indicator), 0x00,
3776
16
                        NULL, HFILL
3777
16
                }
3778
16
        },
3779
16
        {       &hf_smpp_broadcast_content_type_nw,
3780
16
                {       "Broadcast Content Type - Network Tag", "smpp.broadcast_content_type.nw",
3781
16
                        FT_UINT8, BASE_DEC, VALS(vals_broadcast_content_type_nw), 0x00,
3782
16
                        "Cell Broadcast content type", HFILL
3783
16
                }
3784
16
        },
3785
16
        {       &hf_smpp_broadcast_content_type_type,
3786
16
                {       "Broadcast Content Type - Content Type", "smpp.broadcast_content_type.type",
3787
16
                        FT_UINT16, BASE_HEX, VALS(vals_broadcast_content_type_type), 0x00,
3788
16
                        "Cell Broadcast content type", HFILL
3789
16
                }
3790
16
        },
3791
16
        {       &hf_smpp_broadcast_content_type_info,
3792
16
                {       "Broadcast Content Type Info", "smpp.broadcast_content_type.info",
3793
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3794
16
                        "Cell Broadcast content type Info", HFILL
3795
16
                }
3796
16
        },
3797
16
        {       &hf_smpp_broadcast_message_class,
3798
16
                {       "Broadcast Message Class", "smpp.broadcast_message_class",
3799
16
                        FT_UINT8, BASE_HEX, VALS(vals_broadcast_message_class), 0x00,
3800
16
                        "Cell Broadcast Message Class", HFILL
3801
16
                }
3802
16
        },
3803
16
        {       &hf_smpp_broadcast_rep_num,
3804
16
                {       "Broadcast Message - Number of repetitions requested", "smpp.broadcast_rep_num",
3805
16
                        FT_UINT8, BASE_DEC, NULL, 0x00,
3806
16
                        "Cell Broadcast Message - Number of repetitions requested", HFILL
3807
16
                }
3808
16
        },
3809
16
        {       &hf_smpp_broadcast_frequency_interval_unit,
3810
16
                {       "Broadcast Message - frequency interval - Unit", "smpp.broadcast_frequency_interval.unit",
3811
16
                        FT_UINT8, BASE_HEX, VALS(vals_broadcast_frequency_interval_unit), 0x00,
3812
16
                        "Cell Broadcast Message - frequency interval at which broadcast must be repeated", HFILL
3813
16
                }
3814
16
        },
3815
16
        {       &hf_smpp_broadcast_frequency_interval_value,
3816
16
                {       "Broadcast Message - frequency interval - Unit", "smpp.broadcast_frequency_interval.value",
3817
16
                        FT_UINT16, BASE_DEC, NULL, 0x00,
3818
16
                        "Cell Broadcast Message - frequency interval at which broadcast must be repeated", HFILL
3819
16
                }
3820
16
        },
3821
16
        {       &hf_smpp_broadcast_area_identifier,
3822
16
                {       "Broadcast Message - Area Identifier", "smpp.broadcast_area_identifier",
3823
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3824
16
                        "Cell Broadcast Message - Area Identifier", HFILL
3825
16
                }
3826
16
        },
3827
16
        {       &hf_smpp_broadcast_area_identifier_format,
3828
16
                {       "Broadcast Message - Area Identifier Format", "smpp.broadcast_area_identifier.format",
3829
16
                        FT_UINT8, BASE_HEX | BASE_RANGE_STRING, RVALS(vals_broadcast_area_identifier_format), 0x00,
3830
16
                        "Cell Broadcast Message - Area Identifier Format", HFILL
3831
16
                }
3832
16
        },
3833
16
        {       &hf_smpp_broadcast_error_status,
3834
16
                {       "Broadcast Message - Error Status", "smpp.broadcast_error_status",
3835
16
                        FT_UINT32, BASE_HEX | BASE_RANGE_STRING, RVALS(rvals_command_status), 0x00,
3836
16
                        "Cell Broadcast Message - Error Status", HFILL
3837
16
                }
3838
16
        },
3839
16
        {       &hf_smpp_broadcast_area_success,
3840
16
                {       "Broadcast Message - Area Success", "smpp.broadcast_area_success",
3841
16
                        FT_UINT8, BASE_DEC | BASE_RANGE_STRING, RVALS(vals_broadcast_area_success), 0x00,
3842
16
                        "Cell Broadcast Message - success rate indicator (ratio) - No. of BTS which accepted Message:Total BTS", HFILL
3843
16
                }
3844
16
        },
3845
16
        {       &hf_smpp_broadcast_end_time,
3846
16
                {       "Broadcast Message - End Time", "smpp.broadcast_end_time",
3847
16
                        FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x00,
3848
16
                        "Cell Broadcast Message - Date and time at which MC set the state of the message to terminated", HFILL
3849
16
                }
3850
16
        },
3851
16
        {       &hf_smpp_broadcast_end_time_r,
3852
16
                {       "Broadcast Message - End Time", "smpp.broadcast_end_time_r",
3853
16
                        FT_RELATIVE_TIME, BASE_NONE, NULL, 0x00,
3854
16
                        "Cell Broadcast Message - Date and time at which MC set the state of the message to terminated", HFILL
3855
16
                }
3856
16
        },
3857
16
        {       &hf_smpp_broadcast_service_group,
3858
16
                {       "Broadcast Message - Service Group", "smpp.broadcast_service_group",
3859
16
                        FT_BYTES, BASE_NONE, NULL, 0x00,
3860
16
                        "Cell Broadcast Message - Service Group", HFILL
3861
16
                }
3862
16
        },
3863
        /* Huawei SMPP+ extensions */
3864
16
        {        &hf_huawei_smpp_smsc_addr,
3865
16
                {       "SMPP+: GT of SMSC", "smpp.smsc_addr",
3866
16
                        FT_STRING, BASE_NONE, NULL, 0x00,
3867
16
                        NULL, HFILL
3868
16
                }
3869
16
        },
3870
16
        {        &hf_huawei_smpp_msc_addr_noa,
3871
16
                {       "SMPP+: NOA of MSC address", "smpp.msc_addr_noa",
3872
16
                        FT_UINT8, BASE_DEC, VALS(vals_msc_addr_noa), 0x00,
3873
16
                        "SMPP+: Indicates the TON of MSC address", HFILL
3874
16
                }
3875
16
        },
3876
16
        {        &hf_huawei_smpp_msc_addr_npi,
3877
16
                {       "SMPP+: NPI of MSC address", "smpp.msc_addr_npi",
3878
16
                        FT_UINT8, BASE_DEC, VALS(vals_msc_addr_npi), 0x00,
3879
16
                        "SMPP+: Indicates the NPI of MSC address", HFILL
3880
16
                }
3881
16
        },
3882
16
        {        &hf_huawei_smpp_msc_addr,
3883
16
                {       "SMPP+: GT of MSC", "smpp.msc_addr",
3884
16
                        FT_STRING, BASE_NONE, NULL, 0x00,
3885
16
                        NULL, HFILL
3886
16
                }
3887
16
        },
3888
16
        {        &hf_huawei_smpp_mo_mt_flag,
3889
16
                {       "SMPP+: Charge for MO or MT", "smpp.mo_mt_flag",
3890
16
                        FT_UINT8, BASE_DEC, VALS(vals_mo_mt_flag), 0x00,
3891
16
                        "SMPP+: Indicates the Charge side of  MO or MT", HFILL
3892
16
                }
3893
16
        },
3894
16
        {        &hf_huawei_smpp_sm_id,
3895
16
                {       "SMPP+: Unique SM ID", "smpp.sm_id",
3896
16
                        FT_STRING, BASE_NONE, NULL, 0x00,
3897
16
                        "SMPP+: Unique SM ID which is generated by SMSC", HFILL
3898
16
                }
3899
16
        },
3900
16
        {        &hf_huawei_smpp_length_auth,
3901
16
                {       "SMPP+: Length of SMS", "smpp.length_auth",
3902
16
                        FT_UINT32, BASE_DEC, NULL, 0x00,
3903
16
                        "SMPP+: Indicates the Length of SMS", HFILL
3904
16
                }
3905
16
        },
3906
16
        {        &hf_huawei_smpp_service_id,
3907
16
                {       "SMPP+: Service ID of SMSC", "smpp.service_id",
3908
16
                        FT_UINT32, BASE_DEC, NULL, 0x00,
3909
16
                        "SMPP+: Indicates the Service ID of SMSC", HFILL
3910
16
                }
3911
16
        },
3912
16
        {        &hf_huawei_smpp_operation_result,
3913
16
                {       "SMPP+: Authentication result of SCP", "smpp.operation_result",
3914
16
                        FT_UINT32, BASE_DEC, VALS(vals_operation_result), 0x00,
3915
16
                        "SMPP+: Indicates the Authentication result of SCP", HFILL
3916
16
                }
3917
16
        },
3918
16
        {        &hf_huawei_smpp_notify_mode,
3919
16
                {       "SMPP+: SMS notify mode", "smpp.notify_mode",
3920
16
                        FT_UINT8, BASE_DEC, VALS(vals_notify_mode), 0x00,
3921
16
                        "SMPP+: Indicates the SMS notify mode", HFILL
3922
16
                }
3923
16
        },
3924
16
        {        &hf_huawei_smpp_delivery_result,
3925
16
                {       "SMPP+: Delivery result of SMS", "smpp.delivery_result",
3926
16
                        FT_UINT32, BASE_DEC, VALS(vals_delivery_result), 0x00,
3927
16
                        "SMPP+: Indicates the Delivery result of SMS", HFILL
3928
16
                }
3929
16
        },
3930
        /* Conversation tracking */
3931
16
        {       &hf_smpp_response_in,
3932
16
                {       "Response In", "smpp.response_in",
3933
16
                        FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE), 0x0,
3934
16
                        "The response to this SMPP request is in this frame", HFILL
3935
16
                }
3936
16
        },
3937
16
        {       &hf_smpp_request_in,
3938
16
                {       "Request In", "smpp.request_in", FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST), 0x0,
3939
16
                        "This request corresponding to this SMPP response in this frame", HFILL
3940
16
                }
3941
16
        },
3942
16
        {       &hf_smpp_response_time,
3943
16
                {       "Response Time", "smpp.response_time", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
3944
16
                        "The time between the request and the response", HFILL
3945
16
                }
3946
16
        }
3947
16
    };
3948
3949
    /* Setup protocol subtree array */
3950
16
    static int *ett[] = {
3951
16
        &ett_smpp,
3952
16
        &ett_dlist,
3953
16
        &ett_dlist_resp,
3954
16
        &ett_opt_params,
3955
16
        &ett_opt_param,
3956
16
        &ett_dcs,
3957
16
    };
3958
3959
16
    static ei_register_info ei[] = {
3960
16
        { &ei_smpp_message_payload_duplicate,
3961
16
          { "smpp.message_payload.duplicate", PI_PROTOCOL, PI_WARN,
3962
16
            "short_message field and message_payload TLV can only appear once in total",
3963
16
            EXPFILL }
3964
16
        },
3965
16
        { &ei_smpp_date_time_decoding_failed,
3966
16
          { "smpp.date_time.decoding.failed", PI_PROTOCOL, PI_WARN,
3967
16
            "Failed to decode date and time from string",
3968
16
            EXPFILL }
3969
16
        }
3970
16
    };
3971
3972
    /* Encoding used to decode the SMS over SMPP when DCS is 0 */
3973
16
    static const enum_val_t smpp_dcs_0_sms_decode_options[] = {
3974
16
        { "none",        "None",       DO_NOT_DECODE },
3975
16
        { "ascii",       "ASCII",      ENC_ASCII },
3976
16
        { "gsm7",        "GSM 7-bit",  ENC_3GPP_TS_23_038_7BITS_UNPACKED },
3977
16
        { "gsm7-packed", "GSM 7-bit (packed)", ENC_3GPP_TS_23_038_7BITS_PACKED },
3978
16
        { "iso-8859-1",  "ISO-8859-1", ENC_ISO_8859_1 },
3979
16
        { "iso-8859-5",  "ISO-8859-5", ENC_ISO_8859_5 },
3980
16
        { "iso-8859-8",  "ISO-8859-8", ENC_ISO_8859_8 },
3981
16
        { "ucs2",        "UCS2",       ENC_UCS_2|ENC_BIG_ENDIAN },
3982
16
        { "ks-c-5601",   "KS C 5601 (Korean)", ENC_EUC_KR },
3983
16
        { NULL, NULL, 0 }
3984
16
    };
3985
3986
    /* Register the protocol name and description */
3987
16
    proto_smpp = proto_register_protocol("Short Message Peer to Peer",
3988
16
                                         "SMPP", "smpp");
3989
3990
    /* Required function calls to register header fields and subtrees used */
3991
16
    proto_register_field_array(proto_smpp, hf, array_length(hf));
3992
16
    proto_register_subtree_array(ett, array_length(ett));
3993
3994
16
    expert_smpp = expert_register_protocol(proto_smpp);
3995
16
    expert_register_field_array(expert_smpp, ei, array_length(ei));
3996
3997
    /* Allow other dissectors to find this one by name. */
3998
16
    smpp_handle = register_dissector("smpp", dissect_smpp, proto_smpp);
3999
4000
    /* Register for tapping */
4001
16
    smpp_tap = register_tap("smpp");
4002
4003
    /* Preferences */
4004
16
    smpp_module = prefs_register_protocol (proto_smpp, NULL);
4005
16
    prefs_register_bool_preference (smpp_module,
4006
16
            "reassemble_smpp_over_tcp",
4007
16
            "Reassemble SMPP over TCP messages spanning multiple TCP segments",
4008
16
            "Whether the SMPP dissector should reassemble messages spanning multiple TCP segments."
4009
16
            " To use this option, you must also enable "
4010
16
            "\"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
4011
16
            &reassemble_over_tcp);
4012
16
    prefs_register_enum_preference(smpp_module, "decode_sms_over_smpp",
4013
16
            "Decode DCS 0 SMS as",
4014
16
            "Whether to decode the SMS contents when DCS is equal to 0 (zero).",
4015
16
            &smpp_decode_dcs_0_sms, smpp_dcs_0_sms_decode_options, false);
4016
16
    prefs_register_bool_preference(smpp_module, "gsm7_unpacked",
4017
16
            "GSM 7-bit alphabet unpacked",
4018
16
            "When the DCS indicates that the encoding is the GSM 7-bit "
4019
16
            "alphabet, whether to decode it as unpacked (one character "
4020
16
            "per octet) instead of packed.",
4021
16
            &smpp_gsm7_unpacked);
4022
16
}
4023
4024
void
4025
proto_reg_handoff_smpp(void)
4026
16
{
4027
    /*
4028
     * SMPP can be spoken on any port under TCP or X.25
4029
     * ...how *do* we do that under X.25?
4030
     *
4031
     * We can register the heuristic SMPP dissector with X.25, for one
4032
     * thing.  We don't currently have any mechanism to allow the user
4033
     * to specify that a given X.25 circuit is to be dissected as SMPP,
4034
     * however.
4035
     */
4036
16
    dissector_add_for_decode_as_with_preference("tcp.port", smpp_handle);
4037
16
    ssl_dissector_add(0, smpp_handle);
4038
16
    heur_dissector_add("tcp", dissect_smpp_heur, "SMPP over TCP Heuristics", "smpp_tcp", proto_smpp, HEURISTIC_ENABLE);
4039
16
    heur_dissector_add("tls", dissect_smpp_heur, "SMPP over TLS Heuristics", "smpp_tls", proto_smpp, HEURISTIC_ENABLE);
4040
16
    heur_dissector_add("x.25", dissect_smpp_heur, "SMPP over X.25 Heuristics", "smpp_x25", proto_smpp, HEURISTIC_ENABLE);
4041
4042
    /* Required for call_dissector() */
4043
16
    gsm_sms_handle = find_dissector_add_dependency("gsm_sms_ud", proto_smpp);
4044
16
    DISSECTOR_ASSERT(gsm_sms_handle);
4045
4046
    /* Tapping setup */
4047
16
    stats_tree_cfg *st_config = stats_tree_register("smpp","smpp_commands", "SM_PP Operations", 0,
4048
16
                                   smpp_stats_tree_per_packet, smpp_stats_tree_init, NULL);
4049
16
    stats_tree_set_group(st_config, REGISTER_TELEPHONY_GROUP_UNSORTED);
4050
4051
16
    exported_pdu_tap = find_tap_id(EXPORT_PDU_TAP_NAME_LAYER_7);
4052
16
}
4053
4054
/*
4055
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
4056
 *
4057
 * Local variables:
4058
 * c-basic-offset: 4
4059
 * tab-width: 8
4060
 * indent-tabs-mode: nil
4061
 * End:
4062
 *
4063
 * vi: set shiftwidth=4 tabstop=8 expandtab:
4064
 * :indentSize=4:tabSize=8:noTabs=true:
4065
 */