Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: XBeeWiFi_SPI_example
Fork of NetServicesSource by
Diff: if/net/ipaddr.h
- Revision:
- 8:93fa3cfc0219
- Parent:
- 5:dd63a1e02b1b
--- a/if/net/ipaddr.h Wed Jul 28 11:55:27 2010 +0000
+++ b/if/net/ipaddr.h Wed Jul 28 12:45:32 2010 +0000
@@ -37,6 +37,10 @@
class IpAddr;
+///IP Address container
+/**
+This class is a container for an IPv4 address.
+*/
class IpAddr //Basically a C++ frontend to ip_addr_t
{
public:
@@ -47,6 +51,7 @@
}
#endif
+ ///Initializes IP address with provided values
IpAddr(uint8_t ip0, uint8_t ip1, uint8_t ip2, uint8_t ip3)
{
//We are in LE
@@ -56,6 +61,7 @@
m_ip[3] = ip3;
}
+ ///Initializes IP address with null values
IpAddr()
{
m_ip[0] = 0;
@@ -74,6 +80,7 @@
}
#endif
+ ///Returns IP address byte #
uint8_t operator[](unsigned int i) const
{
uint8_t null = 0;
@@ -82,31 +89,55 @@
return m_ip[i];
}
+ ///Compares too addresses
+ /*
+ @return true if the two addresses are equal
+ */
bool isEq(const IpAddr& b) const
{
return (*((uint32_t*)m_ip) == *((uint32_t*)(b.m_ip)));
}
+ ///Compares too addresses
+ /*
+ @return true if the two addresses are equal
+ */
bool operator==(const IpAddr& b) const
{
return isEq(b);
}
-
+
+ ///Compares too addresses
+ /*
+ @return true if the two addresses are different
+ */
bool operator!=(const IpAddr& b) const
{
return !(operator==(b));
}
+ ///Checks whether the address is null
+ /*
+ @return true if the address is null
+ */
bool isNull() const
{
return (*((uint32_t*)m_ip) == 0);
}
+ ///Checks whether the address is a broadcast address
+ /*
+ @return true if the address is a broadcast address
+ */
bool isBroadcast() const
{
return (*((uint32_t*)m_ip) == 0xFFFFFFFF);
}
-
+
+ ///Checks whether the address is a multicast address
+ /*
+ @return true if the address is a multicast address
+ */
bool isMulticast() const
{
return ((m_ip[0] & 0xF0) == 0xE0);
