Module: RubySL::Socket::IPv6
- Defined in:
- lib/rubysl/socket/ipv6.rb
Constant Summary collapse
- LOOPBACK =
The IPv6 loopback address as produced by inet_pton(INET6, “::1”)
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
- UNSPECIFIED =
The bytes used for an unspecified IPv6 address.
[0] * 16
- COMPAT_PREFIX =
The first 10 bytes of an IPv4 compatible IPv6 address.
[0] * 10
Class Method Summary collapse
Class Method Details
.ipv4_compatible?(bytes) ⇒ Boolean
27 28 29 30 31 32 33 34 35 |
# File 'lib/rubysl/socket/ipv6.rb', line 27 def self.ipv4_compatible?(bytes) prefix = bytes.first(10) follow = bytes[10..11] prefix == COMPAT_PREFIX && follow[0] == 0 && follow[1] == 0 && (bytes[-4] > 0 || bytes[-3] > 0 || bytes[-2] > 0) end |
.ipv4_embedded?(bytes) ⇒ Boolean
13 14 15 |
# File 'lib/rubysl/socket/ipv6.rb', line 13 def self.(bytes) ipv4_mapped?(bytes) || ipv4_compatible?(bytes) end |
.ipv4_mapped?(bytes) ⇒ Boolean
17 18 19 20 21 22 23 24 25 |
# File 'lib/rubysl/socket/ipv6.rb', line 17 def self.ipv4_mapped?(bytes) prefix = bytes.first(10) follow = bytes[10..11] prefix == COMPAT_PREFIX && follow[0] == 255 && follow[1] == 255 && (bytes[-4] > 0 || bytes[-3] > 0 || bytes[-2] > 0) end |