Class: Majoron::AntHill::SMPP::SMPPDecoder

Inherits:
AntHill::BinaryDecoder
  • Object
show all
Defined in:
lib/smpp_decoder.rb

Instance Method Summary collapse

Constructor Details

#initializeSMPPDecoder

Constructor. Insert all SMPP commands to hash. Key is SMPP command identity, and value is SMPP command intanse. Hash is used to get PDU to decode PDU.



26
27
28
# File 'lib/smpp_decoder.rb', line 26

def initialize()
	super()
end

Instance Method Details

#decode_additional_status_info_text(limit) ⇒ Object



553
554
555
# File 'lib/smpp_decoder.rb', line 553

def decode_additional_status_info_text(limit)
	decode_binary_tlv(limit)
end

#decode_addr_npi(limit) ⇒ Object



180
181
182
# File 'lib/smpp_decoder.rb', line 180

def decode_addr_npi(limit)
	decode_uchar(limit)
end

#decode_addr_ton(limit) ⇒ Object



176
177
178
# File 'lib/smpp_decoder.rb', line 176

def decode_addr_ton(limit)
	decode_uchar(limit)
end

#decode_address_range(limit) ⇒ Object



184
185
186
# File 'lib/smpp_decoder.rb', line 184

def decode_address_range(limit)
	decode_cstring_max(SMPPMaxLen::ADDRESS_RANGE_MAX_LEN, limit)
end

#decode_alert_on_msg_delivery(limit) ⇒ Object



364
365
366
# File 'lib/smpp_decoder.rb', line 364

def decode_alert_on_msg_delivery(limit)
	decode_uchar_tlv(limit)
end

#decode_broadcast_area_identifier(limit) ⇒ Object



338
339
340
341
# File 'lib/smpp_decoder.rb', line 338

def decode_broadcast_area_identifier(limit)
	data, len = decode_binary_tlv(limit)
	return BroadcastAreaIdentifier.new(data), len
end

#decode_broadcast_area_success(limit) ⇒ Object



351
352
353
# File 'lib/smpp_decoder.rb', line 351

def decode_broadcast_area_success(limit)
	decode_uchar_tlv(limit)
end

#decode_broadcast_channel_indicator(limit) ⇒ Object



368
369
370
# File 'lib/smpp_decoder.rb', line 368

def decode_broadcast_channel_indicator(limit)
	decode_uchar_tlv(limit)
end

#decode_broadcast_content_type(limit) ⇒ Object



457
458
459
# File 'lib/smpp_decoder.rb', line 457

def decode_broadcast_content_type(limit)
	decode_binary_tlv(limit)
end

#decode_broadcast_content_type_info(limit) ⇒ Object



372
373
374
# File 'lib/smpp_decoder.rb', line 372

def decode_broadcast_content_type_info(limit)
	decode_binary_tlv(limit)
end

#decode_broadcast_end_time(limit) ⇒ Object



561
562
563
# File 'lib/smpp_decoder.rb', line 561

def decode_broadcast_end_time(limit)
	decode_cstring_tlv(limit)
end

#decode_broadcast_error_status(limit) ⇒ Object



448
449
450
# File 'lib/smpp_decoder.rb', line 448

def decode_broadcast_error_status(limit)
	decode_uint32_tlv(limit)
end

#decode_broadcast_frequency_interval(limit) ⇒ Object



347
348
349
# File 'lib/smpp_decoder.rb', line 347

def decode_broadcast_frequency_interval(limit)
	decode_binary_tlv(limit)
end

#decode_broadcast_message_class(limit) ⇒ Object



376
377
378
# File 'lib/smpp_decoder.rb', line 376

def decode_broadcast_message_class(limit)
	decode_uchar_tlv(limit)
end

#decode_broadcast_rep_num(limit) ⇒ Object



343
344
345
# File 'lib/smpp_decoder.rb', line 343

def decode_broadcast_rep_num(limit)
	decode_uint16_tlv(limit)
end

#decode_broadcast_service_group(limit) ⇒ Object



380
381
382
# File 'lib/smpp_decoder.rb', line 380

