Sha256: d54e1a3729448cd1e352e950275f36aecc2697b80bd3e9d4b82b0b65c20870c6

Contents?: true

Size: 1.39 KB

Versions: 43

Compression:

Stored size: 1.39 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?
      # [PATCH] Avoid parse failures if using m17n'ed ifconfig
      old_lc_all = ENV[ 'LC_ALL' ]
      ENV[ 'LC_ALL' ] = 'C'
      @ifconfig = IO.popen("/sbin/ifconfig -a"){ |f| f.readlines.join }
      ENV[ 'LC_ALL' ] = old_lc_all
    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

43 entries across 43 versions & 1 rubygems

Version Path
trema-0.3.9 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.8 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.7 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.6 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.5 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.4 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.3 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.2 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.1 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.3.0 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.8 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.7 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.6 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.5 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.4 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.3 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.2.1 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.2 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.1 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb
trema-0.2.0 vendor/ruby-ifconfig-1.2/lib/ifconfig/linux/ifconfig.rb