2007-02-12 19:28:19 +01:00
|
|
|
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2007 INRIA
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
* published by the Free Software Foundation;
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
* Authors:
|
|
|
|
|
* Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
|
|
|
|
|
*/
|
2007-08-12 22:41:24 -07:00
|
|
|
|
2007-09-13 17:47:42 -07:00
|
|
|
#include "ns3/log.h"
|
2007-05-04 15:04:07 +02:00
|
|
|
#include "ns3/net-device.h"
|
2007-06-04 16:21:05 +02:00
|
|
|
#include "ns3/node.h"
|
2007-09-12 11:39:46 +02:00
|
|
|
#include "ns3/mac48-address.h"
|
2007-10-01 14:15:56 +02:00
|
|
|
#include "ns3/packet.h"
|
2007-02-12 19:28:19 +01:00
|
|
|
#include "ipv4-loopback-interface.h"
|
2007-07-31 09:09:31 +02:00
|
|
|
#include "ipv4-l3-protocol.h"
|
2007-02-12 19:28:19 +01:00
|
|
|
|
2007-09-13 17:47:42 -07:00
|
|
|
NS_LOG_COMPONENT_DEFINE ("Ipv4LoopbackInterface");
|
2007-08-12 22:41:24 -07:00
|
|
|
|
2007-02-12 19:28:19 +01:00
|
|
|
namespace ns3 {
|
|
|
|
|
|
2008-05-25 11:07:08 -07:00
|
|
|
TypeId
|
|
|
|
|
Ipv4LoopbackInterface::GetTypeId (void)
|
|
|
|
|
{
|
|
|
|
|
static TypeId tid = TypeId ("ns3::Ipv4LoopbackInterface")
|
|
|
|
|
.SetParent<Ipv4Interface> ()
|
|
|
|
|
;
|
|
|
|
|
return tid;
|
|
|
|
|
}
|
|
|
|
|
|
2008-03-11 13:30:12 -07:00
|
|
|
Ipv4LoopbackInterface::Ipv4LoopbackInterface ()
|
|
|
|
|
: m_node (0)
|
2007-08-12 22:41:24 -07:00
|
|
|
{
|
2008-05-25 14:42:55 -07:00
|
|
|
NS_LOG_FUNCTION (this);
|
2007-08-12 22:41:24 -07:00
|
|
|
}
|
|
|
|
|
|
2007-02-12 19:28:19 +01:00
|
|
|
Ipv4LoopbackInterface::~Ipv4LoopbackInterface ()
|
2007-08-12 22:41:24 -07:00
|
|
|
{
|
2008-05-25 14:42:55 -07:00
|
|
|
NS_LOG_FUNCTION (this);
|
2008-03-11 13:30:12 -07:00
|
|
|
NS_ASSERT (m_node != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ptr<NetDevice>
|
|
|
|
|
Ipv4LoopbackInterface::GetDevice (void) const
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
Ipv4LoopbackInterface::SetNode (Ptr<Node> node)
|
|
|
|
|
{
|
|
|
|
|
m_node = node;
|
2007-08-12 22:41:24 -07:00
|
|
|
}
|
2007-02-12 19:28:19 +01:00
|
|
|
|
|
|
|
|
void
|
2007-10-01 14:15:56 +02:00
|
|
|
Ipv4LoopbackInterface::SendTo (Ptr<Packet> packet, Ipv4Address dest)
|
2007-02-12 19:28:19 +01:00
|
|
|
{
|
2008-04-15 15:10:53 -07:00
|
|
|
NS_LOG_FUNCTION (this << packet << dest);
|
2007-08-12 22:41:24 -07:00
|
|
|
|
|
|
|
|
Ptr<Ipv4L3Protocol> ipv4 =
|
2008-01-31 22:11:03 +01:00
|
|
|
m_node->GetObject<Ipv4L3Protocol> ();
|
2007-08-12 22:41:24 -07:00
|
|
|
|
2007-09-12 11:39:46 +02:00
|
|
|
ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER,
|
2008-07-07 12:18:05 +01:00
|
|
|
Mac48Address ("ff:ff:ff:ff:ff:ff"),
|
|
|
|
|
Mac48Address ("ff:ff:ff:ff:ff:ff"),
|
|
|
|
|
NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here
|
|
|
|
|
);
|
2007-02-12 19:28:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}//namespace ns3
|