41 #ifndef _networkipaddress_cpp
42 #define _networkipaddress_cpp
44 #include "Network/platformincludes.h.cpp"
46 #include "Network/ipaddress.h"
95 memset(&v4Test,0,
sizeof(in_addr));
96 #if defined(MEZZ_WINDOWS)
97 if( InetPton( AF_INET, Address.c_str(), &v4Test ) > 0 ) {
98 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
99 if( inet_pton( AF_INET, Address.c_str(), &v4Test ) > 0 ) {
107 memset(&v6Test,0,
sizeof(in6_addr));
108 #if defined(MEZZ_WINDOWS)
109 if( InetPton( AF_INET6, Address.c_str(), &v6Test ) > 0 ) {
110 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
111 if( inet_pton( AF_INET6, Address.c_str(), &v6Test ) > 0 ) {
124 switch( Address.size() )
134 #if defined(MEZZ_WINDOWS)
135 if( InetNtop( AF_INET, const_cast<Int8*>(&Address[0]), AddStr,
IPv4StringLength ) != NULL ) {
136 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
139 String Ret(AddStr,strlen(AddStr));
145 #if defined(MEZZ_WINDOWS)
146 if( InetNtop( AF_INET6, const_cast<Int8*>(&Address[0]), AddStr,
IPv6StringLength ) != NULL ) {
147 #elif defined(MEZZ_MACOSX) || defined(MEZZ_LINUX)
148 if( inet_ntop( AF_INET6, &Address[0], AddStr,
IPv6StringLength ) != NULL ) {
150 String Ret(AddStr,strlen(AddStr));
257 if( !CurrAttrib.
Empty() )
268 {
return "IPAddress"; }
Attribute AppendAttribute(const Char8 *Name)
Creates an Attribute and puts it at the end of this Nodes attributes.
A light-weight handle for manipulating attributes in DOM tree.
static const UInt16 IPv6BinaryLength
The amount of space needed in a buffer to store the binary representation of an IPv6 address...
static AddressContainer Resolve(const String &Address)
Resolves an IPv4 or IPv6 address as a String to it's binary representation.
static const UInt16 IPv6StringLength
The amount of space needed in a string to store the character representation of an IPv6 address...
Boole operator==(const IPAddress &Other) const
Equality operator.
IPAddress()
Class Constructor.
bool Boole
Generally acts a single bit, true or false.
static const String IPv6LoopbackAddress
The loopback address for IPv6.
~IPAddress()
Class Destructor.
void ProtoDeSerialize(const XML::Node &SelfRoot)
Take the data stored in an XML Node and overwrite this object with it.
Thrown when the requested identity could not be found.
NetworkLayerProtocol
This is an enum listing for recognized protocols on Layer 3 of the OSI model.
#define MEZZ_EXCEPTION(num, desc)
An easy way to throw exceptions with rich information.
Thrown when a version is accessed/parsed/required and it cannot work correctly or is missing...
const Char8 * AsString(const Char8 *def="") const
Attempts to convert the value of the attribute to a String and returns the results.
static const String IPv4BroadcastAddress
The broadcast address for IPv4.
bool Empty() const
Is this storing anything at all?
This implements the exception hiearchy for Mezzanine.
void SetBinaryAddress(const AddressContainer &Address)
Sets the binary form of the address being stored.
UInt32 GetV4Address(const Boole NBO=false) const
Gets a version 4 IP address value.
Internet Protocol version 6.
The interface for serialization.
bool SetValue(const Char8 *rhs)
Set the value of this.
uint16_t UInt16
An 16-bit unsigned integer.
A light-weight handle for manipulating nodes in DOM tree.
int AsInt(int def=0) const
Attempts to convert the value of the attribute to an int and returns the results. ...
uint32_t UInt32
An 32-bit unsigned integer.
AddressContainer InternalAddress
A resizable vector to store the binary IP address regardless of version.
bool Empty() const
Is this storing anything at all?
This is a simple class for representing IP addresses used throughout the Network subsystem.
Used for error conditions.
const AddressContainer & GetBinaryAddress() const
Gets the stored binary address of this IPAddress.
static const String IPv4LoopbackAddress
The loopback address for IPv4.
String GetAsString() const
Gets this IPAddress in a human readable format.
static const UInt16 IPv4BinaryLength
The amount of space needed in a buffer to store the binary representation of an IPv4 address...
Network::NetworkLayerProtocol GetProtocol() const
Gets the type of IP address this is.
static const UInt16 IPv4StringLength
The amount of space needed in a string to store the character representation of an IPv4 address...
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Boole operator!=(const IPAddress &Other) const
Inequality operator.
void SetV4Address(const UInt32 Address, const Boole NBO=false)
Sets a version 4 IP address value.
void ProtoSerialize(XML::Node &ParentNode) const
Convert this class to an XML::Node ready for serialization.
std::vector< Int8 > AddressContainer
Convenience type to store the binary representation of IP addresses.
void operator=(const IPAddress &Other)
Assignment operator.
const Char8 * Name() const
ptrdiff_tGet the name of this Node.
void SerializeError(const String &FailedTo, const String &ClassName, Boole SOrD)
Simply does some string concatenation, then throws an Exception.
static String GetSerializableName()
Get the name of the the XML tag the IPAddress class will leave behind as its instances are serialized...
Node AppendChild(NodeType Type=NodeElement)
Creates a Node and makes it a child of this one.
std::string String
A datatype used to a series of characters.
Internet Protocol version 4.
Attribute GetAttribute(const Char8 *Name) const
Attempt to get an Attribute on this Node with a given name.