def decode_broadcast_service_group(limit)
	decode_binary_tlv(limit)
end

#decode_callback_num(limit) ⇒ Object



384
385
386
# File 'lib/smpp_decoder.rb', line 384

def decode_callback_num(limit)
	decode_binary_tlv(limit)
end

#decode_callback_num_atag(limit) ⇒ Object



388
389
390
# File 'lib/smpp_decoder.rb', line 388

def decode_callback_num_atag(limit)
	decode_binary_tlv(limit)
end

#decode_callback_num_pres_ind(limit) ⇒ Object



392
393
394
# File 'lib/smpp_decoder.rb', line 392

def decode_callback_num_pres_ind(limit)
	decode_uchar_tlv(limit)
end

#decode_data_coding(limit) ⇒ Object



252
253
254
# File 'lib/smpp_decoder.rb', line 252

def decode_data_coding(limit)
	decode_uchar(limit)
end

#decode_delivery_failure_reason(limit) ⇒ Object



549
550
551
# File 'lib/smpp_decoder.rb', line 549

def decode_delivery_failure_reason(limit)
	decode_uchar_tlv(limit)
end

#decode_dest_addr21(limit) ⇒ Object



216
217
218
# File 'lib/smpp_decoder.rb', line 216

def decode_dest_addr21(limit)
	decode_cstring_max(SMPPMaxLen::DESTINATION_ADDR_MAX_LEN_21, limit)
end

#decode_dest_addr65(limit) ⇒ Object



220
221
222
# File 'lib/smpp_decoder.rb', line 220

def decode_dest_addr65(limit)
	decode_cstring_max(SMPPMaxLen::DESTINATION_ADDR_MAX_LEN_65, limit)
end

#decode_dest_addr_npi(limit) ⇒ Object



212
213
214
# File 'lib/smpp_decoder.rb', line 212

def decode_dest_addr_npi(limit)
	decode_uchar(limit)
end

#decode_dest_addr_subunit(limit) ⇒ Object



396
397
398
# File 'lib/smpp_decoder.rb', line 396

def decode_dest_addr_subunit(limit)
	decode_uchar_tlv(limit)
end

#decode_dest_addr_ton(limit) ⇒ Object



208
209
210
# File 'lib/smpp_decoder.rb', line 208

def decode_dest_addr_ton(limit)
	decode_uchar(limit)
end

#decode_dest_addresses(number_of_dests, limit) ⇒ Object



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/smpp_decoder.rb', line 288

def decode_dest_addresses(number_of_dests, limit)
	result = []
	0.upto(number_of_dests - 1) do |i|
		dest_address = DestAddress.new()
		dest_address.dest_flag = decode_uchar(limit)
		case dest_address.dest_flag
			when DestFlag::SME_ADDRESS
				ton = decode_uchar(limit)
				npi = decode_uchar(limit)
				adr = decode_cstring_max(SMPPMaxLen::DESTINATION_ADDR_MAX_LEN_21,limit)
				dest_address.address = SMEAddress.new(ton, npi, adr)
			when DestFlag::DISTR_LIST_NAME
				dest_address.distr_list_name = decode_cstring_max(SMPPMaxLen::DL_NAME_MAX_LEN, limit)
			else
				# Report about error
				raise spritnf(CodecErrors::DECODER_INV_DSTFLAG, @offset, dest_address.dest_flag)
		end
		result << dest_address
	end
	result
end

#decode_dest_bearer_type(limit) ⇒ Object



481
482
483
# File 'lib/smpp_decoder.rb', line 481

def decode_dest_bearer_type(limit)
	decode_uchar_tlv(limit)
end

#decode_dest_network_type(limit) ⇒ Object



477
478
479
# File 'lib/smpp_decoder.rb', line 477

def decode_dest_network_type(limit)
	decode_uchar_tlv(limit)
end

#decode_dest_subaddress(limit) ⇒ Object



400
401
402
# File 'lib/smpp_decoder.rb', line 400

def decode_dest_subaddress(limit)
	decode_binary_tlv(limit)
end

#decode_dest_telematics_id(limit) ⇒ Object



