Class: SNMP::PDU
- Inherits:
-
Object
- Object
- SNMP::PDU
- Defined in:
- lib/snmp/pdu.rb
Direct Known Subclasses
GetBulkRequest, GetNextRequest, GetRequest, Response, SNMPv2_Trap, SetRequest
Constant Summary collapse
- ERROR_STATUS_NAME =
{ 0 => :noError, 1 => :tooBig, 2 => :noSuchName, 3 => :badValue, 4 => :readOnly, 5 => :genErr, 6 => :noAccess, 7 => :wrongType, 8 => :wrongLength, 9 => :wrongEncoding, 10 => :wrongValue, 11 => :noCreation, 12 => :inconsistentValue, 13 => :resourceUnavailable, 14 => :commitFailed, 15 => :undoFailed, 16 => :authorizationError, 17 => :notWritable, 18 => :inconsistentName }
- ERROR_STATUS_CODE =
ERROR_STATUS_NAME.invert
Instance Attribute Summary collapse
-
#error_index ⇒ Object
Returns the value of attribute error_index.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#varbind_list ⇒ Object
(also: #vb_list)
Returns the value of attribute varbind_list.
Class Method Summary collapse
Instance Method Summary collapse
- #each_varbind(&block) ⇒ Object
- #encode_pdu(pdu_tag) ⇒ Object
- #error_status ⇒ Object
- #error_status=(status) ⇒ Object
-
#initialize(request_id, varbind_list, error_status = 0, error_index = 0) ⇒ PDU
constructor
A new instance of PDU.
Constructor Details
#initialize(request_id, varbind_list, error_status = 0, error_index = 0) ⇒ PDU
Returns a new instance of PDU.
155 156 157 158 159 160 |
# File 'lib/snmp/pdu.rb', line 155 def initialize(request_id, varbind_list, error_status=0, error_index=0) @request_id = request_id self.error_status = error_status @error_index = error_index.to_int @varbind_list = varbind_list end |
Instance Attribute Details
#error_index ⇒ Object
Returns the value of attribute error_index.
117 118 119 |
# File 'lib/snmp/pdu.rb', line 117 def error_index @error_index end |
#request_id ⇒ Object
Returns the value of attribute request_id.
116 117 118 |
# File 'lib/snmp/pdu.rb', line 116 def request_id @request_id end |
#varbind_list ⇒ Object Also known as: vb_list
Returns the value of attribute varbind_list.
118 119 120 |
# File 'lib/snmp/pdu.rb', line 118 def varbind_list @varbind_list end |
Class Method Details
.decode(pdu_class, pdu_data) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/snmp/pdu.rb', line 122 def self.decode(pdu_class, pdu_data) request_id, remainder = decode_integer(pdu_data) error_status, remainder = decode_integer(remainder) error_index, remainder = decode_integer(remainder) varbind_list, remainder = VarBindList.decode(remainder) assert_no_remainder(remainder) pdu_class.new(request_id, varbind_list, error_status, error_index) end |
Instance Method Details
#each_varbind(&block) ⇒ Object
185 186 187 |
# File 'lib/snmp/pdu.rb', line 185 def each_varbind(&block) @varbind_list.each(&block) end |
#encode_pdu(pdu_tag) ⇒ Object
177 178 179 180 181 182 183 |
# File 'lib/snmp/pdu.rb', line 177 def encode_pdu(pdu_tag) pdu_data = encode_integer(@request_id) pdu_data << encode_integer(@error_status) pdu_data << encode_integer(@error_index) pdu_data << @varbind_list.encode encode_tlv(pdu_tag, pdu_data) end |
#error_status ⇒ Object
173 174 175 |
# File 'lib/snmp/pdu.rb', line 173 def error_status ERROR_STATUS_NAME[@error_status] end |
#error_status=(status) ⇒ Object
162 163 164 165 166 167 168 169 170 171 |
# File 'lib/snmp/pdu.rb', line 162 def error_status=(status) @error_status = ERROR_STATUS_CODE[status] unless @error_status if status.respond_to?(:to_int) && ERROR_STATUS_NAME[status.to_int] @error_status = status else raise InvalidErrorStatus, status.to_s end end end |