SatCat5
satcat5::ip::Mask Struct Reference

Detailed Description

IPv4 subnet masks share functionality with a basic address, but are constructed differently to match common conventions.

Definition at line 66 of file ip_core.h.

#include <ip_core.h>

Inheritance diagram for satcat5::ip::Mask:
[legend]
Collaboration diagram for satcat5::ip::Mask:
[legend]

Public Member Functions

constexpr Mask ()
 Constructor for the wildcard mask (match all addresses).
 
constexpr Mask (unsigned npre)
 Constructor for the a CIDR prefix (e.g., /24).
 
constexpr Mask (u8 a, u8 b, u8 c, u8 d)
 Constructor in subnet-mask form (a.b.c.d).
 
constexpr Mask (const satcat5::ip::Addr &addr)
 Copy-constructor.
 
Maskoperator= (const Mask &t)=default
 
unsigned prefix () const
 Convert this subnet-mask to a CIDR prefix length. More...
 
void log_to (satcat5::log::LogBuffer &wr) const
 Format this IP address in standard form, e.g., "192.168.1.2".
 
bool is_broadcast () const
 Limited broadcast (255.255.255.255)
 
bool is_multicast () const
 IP multicast (224.*.*.*)
 
bool is_reserved () const
 Reserved blocks (0.*.*.* or 127.*.*.*)
 
bool is_unicast () const
 Any normal single-destination address.
 
bool is_valid () const
 Any nonzero address.
 
constexpr bool operator== (const satcat5::ip::Addr &other) const
 Commonly used operators.
 
constexpr bool operator!= (const satcat5::ip::Addr &other) const
 Commonly used operators.
 
void write_to (satcat5::io::Writeable *wr) const
 Commonly used operators.
 
bool read_from (satcat5::io::Readable *rd)
 Commonly used operators.
 
constexpr satcat5::ip::Addr operator+ (unsigned offset) const
 Commonly used operators.
 

Public Attributes

u32 value
 Raw access to the underlying representation.
 

Member Function Documentation

◆ prefix()

unsigned satcat5::ip::Mask::prefix ( ) const

Convert this subnet-mask to a CIDR prefix length.

(Undefined if this mask is not a valid CIDR subnet.)

Definition at line 67 of file ip_core.cc.


The documentation for this struct was generated from the following files: