Class: SNMP::RequestId

### Home Classes Methods

### In Files

- lib/snmp/manager.rb

### Parent

Object

### Methods

- ::new
- #force_next
- #next

### 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::RequestId

Manage a request-id in the range 1..2**31-1

### Constants

MAX_REQUEST_ID

### Public Class Methods

new() click to toggle source

    # File lib/snmp/manager.rb, line 50
    def initialize
      @lock = Mutex.new
      @request_id = rand(MAX_REQUEST_ID)
    end

### Public Instance Methods

force_next(next_id) click to toggle source

    # File lib/snmp/manager.rb, line 63
    def force_next(next_id)
      new_request_id = next_id.to_i
      if new_request_id < 1 || new_request_id >= MAX_REQUEST_ID
        raise "Invalid request id: #{new_request_id}"
      end
      new_request_id = MAX_REQUEST_ID if new_request_id == 1
      @lock.synchronize do
        @request_id = new_request_id - 1
      end
    end

next() click to toggle source

    # File lib/snmp/manager.rb, line 55
    def next
      @lock.synchronize do
        @request_id += 1
        @request_id = 1 if @request_id == MAX_REQUEST_ID
        return @request_id
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.