Class: Majoron::AntHill::SMPP::SMPPBindResp

Inherits:
SMPPResp show all
Defined in:
lib/pdu/smpp_bind_resp.rb

Instance Attribute Summary collapse

Attributes inherited from SMPPPDU

#header

Instance Method Summary collapse

Methods inherited from SMPPResp

#init

Methods inherited from SMPPPDU

#command_id, #command_length, #command_status, #command_status=, #sequence_number, #sequence_number=

Constructor Details

#initialize(command_id, command_status, sequence_number) ⇒ SMPPBindResp

Returns a new instance of SMPPBindResp.



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pdu/smpp_bind_resp.rb', line 23

def initialize(command_id, command_status, sequence_number)
	super(command_id, command_status, sequence_number)
  
	# Mandatory fields
	@system_id = ""
  
	# Optional fields
	@sc_interface_version = nil
  
	# Optional fields len
	@sc_interface_version_len = SMPPTLVLen::BYTE_LEN
end

Instance Attribute Details

#sc_interface_versionObject

Optional fields



93
94
95
# File 'lib/pdu/smpp_bind_resp.rb', line 93

def sc_interface_version
  @sc_interface_version
end

#sc_interface_version_lenObject

Optional fields length



96
97
98
# File 'lib/pdu/smpp_bind_resp.rb', line 96

def sc_interface_version_len
  @sc_interface_version_len
end

#system_idObject

Mandatory fields



90
91
92
# File 'lib/pdu/smpp_bind_resp.rb', line 90

def system_id
  @system_id
end

Instance Method Details

#decode_packet(decoder) ⇒ Object

Interface to decode SMPP packet



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/pdu/smpp_bind_resp.rb', line 48

def decode_packet(decoder)
	# Decode header and mandatory fields
	@header = decoder.decode_header()
	@system_id = decoder.decode_system_id(command_length())
	
	# Decode optional fields
	while decoder.has_tlvs() 
		case decoder.get_tlv_code()
			when OptTags::TAG_SC_INTERFACE_VERSION
				@sc_interface_version, @sc_interface_version_len = 
					decoder.decode_sc_interface_version(command_length())
			else
				# Report about error
				raise Errors::UNKNOWN_TAG_MSG + decoder.get_tlv_error()
		end
	end
end

#encode_packet(encoder) ⇒ Object

Interface to encode SMPP packet



37
38
39
40
41
42
43
44
45
# File 'lib/pdu/smpp_bind_resp.rb', line 37

def encode_packet(encoder)
	# Encode header and mandatory fields
	encoder.encode_header(@header)
	encoder.encode_system_id(@system_id)
  
	# Encode optional fields
	encoder.encode_sc_interface_version(@sc_interface_version, 
		@sc_interface_version_len) if !@sc_interface_version.nil?
end

#output_packet(outputter) ⇒ Object

Interface to output SMPP packet



78
79
80
81
82
83
84
85
86
# File 'lib/pdu/smpp_bind_resp.rb', line 78

def output_packet(outputter)
	# Output header and mandatory fields
	outputter.output_header(@header)
	outputter.output_system_id(@system_id)
  
	# Output optional fields
	outputter.output_sc_interface_version(@sc_interface_version, 
		@sc_interface_version_len) if !@sc_interface_version.nil?
end

#validate_packet(validator) ⇒ Object

Interface to validate SMPP packet



67
68
69
70
71
72
73
74
75
# File 'lib/pdu/smpp_bind_resp.rb', line 67

def validate_packet(validator)
	# Validate header and mandatory fields
	validator.validate_header(@header)
	validator.validate_system_id(@system_id)
  
	# Validate optional fields
	validator.validate_sc_interface_version(@sc_interface_version, 
		@sc_interface_version_len) if !@sc_interface_version.nil?
end