Class: PacketFu::EthPacket
Overview
Instance Attribute Summary collapse
-
#eth_header ⇒ Object
Returns the value of attribute eth_header.
Attributes inherited from Packet
#flavor, #headers, #iface, #inspect_style
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ EthPacket
constructor
A new instance of EthPacket.
- #read(str = nil, args = {}) ⇒ Object
-
#recalc(args = {}) ⇒ Object
Does nothing, really, since there’s no length or checksum to calculate for a straight Ethernet packet.
Methods inherited from Packet
#==, #clone, #dissect, #dissection_table, force_binary, #handle_is_identity, #hexify, inherited, #inspect, #inspect_hex, #kind_of?, #layer, layer, layer_symbol, #layer_symbol, #method_missing, #orig_kind_of?, parse, #payload, #payload=, #peek, #peek_format, #proto, #respond_to?, #size, #to_f, #to_pcap, #to_s, #to_w, #write
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class PacketFu::Packet
Instance Attribute Details
#eth_header ⇒ Object
Returns the value of attribute eth_header.
262 263 264 |
# File 'lib/packetfu/protos/eth.rb', line 262 def eth_header @eth_header end |
Class Method Details
.can_parse?(str) ⇒ Boolean
264 265 266 267 268 269 270 271 |
# File 'lib/packetfu/protos/eth.rb', line 264 def self.can_parse?(str) # XXX Temporary fix. Need to extend the EthHeader class to handle more. valid_eth_types = [0x0800, 0x0806, 0x86dd] return false unless str.size >= 14 type = str[12,2].unpack("n").first rescue nil return false unless valid_eth_types.include? type true end |
Instance Method Details
#read(str = nil, args = {}) ⇒ Object
273 274 275 276 277 278 |
# File 'lib/packetfu/protos/eth.rb', line 273 def read(str=nil,args={}) raise "Cannot parse `#{str}'" unless self.class.can_parse?(str) @eth_header.read(str) super(args) return self end |
#recalc(args = {}) ⇒ Object
Does nothing, really, since there’s no length or checksum to calculate for a straight Ethernet packet.
282 283 284 |
# File 'lib/packetfu/protos/eth.rb', line 282 def recalc(args={}) @headers[0].inspect end |