Comments (3)
At first sight, it looks like you found a bug. Thanks for reporting it, I'll investigate this case further.
from ipnetwork.
This done in the TryGuessCidr(string ip, out byte cidr)
method, which attempts to find classful netmasks for IPv4 addresses. But since IPv6 was never classful this makes no sense for it. So someone seem to have picked /64 as the default CIDR for IPv6.
The exact line is here: System.Net.IPNetwork/IPNetwork.cs#L1778.
I see no reference to there being a default CIDR for IPv6, but /64 seem to be mentioned a lot in documention and preferred by most. So this does make sense as a default CIDR.
I think the real issue here is that most network engineers would assume that an IP address with no network mask or CIDR is always a single IP address and not an IP network, so therefore defaulting to /32 for IPv4 and /128 for IPv6 makes more sense.
The code in the opening post should have been written as:
IPNetwork rangeToCheck = IPNetwork.Parse("2001:db8:abcd:0012:0000:0000:0000:0000/112");
IPAddress ipToCheck = IPAddress.Parse("2001:db8:abcd:0012:0000:0000:0000:0001");
rangeToCheck.Contains(ipToCheck); // returns true
As shown in Example 2 (IPv6) of the ReadMe.
from ipnetwork.
This seem like a default behaviour in standard tools.
Have a look at af_inet6.c for IPV6.
static void
in6_postproc(int s, const struct afswtch *afp)
{
if (explicit_prefix == 0) {
/* Aggregatable address architecture defines all prefixes
are 64. So, it is convenient to set prefixlen to 64 if
it is not specified. */
setifprefixlen("64", 0, s, afp);
/* in6_getprefix("64", MASK) if MASK is available here... */
}
}
from ipnetwork.
Related Issues (20)
- [ULA] Does it support generating a random unique local IPv6 address? HOT 3
- Equality behaviour HOT 4
- Definition whether remote IPv6-address is in the same network
- The type 'BigInteger' is defined in an assembly that is not referenced HOT 1
- PR #214 breaks backward compatibility HOT 3
- Performance considerations HOT 1
- CidrGuess considerations
- Change log HOT 5
- IPNetwork.Parse(string, ParseOptions) HOT 1
- Misleading release history among 'Releases' and NuGet HOT 3
- TryParse of a CIDR string with a trailing space and subsequent characters and `sanitanize: false` returns true HOT 2
- Please delete.
- Could not load file or assembly HOT 3
- [.NET 8.0] Conflict HOT 7
- Support for SymmetricDifference HOT 2
- Assembly should be marked CLSCompliant HOT 1
- RobiniaDocs API Explorer HOT 1
- IPNetwork.TryParse throws an exception when provided with "*" HOT 3
- Assembly should not use BCL namespaces HOT 3
- Large to very small CIDR taking up too much memory HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipnetwork.