merge
This commit is contained in:
@@ -25,6 +25,15 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
CommandLine::List::~List ()
|
||||
{
|
||||
for (iterator iter = begin (); iter != end (); iter++)
|
||||
{
|
||||
delete *iter;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CommandDefaultValue CommandLine::g_help ("help",
|
||||
"Print Help text for all commands",
|
||||
MakeCallback (&CommandLine::PrintHelp));
|
||||
|
||||
@@ -85,7 +85,12 @@ public:
|
||||
T *m_valuePtr;
|
||||
};
|
||||
static void PrintHelp (void);
|
||||
typedef std::list<DefaultValueBase *> List;
|
||||
|
||||
class List : public std::list<DefaultValueBase *>
|
||||
{
|
||||
public:
|
||||
~List ();
|
||||
};
|
||||
static List *GetUserList (void);
|
||||
static CommandDefaultValue g_help;
|
||||
};
|
||||
|
||||
@@ -452,6 +452,8 @@ UdpSocketTest::RunTests (void)
|
||||
NS_TEST_ASSERT_EQUAL (m_receivedPacket.GetSize (), 123);
|
||||
NS_TEST_ASSERT_EQUAL (m_receivedPacket2.GetSize (), 123);
|
||||
|
||||
Simulator::Destroy ();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,16 +151,6 @@ Ipv4Address::Set (char const *address)
|
||||
m_address = AsciiToIpv4Host (address);
|
||||
}
|
||||
|
||||
bool
|
||||
Ipv4Address::IsEqual (Ipv4Address other) const
|
||||
{
|
||||
if (other.m_address == m_address) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Ipv4Address
|
||||
Ipv4Address::CombineMask (Ipv4Mask const &mask) const
|
||||
{
|
||||
@@ -242,7 +232,7 @@ Ipv4Address::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 4);
|
||||
}
|
||||
Ipv4Address::operator Address ()
|
||||
Ipv4Address::operator Address () const
|
||||
{
|
||||
return ConvertTo ();
|
||||
}
|
||||
@@ -296,19 +286,6 @@ Ipv4Address::GetLoopback (void)
|
||||
return loopback;
|
||||
}
|
||||
|
||||
bool operator == (Ipv4Address const &a, Ipv4Address const &b)
|
||||
{
|
||||
return a.IsEqual (b);
|
||||
}
|
||||
bool operator != (Ipv4Address const &a, Ipv4Address const &b)
|
||||
{
|
||||
return !a.IsEqual (b);
|
||||
}
|
||||
bool operator < (Ipv4Address const &addrA, Ipv4Address const &addrB)
|
||||
{
|
||||
return (addrA.GetHostOrder () < addrB.GetHostOrder ());
|
||||
}
|
||||
|
||||
size_t Ipv4AddressHash::operator()(Ipv4Address const &x) const
|
||||
{
|
||||
return x.GetHostOrder ();
|
||||
|
||||
@@ -73,7 +73,10 @@ public:
|
||||
* \param other address to which to compare this address
|
||||
* \return True if the addresses are equal. False otherwise.
|
||||
*/
|
||||
bool IsEqual (Ipv4Address other) const;
|
||||
bool IsEqual (const Ipv4Address &other) const
|
||||
{
|
||||
return m_address == other.m_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Get the host-order 32-bit IP address
|
||||
@@ -131,7 +134,7 @@ public:
|
||||
bool IsSubnetDirectedBroadcast (Ipv4Mask const &mask) const;
|
||||
|
||||
static bool IsMatchingType (const Address &address);
|
||||
operator Address ();
|
||||
operator Address () const;
|
||||
static Ipv4Address ConvertFrom (const Address &address);
|
||||
|
||||
static Ipv4Address GetZero (void);
|
||||
@@ -142,6 +145,10 @@ private:
|
||||
Address ConvertTo (void) const;
|
||||
static uint8_t GetType (void);
|
||||
uint32_t m_address;
|
||||
|
||||
friend bool operator == (Ipv4Address const &a, Ipv4Address const &b);
|
||||
friend bool operator != (Ipv4Address const &a, Ipv4Address const &b);
|
||||
friend bool operator < (Ipv4Address const &addrA, Ipv4Address const &addrB);
|
||||
};
|
||||
|
||||
|
||||
@@ -177,9 +184,19 @@ private:
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Address const& address);
|
||||
std::ostream& operator<< (std::ostream& os, Ipv4Mask const& mask);
|
||||
|
||||
bool operator == (Ipv4Address const &a, Ipv4Address const &b);
|
||||
bool operator != (Ipv4Address const &a, Ipv4Address const &b);
|
||||
bool operator < (Ipv4Address const &addrA, Ipv4Address const &addrB);
|
||||
inline bool operator == (const Ipv4Address &a, const Ipv4Address &b)
|
||||
{
|
||||
return (a.m_address == b.m_address);
|
||||
}
|
||||
inline bool operator != (const Ipv4Address &a, const Ipv4Address &b)
|
||||
{
|
||||
return (a.m_address != b.m_address);
|
||||
}
|
||||
inline bool operator < (const Ipv4Address &a, const Ipv4Address &b)
|
||||
{
|
||||
return (a.m_address < b.m_address);
|
||||
}
|
||||
|
||||
|
||||
class Ipv4AddressHash : public std::unary_function<Ipv4Address, size_t> {
|
||||
public:
|
||||
|
||||
@@ -95,7 +95,7 @@ Mac48Address::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 6);
|
||||
}
|
||||
Mac48Address::operator Address ()
|
||||
Mac48Address::operator Address () const
|
||||
{
|
||||
return ConvertTo ();
|
||||
}
|
||||
@@ -133,19 +133,48 @@ Mac48Address::GetType (void)
|
||||
return type;
|
||||
}
|
||||
|
||||
bool
|
||||
Mac48Address::IsBroadcast (void) const
|
||||
{
|
||||
return *this == GetBroadcast ();
|
||||
}
|
||||
bool
|
||||
Mac48Address::IsMulticast (void) const
|
||||
{
|
||||
return (m_address[0] & 0x01) == 0x01;
|
||||
}
|
||||
Mac48Address
|
||||
Mac48Address::GetBroadcast (void)
|
||||
{
|
||||
static Mac48Address broadcast = Mac48Address ("ff:ff:ff:ff:ff:ff");
|
||||
return broadcast;
|
||||
}
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
uint8_t ada[6];
|
||||
uint8_t adb[6];
|
||||
a.CopyTo (ada);
|
||||
b.CopyTo (adb);
|
||||
return memcmp (ada, adb, 6) == 0;
|
||||
return memcmp (a.m_address, b.m_address, 6) == 0;
|
||||
}
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
return ! (a == b);
|
||||
}
|
||||
|
||||
bool operator < (const Mac48Address &a, const Mac48Address &b)
|
||||
{
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (a.m_address[i] < b.m_address[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (a.m_address[i] > b.m_address[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address)
|
||||
{
|
||||
uint8_t ad[6];
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
*
|
||||
* Convert an instance of this class to a polymorphic Address instance.
|
||||
*/
|
||||
operator Address ();
|
||||
operator Address () const;
|
||||
/**
|
||||
* \param address a polymorphic address
|
||||
* \returns a new Mac48Address from the polymorphic address
|
||||
@@ -79,6 +79,20 @@ public:
|
||||
* Allocate a new Mac48Address.
|
||||
*/
|
||||
static Mac48Address Allocate (void);
|
||||
|
||||
/**
|
||||
* \returns true if this is a broadcast address, false otherwise.
|
||||
*/
|
||||
bool IsBroadcast (void) const;
|
||||
/**
|
||||
* \returns true if this is a multicast address, false otherwise.
|
||||
*/
|
||||
bool IsMulticast (void) const;
|
||||
|
||||
/**
|
||||
* \returns the broadcast address
|
||||
*/
|
||||
static Mac48Address GetBroadcast (void);
|
||||
private:
|
||||
/**
|
||||
* \returns a new Address instance
|
||||
@@ -87,11 +101,15 @@ private:
|
||||
*/
|
||||
Address ConvertTo (void) const;
|
||||
static uint8_t GetType (void);
|
||||
friend bool operator < (const Mac48Address &a, const Mac48Address &b);
|
||||
friend bool operator == (const Mac48Address &a, const Mac48Address &b);
|
||||
|
||||
uint8_t m_address[6];
|
||||
};
|
||||
|
||||
bool operator == (const Mac48Address &a, const Mac48Address &b);
|
||||
bool operator != (const Mac48Address &a, const Mac48Address &b);
|
||||
bool operator < (const Mac48Address &a, const Mac48Address &b);
|
||||
std::ostream& operator<< (std::ostream& os, const Mac48Address & address);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -95,7 +95,7 @@ Mac64Address::IsMatchingType (const Address &address)
|
||||
{
|
||||
return address.CheckCompatible (GetType (), 8);
|
||||
}
|
||||
Mac64Address::operator Address ()
|
||||
Mac64Address::operator Address () const
|
||||
{
|
||||
return ConvertTo ();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
*
|
||||
* Convert an instance of this class to a polymorphic Address instance.
|
||||
*/
|
||||
operator Address ();
|
||||
operator Address () const;
|
||||
/**
|
||||
* \param address a polymorphic address
|
||||
* \returns a new Mac64Address from the polymorphic address
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
#include "timer.h"
|
||||
#include "simulator.h"
|
||||
#include "simulation-singleton.h"
|
||||
#include "event-garbage-collector.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -31,16 +30,8 @@ Timer::Timer ()
|
||||
m_impl (0)
|
||||
{}
|
||||
|
||||
Timer::Timer (enum SchedulePolicy schedulePolicy,
|
||||
enum DestroyPolicy destroyPolicy)
|
||||
: m_flags (schedulePolicy | destroyPolicy),
|
||||
m_delay (FemtoSeconds (0)),
|
||||
m_event (),
|
||||
m_impl (0)
|
||||
{}
|
||||
|
||||
Timer::Timer (enum GarbageCollectPolicy policy)
|
||||
: m_flags (GARBAGE_COLLECT),
|
||||
Timer::Timer (enum DestroyPolicy destroyPolicy)
|
||||
: m_flags (destroyPolicy),
|
||||
m_delay (FemtoSeconds (0)),
|
||||
m_event (),
|
||||
m_impl (0)
|
||||
@@ -149,26 +140,11 @@ void
|
||||
Timer::Schedule (Time delay)
|
||||
{
|
||||
NS_ASSERT (m_impl != 0);
|
||||
if (m_flags & CHECK_ON_SCHEDULE)
|
||||
if (m_event.IsRunning ())
|
||||
{
|
||||
if (m_event.IsRunning ())
|
||||
{
|
||||
NS_FATAL_ERROR ("Event is still running while re-scheduling.");
|
||||
}
|
||||
}
|
||||
else if (m_flags & CANCEL_ON_SCHEDULE)
|
||||
{
|
||||
m_event.Cancel ();
|
||||
}
|
||||
else if (m_flags & REMOVE_ON_SCHEDULE)
|
||||
{
|
||||
Simulator::Remove (m_event);
|
||||
NS_FATAL_ERROR ("Event is still running while re-scheduling.");
|
||||
}
|
||||
m_event = m_impl->Schedule (delay);
|
||||
if (m_flags & GARBAGE_COLLECT)
|
||||
{
|
||||
SimulationSingleton<EventGarbageCollector>::Get ()->Track (m_event);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -43,23 +43,6 @@ class TimerImpl;
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
enum SchedulePolicy {
|
||||
/**
|
||||
* This policy cancels the event before scheduling a new event
|
||||
* for each call to Timer::Schedule.
|
||||
*/
|
||||
CANCEL_ON_SCHEDULE = (1<<0),
|
||||
/**
|
||||
* This policy removes the event from the simulation event list
|
||||
* before scheduling a new event for each call to Timer::Schedule.
|
||||
*/
|
||||
REMOVE_ON_SCHEDULE = (1<<1),
|
||||
/**
|
||||
* This policy enforces a check before each call to Timer::Schedule
|
||||
* to verify that the timer has already expired.
|
||||
*/
|
||||
CHECK_ON_SCHEDULE = (1<<2),
|
||||
};
|
||||
enum DestroyPolicy {
|
||||
/**
|
||||
* This policy cancels the event from the destructor of the Timer
|
||||
@@ -77,15 +60,6 @@ public:
|
||||
*/
|
||||
CHECK_ON_DESTROY = (1<<5)
|
||||
};
|
||||
enum GarbageCollectPolicy {
|
||||
/**
|
||||
* Every event scheduled with this policy is kept track of by an
|
||||
* event garbage collector which makes sure that all events
|
||||
* of timers with a GARBAGE_COLLECT policy are cancelled at the
|
||||
* end of the simulation.
|
||||
*/
|
||||
GARBAGE_COLLECT = (1<<6)
|
||||
};
|
||||
enum State {
|
||||
RUNNING,
|
||||
EXPIRED,
|
||||
@@ -93,21 +67,13 @@ public:
|
||||
};
|
||||
/**
|
||||
* create a timer with a default event lifetime management policy:
|
||||
* - CHECK_ON_SCHEDULE
|
||||
* - CHECK_ON_DESTROY
|
||||
*/
|
||||
Timer ();
|
||||
/**
|
||||
* \param scheduleFlags the event lifetime management policies to use for schedule events
|
||||
* \param destroyFlags the event lifetime management policies to use for destroy events
|
||||
*/
|
||||
Timer (enum SchedulePolicy schedulePolicy,
|
||||
enum DestroyPolicy destroyPolicy);
|
||||
/**
|
||||
* \param policy the garbage collect policy. Only one
|
||||
* value is possible.
|
||||
*/
|
||||
Timer (enum GarbageCollectPolicy policy);
|
||||
Timer (enum DestroyPolicy destroyPolicy);
|
||||
~Timer ();
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user