|
WSF
|
#include <WsfCommAddress.hpp>
Inherits UtScriptAccessible.
Public Member Functions | |
| Address ()=default | |
| Address (const std::string &aAddress, size_t aSubnetMaskBitLength=IPv4::cDEFAULT_CIDR) | |
| Address (size_t aSubnetMaskBitLength) | |
| virtual | ~Address ()=default |
| const char * | GetScriptClassName () const override |
| void | SetAddress (const std::string &aAddress, size_t aSubnetBitLength=IPv4::cDEFAULT_CIDR) |
Static Public Member Functions | |
| static Address | ProcessInput (UtInput &aInput) |
| static Address | ProcessInput (std::string aInput) |
| static bool | IsValidAddress (const std::string &aPossibleAddress) |
| static size_t | GetCIDR_ValueFromString (std::string &aPossibleAddress) |
Address++ and ++Address Overloads | |
Increments the address by one. Useful when assigning new addresses, in that the highest existing address in a subnet can be copied and then simply incremented to provide a new address.
| |
| Address & | operator++ () |
| Address | operator++ (int) |
| template<typename T> | |
| void | Serialize (T &aBuff) |
| For XIO usage. | |
| std::string | GetGenerationToken () const |
| std::string | GetBroadcastAddress () const |
| Returns the broadcast address of this address. | |
| static size_t | GetStringValue (const std::string &aString) |
| static bool | CheckInAddressRange (const Address &aNetworkAddress, const Address &aCheckAddress) |
| WSF_EXPORT std::ostream & | operator<< (std::ostream &aOut, const Address &aAddress) |
GenerateAddress Method | |
This method populates the address object with an IP address generated from a provided string token. This token can be any string, of which a procedurally generated IP address will be generated that will consistently provide the same address given a particular string. Useful for assigning initial address values, especially for named networks when no address is provided. | |
| void | GenerateAddress (const std::string &aGenerationToken, size_t aSubnetBitLength=IPv4::cDEFAULT_CIDR) |
| const std::string & | GetAddress () const |
| size_t | GetSubnetMaskBitLength () const |
| const std::string & | GetRoutingPrefix () const |
| const std::string & | GetSubnet () const |
| size_t | GetNumHostAddresses () const |
| bool | IsNull () const |
| size_t | GetBinaryInteger () const |
| bool | operator== (const Address &aRhs) const |
| bool | operator!= (const Address &aRhs) const |
| bool | operator< (const Address &aRhs) const |
WsfCommAddress represents a typical IP address, for usage within the context of addressing within the Comm domain. Even though some networks are not formal Internet Protocol networks and would not be subject to this standard of addressing, this method is a standard that provides Comm with a internally consistent means of handling addressing of all comm-capable objects within AFSIM. The addressing here is consistent with the CIDR variable subnet bit masking instead of the deprecated class A,B, and C domain usages. Note that this class now differs from the original instantiation in that platforms are not directly associated with an address within the scope of this class.
|
default |
| wsf::comm::Address::Address | ( | const std::string & | aAddress, |
| size_t | aSubnetMaskBitLength = IPv4::cDEFAULT_CIDR ) |
|
explicit |
Note: This constructor supplies an uninitialized address, but with a specified bit mask length. This allows the conveyance of a required bit length mask for an address that is to be generated at a time beyond construction, typically using GenerateAddress().
|
virtualdefault |
|
static |
A static method for checking whether or not a provided address falls within the range of addresses of a network address using CIDR notation. Be mindful of the order of addresses provided, as the CIDR value of the network address and its subnet mask is used without checking for consistency with the comparing address.
| void wsf::comm::Address::GenerateAddress | ( | const std::string & | aGenerationToken, |
| size_t | aSubnetBitLength = IPv4::cDEFAULT_CIDR ) |
Generate an integer value for the token string.
We always add the above integer value to the integer representation of the existing address. Typically, this will be 0.0.0.0 for previously unused address objects, but this call may have been made previously and resulted in an unsuitable address (due to a collision with an existing address, or range limitations of usage). Thus, we have a predictable and reproducible way of getting new addresses given the same token and subsequent calls to this method, yet get different results from each iteration of the call.
Convert the integer value into an IPV4 format address.
|
inline |
|
inline |
| std::string wsf::comm::Address::GetBroadcastAddress | ( | ) | const |
Returns the broadcast address of this address.
|
static |
Given a possible address string, find the CIDR notation value and return it.
|
inline |
If the address was generated using a user supplied string token, then that value is saved within the address for later retrieval, as the user may identify an address based on this value.
| size_t wsf::comm::Address::GetNumHostAddresses | ( | ) | const |
Note: Typically, we would subtract two available hosts from an IPV4 host range, as the highest and lowest available host addresses are used for broadcasting. We don't make the distinction in this implementation. Therefore, if checking with external references, this value is likely two hosts higher.
|
inline |
|
override |
|
static |
A static method that provides an unsigned integer value from a string. Uses the same value assignment methodology as UtDictionary, and produces a consistent and repeatable value given a specific string.
|
inline |
|
inline |
|
inline |
|
static |
Allows the checking of a string to determine if it is a valid IPV4 format address.
| bool wsf::comm::Address::operator!= | ( | const Address & | aRhs | ) | const |
| Address & wsf::comm::Address::operator++ | ( | ) |
Increment the lowest order byte, carrying the value if we are at the max value for this byte (255).
Reset the other member variables to account for the address change.
| Address wsf::comm::Address::operator++ | ( | int | ) |
| bool wsf::comm::Address::operator< | ( | const Address & | aRhs | ) | const |
Iterate from most significant to least significant bytes. Values may be equal for some higher order bytes, but we're guaranteed to differ somewhere due to the previous equivalence check.
We should never reach this point.
| bool wsf::comm::Address::operator== | ( | const Address & | aRhs | ) | const |
|
static |
Same as the ProcessInput command, expect acts on the raw string input already retrieved from a source such as a input stream.
|
static |
Allows parsing of addresses from the input stream using a defined standard.
|
inline |
For XIO usage.
| void wsf::comm::Address::SetAddress | ( | const std::string & | aAddress, |
| size_t | aSubnetBitLength = IPv4::cDEFAULT_CIDR ) |
Ensure the bit mask length is valid
Parse out the strings associated with each subfield in the address e.g. 123.2.1.33 -> 123, 2, 1, 33
Convert each field value to a integer representing the binary value for each field
Store each field as a byte representation
Store the integer value of the address for possible later comparisons
Get the CIDR mask
Get the vector of integer values for the routing/network address
Get the vector of integer value of the subnet mask
Translate the subnet into an integer value for easy comparisons between addresses
Convert the two values above to strings with delimiters, and save them.
|
friend |