485
486
487
# File 'lib/smpp_decoder.rb', line 485

def decode_dest_telematics_id(limit)
	decode_uchar_tlv(limit)
end

#decode_destination_port(limit) ⇒ Object



473
474
475
# File 'lib/smpp_decoder.rb', line 473

def decode_destination_port(limit)
	decode_uint16_tlv(limit)
end

#decode_display_time(limit) ⇒ Object



404
405
406
# File 'lib/smpp_decoder.rb', line 404

def decode_display_time(limit)
	decode_uchar_tlv(limit)
end

#decode_dpf_result(limit) ⇒ Object



557
558
559
# File 'lib/smpp_decoder.rb', line 557

def decode_dpf_result(limit)
	decode_uchar_tlv(limit)
end

#decode_error_code(limit) ⇒ Object



330
331
332
# File 'lib/smpp_decoder.rb', line 330

def decode_error_code(limit)
	decode_uchar(limit)
end

#decode_esm_class(limit) ⇒ Object



224
225
226
# File 'lib/smpp_decoder.rb', line 224

def decode_esm_class(limit)
	decode_uchar(limit)
end

#decode_esme_addr(limit) ⇒ Object



280
281
282
# File 'lib/smpp_decoder.rb', line 280

def decode_esme_addr(limit)
	decode_cstring_max(SMPPMaxLen::ESME_ADDR_MAX_LEN, limit)
end

#decode_esme_addr_npi(limit) ⇒ Object



276
277
278
# File 'lib/smpp_decoder.rb', line 276

def decode_esme_addr_npi(limit)
	decode_uchar(limit)
end

#decode_esme_addr_ton(limit) ⇒ Object



272
273
274
# File 'lib/smpp_decoder.rb', line 272

def decode_esme_addr_ton(limit)
	decode_uchar(limit)
end

#decode_failed_broadcast_area_identifier(limit) ⇒ Object



452
453
454
455
# File 'lib/smpp_decoder.rb', line 452

def decode_failed_broadcast_area_identifier(limit)
	data, len = decode_binary_tlv(limit)
	return BroadcastAreaIdentifier.new(data), len
end

#decode_final_date(limit) ⇒ Object



326
327
328
# File 'lib/smpp_decoder.rb', line 326

def decode_final_date(limit)
	decode_cstring_max(SMPPMaxLen::SMPP_DATETIME_MAX_LEN, limit)
end

#decode_headerObject

SMPP header decoder



150
151
152
153
154
155
156
157
# File 'lib/smpp_decoder.rb', line 150

def decode_header()
	header = AntHill::SMPP::Header.new()
	header.command_length = decode_unsigned32()
	header.command_id = decode_unsigned32(header.command_length)
	header.command_status = decode_unsigned32(header.command_length)
	header.sequence_number = decode_unsigned32(header.command_length)
	header
end

#decode_interface_version(limit) ⇒ Object



172
173
174
# File 'lib/smpp_decoder.rb', line 172

def decode_interface_version(limit)
	decode_uchar(limit)
end

#decode_its_reply_type(limit) ⇒ Object



537
538
539
# File 'lib/smpp_decoder.rb', line 537

def decode_its_reply_type(limit)
	decode_uchar_tlv(limit)
end

#decode_its_session_info(limit) ⇒ Object



541
542
543
# File 'lib/smpp_decoder.rb', line 541

def decode_its_session_info(limit)
	decode_uint16_tlv(limit)
end

#decode_language_indicator(limit) ⇒ Object



408
409
410
# File 'lib/smpp_decoder.rb', line 408

def decode_language_indicator(limit)
	decode_uchar_tlv(limit)
end

#decode_message_id(limit) ⇒ Object



268
269
270
# File 'lib/smpp_decoder.rb', line 268

def decode_message_id(limit)
	decode_cstring_max(SMPPMaxLen::MESSAGE_ID_MAX_LEN, limit)
end

#decode_message_payload(limit) ⇒ Object



412
413
414
# File 'lib/smpp_decoder.rb', line 412

def decode_message_payload(limit)
	decode_binary_tlv(limit)
end

