class PacketFu::LLDPPacket
Constants
- MAGIC
Attributes
eth_header[RW]
lldp_header[RW]
Public Class Methods
can_parse?(str)
click to toggle source
# File lib/packetfu/protos/lldp.rb, line 16 def self.can_parse?(str) return false unless EthPacket.can_parse? str return false unless str.size >= 6 return false unless str[12,2] == "\x88\xcc" return false unless str =~ MAGIC true end
new(args={})
click to toggle source
Calls superclass method
PacketFu::Packet::new
# File lib/packetfu/protos/lldp.rb, line 31 def initialize(args={}) @eth_header = EthHeader.new(args).read(args[:eth]) @lldp_header = LLDPHeader.new(args).read(args[:lldp]) @eth_header.eth_proto = "\x88\xCC" @eth_header.body=@lldp_header @headers = [@eth_header, @lldp_header] super end
Public Instance Methods
peek_format()
click to toggle source
Generates summary data for LLDP packets.
# File lib/packetfu/protos/lldp.rb, line 42 def peek_format peek_data = ["A "] peek_data << "%-5d" % self.to_s.size peek_data << lldp_saddr_mac peek_data << "(#{lldp_saddr_mac})" peek_data << "->" peek_data << "01:80:c2:00:00:0e" peek_data.join end
read(str=nil,args={})
click to toggle source
Calls superclass method
PacketFu::Packet#read
# File lib/packetfu/protos/lldp.rb, line 24 def read(str=nil,args={}) raise "Cannot parse `#{str}'" unless self.class.can_parse?(str) @eth_header.read(str) super(args) self end
recalc(args={})
click to toggle source
While there are lengths in LLDPPackets, there's not much to do with them.
# File lib/packetfu/protos/lldp.rb, line 54 def recalc(args={}) @headers[0].inspect end