Class: PacketGen::PcapNG::UnknownBlock

Inherits:
Block
  • Object
show all
Defined in:
lib/packetgen/pcapng/unknown_block.rb

Overview

UnknownBlock is used to handle unsupported blocks of a pcapng file.

Author:

  • Sylvain Daubert

Constant Summary collapse

MIN_SIZE =

Minimum Iblock size

12

Instance Attribute Summary collapse

Attributes inherited from Block

#block_len, #block_len2, #type

Instance Method Summary collapse

Methods inherited from Block

#initialize, #pad_field, #recalc_block_len

Constructor Details

This class inherits a constructor from PacketGen::PcapNG::Block

Instance Attribute Details

#bodyBinStruct::String

Returns:

  • (BinStruct::String)


24
# File 'lib/packetgen/pcapng/unknown_block.rb', line 24

define_attr_before :block_len2, :body, BinStruct::String

#endian:little, :big

Returns:

  • (:little, :big)


18
19
20
# File 'lib/packetgen/pcapng/unknown_block.rb', line 18

def endian
  @endian
end

#sectionSHB

Returns:



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?

Returns:

  • (false)

Since:

  • 2.7.0



29
30
31
# File 'lib/packetgen/pcapng/unknown_block.rb', line 29

def options?
  false
end

#read(str_or_io) ⇒ self

Reads a String or a IO to populate the object

Parameters:

  • str_or_io (::String, IO)

Returns:

  • (self)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/packetgen/pcapng/unknown_block.rb', line 36

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_sString

Return the object as a String

Returns:

  • (String)


50
51
52
53
54
# File 'lib/packetgen/pcapng/unknown_block.rb', line 50

def to_s
  pad_field(:body)
  recalc_block_len
  super
end