Skip to content
Snippets Groups Projects
Commit f35aab8e authored by Michael Miller's avatar Michael Miller Committed by Romain Tartière
Browse files

Implement #link_local? methods

parent 591ad0d5
No related branches found
No related tags found
No related merge requests found
......@@ -648,6 +648,20 @@ module IPAddress;
[self.class.new("127.0.0.0/8")].any? {|i| i.include? self}
end
#
# Checks if an IPv4 address objects belongs
# to a link-local network RFC3927
#
# Example:
#
# ip = IPAddress "169.254.0.1"
# ip.link_local?
# #=> true
#
def link_local?
[self.class.new("169.254.0.0/16")].any? {|i| i.include? self}
end
#
# Returns the IP address in in-addr.arpa format
# for DNS lookups
......
......@@ -422,6 +422,20 @@ module IPAddress;
@prefix == 128 and @compressed == "::1"
end
#
# Checks if an IPv4 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
#
# Returns true if the address is a mapped address
#
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment