Class: PacketGen::PcapNG::SPB
- Inherits:
-
Block
- Object
- Types::Fields
- Block
- PacketGen::PcapNG::SPB
- Defined in:
- lib/packetgen/pcapng/spb.rb
Overview
SPB represents a Section Simple Packet Block (SPB) of a pcapng file.
Pcapng::SPB Definition
Int32 :type Default: 0x00000003
Int32 :block_len
Int32 :orig_len
String :data
Int32 :block_len2
Constant Summary collapse
- MIN_SIZE =
Minimum SPB size
4 * 4
Instance Attribute Summary collapse
- #data ⇒ Types::String
- #endian ⇒ :little, :big
- #interface ⇒ IPB
-
#orig_len ⇒ Integer
32-bit original length.
Attributes inherited from Block
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ SPB
constructor
A new instance of SPB.
-
#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
Instance Attribute Details
#data ⇒ Types::String
35 |
# File 'lib/packetgen/pcapng/spb.rb', line 35 define_field_before :block_len2, :data, Types::String |
#endian ⇒ :little, :big
25 26 27 |
# File 'lib/packetgen/pcapng/spb.rb', line 25 def endian @endian end |
#interface ⇒ IPB
27 28 29 |
# File 'lib/packetgen/pcapng/spb.rb', line 27 def interface @interface end |
Instance Method Details
#options? ⇒ false
Has this block options?
56 57 58 |
# File 'lib/packetgen/pcapng/spb.rb', line 56 def false end |
#read(str_or_io) ⇒ self
Reads a String or a IO to populate the object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/packetgen/pcapng/spb.rb', line 63 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[:orig_len].read io.read(4) data_len = compute_data_len self[:data].read io.read(data_len) remove_padding(io, data_len) read_blocklen2_and_check(io) self.type ||= PcapNG::IDB_TYPE.to_i self end |
#to_s ⇒ String
Return the object as a String
81 82 83 84 85 |
# File 'lib/packetgen/pcapng/spb.rb', line 81 def to_s pad_field :data recalc_block_len super end |