Method: FFI::Packets::Util.ipv4_ltoa

Defined in:
lib/ffi/packets/util.rb

.ipv4_ltoa(int) ⇒ Object

takes a 32-bit number and returns it as an IPv4 address string.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ffi/packets/util.rb', line 20

def Util.ipv4_ltoa(int)
  unless(int.is_a? Numeric and int <= 0xffffffff)
    raise(::ArgumentError, "not a long integer: #{int.inspect}")
  end
  ret = []
  4.times do 
    ret.unshift(int & 0xff)
    int >>= 8
  end
  ret.join('.')
end