class Facter::Util::Linux::IfInet6

Constants

IFA_FLAGS

Public Class Methods

read_flags() click to toggle source
# File lib/facter/util/linux/if_inet6.rb, line 29
def read_flags
  return read_flags_from_proc if File.exist?('/proc/net/if_inet6')

  {}
end

Private Class Methods

init_flags() click to toggle source
# File lib/facter/util/linux/if_inet6.rb, line 49
def init_flags
  Hash.new { |h1, k1| h1[k1] = Hash.new { |h2, k2| h2[k2] = [] } }
end
parse_ifa_flags(flag) click to toggle source
# File lib/facter/util/linux/if_inet6.rb, line 53
def parse_ifa_flags(flag)
  flag = flag.hex
  flags = []
  IFA_FLAGS.each_pair do |name, value|
    next if (flag & value).zero?

    flags << name
  end
  flags
end
parse_ip(ip) click to toggle source
# File lib/facter/util/linux/if_inet6.rb, line 64
def parse_ip(ip)
  # The ip address in if_net6 is a long string wit no colons
  ip = ip.scan(/(\h{4})/).join(':')
  IPAddr.new(ip).to_s
end
read_flags_from_proc() click to toggle source
# File lib/facter/util/linux/if_inet6.rb, line 37
def read_flags_from_proc
  flags = init_flags
  Facter::Util::FileHelper.safe_read('/proc/net/if_inet6', nil).each_line do |line|
    iface = line.split
    next unless iface.size == 6

    ip = parse_ip(iface[0])
    flags[iface[5]][ip] = parse_ifa_flags(iface[4])
  end
  flags
end