Class: PacketFu::InvalidHeader

Inherits:
Struct
  • Object
show all
Includes:
StructFu
Defined in:
lib/packetfu/protos/invalid.rb

Overview

InvalidHeader catches all packets that we don't already have a Struct for, or for whatever reason, violates some basic packet rules for other packet types.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StructFu

#clone, #set_endianness, #sz, #typecast

Methods inherited from Struct

#force_binary

Constructor Details

#initialize(args = {}) ⇒ InvalidHeader

Returns a new instance of InvalidHeader


10
11
12
13
# File 'lib/packetfu/protos/invalid.rb', line 10

def initialize(args={})
  args[:body] ||= StructFu::String.new
  super(args[:body])
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body


7
8
9
# File 'lib/packetfu/protos/invalid.rb', line 7

def body
  @body
end

Instance Method Details

#read(str) ⇒ Object

Reads a string to populate the object.


21
22
23
24
25
26
# File 'lib/packetfu/protos/invalid.rb', line 21

def read(str)
  force_binary(str)
  return self if str.nil?
  self[:body].read str
  self
end

#to_sObject

Returns the object in string form.


16
17
18
# File 'lib/packetfu/protos/invalid.rb', line 16

def to_s
  self.to_a.map {|x| x.to_s}.join
end