Class: PacketFu::EthNic
- Defined in:
- lib/packetfu/protos/eth/header.rb
Overview
EthNic is the Network Interface Controler portion of a MAC address, used in EthHeader.
Header Definition
Integer:n1
Integer:n2
Integer:n3
Instance Attribute Summary collapse
-
#n0 ⇒ Object
Returns the value of attribute n0.
-
#n1 ⇒ Object
Returns the value of attribute n1.
-
#n2 ⇒ Object
Returns the value of attribute n2.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ EthNic
constructor
EthNic does not enjoy StructFu typing.
-
#read(str) ⇒ Object
Reads a string to populate the object.
-
#to_s ⇒ Object
Returns the object in string form.
Methods inherited from Struct
Constructor Details
#initialize(args = {}) ⇒ EthNic
EthNic does not enjoy StructFu typing.
78 79 80 81 |
# File 'lib/packetfu/protos/eth/header.rb', line 78 def initialize(args={}) args.each_pair {|k,v| args[k] = 0 unless v} super(args[:n0], args[:n1], args[:n2]) end |
Instance Attribute Details
#n0 ⇒ Object
Returns the value of attribute n0
75 76 77 |
# File 'lib/packetfu/protos/eth/header.rb', line 75 def n0 @n0 end |
#n1 ⇒ Object
Returns the value of attribute n1
75 76 77 |
# File 'lib/packetfu/protos/eth/header.rb', line 75 def n1 @n1 end |
#n2 ⇒ Object
Returns the value of attribute n2
75 76 77 |
# File 'lib/packetfu/protos/eth/header.rb', line 75 def n2 @n2 end |
Instance Method Details
#read(str) ⇒ Object
Reads a string to populate the object.
89 90 91 92 93 94 |
# File 'lib/packetfu/protos/eth/header.rb', line 89 def read(str) force_binary(str) return self if str.nil? self[:n0], self[:n1], self[:n2] = str[0,3].unpack("C3") self end |
#to_s ⇒ Object
Returns the object in string form.
84 85 86 |
# File 'lib/packetfu/protos/eth/header.rb', line 84 def to_s [n0,n1,n2].map {|x| x.to_i}.pack("C3") end |