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

(-)a/examples/tap-wifi-dumbbell.cc (-1 / +1 lines)
 Lines 231-237   main (int argc, char *argv[]) Link Here 
231
  apps = sink.Install (nodesRight.Get (0));
231
  apps = sink.Install (nodesRight.Get (0));
232
  apps.Start (Seconds (1.0));
232
  apps.Start (Seconds (1.0));
233
233
234
  CsmaHelper::EnablePcapAll ("tap-dumbbell", false);
234
  CsmaHelper::EnablePcapAll ("tap-wifi-dumbbell", false);
235
  GlobalRouteManager::PopulateRoutingTables ();
235
  GlobalRouteManager::PopulateRoutingTables ();
236
236
237
  Simulator::Stop (Seconds (60.));
237
  Simulator::Stop (Seconds (60.));
(-)a/src/devices/bridge/bridge-net-device.cc (+7 lines)
 Lines 278-283   BridgeNetDevice::GetChannel (void) const Link Here 
278
  return m_channel;
278
  return m_channel;
279
}
279
}
280
280
281
void
282
BridgeNetDevice::SetAddress (Address address)
283
{
284
  NS_LOG_FUNCTION_NOARGS ();
285
  m_address = Mac48Address::ConvertFrom (address);
286
}
287
281
Address 
288
Address 
282
BridgeNetDevice::GetAddress (void) const
289
BridgeNetDevice::GetAddress (void) const
283
{
290
{
(-)a/src/devices/bridge/bridge-net-device.h (+1 lines)
 Lines 91-96   public: Link Here 
91
  virtual void SetIfIndex(const uint32_t index);
91
  virtual void SetIfIndex(const uint32_t index);
92
  virtual uint32_t GetIfIndex(void) const;
92
  virtual uint32_t GetIfIndex(void) const;
93
  virtual Ptr<Channel> GetChannel (void) const;
93
  virtual Ptr<Channel> GetChannel (void) const;
94
  virtual void SetAddress (Address address);
94
  virtual Address GetAddress (void) const;
95
  virtual Address GetAddress (void) const;
95
  virtual bool SetMtu (const uint16_t mtu);
96
  virtual bool SetMtu (const uint16_t mtu);
96
  virtual uint16_t GetMtu (void) const;
97
  virtual uint16_t GetMtu (void) const;
(-)a/src/devices/csma/csma-net-device.cc (-7 / +7 lines)
 Lines 319-331   CsmaNetDevice::GetFrameSize (void) const Link Here 
319
CsmaNetDevice::GetFrameSize (void) const
319
CsmaNetDevice::GetFrameSize (void) const
320
{
320
{
321
  return m_frameSize;
321
  return m_frameSize;
322
}
323
324
  void 
325
CsmaNetDevice::SetAddress (Mac48Address self)
326
{
327
  NS_LOG_FUNCTION (self);
328
  m_address = self;
329
}
322
}
330
323
331
  void
324
  void
 Lines 875-880   CsmaNetDevice::GetChannel (void) const Link Here 
875
  return m_channel;
868
  return m_channel;
876
}
869
}
877
870
871
  void
872
CsmaNetDevice::SetAddress (Address address)
873
{
874
  NS_LOG_FUNCTION_NOARGS ();
875
  m_address = Mac48Address::ConvertFrom (address);
876
}
877
878
  Address 
878
  Address 