#decode_message_state(limit) ⇒ Object



334
335
336
# File 'lib/smpp_decoder.rb', line 334

def decode_message_state(limit)
	decode_uchar(limit)
end

#decode_message_state_tlv(limit) ⇒ Object



517
518
519
# File 'lib/smpp_decoder.rb', line 517

def decode_message_state_tlv(limit)
	decode_uchar_tlv(limit)
end

#decode_more_messages_to_send(limit) ⇒ Object



501
502
503
# File 'lib/smpp_decoder.rb', line 501

def decode_more_messages_to_send(limit)
	decode_uchar_tlv(limit)
end

#decode_ms_availability_status(limit) ⇒ Object



360
361
362
# File 'lib/smpp_decoder.rb', line 360

def decode_ms_availability_status(limit)
	decode_uchar_tlv(limit)
end

#decode_ms_msg_wait_facilities(limit) ⇒ Object



529
530
531
# File 'lib/smpp_decoder.rb', line 529

def decode_ms_msg_wait_facilities(limit)
	decode_uchar_tlv(limit)
end

#decode_ms_validity(limit) ⇒ Object



416
417
418
# File 'lib/smpp_decoder.rb', line 416

def decode_ms_validity(limit)
	decode_uchar_tlv(limit)
end

#decode_network_error_code(limit) ⇒ Object



521
522
523
524
525
526
527
# File 'lib/smpp_decoder.rb', line 521

def decode_network_error_code(limit)
	skip_n_bytes(SMPPOffset::TLV_TAG_LENGHT)
	len = decode_unsigned16(limit)
	network = decode_uchar(limit)
	error = decode_unsigned16(limit)
	return NetworkErrorCode.new(network, error), len
end

#decode_no_unsuccess(limit) ⇒ Object



310
311
312
# File 'lib/smpp_decoder.rb', line 310

def decode_no_unsuccess(limit)
	decode_uchar(limit)
end

#decode_number_of_dest(limit) ⇒ Object



284
285
286
# File 'lib/smpp_decoder.rb', line 284

def decode_number_of_dest(limit)
	decode_uchar(limit)
end

#decode_number_of_messages(limit) ⇒ Object



533
534
535
# File 'lib/smpp_decoder.rb', line 533

def decode_number_of_messages(limit)
	decode_uchar_tlv(limit)
end

#decode_packetObject

Method



144
145
146
# File 'lib/smpp_decoder.rb', line 144

def decode_packet()
	raise "not implemented yet !!!"
end

#decode_password(limit) ⇒ Object



164
165
166
# File 'lib/smpp_decoder.rb', line 164

def decode_password(limit)
	decode_cstring_max(SMPPMaxLen::PASSWORD_MAX_LEN, limit)
end

#decode_payload_type(limit) ⇒ Object



420
421
422
# File 'lib/smpp_decoder.rb', line 420

def decode_payload_type(limit)
	decode_uchar_tlv(limit)
end

#decode_priority_flag(limit) ⇒ Object



232
233
234
# File 'lib/smpp_decoder.rb', line 232

def decode_priority_flag(limit)
	decode_uchar(limit)
end

#decode_privacy_indicator(limit) ⇒ Object



424
425
426
# File 'lib/smpp_decoder.rb', line 424

def decode_privacy_indicator(limit)
	decode_uchar_tlv(limit)
end

#decode_protocol_id(limit) ⇒ Object



228
229
230
# File 'lib/smpp_decoder.rb', line 228

def decode_protocol_id(limit)
	decode_uchar(limit)
end

#decode_qos_time_to_live(limit) ⇒ Object



505
506
507
# File 'lib/smpp_decoder.rb', line 505

def decode_qos_time_to_live(limit)
	decode_uint32_tlv(limit)
end

#decode_receipted_message_id(limit) ⇒ Object



513
514
515
# File 'lib/smpp_decoder.rb', line 513

def decode_receipted_message_id(limit)
	decode_cstring_tlv(limit)
end

#decode_registered_delivery(limit) ⇒ Object



244
245
246
# File 'lib/smpp_decoder.rb', line 244

def decode_registered_delivery(limit)
	decode_uchar(limit)
