MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::SubnetMaskV4 Struct Reference

Represents the bitwise mask for a version 4 subnet. More...

#include <ip.hpp>

Public Member Functions

SubnetV4 subnet_ip (const IPv4 &ip)
 Subnets an IP address based on the IP mask.
 

Static Public Member Functions

static SubnetMaskV4 by_id (u8 id)
 Retrieves a subnet mask by id (valid ids is 0-32).
 
static constexpr bool valid_id (u8 id)
 Checks if an id is a valid subnet mask id (0-32)
 

Public Attributes

u32 mask = 0
 
u8 id = 0
 

Detailed Description

Represents the bitwise mask for a version 4 subnet.

Definition at line 129 of file ip.hpp.

Member Function Documentation

◆ by_id()

SubnetMaskV4 mtcore::SubnetMaskV4::by_id ( u8 id)
inlinestatic

Retrieves a subnet mask by id (valid ids is 0-32).

Will abort if id is invalid

Parameters
idID of the subnet mask to get

Definition at line 169 of file ip.hpp.

169 {
170 ensure(valid_id(id));
171 return impl::ip4SubnetMasks[id];
172 }
#define ensure(check,...)
Ensures that a check holds true, aborts the program if not true Will print error if the condition is ...
static constexpr bool valid_id(u8 id)
Checks if an id is a valid subnet mask id (0-32)
Definition ip.hpp:167
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subnet_ip()

SubnetV4 mtcore::SubnetMaskV4::subnet_ip ( const IPv4 & ip)

Subnets an IP address based on the IP mask.

Parameters
ipIP address to mask
Returns
Masked IP address
Here is the caller graph for this function:

◆ valid_id()

bool mtcore::SubnetMaskV4::valid_id ( u8 id)
staticconstexpr

Checks if an id is a valid subnet mask id (0-32)

Parameters
idID value to check

Definition at line 167 of file ip.hpp.

167{ return id < impl::ip4SubnetMasks.size(); }
Here is the caller graph for this function:

Member Data Documentation

◆ id

u8 mtcore::SubnetMaskV4::id = 0

Definition at line 131 of file ip.hpp.

◆ mask

u32 mtcore::SubnetMaskV4::mask = 0

Definition at line 130 of file ip.hpp.


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