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 are faster implementations, however they come with the # loss of compressed IPv6 notation. # For benchmarks see spec/codecs/benchmarks/IP6Addr.rb unless self.storage.nil? b = "%032x" % self.storage c = b[0..3] + ":" + b[4..7] + ":" + b[8..11] + ":" + b[12..15] + ":" + b[16..19] + ":" + b[20..23] + ":" + b[24..27] + ":" + b[28..31] IPAddr.new(c).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 |