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

(-)a/src/internet/model/ipv6-end-point-demux.cc (+12 lines)
 Lines 195-200    Link Here 
195
          continue;
195
          continue;
196
        }
196
        }
197
197
198
      if (endP->GetBoundNetDevice ())
199
        {
200
          if (endP->GetBoundNetDevice () != incomingInterface->GetDevice ())
201
            {
202
              NS_LOG_LOGIC ("Skipping endpoint " << &endP
203
                                                 << " because endpoint is bound to specific device and"
204
                                                 << endP->GetBoundNetDevice ()
205
                                                 << " does not match packet device " << incomingInterface->GetDevice ());
206
              continue;
207
            }
208
        }
209
198
      /*    Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */
210
      /*    Ipv6Address incomingInterfaceAddr = incomingInterface->GetAddress (); */
199
      NS_LOG_DEBUG ("dest addr " << daddr);
211
      NS_LOG_DEBUG ("dest addr " << daddr);
200
212
(-)a/src/internet/model/ipv6-end-point.cc (+11 lines)
 Lines 84-89    Link Here 
84
  m_peerPort = port;
84
  m_peerPort = port;
85
}
85
}
86
86
87
void Ipv6EndPoint::BindToNetDevice (Ptr<NetDevice> netdevice)
88
{
89
  m_boundnetdevice = netdevice;
90
  return;
91
}
92
93
Ptr<NetDevice> Ipv6EndPoint::GetBoundNetDevice (void)
94
{
95
  return m_boundnetdevice;
96
}
97
87
void Ipv6EndPoint::SetRxCallback (Callback<void, Ptr<Packet>, Ipv6Address, Ipv6Address, uint16_t> callback)
98
void Ipv6EndPoint::SetRxCallback (Callback<void, Ptr<Packet>, Ipv6Address, Ipv6Address, uint16_t> callback)
88
{
99
{
89
  m_rxCallback = callback;
100
  m_rxCallback = callback;
(-)a/src/internet/model/ipv6-end-point.h (+38 lines)
 Lines 25-30    Link Here 
25
25
26
#include "ns3/ipv6-address.h"
26
#include "ns3/ipv6-address.h"
27
#include "ns3/callback.h"
27
#include "ns3/callback.h"
28
#include "ns3/net-device.h"
28
29
29
namespace ns3
30
namespace ns3
30
{
31
{
 Lines 95-100    Link Here 
95
  void SetPeer (Ipv6Address addr, uint16_t port);
96
  void SetPeer (Ipv6Address addr, uint16_t port);
96
97
97
  /**
98
  /**
99
   * \brief Bind a socket to specific device.
100
   *
101
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
102
   * of real network or BSD sockets.   If set on a socket, this option will
103
   * force packets to leave the bound device regardless of the device that
104
   * IP routing would naturally choose.  In the receive direction, only
105
   * packets received from the bound interface will be delivered.
106
   *
107
   * This option has no particular relationship to binding sockets to
108
   * an address via Socket::Bind ().  It is possible to bind sockets to a
109
   * specific IP address on the bound interface by calling both
110
   * Socket::Bind (address) and Socket::BindToNetDevice (device), but it
111
   * is also possible to bind to mismatching device and address, even if
112
   * the socket can not receive any packets as a result.
113
   *
114
   * \param netdevice Pointer to Netdevice of desired interface
115
   * \returns nothing
116
   */
117
  void BindToNetDevice (Ptr<NetDevice> netdevice);
118
119
  /**
120
   * \brief Returns socket's bound netdevice, if any.
121
   *
122
   * This method corresponds to using getsockopt() SO_BINDTODEVICE
123
   * of real network or BSD sockets.
124
   *
125
   *
126
   * \returns Pointer to interface.
127
   */
128
  Ptr<NetDevice> GetBoundNetDevice (void);
129
130
  /**
98
   * \brief Set the reception callback.
131
   * \brief Set the reception callback.
99
   * \param callback callback function
132
   * \param callback callback function
100
   */
133
   */
 Lines 175-180    Link Here 
175
  uint16_t m_peerPort;
208
  uint16_t m_peerPort;
176
209
177
  /**
210
  /**
211
   * \brief The NetDevice the EndPoint is bound to (if any).
212
   */
213
  Ptr<NetDevice> m_boundnetdevice;
214
215
  /**
178
   * \brief The RX callback.
216
   * \brief The RX callback.
179
   */
217
   */
180
  Callback<void, Ptr<Packet>, Ipv6Address, Ipv6Address, uint16_t> m_rxCallback;
218
  Callback<void, Ptr<Packet>, Ipv6Address, Ipv6Address, uint16_t> m_rxCallback;
(-)a/src/internet/model/ipv6-raw-socket-impl.cc (+16 lines)
 Lines 308-313    Link Here 
308
  return rx;
308
  return rx;
309
}
309
}
310
310
311
void Ipv6RawSocketImpl::BindToNetDevice (Ptr<NetDevice> netdevice)
312
{
313
  NS_LOG_FUNCTION (netdevice);
314
  Socket::BindToNetDevice (netdevice); // Includes sanity check
315
  return;
316
}
317
311
bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device)
318
bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device)
312
{
319
{
313
  NS_LOG_FUNCTION (this << *p << hdr << device);
320
  NS_LOG_FUNCTION (this << *p << hdr << device);
 Lines 317-322    Link Here 
317
      return false;
324
      return false;
318
    }
325
    }
319
326
327
  Ptr<NetDevice> boundNetDevice = Socket::GetBoundNetDevice();
328
  if (boundNetDevice)
329
    {
330
      if (boundNetDevice != device)
331
        {
332
          return false;
333
        }
334
    }
335
320
  if ((m_src == Ipv6Address::GetAny () || hdr.GetDestinationAddress () == m_src) && 
336
  if ((m_src == Ipv6Address::GetAny () || hdr.GetDestinationAddress () == m_src) && 
321
      (m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) &&
337
      (m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) &&
322
      hdr.GetNextHeader () == m_protocol)
338
      hdr.GetNextHeader () == m_protocol)
(-)a/src/internet/model/ipv6-raw-socket-impl.h (+21 lines)
 Lines 119-124    Link Here 
119
  virtual int Bind6 ();
119
  virtual int Bind6 ();
120
120
121
  /**
121
  /**
122
   * \brief Bind a socket to specific device.
123
   *
124
   * This method corresponds to using setsockopt() SO_BINDTODEVICE
125
   * of real network or BSD sockets.   If set on a socket, this option will
126
   * force packets to leave the bound device regardless of the device that
127
   * IP routing would naturally choose.  In the receive direction, only
128
   * packets received from the bound interface will be delivered.
129
   *
130
   * This option has no particular relationship to binding sockets to
131
   * an address via Socket::Bind ().  It is possible to bind sockets to a
132
   * specific IP address on the bound interface by calling both
133
   * Socket::Bind (address) and Socket::BindToNetDevice (device), but it
134
   * is also possible to bind to mismatching device and address, even if
135
   * the socket can not receive any packets as a result.
136
   *
137
   * \param netdevice Pointer to Netdevice of desired interface
138
   * \returns nothing
139
   */
140
  virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
141
142
  /**
122
   * \brief Get socket address.
143
   * \brief Get socket address.
123
   * \param address socket address if method success
144
   * \param address socket address if method success
124
   * \return 0 if success, -1 otherwise
145
   * \return 0 if success, -1 otherwise

Return to bug 1528