879
CsmaNetDevice::GetAddress (void) const
879
CsmaNetDevice::GetAddress (void) const
880
{
880
{
(-)a/src/devices/csma/csma-net-device.h (-7 / +1 lines)
 Lines 183-195   public: Link Here 
183
  void SetReceiveEnable (bool enable);
183
  void SetReceiveEnable (bool enable);
184
184
185
  /**
185
  /**
186
   * Set the MAC address of the the network device.
187
   *
188
   * \param addr The Mac48Address to use as the address of the device.
189
   */
190
  void SetAddress (Mac48Address addr);
191
192
  /**
193
   * Set The max frame size of packets sent over this device.
186
   * Set The max frame size of packets sent over this device.
194
   *
187
   *
195
   * Okay, that was easy to say, but the details are a bit thorny.  We have a MAC-level MTU that is the payload that higher 
188
   * Okay, that was easy to say, but the details are a bit thorny.  We have a MAC-level MTU that is the payload that higher 
 Lines 310-315   public: Link Here 
310
  virtual Ptr<Channel> GetChannel (void) const;
303
  virtual Ptr<Channel> GetChannel (void) const;
311
  virtual bool SetMtu (const uint16_t mtu);
304
  virtual bool SetMtu (const uint16_t mtu);
312
  virtual uint16_t GetMtu (void) const;
305
  virtual uint16_t GetMtu (void) const;
306
  virtual void SetAddress (Address address);
313
  virtual Address GetAddress (void) const;
307
  virtual Address GetAddress (void) const;
314
  virtual bool IsLinkUp (void) const;
308
  virtual bool IsLinkUp (void) const;
315
  virtual void SetLinkChangeCallback (Callback<void> callback);
309
  virtual void SetLinkChangeCallback (Callback<void> callback);
(-)a/src/devices/emu/emu-net-device.cc (-3 / +3 lines)
 Lines 876-885   EmuNetDevice::GetChannel (void) const Link Here 
876
}
876
}
877
877
878
void 
878
void 
879
EmuNetDevice::SetAddress (Mac48Address addr)
879
EmuNetDevice::SetAddress (Address address)
880
{
880
{
881
  NS_LOG_FUNCTION (addr);
881
  NS_LOG_FUNCTION (address);
882
  m_address = addr;
882
  m_address = Mac48Address::ConvertFrom (address);
883
}
883
}
884
884
885
Address 
885
Address 
(-)a/src/devices/emu/emu-net-device.h (-8 / +2 lines)
 Lines 94-107   public: Link Here 
94
   */
94
   */
95
  void SetQueue (Ptr<Queue> queue);
95
  void SetQueue (Ptr<Queue> queue);
96
96
97
  /**
98
   * Assign a MAC address to this device.
99
   *
100
   * @see Mac48Address
101
   * @param addr The new address.
102
   */
103
  void SetAddress (Mac48Address addr);
104
105
//
97
//
106
// Pure virtual methods inherited from NetDevice we must implement.
98
// Pure virtual methods inherited from NetDevice we must implement.
107
//
99
//
 Lines 109-114   public: Link Here 
109
  virtual uint32_t GetIfIndex(void) const;
101
  virtual uint32_t GetIfIndex(void) const;
110
102
111
  virtual Ptr<Channel> GetChannel (void) const;
103
  virtual Ptr<Channel> GetChannel (void) const;
104
105
  virtual void SetAddress (Address address);
112
  virtual Address GetAddress (void) const;
106
  virtual Address GetAddress (void) const;
113
107
114
  virtual bool SetMtu (const uint16_t mtu);
108
  virtual bool SetMtu (const uint16_t mtu);
(-)a/src/devices/point-to-point/point-to-point-net-device.cc (-2 / +3 lines)
 Lines 395-404   PointToPointNetDevice::GetChannel (void) Link Here 
395
// information.  However, the base class NetDevice wants us to define the
395
// information.  However, the base class NetDevice wants us to define the
396
// methods to get and set the address.  Rather than be rude and assert, we let
396
// methods to get and set the address.  Rather than be rude and assert, we let
397
// clients get and set the address, but simply ignore them.
397
// clients get and set the address, but simply ignore them.
398
398
  void 
399
  void 
399
PointToPointNetDevice::SetAddress (Mac48Address addr)
400
PointToPointNetDevice::SetAddress (Address address)
400
{
401
{
401
  m_address = addr;
402
  m_address = Mac48Address::ConvertFrom (address);
402
}
403
}
403
404
404
  Address 
405
  Address 
(-)a/src/devices/point-to-point/point-to-point-net-device.h (-8 / +2 lines)
 Lines 132-145   public: Link Here 
132
  void Receive (Ptr<Packet> p);
132
  void Receive (Ptr<Packet> p);
133
133
134
  /**
134
  /**
135
   * Assign a MAC address to this device.
136
   *
137
   * @see Mac48Address
138
   * @param addr The new address.
139
   */
140
  void SetAddress (Mac48Address addr);
141
142
  /**
143
   * Set The max frame size of packets sent over this device.
135
   * Set The max frame size of packets sent over this device.
144
   *
136
   *
145
   * Okay, that was easy to say, but the details are a bit thorny.  We have a MAC-level MTU that is the payload that higher 
137
   * Okay, that was easy to say, but the details are a bit thorny.  We have a MAC-level MTU that is the payload that higher 
 Lines 230-235   public: Link Here 
230
  virtual uint32_t GetIfIndex(void) const;
222
  virtual uint32_t GetIfIndex(void) const;
231
223
232
  virtual Ptr<Channel> GetChannel (void) const;
224
  virtual Ptr<Channel> GetChannel (void) const;
225
226
  virtual void SetAddress (Address address);
233
  virtual Address GetAddress (void) const;
227
  virtual Address GetAddress (void) const;
234
228
235
  virtual bool SetMtu (const uint16_t mtu);
229
  virtual bool SetMtu (const uint16_t mtu);
(-)a/src/devices/tap-bridge/tap-bridge.cc (-46 / +45 lines)
 Lines 131-137   TapBridge::TapBridge () Link Here 
131
  m_startEvent (),
131
  m_startEvent (),
132
  m_stopEvent (),
132
  m_stopEvent (),
133
  m_readThread (0),
133
  m_readThread (0),
134
  m_learnedMac (Mac48Address ("ff:ff:ff:ff:ff:ff"))
134
  m_ns3AddressRewritten (false)
135
{
135
{
136
  NS_LOG_FUNCTION_NOARGS ();
136
  NS_LOG_FUNCTION_NOARGS ();
137
  Start (m_tStart);
137
  Start (m_tStart);
 Lines 641-647   TapBridge::ReadThread (void) Link Here 
641
          return;
641
          return;
642
        }
642
        }
643
643
644
      NS_LOG_INFO ("TapBridge::ReadThread(): Received packet");
644
      NS_LOG_INFO ("TapBridge::ReadThread(): Received packet on node " << m_node->GetId ());
645
      NS_LOG_INFO ("TapBridge::ReadThread(): Scheduling handler");
645
      NS_LOG_INFO ("TapBridge::ReadThread(): Scheduling handler");
646
      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (
646
      DynamicCast<RealtimeSimulatorImpl> (Simulator::GetImplementation ())->ScheduleRealtimeNow (
647
        MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
647
        MakeEvent (&TapBridge::ForwardToBridgedDevice, this, buf, len));
 Lines 713-733   TapBridge::ForwardToBridgedDevice (uint8 Link Here 
713
      //
713
      //
714
      NS_ASSERT_MSG (Mac48Address::ConvertFrom (src) != Mac48Address ("ff:ff:ff:ff:ff:ff"), 
714
      NS_ASSERT_MSG (Mac48Address::ConvertFrom (src) != Mac48Address ("ff:ff:ff:ff:ff:ff"), 
715
                     "TapBridge::ForwardToBridgedDevice:  Source addr is broadcast");
715
                     "TapBridge::ForwardToBridgedDevice:  Source addr is broadcast");
716
      //
716
      if (m_ns3AddressRewritten == false)
717
      // Remember the Mac address since we are going to spoof it when we go
717
        {
718
      // the other way.
718
          //
719
      //
719
          // Set the ns-3 device's mac address to the overlying container's
720
      m_learnedMac = Mac48Address::ConvertFrom (src);
720
          // mac address
721
      NS_LOG_LOGIC ("Learned MacAddr is " << m_learnedMac);
721
          //
722
722
          Mac48Address learnedMac = Mac48Address::ConvertFrom (src);
723
          NS_LOG_LOGIC ("Learned MacAddr is " << learnedMac << ": setting ns-3 device to use this address");
724
          m_bridgedDevice->SetAddress (Mac48Address::ConvertFrom (learnedMac));
725
          m_ns3AddressRewritten = true;
726
        }
723
      // 
727
      // 
724
      // If we are operating in USE_LOCAL mode, we may be attached to an ns-3
728
      // If we are operating in USE_LOCAL mode, we may be attached to an ns-3
725
      // device that does not support bridging (SupportsSendFrom returns false).
729
      // device that does not support bridging (SupportsSendFrom returns false).
726
      // The whole point of this mode is really to support this case.  We allow
730
      // But, since the mac addresses are now aligned, we can call Send()
727
      // only packets from one source MAC to flow across the TapBridge in this 
728
      // mode and will spoof that address when packets flow the other way.  
729
      // Since we will be doing this spoofing, we can relax the normal bridged
730
      // device requirement to support SendFrom and use Send.
731
      //
731
      //
732
      NS_LOG_LOGIC ("Forwarding packet to ns-3 device via Send()");
732
      NS_LOG_LOGIC ("Forwarding packet to ns-3 device via Send()");
733
      m_bridgedDevice->Send (packet, dst, type);
733
      m_bridgedDevice->Send (packet, dst, type);
 Lines 864-883   TapBridge::SetBridgedNetDevice (Ptr<NetD Link Here 
864
    }
864
    }
865
865
866
  //
866
  //
867
  // Tell the bridged device to forward its received packets here.  We use the 
867
  // We need to disconnect the bridged device from the internet stack on our
868
  // promiscuous mode hook to get both the source and destination addresses.
868
  // node to ensure that only one stack responds to packets inbound over the
869
  // bridged device.  That one stack lives outside ns-3 so we just blatantly
870
  // steal the device callbacks.
869
  //
871
  //
870
  m_node->RegisterProtocolHandler (MakeCallback (&TapBridge::ReceiveFromBridgedDevice, this), 0, bridgedDevice, true);
872
  // N.B This can be undone if someone does a RegisterProtocolHandler later 
873
  // on this node.
874
  //
875
  bridgedDevice->SetReceiveCallback (MakeCallback (&TapBridge::DiscardFromBridgedDevice, this));
876
  bridgedDevice->SetPromiscReceiveCallback (MakeCallback (&TapBridge::ReceiveFromBridgedDevice, this));
871
  m_bridgedDevice = bridgedDevice;
877
  m_bridgedDevice = bridgedDevice;
872
}
878
}
873
879
874
void
880
bool
881
TapBridge::DiscardFromBridgedDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, const Address &src)
882
{
883
  NS_LOG_FUNCTION (device << packet << protocol << src);
884
  NS_LOG_LOGIC ("Discarding packet stolen from bridged device " << device);
885
  return true;
886
}
887
888
bool
875
TapBridge::ReceiveFromBridgedDevice (
889
TapBridge::ReceiveFromBridgedDevice (
876
  Ptr<NetDevice> device, 
890
  Ptr<NetDevice> device, 
877
  Ptr<const Packet> packet, 
891
  Ptr<const Packet> packet, 
878
  uint16_t protocol,
892
  uint16_t protocol,
879
  Address const &src, 
893
  const Address &src, 
880
  Address const &dst, 
894
  const Address &dst, 
881
  PacketType packetType)
895
  PacketType packetType)
882
{
896
{
883
  NS_LOG_FUNCTION (device << packet << protocol << src << dst << packetType);
897
  NS_LOG_FUNCTION (device << packet << protocol << src << dst << packetType);
 Lines 913-947   TapBridge::ReceiveFromBridgedDevice ( Link Here 
913
      // we want to act like a bridge and forward these PACKET_OTHERHOST 
927
      // we want to act like a bridge and forward these PACKET_OTHERHOST 
914
      // packets.
928
      // packets.
915
      //
929
      //
916
      return;
930
      return true;
917
    }
931
    }
918
932
919
  //
920
  // We have received a packet from the ns-3 net device that has been associated
921
  // with this bridge.  We want to take these bits and send them off to the tap
922
  // device on the Linux host.  The only question we have to answer is, what 
923
  // should the destination address be?
924
  //
925
  // If we are in CONFIGURE_LOCAL mode, then the destination address is just
926
  // left alone since it can only be the shared single MAC address, broadcast
927
  // or multicast.
928
  //
929
  // If we are in USE_LOCAL mode, then we need to spoof the destination 
930
  // address with the one we saved.
931
  //
932
  // If we are in USE_BRIDGE mode, then we need to do the equvalent of a 
933
  // SendFrom and leave the source and destination alone.
934
  //
935
  Mac48Address from = Mac48Address::ConvertFrom (src);
933
  Mac48Address from = Mac48Address::ConvertFrom (src);
936
  Mac48Address to;
934
  Mac48Address to = Mac48Address::ConvertFrom (dst);
937
  if (m_mode == USE_LOCAL)
938
    {
939
      to = Mac48Address::ConvertFrom (m_learnedMac);
940
    }
941
  else 
942
    {
943
      to = Mac48Address::ConvertFrom (dst);
944
    }
945
935
946
  Ptr<Packet> p = packet->Copy ();
936
  Ptr<Packet> p = packet->Copy ();
947
  EthernetHeader header = EthernetHeader (false);
937
  EthernetHeader header = EthernetHeader (false);
 Lines 956-964   TapBridge::ReceiveFromBridgedDevice ( Link Here 
956
  NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
946
  NS_LOG_LOGIC ("Pkt destination is " << header.GetDestination ());
957
  NS_LOG_LOGIC ("Pkt LengthType is " << header.GetLengthType ());
947
  NS_LOG_LOGIC ("Pkt LengthType is " << header.GetLengthType ());
958
  NS_LOG_LOGIC ("Pkt size is " << p->GetSize ());
948
  NS_LOG_LOGIC ("Pkt size is " << p->GetSize ());
949
  NS_LOG_LOGIC ("End of receive packet handling on node " << m_node->GetId ());
959
950
960
  uint32_t bytesWritten = write (m_sock, p->PeekData (), p->GetSize ());
951
  uint32_t bytesWritten = write (m_sock, p->PeekData (), p->GetSize ());
961
  NS_ABORT_MSG_IF (bytesWritten != p->GetSize (), "TapBridge::ReceiveFromBridgedDevice(): Write error.");
952
  NS_ABORT_MSG_IF (bytesWritten != p->GetSize (), "TapBridge::ReceiveFromBridgedDevice(): Write error.");
953
  return true;
962
}
954
}
963
955
964
void 
956
void 
 Lines 980-985   TapBridge::GetChannel (void) const Link Here 
980
{
972
{
981
  NS_LOG_FUNCTION_NOARGS ();
973
  NS_LOG_FUNCTION_NOARGS ();
982
  return 0;
974
  return 0;
975
}
976
977
void
978
TapBridge::SetAddress (Address address)
979
{
980
  NS_LOG_FUNCTION (address);
981
  m_address = Mac48Address::ConvertFrom (address);
983
}
982
}
984
983
985
Address 
984
Address 
(-)a/src/devices/tap-bridge/tap-bridge.h (-7 / +8 lines)
 Lines 176-181   public: Link Here 
176
  virtual void SetIfIndex(const uint32_t index);
176
  virtual void SetIfIndex(const uint32_t index);
177
  virtual uint32_t GetIfIndex(void) const;
177
  virtual uint32_t GetIfIndex(void) const;
178
  virtual Ptr<Channel> GetChannel (void) const;
178
  virtual Ptr<Channel> GetChannel (void) const;
179
  virtual void SetAddress (Address address);
179
  virtual Address GetAddress (void) const;
180
  virtual Address GetAddress (void) const;
180
  virtual bool SetMtu (const uint16_t mtu);
181
  virtual bool SetMtu (const uint16_t mtu);
181
  virtual uint16_t GetMtu (void) const;
182
  virtual uint16_t GetMtu (void) const;
 Lines 208-215   protected: Link Here 
208
   */
209
   */
209
  virtual void DoDispose (void);
210
  virtual void DoDispose (void);
210
211
211
  void ReceiveFromBridgedDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
212
  bool ReceiveFromBridgedDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
212
                                 Address const &src, Address const &dst, PacketType packetType);
213
                                 Address const &src, Address const &dst, PacketType packetType);
