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

(-)a/src/devices/bridge/bridge-net-device.cc (-3 / +3 lines)
 Lines 59-65   BridgeNetDevice::BridgeNetDevice () Link Here 
59
}
59
}
60
60
61
void
61
void
62
BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<Packet> packet, uint16_t protocol,
62
BridgeNetDevice::ReceiveFromDevice (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol,
63
                                    Address const &src, Address const &dst, PacketType packetType)
63
                                    Address const &src, Address const &dst, PacketType packetType)
64
{
64
{
65
  NS_LOG_FUNCTION_NOARGS ();
65
  NS_LOG_FUNCTION_NOARGS ();
 Lines 95-101   BridgeNetDevice::ReceiveFromDevice (Ptr< Link Here 
95
}
95
}
96
96
97
void
97
void
98
BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
98
BridgeNetDevice::ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
99
                                 uint16_t protocol, Mac48Address src, Mac48Address dst)
99
                                 uint16_t protocol, Mac48Address src, Mac48Address dst)
100
{
100
{
101
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
101
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
 Lines 128-134   BridgeNetDevice::ForwardUnicast (Ptr<Net Link Here 
128
}
128
}
129
129
130
void
130
void
131
BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
131
BridgeNetDevice::ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
132
                                        uint16_t protocol, Mac48Address src, Mac48Address dst)
132
                                        uint16_t protocol, Mac48Address src, Mac48Address dst)
133
{
133
{
134
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
134
  NS_LOG_DEBUG ("LearningBridgeForward (incomingPort=" << incomingPort->GetName ()
(-)a/src/devices/bridge/bridge-net-device.h (-3 / +3 lines)
 Lines 72-82   protected: Link Here 
72
protected:
72
protected:
73
  virtual void DoDispose (void);
73
  virtual void DoDispose (void);
74
74
75
  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
75
  void ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
76
                          Address const &source, Address const &destination, PacketType packetType);
76
                          Address const &source, Address const &destination, PacketType packetType);
77
  void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
77
  void ForwardUnicast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
78
                       uint16_t protocol, Mac48Address src, Mac48Address dst);
78
                       uint16_t protocol, Mac48Address src, Mac48Address dst);
79
  void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<Packet> packet,
79
  void ForwardBroadcast (Ptr<NetDevice> incomingPort, Ptr<const Packet> packet,
80
                         uint16_t protocol, Mac48Address src, Mac48Address dst);
80
                         uint16_t protocol, Mac48Address src, Mac48Address dst);
81
  void Learn (Mac48Address source, Ptr<NetDevice> port);
81
  void Learn (Mac48Address source, Ptr<NetDevice> port);
82
  Ptr<NetDevice> GetLearnedState (Mac48Address source);
82
  Ptr<NetDevice> GetLearnedState (Mac48Address source);
(-)a/src/internet-stack/arp-l3-protocol.cc (-1 / +3 lines)
 Lines 117-126   ArpL3Protocol::FindCache (Ptr<NetDevice> Link Here 
117
}
117
}
118
118
119
void 
119
void 
120
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
120
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
121
                       const Address &to, NetDevice::PacketType packetType)
121
                       const Address &to, NetDevice::PacketType packetType)
