Class: PacketFu::InvalidPacket

Inherits:
Packet
  • Object
show all
Defined in:
lib/packetfu/protos/invalid.rb

Overview

You probably don’t want to write invalid packets on purpose.

Instance Attribute Summary collapse

Attributes inherited from Packet

#flavor, #headers, #iface, #inspect_style

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Packet

#==, #clone, #dissect, #dissection_table, force_binary, #handle_is_identity, #hexify, inherited, #inspect, #inspect_hex, #kind_of?, #layer, layer_symbol, #layer_symbol, #method_missing, #orig_kind_of?, parse, #payload, #payload=, #peek, #peek_format, #proto, #recalc, #respond_to?, #size, #to_f, #to_pcap, #to_s, #to_w, #write

Constructor Details

#initialize(args = {}) ⇒ InvalidPacket

Returns a new instance of InvalidPacket.



47
48
49
50
# File 'lib/packetfu/protos/invalid.rb', line 47

def initialize(args={})
  @invalid_header =  (args[:invalid] || InvalidHeader.new)
  @headers = [@invalid_header]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PacketFu::Packet

Instance Attribute Details

#invalid_headerObject

Returns the value of attribute invalid_header.



31
32
33
# File 'lib/packetfu/protos/invalid.rb', line 31

def invalid_header
  @invalid_header
end

Class Method Details

.can_parse?(str) ⇒ Boolean

Any packet is potentially an invalid packet

Returns:



34
35
36
# File 'lib/packetfu/protos/invalid.rb', line 34

def self.can_parse?(str)
  true
end

.layerObject



38
39
40
# File 'lib/packetfu/protos/invalid.rb', line 38

def self.layer
  0
end

Instance Method Details

#read(str = nil, args = {}) ⇒ Object



42
43
44
45
# File 'lib/packetfu/protos/invalid.rb', line 42

def read(str=nil,args={})
  @invalid_header.read(str)
  self
end