The PDU class for traps in SNMPv1.
Code map for all of the generic traps defined in RFC 1157.
Name map for all of the generic traps defined in RFC 1157.
Returns the source IP address for the trap, usually derived from the source IP address of the packet that delivered the trap.
# File lib/snmp/pdu.rb, line 389 def each_varbind(&block) @varbind_list.each(&block) end
# File lib/snmp/pdu.rb, line 379 def encode pdu_data = @enterprise.encode << @agent_addr.encode << encode_integer(@generic_trap) << encode_integer(@specific_trap) << @timestamp.encode << @varbind_list.encode encode_tlv(SNMPv1_Trap_PDU_TAG, pdu_data) end
# File lib/snmp/pdu.rb, line 375 def generic_trap GENERIC_TRAP_NAME[@generic_trap] end
# File lib/snmp/pdu.rb, line 364 def generic_trap=(trap) @generic_trap = GENERIC_TRAP_CODE[trap] unless @generic_trap if trap.respond_to?(:to_i) && GENERIC_TRAP_NAME[trap.to_i] @generic_trap = trap else raise InvalidGenericTrap, trap.to_s end end end
# File lib/snmp/pdu.rb, line 326 def self.decode(pdu_data, mib=nil) oid_data, remainder = decode_object_id(pdu_data) enterprise = ObjectId.new(oid_data) ip_data, remainder = decode_ip_address(remainder) agent_addr = IpAddress.new(ip_data) generic_trap, remainder = decode_integer(remainder) specific_trap, remainder = decode_integer(remainder) time_data, remainder = decode_timeticks(remainder) timestamp = TimeTicks.new(time_data) varbind_list, remainder = VarBindList.decode(remainder, mib) assert_no_remainder(remainder) SNMPv1_Trap.new(enterprise, agent_addr, generic_trap, specific_trap, timestamp, varbind_list) end
# File lib/snmp/pdu.rb, line 341 def initialize(enterprise, agent_addr, generic_trap, specific_trap, timestamp, varbind_list) @enterprise = enterprise @agent_addr = agent_addr self.generic_trap = generic_trap @specific_trap = specific_trap @timestamp = timestamp @varbind_list = varbind_list end