Class: IP6Addr
- Inherits:
-
BinData::Primitive
- Object
- BinData::Primitive
- IP6Addr
- Defined in:
- lib/logstash/codecs/netflow/util.rb
Instance Method Summary collapse
Instance Method Details
#get ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/logstash/codecs/netflow/util.rb', line 38 def get # There faster implementations, however they come with the # loss of compressed IPv6 notation. # For benchmarks see spec/codecs/benchmarks/IP6Addr.rb unless self.storage.nil? IPAddr.new_ntoh((0..7).map { |i| (self.storage >> (112 - 16 * i)) & 0xffff }.pack('n8')).to_s end end |
#set(val) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/logstash/codecs/netflow/util.rb', line 28 def set(val) unless val.nil? ip = IPAddr.new(val) if ! ip.ipv6? raise ArgumentError, "invalid IPv6 address `#{val}'" end self.storage = ip.to_i end end |