-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement subtraction between IpNetwork
s
#126
base: master
Are you sure you want to change the base?
Commits on Feb 14, 2020
-
Create
Ipv4NetworkSubSet
helper iteratorThis is a helper type that is created with an initial IPv4 network, represented as a `u32` representation of its IP address and a `u8` with its prefix, and the prefix of a larger IPv4 network which contains the initial IPv4 network. Since one is contained in the other, the IP address shares most bits, so it only needs to keep track of it once. However, proper care must be taken so that the initial network prefix is larger than the larger network prefix. The iterator will produce `Ipv4Network` items representing increasing network ranges that are still inside the larger network but do not include the initial network.
Configuration menu - View commit details
-
Copy full SHA for 47f52e0 - Browse repository at this point
Copy the full SHA 47f52e0View commit details
Commits on Feb 15, 2020
-
Create
Ipv4NetworkSubResult
helper typeThis is also an iterator, and it wraps around the `Ipv4NetworkSubSet` type. However, it also includes entries for when the minuend and the subtrahend don't overlap and for when the subtrahend completly ovelaps the minuend. In the former case, there is no overlap of the networks. Therefore, nothing is subtracted from the original network (the minuend), so the result is just the original network. In the latter case, since the subtrahend completly overlaps the minuend, it is in effect completely removing the original network. Therefore, the result is no networks at all, and the resulting iterator is empty.
Configuration menu - View commit details
-
Copy full SHA for 3bd9cb9 - Browse repository at this point
Copy the full SHA 3bd9cb9View commit details -
The resulting set is returned through a `Ipv4NetworkSubResult` helper iterator.
Configuration menu - View commit details
-
Copy full SHA for bf081f6 - Browse repository at this point
Copy the full SHA bf081f6View commit details -
Implement subtraction of multiple
Ipv4Network
sThis allows one to subtract multiple `Ipv4Network`s from a single `Ipv4Network`. This works by having a subtraction chain, where the original minuend `Ipv4Network` is subtracted by the first `Ipv4Network` subtrahend, and the result is then subtracted by the second `Ipv4Network` subtrahend, and so on. The implementation uses dynamic dispatch because it is impossible to know how many subtrahends there will be. This is a simple initial implementation, and tere might be other solutions, such as creating a custom iterator and looping around all subtrahends to provide the results, but it quickly becomes more complicated. This might be doable as future work. Another possible future work is to remove the dynamic dispatch for known sizes of subtrahend arrays, but this would probably require const generics to be stabilized.
Configuration menu - View commit details
-
Copy full SHA for d98ff92 - Browse repository at this point
Copy the full SHA d98ff92View commit details -
Create
Ipv6NetworkSubSet
helper iteratorThis is the IPv6 equivalent of the `Ipv4NetworkSubSet`. It is a helper type that is created with an initial IPv6 network, represented as a `u128` representation of its IP address and a `u8` with its prefix, and the prefix of a larger IPv6 network which contains the initial IPv6 network. Since one is contained in the other, the IP address shares most bits, so it only needs to keep track of it once. However, proper care must be taken so that the initial network prefix is larger than the larger network prefix. The iterator will produce `Ipv6Network` items representing increasing network ranges that are still inside the larger network but do not include the initial network.
Configuration menu - View commit details
-
Copy full SHA for 9340cc5 - Browse repository at this point
Copy the full SHA 9340cc5View commit details -
Create
Ipv6NetworkSubResult
helper typeThis is the IPv6 equivalent to the `Ipv4NetworkSubResult` type. This is also an iterator, and it wraps around the `Ipv6NetworkSubSet` type. However, it also includes entries for when the minuend and the subtrahend don't overlap and for when the subtrahend completly ovelaps the minuend. In the former case, there is no overlap of the networks. Therefore, nothing is subtracted from the original network (the minuend), so the result is just the original network. In the latter case, since the subtrahend completly overlaps the minuend, it is in effect completely removing the original network. Therefore, the result is no networks at all, and the resulting iterator is empty.
Configuration menu - View commit details
-
Copy full SHA for 3f1955f - Browse repository at this point
Copy the full SHA 3f1955fView commit details -
The resulting set is returned through a `Ipv6NetworkSubResult` helper iterator.
Configuration menu - View commit details
-
Copy full SHA for 01b3bfb - Browse repository at this point
Copy the full SHA 01b3bfbView commit details -
Implement subtraction of multiple
Ipv6Network
sThis allows one to subtract multiple `Ipv6Network`s from a single `Ipv6Network`. This works by having a subtraction chain, where the original minuend `Ipv6Network` is subtracted by the first `Ipv6Network` subtrahend, and the result is then subtracted by the second `Ipv6Network` subtrahend, and so on. The implementation uses dynamic dispatch because it is impossible to know how many subtrahends there will be. This is a simple initial implementation, and tere might be other solutions, such as creating a custom iterator and looping around all subtrahends to provide the results, but it quickly becomes more complicated. This might be doable as future work. Another possible future work is to remove the dynamic dispatch for known sizes of subtrahend arrays, but this would probably require const generics to be stabilized.
Configuration menu - View commit details
-
Copy full SHA for c0e4083 - Browse repository at this point
Copy the full SHA c0e4083View commit details -
Create
IpNetworkSubResult
wrapper typeThis type represents the result of the subtraction of one `IpNetwork` from another. The implementation just wraps the resulting subtraction of the protocol specific (IPv4 or IPv6) subtraction result. Note that this means that it is not currently possible to subtract `IpNetwork`s of different protocols (i.e., either an IPv4 network from an IPv6 network or vice-versa).
Configuration menu - View commit details
-
Copy full SHA for da67e84 - Browse repository at this point
Copy the full SHA da67e84View commit details -
The resulting set is returned through a `IpNetworkSubResult` helper iterator. Note that it is not currently possible to subtract `IpNetwork`s of different protocols (i.e., either an IPv4 network from an IPv6 network or vice-versa).
Configuration menu - View commit details
-
Copy full SHA for 686c060 - Browse repository at this point
Copy the full SHA 686c060View commit details -
Implement subtraction of multiple
IpNetwork
sThis allows one to subtract multiple `IpNetwork`s from a single `IpNetwork`. This works by having a subtraction chain, where the original minuend `IpNetwork` is subtracted by the first `IpNetwork` subtrahend, and the result is then subtracted by the second `IpNetwork` subtrahend, and so on. Since it isn't currently possible to subtract `IpNetworks` of different protocols, all operands must be of the same protocol (either IPv4 or IPv6). Having one operand of a different protocol will cause the code to panic. The implementation uses dynamic dispatch because it is impossible to know how many subtrahends there will be. This is a simple initial implementation, and tere might be other solutions, such as creating a custom iterator and looping around all subtrahends to provide the results, but it quickly becomes more complicated. This might be doable as future work. Another possible future work is to remove the dynamic dispatch for known sizes of subtrahend arrays, but this would probably require const generics to be stabilized.
Configuration menu - View commit details
-
Copy full SHA for 1473c5d - Browse repository at this point
Copy the full SHA 1473c5dView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9031d4d - Browse repository at this point
Copy the full SHA 9031d4dView commit details