Class: Net::SnmpPdu
- Inherits:
-
Object
- Object
- Net::SnmpPdu
- Defined in:
- lib/net/snmp.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- PduTypes =
[ :get_request, :get_next_request, :get_response, :set_request, :trap ]
- ErrorStatusCodes =
Per RFC1157, pgh 4.1.1
{ # Per RFC1157, pgh 4.1.1 0 => "noError", 1 => "tooBig", 2 => "noSuchName", 3 => "badValue", 4 => "readOnly", 5 => "genErr" }
Instance Attribute Summary collapse
-
#community ⇒ Object
Returns the value of attribute community.
-
#error_index ⇒ Object
Returns the value of attribute error_index.
-
#error_status ⇒ Object
Returns the value of attribute error_status.
-
#pdu_type ⇒ Object
Returns the value of attribute pdu_type.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_variable_binding(name, value = nil) ⇒ Object
– Syntactic sugar.
-
#initialize(args = {}) ⇒ SnmpPdu
constructor
A new instance of SnmpPdu.
- #to_ber_string ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ SnmpPdu
Returns a new instance of SnmpPdu.
98 99 100 101 102 103 104 105 |
# File 'lib/net/snmp.rb', line 98 def initialize args={} @version = args[:version] || 0 @community = args[:community] || "public" @pdu_type = args[:pdu_type] # leave nil unless specified; there's no reasonable default value. @error_status = args[:error_status] || 0 @error_index = args[:error_index] || 0 @variables = args[:variables] || [] end |
Instance Attribute Details
#community ⇒ Object
Returns the value of attribute community.
94 95 96 |
# File 'lib/net/snmp.rb', line 94 def community @community end |
#error_index ⇒ Object
Returns the value of attribute error_index.
95 96 97 |
# File 'lib/net/snmp.rb', line 95 def error_index @error_index end |
#error_status ⇒ Object
Returns the value of attribute error_status.
94 95 96 |
# File 'lib/net/snmp.rb', line 94 def error_status @error_status end |
#pdu_type ⇒ Object
Returns the value of attribute pdu_type.
94 95 96 |
# File 'lib/net/snmp.rb', line 94 def pdu_type @pdu_type end |
#request_id ⇒ Object
Returns the value of attribute request_id.
95 96 97 |
# File 'lib/net/snmp.rb', line 95 def request_id @request_id end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
94 95 96 |
# File 'lib/net/snmp.rb', line 94 def variables @variables end |
#version ⇒ Object
Returns the value of attribute version.
94 95 96 |
# File 'lib/net/snmp.rb', line 94 def version @version end |
Class Method Details
.parse(ber_object) ⇒ Object
87 88 89 90 91 |
# File 'lib/net/snmp.rb', line 87 def parse ber_object n = new n.send :parse, ber_object n end |
Instance Method Details
#add_variable_binding(name, value = nil) ⇒ Object
– Syntactic sugar
209 210 211 212 |
# File 'lib/net/snmp.rb', line 209 def add_variable_binding name, value=nil @variables ||= [] @variables << [name, value] end |
#to_ber_string ⇒ Object
214 215 216 217 218 219 220 |
# File 'lib/net/snmp.rb', line 214 def to_ber_string [ version.to_ber, community.to_ber, pdu_to_ber_string ].to_ber_sequence end |