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.
24 25 26 27 28 29 30 31 |
# File 'lib/packetgen/config.rb', line 24 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
22 23 24 |
# File 'lib/packetgen/config.rb', line 22 def default_iface @default_iface end |
Instance Method Details
#hwaddr(iface = nil) ⇒ String
Get MAC address for given network interface
36 37 38 |
# File 'lib/packetgen/config.rb', line 36 def hwaddr(iface=nil) @hwaddr[iface || default_iface] end |
#ip6addr(iface = nil) ⇒ Array<String>
Get IPv6 addresses for given network interface
50 51 52 |
# File 'lib/packetgen/config.rb', line 50 def ip6addr(iface=nil) @ip6addr[iface || default_iface] end |
#ipaddr(iface = nil) ⇒ String
Get IP address for given network interface
43 44 45 |
# File 'lib/packetgen/config.rb', line 43 def ipaddr(iface=nil) @ipaddr[iface || default_iface] end |