214
215
  bool DiscardFromBridgedDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol, Address const &src);
216
213
private:
217
private:
214
218
215
  /**
219
  /**
 Lines 443-455   private: Link Here 
443
  /**
447
  /**
444
   * \internal
448
   * \internal
445
   *
449
   *
446
   * The MAC address of the local tap device is stored in this variable.
450
   * Whether the MAC address of the underlying ns-3 device has already been
447
   * When in UseLocal mode, this address is added back to the destination 
451
   * rewritten is stored in this variable (for UseLocal mode only).
448
   * Mac address for frames destined to the tap device.  It is learned from
449
   * the first frame sent from the host to the TapBridge device.  In the
450
   * other modes of this device, this value is unused.  
451
   */
452
   */
452
  Mac48Address m_learnedMac;
453
  bool m_ns3AddressRewritten;
453
454
454
};
455
};
455
456
(-)a/src/devices/virtual-net-device/virtual-net-device.h (-7 / +1 lines)
 Lines 114-130   public: Link Here 
114
                PacketType packetType);
114
                PacketType packetType);
115
115
116
116
117
  /**
118
   * Set the MAC address of the the network device.
119
   *
120
   * \param addr The Address to use as the address of the device.
121
   */
122
  void SetAddress (Address addr);
123
124
  // inherited from NetDevice base class.
