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

(-)a/src/click/model/ipv4-l3-click-protocol.cc (+57 lines)
 Lines 678-683    Link Here 
678
  return;
678
  return;
679
}
679
}
680
680
681
void 
682
Ipv4L3ClickProtocol::SendWithHeader (Ptr<Packet> packet, 
683
                                Ipv4Header ipHeader,
684
                                Ptr<Ipv4Route> route)
685
{
686
  NS_LOG_FUNCTION (this << packet << ipHeader << route);
687
688
  Ptr<Ipv4ClickRouting> click = DynamicCast<Ipv4ClickRouting> (m_routingProtocol);
689
  if (Node::ChecksumEnabled ())
690
    {
691
      ipHeader.EnableChecksum ();
692
    }
693
  packet->AddHeader (ipHeader);
694
  click->Send (packet->Copy (), ipHeader.GetSource (), ipHeader.GetDestination ());
695
}
696
681
void
697
void
682
Ipv4L3ClickProtocol::SendDown (Ptr<Packet> p, int ifid)
698
Ipv4L3ClickProtocol::SendDown (Ptr<Packet> p, int ifid)
683
{
699
{
 Lines 716-721    Link Here 
716
                               const Address &to, NetDevice::PacketType packetType)
732
                               const Address &to, NetDevice::PacketType packetType)
717
{
733
{
718
  NS_LOG_FUNCTION (this << device << p << from << to);
734
  NS_LOG_FUNCTION (this << device << p << from << to);
735
  Ptr<Packet> packetForRawSocket = p->Copy ();
736
737
  if (protocol == Ipv4L3ClickProtocol::PROT_NUMBER)
738
    {
739
      uint32_t interface = 0;
740
      Ptr<Ipv4Interface> ipv4Interface;
741
      for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); 
742
           i != m_interfaces.end (); 
743
           i++, interface++)
744
        {
745
          ipv4Interface = *i;
746
          if (ipv4Interface->GetDevice () == device)
747
            {
748
              if (ipv4Interface->IsUp ())
749
                {
750
                  break;
751
                }
752
              else
753
                {
754
                  NS_LOG_LOGIC ("Dropping received packet -- interface is down");
755
                  return;
756
                }
757
            }
758
        }
759
760
      Ipv4Header ipHeader;
761
      if (Node::ChecksumEnabled ())
762
        {
763
          ipHeader.EnableChecksum ();
764
        }
765
      packetForRawSocket->RemoveHeader (ipHeader);
766
767
      
768
      for (SocketList::iterator i = m_sockets.begin (); i != m_sockets.end (); ++i)
769
        {
770
          NS_LOG_LOGIC ("Forwarding to raw socket"); 
771
          Ptr<Ipv4RawSocketImpl> socket = *i;
772
          socket->ForwardUp (packetForRawSocket, ipHeader, ipv4Interface);
773
        }
774
    }
775
719
  Ptr<Packet> packet = p->Copy ();
776
  Ptr<Packet> packet = p->Copy ();
720
777
721
  // Add an ethernet frame. This allows
778
  // Add an ethernet frame. This allows
(-)a/src/click/model/ipv4-l3-click-protocol.h (+3 lines)
 Lines 116-121    Link Here 
116
  void Send (Ptr<Packet> packet, Ipv4Address source,
116
  void Send (Ptr<Packet> packet, Ipv4Address source,
117
             Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route);
117
             Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route);
118
118
119
  
120
  void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route);
