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



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

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

#set(val) ⇒ Object



257
258
259
260
261
262
263
# File 'lib/fluent/plugin/parser_netflow.rb', line 257

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