Class: PacketGen::PcapNG::SPB
- Defined in:
- lib/packetgen/pcapng/spb.rb
Overview
SPB represents a 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 ⇒ BinStruct::String
- #endian ⇒ :little, :big
- #interface ⇒ IPB
-
#orig_len ⇒ Integer
32-bit original length.
Attributes inherited from Block
#block_len, #block_len2, #type
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
Constructor Details
Instance Attribute Details
#data ⇒ BinStruct::String
35 |
# File 'lib/packetgen/pcapng/spb.rb', line 35 define_attr_before :block_len2, :data, BinStruct::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 |
#orig_len ⇒ Integer
32-bit original length
32 |
# File 'lib/packetgen/pcapng/spb.rb', line 32 define_attr_before :block_len2, :orig_len, BinStruct::Int32, default: 0 |
Instance Method Details
#options? ⇒ false
Has this block options?
54 55 56 |
# File 'lib/packetgen/pcapng/spb.rb', line 54 def false end |
#read(str_or_io) ⇒ self
Reads a String or a IO to populate the object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/packetgen/pcapng/spb.rb', line 61 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
79 80 81 82 83 |
# File 'lib/packetgen/pcapng/spb.rb', line 79 def to_s pad_field(:data) recalc_block_len super end |