122
{
122
{
123
  NS_LOG_FUNCTION_NOARGS ();
123
  NS_LOG_FUNCTION_NOARGS ();
124
125
  Ptr<Packet> packet = p->Copy ();
124
126
125
  Ptr<ArpCache> cache = FindCache (device);
127
  Ptr<ArpCache> cache = FindCache (device);
126
  ArpHeader arp;
128
  ArpHeader arp;
(-)a/src/internet-stack/arp-l3-protocol.h (-1 / +1 lines)
 Lines 54-60   public: Link Here 
54
  /**
54
  /**
55
   * \brief Receive a packet
55
   * \brief Receive a packet
56
   */
56
   */
57
  void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from, const Address &to,
57
  void Receive(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, const Address &to,
58
               NetDevice::PacketType packetType);
58
               NetDevice::PacketType packetType);
59
  /**
59
  /**
60
   * \brief Perform an ARP lookup
60
   * \brief Perform an ARP lookup
(-)a/src/internet-stack/ipv4-l3-protocol.cc (-2 / +4 lines)
 Lines 449-460   Ipv4L3Protocol::FindInterfaceForDevice ( Link Here 
449
}  
449
}  
450
450
451
void 
451
void 
452
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
452
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
453
                         const Address &to, NetDevice::PacketType packetType)
453
                         const Address &to, NetDevice::PacketType packetType)
454
{
454
{
455
  NS_LOG_FUNCTION (this << &device << packet << protocol <<  from);
455
  NS_LOG_FUNCTION (this << &device << p << protocol <<  from);
456
456
457
  NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
457
  NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
458
459
  Ptr<Packet> packet = p->Copy ();
458
460
459
  uint32_t index = 0;
461
  uint32_t index = 0;
460
  Ptr<Ipv4Interface> ipv4Interface;
462
  Ptr<Ipv4Interface> ipv4Interface;
(-)a/src/internet-stack/ipv4-l3-protocol.h (-1 / +1 lines)
 Lines 83-89   public: Link Here 
83
   *    - implement a per-NetDevice ARP cache
83
   *    - implement a per-NetDevice ARP cache
84
   *    - send back arp replies on the right device
84
   *    - send back arp replies on the right device
85
   */
85
   */
86
  void Receive( Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from,
86
  void Receive( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
87
                const Address &to, NetDevice::PacketType packetType);
87
                const Address &to, NetDevice::PacketType packetType);
88
88
89
  /**
89
  /**
(-)a/src/node/net-device.h (-2 / +2 lines)
 Lines 274-280   public: Link Here 
274
   * \returns true if the callback could handle the packet successfully, false
274
   * \returns true if the callback could handle the packet successfully, false
275
   *          otherwise.
275
   *          otherwise.
276
   */
276
   */
277
  typedef Callback<bool,Ptr<NetDevice>,Ptr<Packet>,uint16_t,const Address &> ReceiveCallback;
277
  typedef Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &> ReceiveCallback;
278
278
279
  /**
279
  /**
280
   * \param cb callback to invoke whenever a packet has been received and must
280
   * \param cb callback to invoke whenever a packet has been received and must
 Lines 296-302   public: Link Here 
296
   * \returns true if the callback could handle the packet successfully, false
296
   * \returns true if the callback could handle the packet successfully, false
297
   *          otherwise.
297
   *          otherwise.
298
   */
298
   */
299
  typedef Callback< bool, Ptr<NetDevice>, Ptr<Packet>, uint16_t,
299
  typedef Callback< bool, Ptr<NetDevice>, Ptr<const Packet>, uint16_t,
300
                    const Address &, const Address &, PacketType > PromiscReceiveCallback;
300
                    const Address &, const Address &, PacketType > PromiscReceiveCallback;
301
301
302
  /**
302
  /**
(-)a/src/node/node.cc (-8 / +4 lines)
 Lines 222-228   Node::UnregisterProtocolHandler (Protoco Link Here 
222
}
222
}
223
223
224
bool
224
bool
225
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
225
Node::PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
226
                                const Address &from, const Address &to, NetDevice::PacketType packetType)
226
                                const Address &from, const Address &to, NetDevice::PacketType packetType)
227
{
227
{
228
  NS_LOG_FUNCTION(device->GetName ());
228
  NS_LOG_FUNCTION(device->GetName ());
 Lines 230-236   Node::PromiscReceiveFromDevice (Ptr<NetD Link Here 
230
}
230
}
231
231
232
bool
232
bool
233
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
233
Node::NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
234
                                   const Address &from)
234
                                   const Address &from)
235
{
235
{
236
  NS_LOG_FUNCTION(device->GetName ());
236
  NS_LOG_FUNCTION(device->GetName ());
 Lines 238-252   Node::NonPromiscReceiveFromDevice (Ptr<N Link Here 
238
}
238
}
239
239
240
bool
240
bool
241
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol,
241
Node::ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet> packet, uint16_t protocol,
242
                         const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
242
                         const Address &from, const Address &to, NetDevice::PacketType packetType, bool promiscuous)
243
{
243
{
244
  NS_LOG_FUNCTION(device->GetName ());
244
  NS_LOG_FUNCTION(device->GetName ());
245
  bool found = false;
245
  bool found = false;
246
  // if there are (potentially) multiple handlers, we need to copy the
247
  // packet before passing it to each handler, because handlers may
248
  // modify it.
249
  bool copyNeeded = (m_handlers.size () > 1);
250
246
251
  for (ProtocolHandlerList::iterator i = m_handlers.begin ();
247
  for (ProtocolHandlerList::iterator i = m_handlers.begin ();
252
       i != m_handlers.end (); i++)
248
       i != m_handlers.end (); i++)
 Lines 259-265   Node::ReceiveFromDevice (Ptr<NetDevice> Link Here 
259
            {
255
            {
260
              if (promiscuous == i->promiscuous)
256
              if (promiscuous == i->promiscuous)
261
                {
257
                {
262
                  i->handler (device, (copyNeeded ? packet->Copy () : packet), protocol, from, to, packetType);
258
                  i->handler (device, packet->Copy (), protocol, from, to, packetType);
263
                  found = true;
259
                  found = true;
264
                }
260
                }
265
            }
261
            }
(-)a/src/node/node.h (-4 / +4 lines)
 Lines 145-151   public: Link Here 
145
   *                   this value is only valid for promiscuous mode
145
   *                   this value is only valid for promiscuous mode
146
   *                   protocol handlers.
146
   *                   protocol handlers.
147
   */
147
   */
148
  typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,const Address &,
148
  typedef Callback<void,Ptr<NetDevice>, Ptr<const Packet>,uint16_t,const Address &,
149
                   const Address &, NetDevice::PacketType> ProtocolHandler;
149
                   const Address &, NetDevice::PacketType> ProtocolHandler;
150
  /**
150
  /**
151
   * \param handler the handler to register
151
   * \param handler the handler to register
 Lines 189-198   private: Link Here 
189
   */
189
   */
190
  virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
190
  virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
191
191
192
  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol, const Address &from);