117
  // inherited from NetDevice base class.
125
  virtual void SetIfIndex(const uint32_t index);
118
  virtual void SetIfIndex(const uint32_t index);
126
  virtual uint32_t GetIfIndex(void) const;
119
  virtual uint32_t GetIfIndex(void) const;
127
  virtual Ptr<Channel> GetChannel (void) const;
120
  virtual Ptr<Channel> GetChannel (void) const;
121
  virtual void SetAddress (Address address);
128
  virtual Address GetAddress (void) const;
122
  virtual Address GetAddress (void) const;
129
  virtual uint16_t GetMtu (void) const;
123
  virtual uint16_t GetMtu (void) const;
130
  virtual bool IsLinkUp (void) const;
124
  virtual bool IsLinkUp (void) const;
(-)a/src/devices/wifi/wifi-net-device.cc (+5 lines)
 Lines 156-161   WifiNetDevice::DoGetChannel (void) const Link Here 
156
WifiNetDevice::DoGetChannel (void) const
156
WifiNetDevice::DoGetChannel (void) const
157
{
157
{
158
  return m_phy->GetChannel ();
158
  return m_phy->GetChannel ();
159
}
160
void 
161
WifiNetDevice::SetAddress (Address address)
162
{
163
  m_mac->SetAddress (Mac48Address::ConvertFrom (address));
159
}
164
}
160
Address 
165
Address 
161
WifiNetDevice::GetAddress (void) const
166
WifiNetDevice::GetAddress (void) const
(-)a/src/devices/wifi/wifi-net-device.h (+1 lines)
 Lines 78-83   public: Link Here 
