View | Details | Raw Unified | Return to bug 1192
Collapse All | Expand All

(-)a/src/network/model/packet-metadata.cc (+20 lines)
 Lines 67-72    Link Here 
67
  m_enableChecking = true;
67
  m_enableChecking = true;
68
}
68
}
69
69
70
void 
71
PacketMetadata::Disable (void)
72
{
73
  NS_ASSERT_MSG (!m_metadataSkipped,
74
                 "Error: attempting to enable the packet metadata "
75
                 "subsystem too late in the simulation, which is not allowed.\n"
76
                 "A common cause for this problem is to enable ASCII tracing "
77
                 "after sending any packets.  One way to fix this problem is "
78
                 "to call ns3::PacketMetadata::Enable () near the beginning of"
79
                 " the program, before any packets are sent.");
80
  m_enable = false;
81
}
82
83
void 
84
PacketMetadata::DisableChecking (void)
85
{
86
  Disable ();
87
  m_enableChecking = false;
88
}
89
70
void
90
void
71
PacketMetadata::ReserveCopy (uint32_t size)
91
PacketMetadata::ReserveCopy (uint32_t size)
72
{
92
{
(-)a/src/network/model/packet-metadata.h (+3 lines)
 Lines 127-132    Link Here 
127
  static void Enable (void);
127
  static void Enable (void);
128
  static void EnableChecking (void);
128
  static void EnableChecking (void);
129
129
130
  static void Disable (void);
131
  static void DisableChecking (void);
132
130
  inline PacketMetadata (uint64_t uid, uint32_t size);
133
  inline PacketMetadata (uint64_t uid, uint32_t size);
131
  inline PacketMetadata (PacketMetadata const &o);
134
  inline PacketMetadata (PacketMetadata const &o);
132
  inline PacketMetadata &operator = (PacketMetadata const& o);
135
  inline PacketMetadata &operator = (PacketMetadata const& o);
(-)a/src/network/model/packet.cc (+14 lines)
 Lines 560-565    Link Here 
560
  PacketMetadata::EnableChecking ();
560
  PacketMetadata::EnableChecking ();
561
}
561
}
562
562
563
void
564
Packet::DisablePrinting (void)
565
{
566
  NS_LOG_FUNCTION_NOARGS ();
567
  PacketMetadata::Disable ();
568
}
569
570
void
571
Packet::DisableChecking (void)
572
{
573
  NS_LOG_FUNCTION_NOARGS ();
574
  PacketMetadata::DisableChecking ();
575
}
576
563
uint32_t Packet::GetSerializedSize (void) const
577
uint32_t Packet::GetSerializedSize (void) const
564
{
578
{
565
  uint32_t size = 0;
579
  uint32_t size = 0;
(-)a/src/network/model/packet.h (+8 lines)
 Lines 429-434    Link Here 
429
   * errors will be detected and will abort the program.
429
   * errors will be detected and will abort the program.
430
   */
430
   */
431
  static void EnableChecking (void);
431
  static void EnableChecking (void);
432
  /**
433
   * \sa EnablePrinting
434
   */
435
  static void DisablePrinting (void);
436
  /**
437
   * \sa EnableChecking
438
   */
439
  static void DisableChecking (void);
432
440
433
  /**
441
  /**
434
   * For packet serializtion, the total size is checked 
442
   * For packet serializtion, the total size is checked 
(-)a/src/core/model/config.cc (+5 lines)
 Lines 603-608    Link Here 
603
{
603
{
604
  return GlobalValue::BindFailSafe (name, value);
604
  return GlobalValue::BindFailSafe (name, value);
605
}
605
}
606
void Reset ()
607
{
608
  AttributeList::GetGlobal ()->Reset ();
609
  GlobalValue::ResetAll ();
610
}
606
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
611
void ConnectWithoutContext (std::string path, const CallbackBase &cb)
607
{
612
{
608
  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
613
  Singleton<ConfigImpl>::Get ()->ConnectWithoutContext (path, cb);
(-)a/src/core/model/config.h (+5 lines)
 Lines 110-115    Link Here 
110
 * This function undoes the work of Config::ConnectWithContext.
110
 * This function undoes the work of Config::ConnectWithContext.
111
 */
111
 */
112
void Disconnect (std::string path, const CallbackBase &cb);
112
void Disconnect (std::string path, const CallbackBase &cb);
113
/**
114
 * This method resets the effect of all SetDefault, SetDefaultFailSafe,
115
 * SetGlobal, and SetGlobalFailSafe calls.
116
 */
117
void Reset ();
113
118
114
/**
119
/**
115
 * \brief hold a set of objects which match a specific search string.
120
 * \brief hold a set of objects which match a specific search string.
(-)a/src/core/model/global-value.cc (-4 / +18 lines)
 Lines 49-54    Link Here 
49
void
49
void
50
GlobalValue::InitializeFromEnv (void)
50
GlobalValue::InitializeFromEnv (void)
51
{
51
{
52
  m_value = m_initialValue->Copy ();
52
#ifdef HAVE_GETENV
53
#ifdef HAVE_GETENV
53
  char *envVar = getenv ("NS_GLOBAL_VALUE");
54
  char *envVar = getenv ("NS_GLOBAL_VALUE");
54
  if (envVar == 0)
55
  if (envVar == 0)
 Lines 88-96    Link Here 
88
  return m_help;
89
  return m_help;
89
}
90
}
90
void
91
void
92
GlobalValue::ResetValue (void)
93
{
94
  InitializeFromEnv ();
95
}
96
void
97
GlobalValue::ResetAll (void)
98
{
99
  for (Iterator i = Begin (); i != End (); i++)
100
    {
101
      (*i)->ResetValue ();
102
    }
103
}
104
void
91
GlobalValue::GetValue (AttributeValue &value) const
105
GlobalValue::GetValue (AttributeValue &value) const
92
{
106
{
93
  bool ok = m_checker->Copy (*m_initialValue, value);
107
  bool ok = m_checker->Copy (*m_value, value);
94
  if (ok)
108
  if (ok)
95
    {
109
    {
96
      return;
110
      return;
 Lines 100-106    Link Here 
100
    {
114
    {
101
      NS_FATAL_ERROR ("GlobalValue name="<<m_name<<": input value is not a string");
115
      NS_FATAL_ERROR ("GlobalValue name="<<m_name<<": input value is not a string");
102
    }
116
    }
103
  str->Set (m_initialValue->SerializeToString (m_checker));
117
  str->Set (m_value->SerializeToString (m_checker));
104
}
118
}
105
Ptr<const AttributeChecker> 
119
Ptr<const AttributeChecker> 
106
GlobalValue::GetChecker (void) const
120
GlobalValue::GetChecker (void) const
 Lines 113-119    Link Here 
113
{
127
{
114
  if (m_checker->Check (value))
128
  if (m_checker->Check (value))
115
    {
129
    {
116
      m_initialValue = value.Copy ();
130
      m_value = value.Copy ();
117
      return true;
131
      return true;
118
    }
132
    }
119
  // attempt to convert to string.
133
  // attempt to convert to string.
 Lines 134-140    Link Here 
134
    {
148
    {
135
      return false;
149
      return false;
136
    }
150
    }
137
  m_checker->Copy (*v, *PeekPointer (m_initialValue));
151
  m_checker->Copy (*v, *PeekPointer (m_value));
138
  return true;
152
  return true;
139
}
153
}
140
154
(-)a/src/core/model/global-value.h (+10 lines)
 Lines 84-89    Link Here 
84
   * \param value the new value to set in this GlobalValue.
84
   * \param value the new value to set in this GlobalValue.
85
   */
85
   */
86
  bool SetValue (const AttributeValue &value);
86
  bool SetValue (const AttributeValue &value);
87
  /**
88
   * Reset the global value to its default/initial value.
89
   */
90
  void ResetValue ();
87
91
88
  /**
92
  /**
89
   * \param name the name of the global value
93
   * \param name the name of the global value
 Lines 136-141    Link Here 
136
   * 
140
   * 
137
   */
141
   */
138
  static void GetValueByName (std::string name, AttributeValue &value);
142
  static void GetValueByName (std::string name, AttributeValue &value);
143
  
144
  /**
145
   * Resets all GlobalValue s to their defaults.
146
   */
147
  static void ResetAll ();
139
148
140
149
141
private:
150
private:
 Lines 145-150    Link Here 
145
  void InitializeFromEnv (void);
154
  void InitializeFromEnv (void);
146
  std::string m_name;
155
  std::string m_name;
147
  std::string m_help;
156
  std::string m_help;
157
  Ptr<AttributeValue> m_value;
148
  Ptr<AttributeValue> m_initialValue;
158
  Ptr<AttributeValue> m_initialValue;
149
  Ptr<const AttributeChecker> m_checker;
159
  Ptr<const AttributeChecker> m_checker;
150
};
160
};
(-)a/src/network/utils/mac48-address.cc (-1 / +15 lines)
 Lines 20-29    Link Here 