end

#decode_replace_if_present_flag(limit) ⇒ Object



248
249
250
# File 'lib/smpp_decoder.rb', line 248

def decode_replace_if_present_flag(limit)
	decode_uchar(limit)
end

#decode_sar_msg_ref_num(limit) ⇒ Object



489
490
491
# File 'lib/smpp_decoder.rb', line 489

def decode_sar_msg_ref_num(limit)
	decode_uint16_tlv(limit)
end

#decode_sar_segment_seqnum(limit) ⇒ Object



497
498
499
# File 'lib/smpp_decoder.rb', line 497

def decode_sar_segment_seqnum(limit)
	decode_uchar_tlv(limit)
end

#decode_sar_total_segments(limit) ⇒ Object



493
494
495
# File 'lib/smpp_decoder.rb', line 493

def decode_sar_total_segments(limit)
	decode_uchar_tlv(limit)
end

#decode_sc_interface_version(limit) ⇒ Object

Optional (TLV) SMPP fields decoder



356
357
358
# File 'lib/smpp_decoder.rb', line 356

def decode_sc_interface_version(limit)
	decode_uchar_tlv(limit)
end

#decode_schedule_delivery_time(limit) ⇒ Object



236
237
238
# File 'lib/smpp_decoder.rb', line 236

def decode_schedule_delivery_time(limit)
	decode_cstring_max(SMPPMaxLen::SMPP_DATETIME_MAX_LEN, limit)
end

#decode_service_type(limit) ⇒ Object



188
189
190
# File 'lib/smpp_decoder.rb', line 188

def decode_service_type(limit)
	decode_cstring_max(SMPPMaxLen::SERVICE_TYPE_MAX_LEN, limit)
end

#decode_set_dpf(limit) ⇒ Object



509
510
511
# File 'lib/smpp_decoder.rb', line 509

def decode_set_dpf(limit)
	decode_uchar_tlv(limit)
end

#decode_short_message(sm_length, limit) ⇒ Object



264
265
266
# File 'lib/smpp_decoder.rb', line 264

def decode_short_message(sm_length, limit)
	decode_binary(sm_length, limit)
end

#decode_sm_default_msg_id(limit) ⇒ Object



256
257
258
# File 'lib/smpp_decoder.rb', line 256

def decode_sm_default_msg_id(limit)
	decode_uchar(limit)
end

#decode_sm_length(limit) ⇒ Object



260
261
262
# File 'lib/smpp_decoder.rb', line 260

def decode_sm_length(limit)
	decode_uchar(limit)
end

#decode_sms_signal(limit) ⇒ Object



428
429
430
# File 'lib/smpp_decoder.rb', line 428

def decode_sms_signal(limit)
	decode_uint16_tlv(limit)
end

#decode_source_addr21(limit) ⇒ Object



200
201
202
# File 'lib/smpp_decoder.rb', line 200

def decode_source_addr21(limit)
	decode_cstring_max(SMPPMaxLen::SOURCE_ADDR_MAX_LEN_21, limit)
end

#decode_source_addr65(limit) ⇒ Object



204
205
206
# File 'lib/smpp_decoder.rb', line 204

def decode_source_addr65(limit)
	decode_cstring_max(SMPPMaxLen::SOURCE_ADDR_MAX_LEN_65, limit)
end

#decode_source_addr_npi(limit) ⇒ Object



196
197
198
# File 'lib/smpp_decoder.rb', line 196

def decode_source_addr_npi(limit)
	decode_uchar(limit)
end

#decode_source_addr_subunit(limit) ⇒ Object



432
433
434
# File 'lib/smpp_decoder.rb', line 432

def decode_source_addr_subunit(limit)
	decode_uchar_tlv(limit)
end

#decode_source_addr_ton(limit) ⇒ Object



192
193
194
# File 'lib/smpp_decoder.rb', line 192

def decode_source_addr_ton(limit)
	decode_uchar(limit)
end

#decode_source_bearer_type(limit) ⇒ Object



465
466
467
# File 'lib/smpp_decoder.rb', line 465

