Class: PacketGen::Config
- Inherits:
-
Object
- Object
- PacketGen::Config
- Includes:
- Singleton
- Defined in:
- lib/packetgen/config.rb
Overview
Config class to provide config
object to pgconsole
Instance Attribute Summary collapse
-
#default_iface ⇒ String
readonly
Default network interface.
Instance Method Summary collapse
-
#hwaddr(iface = nil) ⇒ String
Get MAC address for given network interface.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#ip6addr(iface = nil) ⇒ Array<String>
Get IPv6 addresses for given network interface.
-
#ipaddr(iface = nil) ⇒ String
Get IP address for given network interface.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 |
# File 'lib/packetgen/config.rb', line 25 def initialize @default_iface = PacketGen.default_iface || PacketGen.loopback_iface @hwaddr = {} @ipaddr = {} @ip6addr = {} initialize_local_addresses end |
Instance Attribute Details
#default_iface ⇒ String (readonly)
Default network interface
23 24 25 |
# File 'lib/packetgen/config.rb', line 23 def default_iface @default_iface end |
Instance Method Details
#hwaddr(iface = nil) ⇒ String
Get MAC address for given network interface
37 38 39 |
# File 'lib/packetgen/config.rb', line 37 def hwaddr(iface=nil) @hwaddr[iface || default_iface] end |
#ip6addr(iface = nil) ⇒ Array<String>
Get IPv6 addresses for given network interface
51 52 53 |
# File 'lib/packetgen/config.rb', line 51 def ip6addr(iface=nil) @ip6addr[iface || default_iface] end |
#ipaddr(iface = nil) ⇒ String
Get IP address for given network interface
44 45 46 |
# File 'lib/packetgen/config.rb', line 44 def ipaddr(iface=nil) @ipaddr[iface || default_iface] end |