192
  bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol, const Address &from);
193
  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
193
  bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
194
                                 const Address &from, const Address &to, NetDevice::PacketType packetType);
194
                                 const Address &from, const Address &to, NetDevice::PacketType packetType);
195
  bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
195
  bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<const Packet>, uint16_t protocol,
196
                          const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc);
196
                          const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc);
197
197
198
  void Construct (void);
198
  void Construct (void);
(-)a/src/node/packet-socket.cc (-2 / +2 lines)
 Lines 344-350   PacketSocket::SendTo (Ptr<Packet> p, uin Link Here 
344
}
344
}
345
345
346
void 
346
void 
347
PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
347
PacketSocket::ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet, 
348
                         uint16_t protocol, const Address &from,
348
                         uint16_t protocol, const Address &from,
349
                         const Address &to, NetDevice::PacketType packetType)
349
                         const Address &to, NetDevice::PacketType packetType)
350
{
350
{
 Lines 369-375   PacketSocket::ForwardUp (Ptr<NetDevice> Link Here 
369
      SocketAddressTag tag;
369
      SocketAddressTag tag;
370
      tag.SetAddress (address);
370
      tag.SetAddress (address);
371
      packet->AddTag (tag);
371
      packet->AddTag (tag);
372
      m_deliveryQueue.push (packet);
372
      m_deliveryQueue.push (packet->Copy ());
373
      m_rxAvailable += packet->GetSize ();
373
      m_rxAvailable += packet->GetSize ();
374
      NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this);
374
      NS_LOG_LOGIC ("UID is " << packet->GetUid() << " PacketSocket " << this);
375
      NotifyDataRecv ();
375
      NotifyDataRecv ();
(-)a/src/node/packet-socket.h (-1 / +1 lines)
 Lines 103-109   public: Link Here 
103
    Address &fromAddress);
103
    Address &fromAddress);
104
104
105
private:
105
private:
106
  void ForwardUp (Ptr<NetDevice> device, Ptr<Packet> packet, 
106
  void ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet, 
107
                  uint16_t protocol, const Address &from, const Address &to,
107
                  uint16_t protocol, const Address &from, const Address &to,
108
                  NetDevice::PacketType packetType);
108
                  NetDevice::PacketType packetType);
109
  int DoBind (const PacketSocketAddress &address);
109
  int DoBind (const PacketSocketAddress &address);

Return to bug 273