def decode_source_bearer_type(limit)
	decode_uchar_tlv(limit)
end

#decode_source_network_type(limit) ⇒ Object



461
462
463
# File 'lib/smpp_decoder.rb', line 461

def decode_source_network_type(limit)
	decode_uchar_tlv(limit)
end

#decode_source_port(limit) ⇒ Object



436
437
438
# File 'lib/smpp_decoder.rb', line 436

def decode_source_port(limit)
	decode_uint16_tlv(limit)
end

#decode_source_subaddress(limit) ⇒ Object



440
441
442
# File 'lib/smpp_decoder.rb', line 440

def decode_source_subaddress(limit)
	decode_binary_tlv(limit)
end

#decode_source_telematics_id(limit) ⇒ Object



469
470
471
# File 'lib/smpp_decoder.rb', line 469

def decode_source_telematics_id(limit)
	decode_uchar_tlv(limit)
end

#decode_system_id(limit) ⇒ Object

Mandatory SMPP fields decoder



160
161
162
# File 'lib/smpp_decoder.rb', line 160

def decode_system_id(limit)
	decode_cstring_max(SMPPMaxLen::SYSTEM_ID_MAX_LEN, limit)
end

#decode_system_type(limit) ⇒ Object



168
169
170
# File 'lib/smpp_decoder.rb', line 168

def decode_system_type(limit)
	decode_cstring_max(SMPPMaxLen::SYSTEM_TYPE_MAX_LEN, limit)
end

#decode_unsuccess_smes(no_unsuccess, limit) ⇒ Object



314
315
316
317
318
319
320
321
322
323
324
# File 'lib/smpp_decoder.rb', line 314

def decode_unsuccess_smes(no_unsuccess, limit)
	result = []
	0.upto(no_unsuccess - 1) do |i|
		ton = decode_uchar(limit)
		npi = decode_uchar(limit)
		adr = decode_cstring_max(SMPPMaxLen::DESTINATION_ADDR_MAX_LEN_21,limit)
		err = decode_unsigned32(limit)
		result << UnsuccessSME.new(SMEAddress.new(ton, npi, adr), err)
	end
	result
end

#decode_user_message_reference(limit) ⇒ Object



444
445
446
# File 'lib/smpp_decoder.rb', line 444

def decode_user_message_reference(limit)
	decode_uint16_tlv(limit)
end

#decode_user_response_code(limit) ⇒ Object



545
546
547
# File 'lib/smpp_decoder.rb', line 545

def decode_user_response_code(limit)
	decode_uchar_tlv(limit)
end

#decode_ussd_service_op(limit) ⇒ Object



565
566
567
# File 'lib/smpp_decoder.rb', line 565

def decode_ussd_service_op(limit)
	decode_uchar_tlv(limit)
end

#decode_validity_period(limit) ⇒ Object



240
241
242
# File 'lib/smpp_decoder.rb', line 240

def decode_validity_period(limit)
	decode_cstring_max(SMPPMaxLen::SMPP_DATETIME_MAX_LEN, limit)
end

#get_packetObject

Method to get new copy of SMPP command based on byte buffer located at decoder. If byte buffer is large enough then command id extracted and then pdu is returned



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/smpp_decoder.rb', line 68