121
119
  /**
122
  /**
120
   * \param packet packet to send down the stack
123
   * \param packet packet to send down the stack
121
   * \param ifid interface to be used for sending down packet
124
   * \param ifid interface to be used for sending down packet
(-)a/src/internet/model/icmpv4-l4-protocol.cc (-4 / +4 lines)
 Lines 56-69    Link Here 
56
      Ptr<Node> node = this->GetObject<Node> ();
56
      Ptr<Node> node = this->GetObject<Node> ();
57
      if (node != 0)
57
      if (node != 0)
58
        {
58
        {
59
          Ptr<Ipv4L3Protocol> ipv4 = this->GetObject<Ipv4L3Protocol> ();
59
          Ptr<Ipv4> ipv4 = this->GetObject<Ipv4> ();
60
          if (ipv4 != 0 && m_downTarget.IsNull ())
60
          if (ipv4 != 0 && m_downTarget.IsNull ())
61
            {
61
            {
62
              this->SetNode (node);
62
              this->SetNode (node);
63
              ipv4->Insert (this);
63
              ipv4->Insert (this);
64
              Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
64
              Ptr<Ipv4RawSocketFactoryImpl> rawFactory = CreateObject<Ipv4RawSocketFactoryImpl> ();
65
              ipv4->AggregateObject (rawFactory);
65
              ipv4->AggregateObject (rawFactory);
66
              this->SetDownTarget (MakeCallback (&Ipv4L3Protocol::Send, ipv4));
66
              this->SetDownTarget (MakeCallback (&Ipv4::Send, ipv4));
67
            }
67
            }
68
        }
68
        }
69
    }
69
    }
 Lines 84-90    Link Here 
84
void
84
void
85
Icmpv4L4Protocol::SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code)
85
Icmpv4L4Protocol::SendMessage (Ptr<Packet> packet, Ipv4Address dest, uint8_t type, uint8_t code)
86
{
86
{
87
  Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
87
  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
88
  NS_ASSERT (ipv4 != 0 && ipv4->GetRoutingProtocol () != 0);
88
  NS_ASSERT (ipv4 != 0 && ipv4->GetRoutingProtocol () != 0);
89
  Ipv4Header header;
89
  Ipv4Header header;
90
  header.SetDestination (dest);
90
  header.SetDestination (dest);
 Lines 179-185    Link Here 
179
                           uint32_t info, Ipv4Header ipHeader,
179
                           uint32_t info, Ipv4Header ipHeader,
180
                           const uint8_t payload[8])
180
                           const uint8_t payload[8])
181
{
181
{
182
  Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
182
  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
183
  Ptr<IpL4Protocol> l4 = ipv4->GetProtocol (ipHeader.GetProtocol ());
183
  Ptr<IpL4Protocol> l4 = ipv4->GetProtocol (ipHeader.GetProtocol ());
184
  if (l4 != 0)
184
  if (l4 != 0)
185
    {
185
    {
(-)a/src/internet/model/ipv4-raw-socket-factory-impl.cc (-1 / +1 lines)
 Lines 28-34    Link Here 
28
Ptr<Socket> 
28
Ptr<Socket> 
29
Ipv4RawSocketFactoryImpl::CreateSocket (void)
29
Ipv4RawSocketFactoryImpl::CreateSocket (void)
30
{
30
{
31
  Ptr<Ipv4L3Protocol> ipv4 = GetObject<Ipv4L3Protocol> ();
31
  Ptr<Ipv4> ipv4 = GetObject<Ipv4> ();
32
  Ptr<Socket> socket = ipv4->CreateRawSocket ();
32
  Ptr<Socket> socket = ipv4->CreateRawSocket ();
33
  return socket;
33
  return socket;
34
}
34
}
(-)a/src/internet/model/ipv4-raw-socket-impl.cc (-2 / +2 lines)
 Lines 130-136    Link Here 
130
Ipv4RawSocketImpl::Close (void)
130
Ipv4RawSocketImpl::Close (void)
131
{
131
{
132
  NS_LOG_FUNCTION (this);
132
  NS_LOG_FUNCTION (this);
133
  Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
133
  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
134
  if (ipv4 != 0)
134
  if (ipv4 != 0)
135
    {
135
    {
136
      ipv4->DeleteRawSocket (this);
136
      ipv4->DeleteRawSocket (this);
 Lines 199-205    Link Here 
199
      return 0;
199
      return 0;
200
    }
200
    }
201
  InetSocketAddress ad = InetSocketAddress::ConvertFrom (toAddress);
201
  InetSocketAddress ad = InetSocketAddress::ConvertFrom (toAddress);
202
  Ptr<Ipv4L3Protocol> ipv4 = m_node->GetObject<Ipv4L3Protocol> ();
202
  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
203
  Ipv4Address dst = ad.GetIpv4 ();
203
  Ipv4Address dst = ad.GetIpv4 ();
204
  Ipv4Address src = m_src;
204
  Ipv4Address src = m_src;
205
  if (ipv4->GetRoutingProtocol ())
205
  if (ipv4->GetRoutingProtocol ())
(-)a/src/internet/model/ipv4.h (+17 lines)
 Lines 143-148    Link Here 
143
  virtual void Send (Ptr<Packet> packet, Ipv4Address source,
143
  virtual void Send (Ptr<Packet> packet, Ipv4Address source,
144
                     Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route) = 0;
144
                     Ipv4Address destination, uint8_t protocol, Ptr<Ipv4Route> route) = 0;
145
145
146
  virtual void SendWithHeader (Ptr<Packet> packet, Ipv4Header ipHeader, Ptr<Ipv4Route> route) = 0;
147
146
  /**
148
  /**
147
   * \param protocol a pointer to the protocol to add to this L4 Demux.
149
   * \param protocol a pointer to the protocol to add to this L4 Demux.
148
   *
150
   *
 Lines 333-338    Link Here 
333
   * If set to true, IP forwarding is enabled for input datagrams on this device
335
   * If set to true, IP forwarding is enabled for input datagrams on this device
334
   */
336
   */
335
  virtual void SetForwarding (uint32_t interface, bool val) = 0;
337
  virtual void SetForwarding (uint32_t interface, bool val) = 0;
338
  
339
  /**
340
   * \param protocolNumber number of protocol to lookup
341
   *        in this L4 Demux
342
   * \returns a matching L4 Protocol
343
   *
344
   * This method is typically called by lower layers
345
   * to forward packets up the stack to the right protocol.
346
   * It is also called from NodeImpl::GetUdp for example.
347
   */
348
  virtual Ptr<IpL4Protocol> GetProtocol (int protocolNumber) const = 0;
349
350
  virtual Ptr<Socket> CreateRawSocket (void) = 0;
351
  virtual void DeleteRawSocket (Ptr<Socket> socket) = 0;  
352
336
353
337
  static const uint32_t IF_ANY = 0xffffffff;
354
  static const uint32_t IF_ANY = 0xffffffff;
338
355

Return to bug 1477