diff --git a/examples/csma-cd-one-subnet.cc b/examples/csma-cd-one-subnet.cc index e19ed7e63..db0731a23 100644 --- a/examples/csma-cd-one-subnet.cc +++ b/examples/csma-cd-one-subnet.cc @@ -127,7 +127,7 @@ int main (int argc, char *argv[]) // from n0 to n1 Ptr ooff = Create ( n0, - InetSocketAddress (Ipv4Address("10.1.1.2"), 80).ConvertTo (), + InetSocketAddress ("10.1.1.2", 80), "Udp", ConstantVariable(1), ConstantVariable(0)); @@ -138,7 +138,7 @@ int main (int argc, char *argv[]) // Create a similar flow from n3 to n0, starting at time 1.1 seconds ooff = Create ( n3, - InetSocketAddress (Ipv4Address("10.1.1.1"), 80).ConvertTo (), + InetSocketAddress ("10.1.1.1", 80), "Udp", ConstantVariable(1), ConstantVariable(0)); diff --git a/examples/csma-cd-packet-socket.cc b/examples/csma-cd-packet-socket.cc index f19249789..ed1976645 100644 --- a/examples/csma-cd-packet-socket.cc +++ b/examples/csma-cd-packet-socket.cc @@ -105,7 +105,7 @@ int main (int argc, char *argv[]) // from n0 to n1 Ptr ooff = Create ( n0, - n0ToN1.ConvertTo (), + n0ToN1, "Packet", ConstantVariable(1), ConstantVariable(0)); @@ -116,7 +116,7 @@ int main (int argc, char *argv[]) // Create a similar flow from n3 to n0, starting at time 1.1 seconds ooff = Create ( n3, - n3ToN0.ConvertTo (), + n3ToN0, "Packet", ConstantVariable(1), ConstantVariable(0)); diff --git a/examples/simple-point-to-point.cc b/examples/simple-point-to-point.cc index 806c4d120..fa826ab5c 100644 --- a/examples/simple-point-to-point.cc +++ b/examples/simple-point-to-point.cc @@ -144,7 +144,7 @@ int main (int argc, char *argv[]) // 210 bytes at a rate of 448 Kb/s Ptr ooff = Create ( n0, - InetSocketAddress (Ipv4Address("10.1.3.2"), 80).ConvertTo (), + InetSocketAddress ("10.1.3.2", 80), "Udp", ConstantVariable(1), ConstantVariable(0)); @@ -155,7 +155,7 @@ int main (int argc, char *argv[]) // Create a similar flow from n3 to n1, starting at time 1.1 seconds ooff = Create ( n3, - InetSocketAddress (Ipv4Address("10.1.2.1"), 80).ConvertTo (), + InetSocketAddress ("10.1.2.1", 80), "Udp", ConstantVariable(1), ConstantVariable(0)); diff --git a/samples/main-simple.cc b/samples/main-simple.cc index e3567e0b1..3be286c46 100644 --- a/samples/main-simple.cc +++ b/samples/main-simple.cc @@ -46,11 +46,11 @@ RunSimulation (void) Ptr sink = socketFactory->CreateSocket (); InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (), 80); - sink->Bind (local.ConvertTo ()); + sink->Bind (local); Ptr source = socketFactory->CreateSocket (); InetSocketAddress remote = InetSocketAddress (Ipv4Address::GetLoopback (), 80); - source->Connect (remote.ConvertTo ()); + source->Connect (remote); GenerateTraffic (source, 500); PrintTraffic (sink); diff --git a/src/devices/csma-cd/csma-cd-net-device.cc b/src/devices/csma-cd/csma-cd-net-device.cc index 538625ee5..3d8919fcb 100644 --- a/src/devices/csma-cd/csma-cd-net-device.cc +++ b/src/devices/csma-cd/csma-cd-net-device.cc @@ -46,7 +46,7 @@ CsmaCdNetDevice::CsmaCdNetDevice (Ptr node) CsmaCdNetDevice::CsmaCdNetDevice (Ptr node, Eui48Address addr, CsmaCdEncapsulationMode encapMode) - : NetDevice(node, addr.ConvertTo ()), + : NetDevice(node, addr), m_bps (DataRate (0xffffffff)) { NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << node << ")"); @@ -58,7 +58,7 @@ CsmaCdNetDevice::CsmaCdNetDevice (Ptr node, Eui48Address addr, CsmaCdNetDevice::CsmaCdNetDevice (Ptr node, Eui48Address addr, CsmaCdEncapsulationMode encapMode, bool sendEnable, bool receiveEnable) - : NetDevice(node, addr.ConvertTo ()), + : NetDevice(node, addr), m_bps (DataRate (0xffffffff)) { NS_DEBUG ("CsmaCdNetDevice::CsmaCdNetDevice (" << node << ")"); @@ -105,7 +105,7 @@ CsmaCdNetDevice::Init(bool sendEnable, bool receiveEnable) m_channel = 0; m_queue = 0; - EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff").ConvertTo ()); + EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff")); EnableMulticast(); EnablePointToPoint(); @@ -210,10 +210,8 @@ CsmaCdNetDevice::ProcessHeader (Packet& p, uint16_t & param) trailer.CheckFcs(p); p.RemoveHeader(header); - Eui48Address broadcast = Eui48Address::ConvertFrom (GetBroadcast ()); - Eui48Address destination = Eui48Address::ConvertFrom (GetAddress ()); - if ((header.GetDestination() != broadcast) && - (header.GetDestination() != destination)) + if ((header.GetDestination() != GetBroadcast ()) && + (header.GetDestination() != GetAddress ())) { return false; } @@ -261,8 +259,8 @@ CsmaCdNetDevice::SendTo (Packet& p, const Address& dest, uint16_t protocolNumber if (!IsSendEnabled()) return false; - Eui48Address address = Eui48Address::ConvertFrom (dest); - AddHeader(p, address, protocolNumber); + Eui48Address destination = Eui48Address::ConvertFrom (dest); + AddHeader(p, destination, protocolNumber); // Place the packet to be sent on the send queue if (m_queue->Enqueue(p) == false ) diff --git a/src/devices/point-to-point/point-to-point-net-device.cc b/src/devices/point-to-point/point-to-point-net-device.cc index b450421f5..7e9d5c601 100644 --- a/src/devices/point-to-point/point-to-point-net-device.cc +++ b/src/devices/point-to-point/point-to-point-net-device.cc @@ -43,7 +43,7 @@ DataRateDefaultValue PointToPointNetDevice::g_defaultRate( PointToPointNetDevice::PointToPointNetDevice (Ptr node, const DataRate& rate) : - NetDevice(node, Eui48Address::Allocate ().ConvertTo ()), + NetDevice(node, Eui48Address::Allocate ()), m_txMachineState (READY), m_bps (rate), m_tInterframeGap (Seconds(0)), @@ -56,7 +56,7 @@ PointToPointNetDevice::PointToPointNetDevice (Ptr node, // BUGBUG FIXME // // You _must_ support broadcast to get any sort of packet from the ARP layer. - EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff").ConvertTo ()); + EnableBroadcast (Eui48Address ("ff:ff:ff:ff:ff:ff")); EnableMulticast(); EnablePointToPoint(); } diff --git a/src/internet-node/udp-socket.cc b/src/internet-node/udp-socket.cc index 61d32499e..0817ae937 100644 --- a/src/internet-node/udp-socket.cc +++ b/src/internet-node/udp-socket.cc @@ -271,7 +271,7 @@ UdpSocket::ForwardUp (const Packet &packet, Ipv4Address ipv4, uint16_t port) return; } - Address address = InetSocketAddress (ipv4, port).ConvertTo (); + Address address = InetSocketAddress (ipv4, port); Packet p = packet; if (!m_dummyRxCallback.IsNull ()) { diff --git a/src/node/eui48-address.cc b/src/node/eui48-address.cc index 096a1cc38..4df16c829 100644 --- a/src/node/eui48-address.cc +++ b/src/node/eui48-address.cc @@ -95,6 +95,14 @@ Eui48Address::IsMatchingType (const Address &address) { return address.CheckCompatible (GetType (), 6); } +Eui48Address::operator Address () +{ + return ConvertTo (); +} +Eui48Address::Eui48Address (const Address &address) +{ + *this = ConvertFrom (address); +} Address Eui48Address::ConvertTo (void) const { diff --git a/src/node/eui48-address.h b/src/node/eui48-address.h index 3156782ef..bd778a444 100644 --- a/src/node/eui48-address.h +++ b/src/node/eui48-address.h @@ -55,28 +55,37 @@ public: * Copy the internal address to the input buffer. */ void CopyTo (uint8_t buffer[6]) const; + + /** + * \returns a new Address instance + * + * Convert an instance of this class to a polymorphic Address instance. + */ + operator Address (); + /** + * \param address a polymorphic address + * \returns a new Eui48Address from the polymorphic address + * + * This function performs a type check and asserts if the + * type of the input address is not compatible with an + * Eui48Address. + */ + static Eui48Address ConvertFrom (const Address &address); + /** + * \returns true if the address matches, false otherwise. + */ + static bool IsMatchingType (const Address &address); + /** + * Allocate a new Eui48Address. + */ + static Eui48Address Allocate (void); +private: /** * \returns a new Address instance * * Convert an instance of this class to a polymorphic Address instance. */ Address ConvertTo (void) const; - /** - * \returns true if the address matches, false otherwise. - */ - static bool IsMatchingType (const Address &address); - /** - * \param address a polymorphic address - * - * Convert a polymorphic address to an Eui48Address instance. - * The conversion performs a type check. - */ - static Eui48Address ConvertFrom (const Address &address); - /** - * Allocate a new Eui48Address. - */ - static Eui48Address Allocate (void); -private: static uint8_t GetType (void); uint8_t m_address[6]; }; diff --git a/src/node/eui64-address.cc b/src/node/eui64-address.cc index 342fd4d91..e29150542 100644 --- a/src/node/eui64-address.cc +++ b/src/node/eui64-address.cc @@ -95,6 +95,14 @@ Eui64Address::IsMatchingType (const Address &address) { return address.CheckCompatible (GetType (), 8); } +Eui48Address::operator Address () +{ + return ConvertTo (); +} +Eui48Address::Eui48Address (const Address &address) +{ + *this = ConvertFrom (address); +} Address Eui64Address::ConvertTo (void) const { diff --git a/src/node/eui64-address.h b/src/node/eui64-address.h index 6b407bfa0..f4ef91d48 100644 --- a/src/node/eui64-address.h +++ b/src/node/eui64-address.h @@ -60,12 +60,22 @@ public: * * Convert an instance of this class to a polymorphic Address instance. */ - Address ConvertTo (void) const; + operator Address (); + /** + * \param address a polymorphic address + * \returns a new Eui48Address from the polymorphic address + * + * This function performs a type check and asserts if the + * type of the input address is not compatible with an + * Eui48Address. + */ + static Eui48Address ConvertFrom (const Address &address); /** * \returns true if the address matches, false otherwise. */ static bool IsMatchingType (const Address &address); /** +<<<<<<< /auto/fugue/u/fugue/home/mlacage/code/ns-3-dev/src/node/eui64-address.h * \param address a polymorphic address * * Convert a polymorphic address to an Eui64Address instance. @@ -74,9 +84,18 @@ public: static Eui64Address ConvertFrom (const Address &address); /** * Allocate a new Eui64Address. +======= + * Allocate a new Eui48Address. +>>>>>>> /tmp/eui48-address.h~other.OBFjbL */ static Eui64Address Allocate (void); private: + /** + * \returns a new Address instance + * + * Convert an instance of this class to a polymorphic Address instance. + */ + Address ConvertTo (void) const; static uint8_t GetType (void); uint8_t m_address[8]; }; diff --git a/src/node/inet-socket-address.cc b/src/node/inet-socket-address.cc index 232e9215f..3b2ad5ba8 100644 --- a/src/node/inet-socket-address.cc +++ b/src/node/inet-socket-address.cc @@ -51,6 +51,11 @@ InetSocketAddress::IsMatchingType (const Address &address) return address.CheckCompatible (GetType (), 6); } +InetSocketAddress::operator Address () const +{ + return ConvertTo (); +} + Address InetSocketAddress::ConvertTo (void) const { diff --git a/src/node/inet-socket-address.h b/src/node/inet-socket-address.h index 6734f1496..0a00172ba 100644 --- a/src/node/inet-socket-address.h +++ b/src/node/inet-socket-address.h @@ -73,14 +73,18 @@ public: * \returns an Address instance which represents this * InetSocketAddress instance. */ - Address ConvertTo (void) const; + operator Address () const; + /** * \param address the Address instance to convert from. - * \returns an InetSocketAddress which corresponds to the input + * + * Returns an InetSocketAddress which corresponds to the input * Address */ static InetSocketAddress ConvertFrom (const Address &address); private: + Address ConvertTo (void) const; + static uint8_t GetType (void); Ipv4Address m_ipv4; uint16_t m_port; diff --git a/src/node/ipv4-address.cc b/src/node/ipv4-address.cc index 4404ac084..34b15372d 100644 --- a/src/node/ipv4-address.cc +++ b/src/node/ipv4-address.cc @@ -222,6 +222,11 @@ Ipv4Address::IsMatchingType (const Address &address) { return address.CheckCompatible (GetType (), 4); } +Ipv4Address::operator Address () +{ + return ConvertTo (); +} + Address Ipv4Address::ConvertTo (void) const { diff --git a/src/node/ipv4-address.h b/src/node/ipv4-address.h index 5d0e53ab5..8bf91f5c9 100644 --- a/src/node/ipv4-address.h +++ b/src/node/ipv4-address.h @@ -121,7 +121,7 @@ public: Ipv4Address CombineMask (Ipv4Mask const &mask) const; static bool IsMatchingType (const Address &address); - Address ConvertTo (void) const; + operator Address (); static Ipv4Address ConvertFrom (const Address &address); static Ipv4Address GetZero (void); @@ -129,6 +129,7 @@ public: static Ipv4Address GetBroadcast (void); static Ipv4Address GetLoopback (void); private: + Address ConvertTo (void) const; static uint8_t GetType (void); uint32_t m_address; };