summaryrefslogtreecommitdiff
path: root/lib/ipaddress/ipv6.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ipaddress/ipv6.rb')
-rw-r--r--lib/ipaddress/ipv6.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/ipaddress/ipv6.rb b/lib/ipaddress/ipv6.rb
index 3e506ac..adc6243 100644
--- a/lib/ipaddress/ipv6.rb
+++ b/lib/ipaddress/ipv6.rb
@@ -423,6 +423,34 @@ module IPAddress;
@prefix == 128 and @compressed == "::1"
end
+ #
+ # Checks if an IPv6 address objects belongs
+ # to a link-local network RFC4291
+ #
+ # Example:
+ #
+ # ip = IPAddress "fe80::1"
+ # ip.link_local?
+ # #=> true
+ #
+ def link_local?
+ [self.class.new("fe80::/64")].any? {|i| i.include? self}
+ end
+
+ #
+ # Checks if an IPv6 address objects belongs
+ # to a unique-local network RFC4193
+ #
+ # Example:
+ #
+ # ip = IPAddress "fc00::1"
+ # ip.unique_local?
+ # #=> true
+ #
+ def unique_local?
+ [self.class.new("fc00::/7")].any? {|i| i.include? self}
+ end
+
#
# Returns true if the address is a mapped address
#