78
  virtual void SetIfIndex(const uint32_t index);
78
  virtual void SetIfIndex(const uint32_t index);
79
  virtual uint32_t GetIfIndex(void) const;
79
  virtual uint32_t GetIfIndex(void) const;
80
  virtual Ptr<Channel> GetChannel (void) const;
80
  virtual Ptr<Channel> GetChannel (void) const;
81
  virtual void SetAddress (Address address);
81
  virtual Address GetAddress (void) const;
82
  virtual Address GetAddress (void) const;
82
  virtual bool SetMtu (const uint16_t mtu);
83
  virtual bool SetMtu (const uint16_t mtu);
83
  virtual uint16_t GetMtu (void) const;
84
  virtual uint16_t GetMtu (void) const;
(-)a/src/internet-stack/icmpv4.h (-1 / +1 lines)
 Lines 64-70   private: Link Here 
64
private:
64
private:
65
  uint16_t m_identifier;
65
  uint16_t m_identifier;
66
  uint16_t m_sequence;
66
  uint16_t m_sequence;
67
  uint8_t m_data[16];
67
  uint8_t m_data[64];
68
  uint32_t m_dataSize;
68
  uint32_t m_dataSize;
69
};
69
};
70
70
(-)a/src/internet-stack/loopback-net-device.cc (+6 lines)
 Lines 91-96   LoopbackNetDevice::GetChannel (void) con Link Here 