def get_packet()
			case decode_command_id()
				when nil
					return nil
				when CommandId::CM_GENERIC_NACK
					return SMPPGenericNack.new()
				when CommandId::CM_BIND_RECEIVER
					return SMPPBindReceiver.new()
				when CommandId::CM_BIND_RECEIVER_RESP
					return SMPPBindReceiverResp.new()
				when CommandId::CM_BIND_TRANSMITTER
					return SMPPBindTransmitter.new()
				when CommandId::CM_BIND_TRANSMITTER_RESP
					return SMPPBindTransmitterResp.new()
				when CommandId::CM_QUERY_SM
					return SMPPQuerySM.new()
				when CommandId::CM_QUERY_SM_RESP
					return SMPPQuerySMResp.new()
				when CommandId::CM_SUBMIT_SM
			return SMPPSubmitSM.new()
		when CommandId::CM_SUBMIT_SM_RESP
			return SMPPSubmitSMResp.new()
		when CommandId::CM_DELIVER_SM
			return SMPPDeliverSM.new()
		when CommandId::CM_DELIVER_SM_RESP
			return SMPPDeliverSMResp.new()
		when CommandId::CM_UNBIND
			return SMPPUnbind.new()
		when CommandId::CM_UNBIND_RESP
			return SMPPUnbindResp.new()
		when CommandId::CM_REPLACE_SM
			return SMPPReplaceSM.new()
		when CommandId::CM_REPLACE_SM_RESP
			return SMPPReplaceSMResp.new()
		when CommandId::CM_CANCEL_SM
			return SMPPCancelSM.new()
		when CommandId::CM_CANCEL_SM_RESP
			return SMPPCancelSMResp.new()
		when CommandId::CM_BIND_TRANSCEIVER
			return SMPPBindTransceiver.new()
		when CommandId::CM_BIND_TRANSCEIVER_RESP
			return SMPPBindTransceiverResp.new()
		when CommandId::CM_OUTBIND
			return SMPPOutbind.new()
		when CommandId::CM_ENQUIRE_LINK
			return SMPPEnquireLink.new()
		when CommandId::CM_ENQUIRE_LINK_RESP
			return SMPPEnquireLinkResp.new()
		when CommandId::CM_SUBMIT_MULTI
			return SMPPSubmitMulti.new()
		when CommandId::CM_SUBMIT_MULTI_RESP
			return SMPPSubmitMultiResp.new()
		when CommandId::CM_ALERT_NOTIFICATION
			return SMPPAlertNotification.new()
		when CommandId::CM_DATA_SM
			return SMPPDataSM.new()
		when CommandId::CM_DATA_SM_RESP
			return SMPPDataSMResp.new()
		when CommandId::CM_BROADCAST_SM
			return SMPPBroadcastSM.new()
		when CommandId::CM_BROADCAST_SM_RESP
			return SMPPBroadcastSMResp.new()
		when CommandId::CM_QUERY_BROADCAST_SM
			return SMPPQueryBroadcastSM.new()
		when CommandId::CM_QUERY_BROADCAST_SM_RESP
			return SMPPQueryBroadcastSMResp.new()
		when CommandId::CM_CANCEL_BROADCAST_SM
			return SMPPCancelBroadcastSM.new()
		when CommandId::CM_CANCEL_BROADCAST_SM_RESP
			return SMPPCancelBroadcastSMResp.new()
		else
			return nil
	end
end

#get_tlv_codeObject

Method



45
46
47
48
49
50
51
52
53
# File 'lib/smpp_decoder.rb', line 45

def get_tlv_code()
	result = 0
	sizeof = 2
	if SMPPOffset::TLV_CODE_POS + sizeof <= @buffer.size()
		shift = @offset + SMPPOffset::TLV_CODE_POS
		result = @buffer[shift..shift+(sizeof-1)].unpack('n').first
	end
	result
end

#get_tlv_errorObject

Method



56
57
58
59
60
61
62
63
# File 'lib/smpp_decoder.rb', line 56

def get_tlv_error()
	tlv_code = get_tlv_code()
	begin_pos = @offset > 2 ? @offset - 2 : 0
	finish_pos = @offset + 2 > @buffer.size() ? @buffer.size() : @offset + 2
	dump = AntHill::ByteBuffer.encode_hex(@buffer[begin_pos .. finish_pos])
	sprintf("Offset: %d, TLVCode: %d, TLVCode 0x%X, Dump[offset-2..@offset+2]: %s",
		@offset, tlv_code, tlv_code, dump)
end

#has_packetsObject

Method



38
39
40
41
42
# File 'lib/smpp_decoder.rb', line 38

def has_packets()
	return false if @buffer.size() < SMPPOffset::SMPP_HEADER_SIZE
	return false if @buffer.size() < decode_command_length()
	return true
end

#has_tlvsObject

Method



32
33
34
35
# File 'lib/smpp_decoder.rb', line 32

def has_tlvs()
	return true if @offset + 1 < decode_command_length()
	return false
end