Class: PacketFu::EthMac

Inherits:
Struct
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from Struct

#force_binary

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

#nicObject

Returns the value of attribute nic

Returns:

  • (Object)

    the current value of nic


104
105
106
# File 'lib/packetfu/protos/eth/header.rb', line 104

def nic
  @nic
end

#ouiObject

Returns the value of attribute oui

Returns:

  • (Object)

    the current value of 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_sObject

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