91
LoopbackNetDevice::GetChannel (void) const
91
LoopbackNetDevice::GetChannel (void) const
92
{
92
{
93
  return 0;
93
  return 0;
94
}
95
96
void 
97
LoopbackNetDevice::SetAddress (Address address)
98
{
99
  m_address = Mac48Address::ConvertFrom (address);
94
}
100
}
95
101
96
Address 
102
Address 
(-)a/src/internet-stack/loopback-net-device.h (+1 lines)
 Lines 45-50   public: Link Here 
45
  virtual void SetIfIndex(const uint32_t index);
45
  virtual void SetIfIndex(const uint32_t index);
46
  virtual uint32_t GetIfIndex(void) const;
46
  virtual uint32_t GetIfIndex(void) const;
47
  virtual Ptr<Channel> GetChannel (void) const;
47
  virtual Ptr<Channel> GetChannel (void) const;
48
  virtual void SetAddress (Address address);
48
  virtual Address GetAddress (void) const;
49
  virtual Address GetAddress (void) const;
49
  virtual bool SetMtu (const uint16_t mtu);
50
  virtual bool SetMtu (const uint16_t mtu);
50
  virtual uint16_t GetMtu (void) const;
51
  virtual uint16_t GetMtu (void) const;
(-)a/src/internet-stack/tcp-test.cc (-1 / +1 lines)
 Lines 303-309   TcpSocketImplTest::AddSimpleNetDevice (P Link Here 
303
TcpSocketImplTest::AddSimpleNetDevice (Ptr<Node> node, const char* ipaddr, const char* netmask)
303
TcpSocketImplTest::AddSimpleNetDevice (Ptr<Node> node, const char* ipaddr, const char* netmask)
304
{
304
{
305
  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
305
  Ptr<SimpleNetDevice> dev = CreateObject<SimpleNetDevice> ();
306
  dev->SetAddress (Mac48Address::Allocate ());
306
  dev->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
307
  node->AddDevice (dev);
307
  node->AddDevice (dev);
308
  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
308
  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
309
  uint32_t ndid = ipv4->AddInterface (dev);
309
  uint32_t ndid = ipv4->AddInterface (dev);
(-)a/src/internet-stack/udp-test.cc (-4 / +4 lines)
 Lines 136-142   UdpSocketImplTest::RunTests (void) Link Here 
136
  Ptr<SimpleNetDevice> rxDev1, rxDev2;
136
  Ptr<SimpleNetDevice> rxDev1, rxDev2;
137
  { // first interface
137
  { // first interface
138
    rxDev1 = CreateObject<SimpleNetDevice> ();
138
    rxDev1 = CreateObject<SimpleNetDevice> ();
139
    rxDev1->SetAddress (Mac48Address::Allocate ());
139
    rxDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
140
    rxNode->AddDevice (rxDev1);
140
    rxNode->AddDevice (rxDev1);
141
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
141
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
142
    uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
142
    uint32_t netdev_idx = ipv4->AddInterface (rxDev1);
 Lines 147-153   UdpSocketImplTest::RunTests (void) Link Here 
147
147
148
  { // second interface
148
  { // second interface
149
    rxDev2 = CreateObject<SimpleNetDevice> ();
149
    rxDev2 = CreateObject<SimpleNetDevice> ();
150
    rxDev2->SetAddress (Mac48Address::Allocate ());
150
    rxDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
151
    rxNode->AddDevice (rxDev2);
151
    rxNode->AddDevice (rxDev2);
152
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
152
    Ptr<Ipv4> ipv4 = rxNode->GetObject<Ipv4> ();
153
    uint32_t netdev_idx = ipv4->AddInterface (rxDev2);
153
    uint32_t netdev_idx = ipv4->AddInterface (rxDev2);
 Lines 162-168   UdpSocketImplTest::RunTests (void) Link Here 
162
  Ptr<SimpleNetDevice> txDev1;
162
  Ptr<SimpleNetDevice> txDev1;
163
  {
163
  {
164
    txDev1 = CreateObject<SimpleNetDevice> ();
164
    txDev1 = CreateObject<SimpleNetDevice> ();
165
    txDev1->SetAddress (Mac48Address::Allocate ());
165
    txDev1->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
166
    txNode->AddDevice (txDev1);
166
    txNode->AddDevice (txDev1);
167
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
167
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
168
    uint32_t netdev_idx = ipv4->AddInterface (txDev1);
168
    uint32_t netdev_idx = ipv4->AddInterface (txDev1);
 Lines 173-179   UdpSocketImplTest::RunTests (void) Link Here 
173
  Ptr<SimpleNetDevice> txDev2;
173
  Ptr<SimpleNetDevice> txDev2;
174
  {
174
  {
175
    txDev2 = CreateObject<SimpleNetDevice> ();
175
    txDev2 = CreateObject<SimpleNetDevice> ();
176
    txDev2->SetAddress (Mac48Address::Allocate ());
176
    txDev2->SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
177
    txNode->AddDevice (txDev2);
177
    txNode->AddDevice (txDev2);
178
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
178
    Ptr<Ipv4> ipv4 = txNode->GetObject<Ipv4> ();
179
    uint32_t netdev_idx = ipv4->AddInterface (txDev2);
179
    uint32_t netdev_idx = ipv4->AddInterface (txDev2);
(-)a/src/node/net-device.h (+6 lines)
 Lines 98-106   public: Link Here 
98
  virtual Ptr<Channel> GetChannel (void) const = 0;
98
  virtual Ptr<Channel> GetChannel (void) const = 0;
99
99
100
  /**
100
  /**
101
   * Set the address of this interface
102
   */
103
  virtual void SetAddress (Address address) = 0;
104
105
  /**
101
   * \return the current Address of this interface.
106
   * \return the current Address of this interface.
102
   */
107
   */
103
  virtual Address GetAddress (void) const = 0;
108
  virtual Address GetAddress (void) const = 0;
109
104
  /**
110
  /**
105
   * \param mtu MTU value, in bytes, to set for the device
111
   * \param mtu MTU value, in bytes, to set for the device
106
   * \return whether the MTU value was within legal bounds
112
   * \return whether the MTU value was within legal bounds
(-)a/src/node/node.cc (-13 / +2 lines)
 Lines 185-207   Node::RegisterProtocolHandler (ProtocolH Link Here 
185
               i != m_devices.end (); i++)
185
               i != m_devices.end (); i++)
186
            {
186
            {
187
              Ptr<NetDevice> dev = *i;
187
              Ptr<NetDevice> dev = *i;
188
              if (dev->SupportsSendFrom ())
188
              dev->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this));
189
                {
190
                  dev->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this));
191
                }
192
            }
189
            }
193
        }
190
        }
194
      else
191
      else
195
        {
192
        {
196
          if (device->SupportsSendFrom ())
193
          device->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this));
197
            {
198
              device->SetPromiscReceiveCallback (MakeCallback (&Node::PromiscReceiveFromDevice, this));
199
            }
200
          else
201
            {
202
              NS_LOG_WARN ("Protocol handler request promiscuous mode for a specific netdevice,"
203
                           " but netdevice does not support promiscuous mode.");
204
            }
205
        }
194
        }
206
    }
195
    }
207
196
(-)a/src/node/simple-net-device.cc (-6 / +8 lines)
 Lines 77-88   SimpleNetDevice::SetChannel (Ptr<SimpleC Link Here 
77
}
77
}
78
78
79
void 
79
void 
80
SimpleNetDevice::SetAddress (Mac48Address address)
81
{
82
  m_address = address;
83
}
84
85
void 
86
SimpleNetDevice::SetIfIndex(const uint32_t index)
80
SimpleNetDevice::SetIfIndex(const uint32_t index)
87
{
81
{
88
  m_ifIndex = index;
82
  m_ifIndex = index;
 Lines 97-105   SimpleNetDevice::GetChannel (void) const Link Here 
97
{
91
{
98
  return m_channel;
92
  return m_channel;
99
}
93
}
94
void
95
SimpleNetDevice::SetAddress (Address address)
96
{
97
  m_address = Mac48Address::ConvertFrom(address);
98
}
100
Address 
99
Address 
101
SimpleNetDevice::GetAddress (void) const
100
SimpleNetDevice::GetAddress (void) const
102
{
101
{
102
  //
103
  // Implicit conversion from Mac48Address to Address
104
  //
103
  return m_address;
105
  return m_address;
104
}
106
}
105
bool 
107
bool 
(-)a/src/node/simple-net-device.h (-1 / +1 lines)
 Lines 43-54   public: Link Here 
43
43
44
  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
44
  void Receive (Ptr<Packet> packet, uint16_t protocol, Mac48Address to, Mac48Address from);
45
  void SetChannel (Ptr<SimpleChannel> channel);
45
  void SetChannel (Ptr<SimpleChannel> channel);
46
  void SetAddress (Mac48Address address);
47
46
48
  // inherited from NetDevice base class.
47
  // inherited from NetDevice base class.
49
  virtual void SetIfIndex(const uint32_t index);
48
  virtual void SetIfIndex(const uint32_t index);
50
  virtual uint32_t GetIfIndex(void) const;
49
  virtual uint32_t GetIfIndex(void) const;
51
  virtual Ptr<Channel> GetChannel (void) const;
50
  virtual Ptr<Channel> GetChannel (void) const;
51
  virtual void SetAddress (Address address);
52
  virtual Address GetAddress (void) const;
52
  virtual Address GetAddress (void) const;
53
  virtual bool SetMtu (const uint16_t mtu);
53
  virtual bool SetMtu (const uint16_t mtu);
54
  virtual uint16_t GetMtu (void) const;
54
  virtual uint16_t GetMtu (void) const;

Return to bug 569