Sha256: 8403658a6200fbc3e6ec3fd2158d457fdb1cda9bc901d8a580c9e06e504a42d3

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

# $Id: ifconfig.rb,v 1.1.1.1 2005/07/02 19:10:57 hobe Exp $
#

require 'ifconfig/common/ifconfig'
require 'ifconfig/linux/network_types'
require 'ifconfig/linux/interface_types'

class Ifconfig
  #
  # Can manually specify the platform (should be output of the 'uname' command)
  # and the ifconfig input
  # 
  def initialize(input=nil,verbose=nil)
    if input.nil?
      cmd = IO.popen('which ifconfig'){ |f| f.readlines[0] }
      exit unless !cmd.nil?
      @ifconfig = IO.popen("/sbin/ifconfig -a"){ |f| f.readlines.join }
    else
      @ifconfig = input
    end
    @verbose = verbose
    @ifaces = {}
    split_interfaces(@ifconfig).each do |iface|
      iface_name = get_iface_name(iface)
      case iface
        when /encap\:ethernet/im
          @ifaces[iface_name] = EthernetAdapter.new(iface_name,iface)
        when /encap\:Local Loopback/im
          @ifaces[iface_name] = LoopbackInterface.new(iface_name,iface)
        when /encap\:IPv6-in-IPv4/im
          @ifaces[iface_name] = IPv6_in_IPv4.new(iface_name,iface)
        when /encap\:Point-to-Point Protocol/im
          @ifaces[iface_name] = PPP.new(iface_name,iface)
        when /encap\:Serial Line IP/im
          @ifaces[iface_name] = SerialLineIP.new(iface_name,iface)
        else
          puts "Unknown Adapter Type on Linux: #{iface}" if @verbose
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aaalex-ruby-ifconfig-1.2.1 lib/ifconfig/linux/ifconfig.rb
aaalex-ruby-ifconfig-1.2.2 lib/ifconfig/linux/ifconfig.rb