Module: PacketFu::PcapNG::Block

Included in:
EPB, IDB, SHB, SPB, UnknownBlock
Defined in:
lib/packetfu/pcapng/block.rb

Instance Method Summary collapse

Instance Method Details

#pad_field(*fields) ⇒ Object

Pad given field to 32 bit boundary, if needed



14
15
16
17
18
19
20
# File 'lib/packetfu/pcapng/block.rb', line 14

def pad_field(*fields)
  fields.each do |field|
    unless self[field].size % 4 == 0
      self[field] << "\x00" * (4 - (self[field].size % 4))
    end
  end
end

#recalc_block_lenObject

Calculate block length and update :block_len and block_len2 fields



8
9
10
11
# File 'lib/packetfu/pcapng/block.rb', line 8

def recalc_block_len
  len = to_a.map(&:to_s).join.size
  self[:block_len].value = self[:block_len2].value = len
end