Class: Fluent::Plugin::NetflowParser::IP6Addr

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/fluent/plugin/netflow_records.rb

Instance Method Summary collapse

Instance Method Details

#getObject



35
36
37
38
39
# File 'lib/fluent/plugin/netflow_records.rb', line 35

def get
  IPAddr.new_ntoh((0..7).map { |i|
      (self.storage >> (112 - 16 * i)) & 0xffff
    }.pack('n8')).to_s
end

#set(val) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/fluent/plugin/netflow_records.rb', line 27

def set(val)
  ip = IPAddr.new(val)
  if ! ip.ipv6?
    raise ArgumentError, "invalid IPv6 address `#{val}'"
  end
  self.storage = ip.to_i
end