42#ifndef _DWMIPPREFIX_HH_
43#define _DWMIPPREFIX_HH_
63 IpPrefix(
const std::string & prefix);
68 const T * Prefix()
const {
return std::get_if<T>(&_prefix); }
70 operator std::string ()
const;
72 bool Set(
const IpAddress & network, uint8_t maskLength);
74 bool Contains(
const IpAddress & addr)
const;
78 bool operator < (
const IpPrefix & prefix)
const;
79 bool operator > (
const IpPrefix & prefix)
const;
80 bool operator == (
const IpPrefix & prefix)
const;
81 bool operator != (
const IpPrefix & prefix)
const;
114 std::istream &
Read(std::istream & is);
119 std::ostream &
Write(std::ostream & os)
const;
148 std::variant<Ipv6Prefix,Ipv4Prefix> _prefix;
150 static constexpr int k_families[2] = { AF_INET6, AF_INET };
Dwm::IpAddress class definition.
Dwm::Ipv4Prefix class definition.
Dwm::Ipv6Prefix class definition.
This class encapsulates an IP address.
Definition DwmIpAddress.hh:61
Encapsulates an IP prefix (v4 or v6).
Definition DwmIpPrefix.hh:57
int BZRead(BZFILE *bzf)
Reads the prefix from a BZFILE pointer.
ssize_t Read(int fd)
Reads the prefix from a file descriptor.
int Write(gzFile gzf) const
Writes the prefix to a gzFile.
int BZWrite(BZFILE *bzf) const
Writes the prefix to a BZFILE pointer.
std::istream & Read(std::istream &is)
Reads the prefix from an istream. Returns the istream.
int Read(gzFile gzf)
Reads the prefix from a gzFile.
std::ostream & Write(std::ostream &os) const
Writes the prefix to an ostream. Returns the ostream.
uint64_t StreamedLength() const
Returns the number of bytes that would be written if the prefix was written to a file descriptor or o...
ssize_t Write(int fd) const
Writes the prefix to a file descriptor.
friend std::ostream & operator<<(std::ostream &os, const IpPrefix &addr)
ostream output operator
size_t Read(FILE *f)
Reads the prefix from a FILE pointer.
size_t Write(FILE *f) const
Writes the prefix to a FILE pointer.
This class encapsulates an IPv4 address.
Definition DwmIpv4Address.hh:63
This class encapsulates an IPv4 address and netmask.
Definition DwmIpv4Prefix.hh:59
This class encapsulates an IPv6 address.
Definition DwmIpv6Address.hh:64
This class encapsulates an IPv6 network prefix.
Definition DwmIpv6Prefix.hh:52