Class: IP6Addr

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/logstash/codecs/netflow/util.rb

Instance Method Summary collapse

Instance Method Details

#getObject



34
35
36
37
38
# File 'lib/logstash/codecs/netflow/util.rb', line 34

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

#set(val) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/logstash/codecs/netflow/util.rb', line 26

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