Class: PacketFu::EthMac
- Defined in:
- lib/packetfu/protos/eth/header.rb
Overview
EthMac is the combination of an EthOui and EthNic, used in EthHeader.
Header Definition
EthOui :oui # See EthOui
EthNic :nic # See EthNic
Instance Attribute Summary collapse
-
#nic ⇒ Object
Returns the value of attribute nic.
-
#oui ⇒ Object
Returns the value of attribute oui.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ EthMac
constructor
A new instance of EthMac.
-
#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 = {}) ⇒ EthMac
Returns a new instance of EthMac.
106 107 108 109 110 |
# File 'lib/packetfu/protos/eth/header.rb', line 106 def initialize(args={}) super( EthOui.new.read(args[:oui]), EthNic.new.read(args[:nic])) end |
Instance Attribute Details
#nic ⇒ Object
Returns the value of attribute nic
104 105 106 |
# File 'lib/packetfu/protos/eth/header.rb', line 104 def nic @nic end |
#oui ⇒ Object
Returns the value of attribute oui
104 105 106 |
# File 'lib/packetfu/protos/eth/header.rb', line 104 def oui @oui end |
Instance Method Details
#read(str) ⇒ Object
Reads a string to populate the object.
118 119 120 121 122 123 124 |
# File 'lib/packetfu/protos/eth/header.rb', line 118 def read(str) force_binary(str) return self if str.nil? self.oui.read str[0,3] self.nic.read str[3,3] self end |
#to_s ⇒ Object
Returns the object in string form.
113 114 115 |
# File 'lib/packetfu/protos/eth/header.rb', line 113 def to_s "#{self[:oui]}#{self[:nic]}" end |