Build Status

This module provides types and useful methods for working with IPv4 and IPv6 network addresses, commonly called IP prefixes. The new IpNet, Ipv4Net, and Ipv6Net types build on the existing IpAddr, Ipv4Addr, and Ipv6Addr types already provided in Rust's standard library and align to their design to stay consistent.

The module also provides types for iterating over IP address ranges, and useful traits that extend Ipv4Addr and Ipv6Addr with methods for addition, subtraction, bitwise-and, and bitwise-or operations that are missing in Rust's standard library.

The module only uses stable features so it is guaranteed to compile using the stable toolchain. Tests aim for thorough coverage and can be found in both the test modules and doctests. Please file an [issue on GitHub] if you have any problems, requests, or suggested improvements.

Read the [documentation] for the full details. And find it on [Crates.io].

Examples

Aggregate a list of IP prefixes:

```rust extern crate ipnet; use ipnet::IpNet;

fn main() { let strings = vec![ "10.0.0.0/24", "10.0.1.0/24", "10.0.1.1/24", "10.0.1.2/24", "10.0.2.0/24", "10.1.0.0/24", "10.1.1.0/24", "192.168.0.0/24", "192.168.1.0/24", "192.168.2.0/24", "192.168.3.0/24", "fd00::/32", "fd00:1::/32", ];

let nets: Vec<IpNet> = strings.iter().filter_map(|p| p.parse().ok()).collect();

println!("\nInput IP prefix list:");

for n in &nets {
    println!("{}", n);
}

println!("\nAggregated IP prefixes:");

for n in IpNet::aggregate(&nets) {
    println!("{}", n);
}

} ```

Future

License

Copyright (c) 2017, Juniper Networks, Inc. All rights reserved.

This code is licensed to you under the Apache License, Version 2.0 (the "License"). You may not use this code except in compliance with the License. This code is not an official Juniper product. You can obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0