tweaked get-response parsing
This commit is contained in:
parent
977f276191
commit
40b5554389
|
@ -163,8 +163,9 @@ module Net
|
||||||
when 2
|
when 2
|
||||||
send :pdu_type=, :get_response
|
send :pdu_type=, :get_response
|
||||||
# This PDU is identical to get-request except for the type,
|
# This PDU is identical to get-request except for the type,
|
||||||
|
# the error_status and error_index values are meaningful,
|
||||||
# and the fact that the variable bindings will be non-null.
|
# and the fact that the variable bindings will be non-null.
|
||||||
parse_get_request data
|
parse_get_response data
|
||||||
else
|
else
|
||||||
raise Error.new( "unknown snmp-pdu type: #{app_tag}" )
|
raise Error.new( "unknown snmp-pdu type: #{app_tag}" )
|
||||||
end
|
end
|
||||||
|
@ -175,8 +176,10 @@ module Net
|
||||||
# Defined in RFC1157, pgh 4.1.2.
|
# Defined in RFC1157, pgh 4.1.2.
|
||||||
def parse_get_request data
|
def parse_get_request data
|
||||||
send :request_id=, data[0].to_i
|
send :request_id=, data[0].to_i
|
||||||
send :error_status=, data[1].to_i
|
# data[1] is error_status, always zero.
|
||||||
send :error_index=, data[2].to_i
|
# data[2] is error_index, always zero.
|
||||||
|
send :error_status=, 0
|
||||||
|
send :error_index=, 0
|
||||||
data[3].each {|n,v|
|
data[3].each {|n,v|
|
||||||
# A variable-binding, of which there may be several,
|
# A variable-binding, of which there may be several,
|
||||||
# consists of an OID and a BER null.
|
# consists of an OID and a BER null.
|
||||||
|
@ -189,6 +192,21 @@ module Net
|
||||||
end
|
end
|
||||||
private :parse_get_request
|
private :parse_get_request
|
||||||
|
|
||||||
|
#--
|
||||||
|
# Defined in RFC1157, pgh 4.1.4
|
||||||
|
def parse_get_response data
|
||||||
|
send :request_id=, data[0].to_i
|
||||||
|
send :error_status=, data[1].to_i
|
||||||
|
send :error_index=, data[2].to_i
|
||||||
|
data[3].each {|n,v|
|
||||||
|
# A variable-binding, of which there may be several,
|
||||||
|
# consists of an OID and a BER null.
|
||||||
|
# We're ignoring the null, we might want to verify it instead.
|
||||||
|
add_variable_binding n, v
|
||||||
|
}
|
||||||
|
end
|
||||||
|
private :parse_get_response
|
||||||
|
|
||||||
|
|
||||||
def version= ver
|
def version= ver
|
||||||
unless [0,2].include?(ver)
|
unless [0,2].include?(ver)
|
||||||
|
|
Loading…
Reference in a new issue