summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Ceresa <ceresa@gmail.com>2014-10-06 11:02:20 +0200
committerMarco Ceresa <ceresa@gmail.com>2014-10-06 11:02:20 +0200
commit27a4d39661507bd068f50cc9cb3f652772ff56a3 (patch)
treea5da5300af5d183fea13d557530338e68126f352
parentdae93ad0e4fb9a5d547a15dae0c3f2417078c845 (diff)
parent759ab15213b99c0955bfe264ad0f2729b2bd4886 (diff)
downloadipaddress-27a4d39661507bd068f50cc9cb3f652772ff56a3.tar.gz
Merge pull request #16 from schmurfy/master
bugfix: do not consider /32 addresses as network adresses Thanks Julien Ammous!
-rw-r--r--lib/ipaddress/ipv4.rb2
-rw-r--r--test/ipaddress/ipv4_test.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/ipaddress/ipv4.rb b/lib/ipaddress/ipv4.rb
index a798a24..716d4d9 100644
--- a/lib/ipaddress/ipv4.rb
+++ b/lib/ipaddress/ipv4.rb
@@ -311,7 +311,7 @@ module IPAddress;
# #=> true
#
def network?
- @u32 | @prefix.to_u32 == @prefix.to_u32
+ (@prefix < 32) && (@u32 | @prefix.to_u32 == @prefix.to_u32)
end
#
diff --git a/test/ipaddress/ipv4_test.rb b/test/ipaddress/ipv4_test.rb
index f144634..5177c75 100644
--- a/test/ipaddress/ipv4_test.rb
+++ b/test/ipaddress/ipv4_test.rb
@@ -148,6 +148,11 @@ class IPv4Test < Test::Unit::TestCase
assert_equal true, @network.network?
assert_equal false, @ip.network?
end
+
+ def test_one_address_network
+ network = @klass.new("172.16.10.1/32")
+ assert_equal false, network.network?
+ end
def test_method_broadcast
@broadcast.each do |addr,bcast|