Class: SNMP::SNMPv2_Trap

### Home Classes Methods

### In Files

- lib/snmp/pdu.rb

### Parent

SNMP::PDU

### Methods

- #encode
- #sys_up_time
- #trap_oid

### Files

- README.rdoc

### Class/Module Index

Quicksearch

- SNMP
- SNMP::BER
- SNMP::Counter32
- SNMP::Counter64
- SNMP::EndOfMibView
- SNMP::Gauge32
- SNMP::GetBulkRequest
- SNMP::GetNextRequest
- SNMP::GetRequest
- SNMP::InformRequest
- SNMP::Integer
- SNMP::Integer32
- SNMP::InvalidErrorStatus
- SNMP::InvalidGenericTrap
- SNMP::InvalidIpAddress
- SNMP::InvalidPduTag
- SNMP::InvalidTrapVarbind
- SNMP::IpAddress
- SNMP::MIB
- SNMP::MIB::ModuleNotLoadedError
- SNMP::Manager
- SNMP::Manager::Config
- SNMP::Message
- SNMP::NoSuchInstance
- SNMP::NoSuchObject
- SNMP::Null
- SNMP::ObjectId
- SNMP::ObjectName
- SNMP::OctetString
- SNMP::Opaque
- SNMP::PDU
- SNMP::ParseError
- SNMP::RequestId
- SNMP::RequestTimeout
- SNMP::Response
- SNMP::SNMPv1_Trap
- SNMP::SNMPv2_Trap
- SNMP::SetRequest
- SNMP::TimeTicks
- SNMP::TrapListener
- SNMP::TrapListener::Config
- SNMP::UDPServerTransport
- SNMP::UDPTransport
- SNMP::Unsigned32
- SNMP::UnsignedInteger
- SNMP::UnsupportedPduTag
- SNMP::UnsupportedValueTag
- SNMP::UnsupportedVersion
- SNMP::VarBind
- SNMP::VarBindList
- Fixnum
- Object

No matching classes.

# SNMP::SNMPv2_Trap

The PDU class for traps in SNMPv2c. Methods are provided for retrieving the values of the mandatory varbinds: the system uptime and the OID of the trap. The complete varbind list is available through the usual varbind_list method. The first two varbinds in this list will always be the uptime and trap OID varbinds.

### Attributes

source_ip[RW]

Returns the source IP address for the trap, usually derived from the source IP address of the packet that delivered the trap.

### Public Instance Methods

encode() click to toggle source

    # File lib/snmp/pdu.rb, line 246
    def encode
      encode_pdu(SNMPv2_Trap_PDU_TAG)
    end

sys_up_time() click to toggle source

Returns the value of the mandatory sysUpTime varbind for this trap.

Throws InvalidTrapVarbind if the sysUpTime varbind is not present.

    # File lib/snmp/pdu.rb, line 261
    def sys_up_time
      varbind = @varbind_list[0]
      if varbind && (varbind.name == SYS_UP_TIME_OID)
        return varbind.value
      else
        raise InvalidTrapVarbind, "Expected sysUpTime.0, found " + varbind.to_s
      end
    end

trap_oid() click to toggle source

Returns the value of the mandatory snmpTrapOID varbind for this trap.

Throws InvalidTrapVarbind if the snmpTrapOID varbind is not present.

    # File lib/snmp/pdu.rb, line 275
    def trap_oid
      varbind = @varbind_list[1]
      if varbind && (varbind.name == SNMP_TRAP_OID_OID)
        return varbind.value
      else
        raise InvalidTrapVarbind, "Expected snmpTrapOID.0, found " + varbind.to_s
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.