--- a/src/node/ipv4-address.cc Mon Jul 30 14:48:56 2007 +0100
+++ b/src/node/ipv4-address.cc Wed Sep 05 18:35:39 2007 +0100
@@ -19,11 +19,11 @@
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "ns3/debug.h"
+#include "ipv4-address.h"
+#include "ns3/assert.h"
NS_DEBUG_COMPONENT_DEFINE("Ipv4Address");
-#include "ipv4-address.h"
-
namespace ns3 {
@@ -135,6 +135,17 @@
m_address = AsciiToIpv4Host (address);
}
+void
+Ipv4Address::Set (uint32_t address)
+{
+ m_address = address;
+}
+void
+Ipv4Address::Set (char const *address)
+{
+ m_address = AsciiToIpv4Host (address);
+}
+
bool
Ipv4Address::IsEqual (Ipv4Address other) const
{
@@ -160,8 +171,11 @@
bool
Ipv4Address::IsMulticast (void) const
{
- // XXX
- return false;
+//
+// Multicast addresses are defined as ranging from 224.0.0.0 through
+// 239.255.255.255 (which is E0000000 through EFFFFFFF in hex).
+//
+ return (m_address >= 0xe0000000 && m_address <= 0xefffffff);
}
uint32_t
@@ -182,6 +196,20 @@
buf[2] = (m_address >> 8) & 0xff;
buf[3] = (m_address >> 0) & 0xff;
}
+Ipv4Address
+Ipv4Address::Deserialize (const uint8_t buf[4])
+{
+ Ipv4Address ipv4;
+ ipv4.m_address = 0;
+ ipv4.m_address |= buf[0];
+ ipv4.m_address <<= 8;
+ ipv4.m_address |= buf[1];
+ ipv4.m_address <<= 8;
+ ipv4.m_address |= buf[2];
+ ipv4.m_address <<= 8;
+ ipv4.m_address |= buf[3];
+ return ipv4;
+}
void
Ipv4Address::Print (std::ostream &os) const
@@ -192,7 +220,39 @@
<< ((m_address >> 0) & 0xff);
}
+bool
+Ipv4Address::IsMatchingType (const Address &address)
+{
+ return address.CheckCompatible (GetType (), 4);
+}
+Ipv4Address::operator Address ()
+{
+ return ConvertTo ();
+}
+Address
+Ipv4Address::ConvertTo (void) const
+{
+ uint8_t buf[4];
+ Serialize (buf);
+ return Address (GetType (), buf, 4);
+}
+
+Ipv4Address
+Ipv4Address::ConvertFrom (const Address &address)
+{
+ NS_ASSERT (address.CheckCompatible (GetType (), 4));
+ uint8_t buf[4];
+ address.CopyTo (buf);
+ return Deserialize (buf);
+}
+
+uint8_t
+Ipv4Address::GetType (void)
+{
+ static uint8_t type = Address::Register ();
+ return type;
+}
Ipv4Address
Ipv4Address::GetZero (void)