Skip to content

Commit a26237e

Browse files
committed
Remove Ipv4Addr::is_ietf_protocol_assignment
1 parent d192c80 commit a26237e

File tree

2 files changed

+6
-51
lines changed

2 files changed

+6
-51
lines changed

library/std/src/net/ip.rs

+3-37
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,7 @@ impl Ipv4Addr {
486486
/// - addresses used for documentation (see [`Ipv4Addr::is_documentation()`])
487487
/// - the unspecified address (see [`Ipv4Addr::is_unspecified()`]), and the whole
488488
/// `0.0.0.0/8` block
489-
/// - addresses reserved for future protocols (see
490-
/// [`Ipv4Addr::is_ietf_protocol_assignment()`], except
489+
/// - addresses reserved for future protocols, except
491490
/// `192.0.0.9/32` and `192.0.0.10/32` which are globally routable
492491
/// - addresses reserved for future use (see [`Ipv4Addr::is_reserved()`]
493492
/// - addresses reserved for networking devices benchmarking (see
@@ -560,7 +559,8 @@ impl Ipv4Addr {
560559
&& !self.is_broadcast()
561560
&& !self.is_documentation()
562561
&& !self.is_shared()
563-
&& !self.is_ietf_protocol_assignment()
562+
// addresses reserved for future protocols (`192.0.0.0/24`)
563+
&& !(self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0)
564564
&& !self.is_reserved()
565565
&& !self.is_benchmarking()
566566
// Make sure the address is not in 0.0.0.0/8
@@ -589,40 +589,6 @@ impl Ipv4Addr {
589589
self.octets()[0] == 100 && (self.octets()[1] & 0b1100_0000 == 0b0100_0000)
590590
}
591591

592-
/// Returns [`true`] if this address is part of `192.0.0.0/24`, which is reserved to
593-
/// IANA for IETF protocol assignments, as documented in [IETF RFC 6890].
594-
///
595-
/// Note that parts of this block are in use:
596-
///
597-
/// - `192.0.0.8/32` is the "IPv4 dummy address" (see [IETF RFC 7600])
598-
/// - `192.0.0.9/32` is the "Port Control Protocol Anycast" (see [IETF RFC 7723])
599-
/// - `192.0.0.10/32` is used for NAT traversal (see [IETF RFC 8155])
600-
///
601-
/// [IETF RFC 6890]: https://tools.ietf.org/html/rfc6890
602-
/// [IETF RFC 7600]: https://tools.ietf.org/html/rfc7600
603-
/// [IETF RFC 7723]: https://tools.ietf.org/html/rfc7723
604-
/// [IETF RFC 8155]: https://tools.ietf.org/html/rfc8155
605-
///
606-
/// # Examples
607-
///
608-
/// ```
609-
/// #![feature(ip)]
610-
/// use std::net::Ipv4Addr;
611-
///
612-
/// assert_eq!(Ipv4Addr::new(192, 0, 0, 0).is_ietf_protocol_assignment(), true);
613-
/// assert_eq!(Ipv4Addr::new(192, 0, 0, 8).is_ietf_protocol_assignment(), true);
614-
/// assert_eq!(Ipv4Addr::new(192, 0, 0, 9).is_ietf_protocol_assignment(), true);
615-
/// assert_eq!(Ipv4Addr::new(192, 0, 0, 255).is_ietf_protocol_assignment(), true);
616-
/// assert_eq!(Ipv4Addr::new(192, 0, 1, 0).is_ietf_protocol_assignment(), false);
617-
/// assert_eq!(Ipv4Addr::new(191, 255, 255, 255).is_ietf_protocol_assignment(), false);
618-
/// ```
619-
#[rustc_const_unstable(feature = "const_ipv4", issue = "76205")]
620-
#[unstable(feature = "ip", issue = "27709")]
621-
#[inline]
622-
pub const fn is_ietf_protocol_assignment(&self) -> bool {
623-
self.octets()[0] == 192 && self.octets()[1] == 0 && self.octets()[2] == 0
624-
}
625-
626592
/// Returns [`true`] if this address part of the `198.18.0.0/15` range, which is reserved for
627593
/// network devices benchmarking. This range is defined in [IETF RFC 2544] as `192.18.0.0`
628594
/// through `198.19.255.255` but [errata 423] corrects it to `198.18.0.0/15`.

library/std/src/net/ip/tests.rs

+3-14
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ fn ipv4_properties() {
339339
let broadcast: u16 = 1 << 6;
340340
let documentation: u16 = 1 << 7;
341341
let benchmarking: u16 = 1 << 8;
342-
let ietf_protocol_assignment: u16 = 1 << 9;
343342
let reserved: u16 = 1 << 10;
344343
let shared: u16 = 1 << 11;
345344

@@ -397,12 +396,6 @@ fn ipv4_properties() {
397396
assert!(!ip!($s).is_benchmarking());
398397
}
399398

400-
if ($mask & ietf_protocol_assignment) == ietf_protocol_assignment {
401-
assert!(ip!($s).is_ietf_protocol_assignment());
402-
} else {
403-
assert!(!ip!($s).is_ietf_protocol_assignment());
404-
}
405-
406399
if ($mask & reserved) == reserved {
407400
assert!(ip!($s).is_reserved());
408401
} else {
@@ -426,7 +419,6 @@ fn ipv4_properties() {
426419
let broadcast: u16 = 1 << 6;
427420
let documentation: u16 = 1 << 7;
428421
let benchmarking: u16 = 1 << 8;
429-
let ietf_protocol_assignment: u16 = 1 << 9;
430422
let reserved: u16 = 1 << 10;
431423
let shared: u16 = 1 << 11;
432424

@@ -449,9 +441,9 @@ fn ipv4_properties() {
449441
check!("198.18.0.0", benchmarking);
450442
check!("198.18.54.2", benchmarking);
451443
check!("198.19.255.255", benchmarking);
452-
check!("192.0.0.0", ietf_protocol_assignment);
453-
check!("192.0.0.255", ietf_protocol_assignment);
454-
check!("192.0.0.100", ietf_protocol_assignment);
444+
check!("192.0.0.0");
445+
check!("192.0.0.255");
446+
check!("192.0.0.100");
455447
check!("240.0.0.0", reserved);
456448
check!("251.54.1.76", reserved);
457449
check!("254.255.255.255", reserved);
@@ -823,9 +815,6 @@ fn ipv4_const() {
823815
const IS_SHARED: bool = IP_ADDRESS.is_shared();
824816
assert!(!IS_SHARED);
825817

826-
const IS_IETF_PROTOCOL_ASSIGNMENT: bool = IP_ADDRESS.is_ietf_protocol_assignment();
827-
assert!(!IS_IETF_PROTOCOL_ASSIGNMENT);
828-
829818
const IS_BENCHMARKING: bool = IP_ADDRESS.is_benchmarking();
830819
assert!(!IS_BENCHMARKING);
831820

0 commit comments

Comments
 (0)