Class: PacketGen::Header::SNMP
- Defined in:
- lib/packetgen/header/snmp.rb
Overview
Simple Network Management Protocol (SNMP)
Defined Under Namespace
Classes: Bulk, GetNextRequest, GetRequest, GetResponse, InformRequest, PDUs, Report, SetRequest, Trapv1, Trapv2, VarBind, VariableBindings
Constant Summary collapse
- UDP_PORT1 =
Agents listen to this port
161
- UDP_PORT2 =
Configuration sinks listen to this port
162
- PDU_GET =
rubocop:disable Naming/ConstantName
0
- PDU_NEXT =
1
- PDU_RESPONSE =
2
- PDU_SET =
3
- PDU_TRAPv1 =
4
- PDU_BULK =
5
- PDU_INFORM =
6
- PDU_TRAPv2 =
7
- PDU_REPORT =
8
- ERRORS =
rubocop:enable Naming/ConstantName
{ 'no_error' => 0, 'too_big' => 1, 'no_such_name' => 2, 'bad_value' => 3, 'read_only' => 4, 'generic_error' => 5, 'no_access' => 6, 'wrong_type' => 7, 'wrong_length' => 8, 'wrong_encoding' => 9, 'wrong_value' => 10, 'no_creation' => 11, 'inconsistent_value' => 12, 'ressource_unavailable' => 13, 'commit_failed' => 14, 'undo_failed' => 15, 'authorization_error' => 16, 'not_writable' => 17, 'inconsistent_name' => 18 }.freeze
Instance Method Summary collapse
- #added_to_packet(packet) ⇒ void private
-
#data ⇒ ASN1::Types::Choice
accessor to data payload.
-
#initialize(options = {}) ⇒ SNMP
constructor
A new instance of SNMP.
- #inspect ⇒ Object
-
#pdu ⇒ GetRequest, ...
shortcut to PDU.
Methods inherited from ASN1Base
define_attributes, known_headers, #read
Methods included from PacketGen::Headerable
included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read
Constructor Details
#initialize(options = {}) ⇒ SNMP
Returns a new instance of SNMP.
279 280 281 282 283 284 285 286 |
# File 'lib/packetgen/header/snmp.rb', line 279 def initialize(={}) super data.chosen = [:chosen_pdu] if [:chosen_pdu] return unless [:pdu] klass = data.root.chosen_value.class data.root.value[data.chosen] = klass.new([:pdu]) end |
Instance Method Details
#added_to_packet(packet) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method is used internally by PacketGen and should not be directly called
This method returns an undefined value.
321 322 323 324 325 326 |
# File 'lib/packetgen/header/snmp.rb', line 321 def added_to_packet(packet) return unless packet.is? 'UDP' return unless packet.udp.sport.zero? packet.udp.sport = packet.udp.dport end |
#data ⇒ ASN1::Types::Choice
accessor to data payload
290 291 292 |
# File 'lib/packetgen/header/snmp.rb', line 290 def data @elements[:data] end |
#inspect ⇒ Object
304 305 306 307 308 309 310 311 312 |
# File 'lib/packetgen/header/snmp.rb', line 304 def inspect str = super str << Inspect.shift_level str << if self[:data].chosen.nil? Inspect::FMT_ATTR % [self[:data].type, :data, ''] else inspect_data end end |
#pdu ⇒ GetRequest, ...
shortcut to PDU
296 297 298 299 300 301 302 |
# File 'lib/packetgen/header/snmp.rb', line 296 def pdu if data.chosen.nil? nil else data.root.chosen_value end end |