iprfc/
rfc5735.rs

1use core::net::Ipv4Addr;
2
3use ipnet::{IpNet, Ipv4Net};
4
5use super::RFC;
6
7const IPV4_1: Ipv4Net = Ipv4Net::new_assert(Ipv4Addr::new(192, 0, 2, 0), 24);
8const IPV4_2: Ipv4Net = Ipv4Net::new_assert(Ipv4Addr::new(198, 51, 100, 0), 24);
9const IPV4_3: Ipv4Net = Ipv4Net::new_assert(Ipv4Addr::new(203, 0, 113, 0), 24);
10const IPV4_4: Ipv4Net = Ipv4Net::new_assert(Ipv4Addr::new(198, 18, 0, 0), 15);
11
12/// [RFC 5735] Special Use IPv4 Addresses
13///
14/// **Addresses:**
15/// - **IPv4:**
16///   1. `192.0.2.0/24`: TEST-NET-1
17///   2. `198.51.100.0/24`: TEST-NET-2
18///   3. `203.0.113.0/24`: TEST-NET-3
19///   4. `198.18.0.0/15`: Benchmarks
20///
21/// [RFC 5735]: https://datatracker.ietf.org/doc/rfc5735/
22pub const RFC5735: RFC = RFC {
23  id: 5735,
24  ip_nets: &[IpNet::V4(IPV4_1), IpNet::V4(IPV4_2), IpNet::V4(IPV4_3), IpNet::V4(IPV4_4)],
25  ipv4_nets: &[IPV4_1, IPV4_2, IPV4_3, IPV4_4],
26  ipv6_nets: &[],
27};
28
29#[test]
30fn t() {
31  for (idx, s) in ["192.0.2.0/24", "198.51.100.0/24", "203.0.113.0/24", "198.18.0.0/15"]
32    .iter()
33    .enumerate()
34  {
35    let addr: Ipv4Net = s.parse().unwrap();
36    assert_eq!(RFC5735.ipv4_nets[idx], addr);
37  }
38}