lib/net/snmp.rb
#--
# Helper method that returns a PDU payload in BER form,
# depending on the PDU type.
Helper method that returns a PDU payload in BER form,
depending on the PDU type.
Helper method that returns a PDU payload in BER form depending on the PDU type .
def pdu_to_ber_string
      case pdu_type
      when :get_request
        [
          request_id.to_ber,
          error_status.to_ber,
          error_index.to_ber,
          [
            @variables.map do|n, v|
              [n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].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 do|n, v|
              [n.to_ber_oid, Net::BER::BerIdentifiedNull.new.to_ber].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 do|n, v|
              [n.to_ber_oid, v.to_ber].to_ber_sequence
            end,
          ].to_ber_sequence,
        ].to_ber_contextspecific(2)
      else
        raise Error.new( "unknown pdu-type: #{pdu_type}" )
      end
    end
def pdu_to_ber_string case pdu_type when :get_request [ request_id . to_ber , error_status . to_ber , error_index . to_ber , [ @variables . map do | n , v | [ n . to_ber_oid , Net :: BER :: BerIdentifiedNull . new . to_ber ] . 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 do | n , v | [ n . to_ber_oid , Net :: BER :: BerIdentifiedNull . new . to_ber ] . 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 do | n , v | [ n . to_ber_oid , v . to_ber ] . to_ber_sequence end , ] . to_ber_sequence , ] . to_ber_contextspecific ( 2 ) else raise Error . new ( "unknown pdu-type: #{pdu_type}" ) end end
Helper method that returns a PDU payload in BER form,
depending on the PDU type.
Helper method that returns a PDU payload in BER form depending on the PDU type .