Class: Fluent::TextParser::NetflowParser::IP6Addr

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

Instance Method Summary collapse

Instance Method Details

#getObject



274
275
276
277
278
# File 'lib/fluent/plugin/parser_netflow.rb', line 274

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

#set(val) ⇒ Object



266
267
268
269
270
271
272
# File 'lib/fluent/plugin/parser_netflow.rb', line 266

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