Class: PacketGen::PcapNG::UnknownBlock
- Inherits:
-
Block
- Object
- Types::Fields
- Block
- PacketGen::PcapNG::UnknownBlock
- Defined in:
- lib/packetgen/pcapng/unknown_block.rb
Overview
UnknownBlock is used to handle unsupported blocks of a pcapng file.
Constant Summary collapse
- MIN_SIZE =
Minimum Iblock size
12
Instance Attribute Summary collapse
Attributes inherited from Block
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ UnknownBlock
constructor
A new instance of UnknownBlock.
-
#options? ⇒ false
Has this block options?.
-
#read(str_or_io) ⇒ self
Reads a String or a IO to populate the object.
-
#to_s ⇒ String
Return the object as a String.
Methods inherited from Block
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #inspect, #offset_of, #optional?, #optional_fields, #present?, remove_bit_fields_on, remove_field, #sz, #to_h, update_field
Constructor Details
#initialize(options = {}) ⇒ UnknownBlock
Returns a new instance of UnknownBlock.
31 32 33 34 35 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 31 def initialize(={}) super endianness([:endian] || :little) recalc_block_len end |
Instance Attribute Details
#body ⇒ Types::String
24 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 24 define_field_before :block_len2, :body, Types::String |
#endian ⇒ :little, :big
18 19 20 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 18 def endian @endian end |
#section ⇒ SHB
20 21 22 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 20 def section @section end |
Instance Method Details
#options? ⇒ false
Has this block options?
40 41 42 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 40 def false end |
#read(str_or_io) ⇒ self
Reads a String or a IO to populate the object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 47 def read(str_or_io) io = to_io(str_or_io) return self if io.eof? self[:type].read io.read(4) self[:block_len].read io.read(4) self[:body].read io.read(self[:block_len].to_i - MIN_SIZE) read_blocklen2_and_check(io) self end |
#to_s ⇒ String
Return the object as a String
61 62 63 64 65 |
# File 'lib/packetgen/pcapng/unknown_block.rb', line 61 def to_s pad_field :body recalc_block_len super end |