janvanbesien / java-ipv6

Java library to represent IPv6 addresses, networks, and related concepts
Apache License 2.0
85 stars 33 forks source link

IPv6Network does not except default route ::/0 #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. IPv6Network.fromString("::/0");

What is the expected output? What do you see instead?

java.lang.IllegalArgumentException: prefix length should be in interval ]0, 128]
    at com.googlecode.ipv6.IPv6NetworkMask.<init>(IPv6NetworkMask.java:26)
    at com.googlecode.ipv6.IPv6Network.fromString(IPv6Network.java:72)

What version of the product are you using? On what operating system?

0.8

Please provide any additional information below.

The following should also be valid

0000:0000:0000:0000:0000:0000:0000:0000/0

0000::0000/0

0:0:0:0:0:0:0:0/0

0::0/0

I need to verify if an IPv6 Address is contained in the Network - in the above 
case - any IPv6 address should return true for 
network.contains(IPv6Address.fromString(-any-host-));

Original issue reported on code.google.com by harakiri...@yahoo.com on 1 Feb 2013 at 11:26

GoogleCodeExporter commented 9 years ago
I understand, but does it really make sense to accept /0 as a valid prefix 
length? As you say, any address will be contained in this network... so I don't 
immediately see the use case.

I'll have a look to see if there are reasons why I excluded /0 in the first 
place.

Original comment by janvanbesien@gmail.com on 1 Feb 2013 at 11:43

GoogleCodeExporter commented 9 years ago
I didn't see any additional problems, so I added support for /0 prefix length 
in trunk. I didn't make a new release yet. Are you in a position to try out the 
fix by building a new binary yourself? I'll see to creating a release beginning 
next week.

Original comment by janvanbesien@gmail.com on 1 Feb 2013 at 12:47

GoogleCodeExporter commented 9 years ago
Thanks for your fix - i will try it out next week, cant do it earlier sorry.

The reason for /0 is basically - im using it for verifying some firewall rules 
and need to verify if a specific IP address is within a network - its a list of 
networks so it could be that it contains the default one too.

Original comment by harakiri...@yahoo.com on 2 Feb 2013 at 10:44

GoogleCodeExporter commented 9 years ago
I tested it, and it works fine for my testcases.

Thanks

Original comment by harakiri...@yahoo.com on 4 Feb 2013 at 10:40

GoogleCodeExporter commented 9 years ago
released 0.9. Should be in maven central repository later today.

Original comment by janvanbesien@gmail.com on 5 Feb 2013 at 9:30