20
#include "mac48-address.h"
20
#include "mac48-address.h"
21
#include "ns3/address.h"
21
#include "ns3/address.h"
22
#include "ns3/assert.h"
22
#include "ns3/assert.h"
23
#include "ns3/uinteger.h"
24
#include "ns3/global-value.h"
23
#include <iomanip>
25
#include <iomanip>
24
#include <iostream>
26
#include <iostream>
25
#include <string.h>
27
#include <string.h>
26
28
29
static ns3::GlobalValue g_Mac48Origin ("Mac48Origin", 
30
                                   "The initial value the Mac48Address::Allocate helper will use.",
31
                                   ns3::UintegerValue (0),
32
                                   ns3::MakeUintegerChecker<uint64_t> ());
33
27
namespace ns3 {
34
namespace ns3 {
28
35
29
ATTRIBUTE_HELPER_CPP (Mac48Address);
36
ATTRIBUTE_HELPER_CPP (Mac48Address);
 Lines 118-124    Link Here 
118
Mac48Address 
125
Mac48Address 
119
Mac48Address::Allocate (void)
126
Mac48Address::Allocate (void)
120
{
127
{
121
  static uint64_t id = 0;
128
  UintegerValue value;
129
  g_Mac48Origin.GetValue (value);
130
  uint64_t id = value.Get();
131
  
122
  id++;
132
  id++;
123
  Mac48Address address;
133
  Mac48Address address;
124
  address.m_address[0] = (id >> 40) & 0xff;
134
  address.m_address[0] = (id >> 40) & 0xff;
 Lines 127-132    Link Here 
127
  address.m_address[3] = (id >> 16) & 0xff;
137
  address.m_address[3] = (id >> 16) & 0xff;
128
  address.m_address[4] = (id >> 8) & 0xff;
138
  address.m_address[4] = (id >> 8) & 0xff;
129
  address.m_address[5] = (id >> 0) & 0xff;
139
  address.m_address[5] = (id >> 0) & 0xff;
140
  
141
  value.Set(id);
142
  g_Mac48Origin.SetValue (value);
143
  
130
  return address;
144
  return address;
131
}
145
}
132
uint8_t 
146
uint8_t 

Return to bug 1192