|
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 |
References wsf::comm::IPv4::cDEFAULT_CIDR.
Referenced by CheckInAddressRange(), GetCIDR_ValueFromString(), GetScriptClassName(), IsValidAddress(), operator!=(), operator++(), operator++(), operator<(), operator<<, operator==(), ProcessInput(), and ProcessInput().
| wsf::comm::Address::Address | ( | const std::string & | aAddress, |
| size_t | aSubnetMaskBitLength = IPv4::cDEFAULT_CIDR ) |
References SetAddress().
|
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.
References Address().
Referenced by wsf::comm::NetworkManager::GetManagingNetworkAddress(), wsf::comm::ReservedAddressingImplementation::IsReserved(), wsf::comm::ProtocolIGMP::NetworkReceive(), wsf::comm::ProtocolIGMP::NetworkSend(), wsf::comm::ProtocolIGMP::PhysicalReceive(), wsf::comm::router::ProtocolMulticast::Receive(), wsf::comm::router::ProtocolMulticast::Send(), and UT_DEFINE_SCRIPT_METHOD().
| 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.
References wsf::comm::IPv4::cNUM_FIELDS, and GetStringValue().
Referenced by wsf::comm::NetworkManager::AddComm(), wsf::comm::NetworkManager::AddNetwork(), and GetScriptClassName().
|
inline |
Referenced by wsf::comm::NetworkManager::AddNetwork(), WsfXIO_AutoDisMapping::ForwardMessage(), wsf::comm::NetworkManager::GetAddressesInNetwork(), WsfTaskManager::GetMessageSender(), wsf::comm::router::ProtocolOSPF::InitializeLinkState(), wsf::comm::NetworkManager::InitializeUserLinks(), wsf::comm::ProtocolIGMP::JoinGroup(), wsf::comm::ProtocolIGMP::LeaveGroup(), std::hash< wsf::comm::Address >::operator()(), wsf::comm::router::ProtocolOSPF::PlatformInitialized(), WsfUplinkProcessor::ProcessMessage(), wsf::comm::NetworkManager::RemoveComm(), wsf::comm::router::ProtocolOSPF::RouteToBackbone(), wsf::comm::router::ProtocolOSPF::Routing(), wsf::comm::router::rip::RIPv2::Routing(), WsfRIPRJob::SendMessageBidJob(), WsfRIPRProcessor::SendMessageJobAward(), WsfRIPRJob::SendMessageSetProgress(), WsfRIPRJob::SendMessageUnbidJob(), wsf::comm::router::ProtocolOSPF::Setup(), WsfScriptCommAddressClass::ToString(), wsf::comm::medium::Guided::TransmitMessage(), wsf::comm::medium::Unguided::TransmitMessage(), wsf::comm::router::rip::RIPv2::TurnOn(), UT_DEFINE_SCRIPT_METHOD(), UT_DEFINE_SCRIPT_METHOD(), and wsf::comm::UT_DEFINE_SCRIPT_METHOD().
|
inline |
| std::string wsf::comm::Address::GetBroadcastAddress | ( | ) | const |
Returns the broadcast address of this address.
References wsf::comm::IPv4::cDELIMITER, and wsf::comm::IPv4::cNUM_FIELDS.
Referenced by UT_DEFINE_SCRIPT_METHOD().
|
static |
Given a possible address string, find the CIDR notation value and return it.
References Address(), wsf::comm::IPv4::cBIT_SIZE, wsf::comm::IPv4::cCIDR_DELIMITER, wsf::comm::IPv4::cDEFAULT_CIDR, and IsValidAddress().
Referenced by GetScriptClassName(), and ProcessInput().
|
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.
Referenced by UT_DEFINE_SCRIPT_METHOD().
| 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.
References wsf::comm::IPv4::cBIT_SIZE.
Referenced by UT_DEFINE_SCRIPT_METHOD().
|
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.
Referenced by GenerateAddress(), and std::hash< wsf::comm::Address >::operator()().
|
inline |
Referenced by UT_DEFINE_SCRIPT_METHOD().
|
inline |
Referenced by wsf::comm::NetworkManager::AddComm(), wsf::comm::NetworkManager::AddComm(), wsf::comm::NetworkManager::AddNetwork(), WsfXIO_AutoDisMapping::ForwardMessage(), wsf::comm::ReservedAddressingImplementation::IsReserved(), wsf::comm::ProtocolIGMP::JoinGroup(), wsf::comm::ProtocolIGMP::LeaveGroup(), WsfScriptCommAddressClass::ToString(), and UT_DEFINE_SCRIPT_METHOD().
|
inline |
References wsf::comm::IPv4::cNULL_ADDRESS.
Referenced by wsf::comm::NetworkManager::AddComm(), wsf::comm::NetworkManager::AddMulticastMember(), wsf::comm::router::ProtocolOSPF::DR_GraphAdd(), wsf::comm::NetworkManager::ManageComm(), wsf::comm::ReservedAddressing::QueryAddressByType(), wsf::comm::NetworkManager::RemoveMulticastMember(), wsf::comm::router::ProtocolOSPF::Routing(), UT_DEFINE_SCRIPT_METHOD(), and UT_DEFINE_SCRIPT_METHOD().
|
static |
Allows the checking of a string to determine if it is a valid IPV4 format address.
References Address(), wsf::comm::IPv4::cDELIMITER, and wsf::comm::IPv4::cNUM_FIELDS.
Referenced by GetCIDR_ValueFromString(), GetScriptClassName(), and ProcessInput().
| 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.
References Address(), wsf::comm::IPv4::cMASK_FIELD, and wsf::comm::IPv4::cNUM_FIELDS.
| 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.
References Address().
|
static |
Same as the ProcessInput command, expect acts on the raw string input already retrieved from a source such as a input stream.
References Address(), GetCIDR_ValueFromString(), and IsValidAddress().
|
static |
Allows parsing of addresses from the input stream using a defined standard.
References Address(), and ProcessInput().
Referenced by GetScriptClassName(), wsf::comm::Network::ProcessAddressLinkListInput(), wsf::comm::Network::ProcessAddressListInput(), wsf::comm::NetworkAdHoc::ProcessAddressRate(), ProcessInput(), wsf::comm::Comm::ProcessInput(), wsf::comm::NetworkGeneric::ProcessInput(), wsf::comm::NetworkMesh::ProcessInput(), wsf::comm::NetworkPointToPoint::ProcessInput(), wsf::comm::NetworkRing::ProcessInput(), wsf::comm::NetworkStar::ProcessInput(), wsf::comm::ProtocolIGMP::ProcessInput(), wsf::comm::router::ProtocolOSPF::ProcessInput(), wsf::comm::router::Router::ProcessInput(), and wsf::ExternalLinks::ProcessInput().
|
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.
References wsf::comm::IPv4::cBIT_SIZE, wsf::comm::IPv4::cDELIMITER, wsf::comm::IPv4::cMASK_MAX, and wsf::comm::IPv4::cNUM_FIELDS.
Referenced by Address(), WsfXIO_AutoDisMapping::ForwardMessage(), GetScriptClassName(), UT_DEFINE_SCRIPT_METHOD(), and wsf::comm::UT_DEFINE_SCRIPT_METHOD().
|
friend |
References Address().