@@ -532,6 +532,31 @@ impl Ipv4Addr {
532
532
!self . is_broadcast ( ) && !self . is_documentation ( ) && !self . is_unspecified ( )
533
533
}
534
534
535
+ /// Returns [`true`] if this address part of the `198.18.0.0/15` range, which is reserved for
536
+ /// network devices benchmarking. This range is defined in [IETF RFC 2544] as `192.18.0.0`
537
+ /// through `198.19.255.255` but [errata 423] corrects it to `198.18.0.0/15`.
538
+ ///
539
+ /// [IETF RFC 1112]: https://tools.ietf.org/html/rfc1112
540
+ /// [errate 423]: https://www.rfc-editor.org/errata/eid423
541
+ /// [`true`]: ../../std/primitive.bool.html
542
+ ///
543
+ /// # Examples
544
+ ///
545
+ /// ```
546
+ /// #![feature(ip)]
547
+ /// use std::net::Ipv4Addr;
548
+ ///
549
+ /// fn main() {
550
+ /// assert_eq!(Ipv4Addr::new(198, 17, 255, 255).is_benchmarking(), false);
551
+ /// assert_eq!(Ipv4Addr::new(198, 18, 0, 0).is_benchmarking(), true);
552
+ /// assert_eq!(Ipv4Addr::new(198, 19, 255, 255).is_benchmarking(), true);
553
+ /// assert_eq!(Ipv4Addr::new(198, 20, 0, 0).is_benchmarking(), false);
554
+ /// }
555
+ /// ```
556
+ pub fn is_benchmarking ( & self ) -> bool {
557
+ self . octets ( ) [ 0 ] == 198 && ( self . octets ( ) [ 1 ] & 0xfe ) == 18
558
+ }
559
+
535
560
/// Returns [`true`] if this address is reserved by IANA for future use. [IETF RFC 1112]
536
561
/// defines the block of reserved addresses as `240.0.0.0/4`. This range normally includes the
537
562
/// broadcast address `255.255.255.255`, but this implementation explicitely excludes it, since
0 commit comments