Class: PacketGen::Header::IP::LSRR
- Inherits:
-
Option
- Object
- Types::Fields
- Option
- PacketGen::Header::IP::LSRR
- Defined in:
- lib/packetgen/header/ip/option.rb
Overview
Loose Source and Record Route IP option
Constant Summary
Constants inherited from Option
Option::EOL_TYPE, Option::LSRR_TYPE, Option::NOP_TYPE, Option::RA_TYPE, Option::RR_TYPE, Option::SI_TYPE, Option::SSRR_TYPE
Instance Attribute Summary collapse
-
#data ⇒ Types::Array<IP::Addr>
Array of IP addresses.
-
#pointer ⇒ Integer
8-bit pointer on next address.
Attributes inherited from Option
#copied, #length, #option_class, #type
Instance Method Summary collapse
-
#pointed_addr ⇒ Addr
Get IP address pointer by #pointer.
-
#read(str) ⇒ Fields
Populate object from a binary string.
-
#to_human ⇒ String
Get a human readable string.
Methods inherited from Option
Methods inherited from Types::Fields
#[], #[]=, #bits_on, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, #fields, fields, #force_binary, inherited, #initialize, #inspect, #is_optional?, #is_present?, #offset_of, #optional?, #optional_fields, #present?, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Header::IP::Option
Instance Attribute Details
#data ⇒ Types::Array<IP::Addr>
Array of IP addresses
131 132 |
# File 'lib/packetgen/header/ip/option.rb', line 131 define_field :data, ArrayOfAddr, builder: ->(h, t) { t.new(length_from: -> { h.length - 2 }) } |
Instance Method Details
#pointed_addr ⇒ Addr
Get IP address pointer by #pointer
149 150 151 |
# File 'lib/packetgen/header/ip/option.rb', line 149 def pointed_addr data[pointer / 4 - 1] end |
#read(str) ⇒ Fields
Populate object from a binary string
137 138 139 140 141 142 143 144 145 |
# File 'lib/packetgen/header/ip/option.rb', line 137 def read(str) return self if str.nil? force_binary str self[:type].read str[0, 1] self[:length].read str[1, 1] self[:pointer].read str[2, 1] self[:data].read str[3, length - 3] self end |
#to_human ⇒ String
Get a human readable string
155 156 157 158 |
# File 'lib/packetgen/header/ip/option.rb', line 155 def to_human str = self.class.to_s.sub(/.*::/, '') str << ':' << self[:data].to_human end |