Class: Nmunch::Dissectors::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/nmunch/dissectors/base.rb

Overview

Public: Base dissector class

Direct Known Subclasses

Arp, Ip

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pcap_packet) ⇒ Base

Public: Initializer

pcap_packet - An instance of Pcap::Packet

Stores the packet and extracts to raw packet data in a way that makes it easy to dissect

Returns nothing



16
17
18
19
# File 'lib/nmunch/dissectors/base.rb', line 16

def initialize(pcap_packet)
  @pcap_packet = pcap_packet
  extract_raw_packet_data
end

Instance Attribute Details

#pcap_packetObject (readonly)

Returns the value of attribute pcap_packet.



6
7
8
# File 'lib/nmunch/dissectors/base.rb', line 6

def pcap_packet
  @pcap_packet
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



6
7
8
# File 'lib/nmunch/dissectors/base.rb', line 6

def raw_data
  @raw_data
end

Class Method Details

.factory(pcap_packet) ⇒ Object

Public: Dissector factory

pcap_packet - An instance of Pcap::Packet

Returns an instance of a dissector



26
27
28
29
30
31
32
# File 'lib/nmunch/dissectors/base.rb', line 26

def self.factory(pcap_packet)
  if pcap_packet.ip?
    Nmunch::Dissectors::Ip.new(pcap_packet)
  else
    Nmunch::Dissectors::Arp.new(pcap_packet)
  end
end