lib/net/snmp.rb in net-ldap-0.13.0 vs lib/net/snmp.rb in net-ldap-0.14.0

- old
+ new

@@ -10,20 +10,20 @@ :primitive => { 1 => :integer, # Counter32, (RFC2578 sec 2) 2 => :integer, # Gauge32 or Unsigned32, (RFC2578 sec 2) 3 => :integer # TimeTicks32, (RFC2578 sec 2) }, - :constructed => {} + :constructed => {}, }, :context_specific => { :primitive => {}, :constructed => { 0 => :array, # GetRequest PDU (RFC1157 pgh 4.1.2) 1 => :array, # GetNextRequest PDU (RFC1157 pgh 4.1.3) 2 => :array # GetResponse PDU (RFC1157 pgh 4.1.4) - } - } + }, + }, }) # SNMP 32-bit counter. # Defined in RFC1155 (Structure of Mangement Information), section 6. # A 32-bit counter is an ASN.1 application [1] implicit unsigned integer @@ -68,19 +68,19 @@ PduTypes = [ :get_request, :get_next_request, :get_response, :set_request, - :trap + :trap, ] ErrorStatusCodes = { # Per RFC1157, pgh 4.1.1 0 => "noError", 1 => "tooBig", 2 => "noSuchName", 3 => "badValue", 4 => "readOnly", - 5 => "genErr" + 5 => "genErr", } class << self def parse ber_object n = new @@ -146,11 +146,11 @@ send :request_id=, data[0].to_i # data[1] is error_status, always zero. # data[2] is error_index, always zero. send :error_status=, 0 send :error_index=, 0 - data[3].each do |n,v| + data[3].each do |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. unless v.is_a?(Net::BER::BerIdentifiedNull) raise Error.new(" invalid variable-binding in get-request" ) @@ -164,22 +164,22 @@ # 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 do |n,v| + data[3].each do |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 end private :parse_get_response def version= ver - unless [0,2].include?(ver) + unless [0, 2].include?(ver) raise Error.new("unknown snmp-version: #{ver}") end @version = ver end @@ -189,11 +189,11 @@ end @pdu_type = t end def error_status= es - unless ErrorStatusCodes.has_key?(es) + unless ErrorStatusCodes.key?(es) raise Error.new("unknown error-status: #{es}") end @error_status = es end @@ -225,35 +225,35 @@ [ request_id.to_ber, error_status.to_ber, error_index.to_ber, [ - @variables.map {|n,v| + @variables.map do|n, v| [n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].to_ber_sequence - } - ].to_ber_sequence + end, + ].to_ber_sequence, ].to_ber_contextspecific(0) when :get_next_request [ request_id.to_ber, error_status.to_ber, error_index.to_ber, [ - @variables.map {|n,v| + @variables.map do|n, v| [n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].to_ber_sequence - } - ].to_ber_sequence + end, + ].to_ber_sequence, ].to_ber_contextspecific(1) when :get_response [ request_id.to_ber, error_status.to_ber, error_index.to_ber, [ - @variables.map {|n,v| + @variables.map do|n, v| [n.to_ber_oid, v.to_ber].to_ber_sequence - } - ].to_ber_sequence + end, + ].to_ber_sequence, ].to_ber_contextspecific(2) else raise Error.new( "unknown pdu-type: #{pdu_type}" ) end end