From eb88ddda8f97f8cf2feea1a73cce95547cf1ad50 Mon Sep 17 00:00:00 2001 From: Tod Beardsley Date: Sun, 9 Jun 2013 13:22:29 -0500 Subject: [PATCH] Use a magic regex, force no encoding for LLDP See #28. This doesn't solve the other problems with string encoding but at least packetfu will load without errors. --- lib/packetfu/protos/lldp.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/packetfu/protos/lldp.rb b/lib/packetfu/protos/lldp.rb index da73d65..3d7a4ab 100644 --- a/lib/packetfu/protos/lldp.rb +++ b/lib/packetfu/protos/lldp.rb @@ -7,6 +7,7 @@ module PacketFu class LLDPPacket < Packet + MAGIC = Regexp.new("^\x01\x80\xc2\x00\x00[\x0e\x03\x00]", nil, "n") include ::PacketFu::EthHeaderMixin include ::PacketFu::LLDPHeaderMixin @@ -16,7 +17,7 @@ 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 =~ /^\x01\x80\xc2\x00\x00[\x0e\x03\x00]/ + return false unless str =~ MAGIC true end