Bitcoin Core  27.99.0
P2P Digital Currency
Public Member Functions | Protected Attributes | Friends | List of all members
CSubNet Class Reference

#include <netaddress.h>

Collaboration diagram for CSubNet:
[legend]

Public Member Functions

 CSubNet ()
 Construct an invalid subnet (empty, Match() always returns false). More...
 
 CSubNet (const CNetAddr &addr, uint8_t mask)
 Construct from a given network start and number of bits (CIDR mask). More...
 
 CSubNet (const CNetAddr &addr, const CNetAddr &mask)
 Construct from a given network start and mask. More...
 
 CSubNet (const CNetAddr &addr)
 Construct a single-host subnet. More...
 
bool Match (const CNetAddr &addr) const
 
std::string ToString () const
 
bool IsValid () const
 

Protected Attributes

CNetAddr network
 Network (base) address. More...
 
uint8_t netmask [16]
 Netmask, in network byte order. More...
 
bool valid
 Is this value valid? (only used to signal parse errors) More...
 

Friends

bool operator== (const CSubNet &a, const CSubNet &b)
 
bool operator!= (const CSubNet &a, const CSubNet &b)
 
bool operator< (const CSubNet &a, const CSubNet &b)
 

Detailed Description

Definition at line 479 of file netaddress.h.

Constructor & Destructor Documentation

◆ CSubNet() [1/4]

CSubNet::CSubNet ( )

Construct an invalid subnet (empty, Match() always returns false).

Definition at line 913 of file netaddress.cpp.

◆ CSubNet() [2/4]

CSubNet::CSubNet ( const CNetAddr addr,
uint8_t  mask 
)

Construct from a given network start and number of bits (CIDR mask).

Parameters
[in]addrNetwork start. Must be IPv4 or IPv6, otherwise an invalid subnet is created.
[in]maskCIDR mask, must be in [0, 32] for IPv4 addresses and in [0, 128] for IPv6 addresses. Otherwise an invalid subnet is created.

Definition at line 919 of file netaddress.cpp.

Here is the call graph for this function:

◆ CSubNet() [3/4]

CSubNet::CSubNet ( const CNetAddr addr,
const CNetAddr mask 
)

Construct from a given network start and mask.

Parameters
[in]addrNetwork start. Must be IPv4 or IPv6, otherwise an invalid subnet is created.
[in]maskNetwork mask, must be of the same type as addr and not contain 0-bits followed by 1-bits. Otherwise an invalid subnet is created.

Definition at line 960 of file netaddress.cpp.

Here is the call graph for this function:

◆ CSubNet() [4/4]

CSubNet::CSubNet ( const CNetAddr addr)
explicit

Construct a single-host subnet.

Parameters
[in]addrThe sole address to be contained in the subnet, can also be non-IPv[46].

Definition at line 991 of file netaddress.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ IsValid()

bool CSubNet::IsValid ( ) const

Definition at line 1079 of file netaddress.cpp.

Here is the caller graph for this function:

◆ Match()

bool CSubNet::Match ( const CNetAddr addr) const
Returns
True if this subnet is valid, the specified address is valid, and the specified address belongs in this subnet.

Definition at line 1018 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ToString()

std::string CSubNet::ToString ( ) const

Definition at line 1046 of file netaddress.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const CSubNet a,
const CSubNet b 
)
friend

Definition at line 525 of file netaddress.h.

◆ operator<

bool operator< ( const CSubNet a,
const CSubNet b 
)
friend

Definition at line 1089 of file netaddress.cpp.

◆ operator==

bool operator== ( const CSubNet a,
const CSubNet b 
)
friend

Definition at line 1084 of file netaddress.cpp.

Member Data Documentation

◆ netmask

uint8_t CSubNet::netmask[16]
protected

Netmask, in network byte order.

Definition at line 485 of file netaddress.h.

◆ network

CNetAddr CSubNet::network
protected

Network (base) address.

Definition at line 483 of file netaddress.h.

◆ valid

bool CSubNet::valid
protected

Is this value valid? (only used to signal parse errors)

Definition at line 487 of file netaddress.h.


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