make the sample code compile and link.

This commit is contained in:
Mathieu Lacage committed 2007-02-12 19:28:48 +01:00
1 parent 3eb2157400
commit c106232f07
13 files changed
+141 -26

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@
*
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
*/
#include "chunk-utils.h"
#include "header-utils.h"
namespace ns3 {
@@ -30,7 +30,7 @@ void WriteTo (Buffer::Iterator &i, MacAddress ad)
{
uint8_t mac[MacAddress::MAX_LEN];
ad.Peek (mac);
i.Write (mac, ad.GetLen ());
i.Write (mac, ad.GetLength ());
}
void ReadFrom (Buffer::Iterator &i, Ipv4Address &ad)
+31
View File
@@ -31,6 +31,7 @@
#include "arp.h"
#include "udp-ipv4-l4-protocol.h"
#include "arp-l3-protocol.h"
#include "ipv4-loopback-interface.h"
namespace ns3 {
@@ -46,6 +47,7 @@ InternetNode::InternetNode()
m_l3Demux->Insert (Ipv4L3Protocol (this));
m_l3Demux->Insert (ArpL3Protocol (this));
m_ipv4L4Demux->Insert (UdpIpv4L4Protocol (this));
SetupLoopback ();
}
InternetNode::InternetNode (InternetNode const &o)
@@ -56,6 +58,17 @@ InternetNode::InternetNode (InternetNode const &o)
m_udp = o.m_udp->Copy (this);
m_ipv4 = o.m_ipv4->Copy (this);
m_arp = o.m_arp->Copy (this);
SetupLoopback ();
}
void
InternetNode::SetupLoopback (void)
{
Ipv4LoopbackInterface * interface = new Ipv4LoopbackInterface (this);
interface->SetAddress (Ipv4Address::GetLoopback ());
interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
uint32_t index = m_ipv4->AddInterface (interface);
m_ipv4->AddHostRouteTo (Ipv4Address::GetLoopback (), index);
}
// Copy this node
@@ -85,4 +98,22 @@ InternetNode::GetIpv4L4Demux() const
return m_ipv4L4Demux;
}
Ipv4 *
InternetNode::GetIpv4 (void) const
{
return m_ipv4;
}
Udp *
InternetNode::GetUdp (void) const
{
return m_udp;
}
Arp *
InternetNode::GetArp (void) const
{
return m_arp;
}
}//namespace ns3
+1
View File
@@ -46,6 +46,7 @@ public:
virtual Arp * GetArp (void) const;
private:
void SetupLoopback (void);
// Capabilities
NetDeviceList* m_netDevices;
L3Demux* m_l3Demux;
+50
View File
@@ -0,0 +1,50 @@
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
//
// 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
//
// Author: George F. Riley<riley@ece.gatech.edu>
//
// Manages the list of network device interfaces associated with a node.
// George F. Riley, Georgia Tech, Spring 2007
#include "net-device-list.h"
namespace ns3 {
NetDeviceList::NetDeviceList()
{}
NetDeviceList::~NetDeviceList()
{
// XXX shall I delete each NetDevice ?
}
void
NetDeviceList::Add(NetDevice *device)
{
m_netdevices.push_back (device);
}
NetDeviceList::Iterator
NetDeviceList::Begin () const
{
return m_netdevices.begin ();
}
NetDeviceList::Iterator
NetDeviceList::End () const
{
return m_netdevices.end ();
}
}//namespace ns3
+4 -4
View File
@@ -1,4 +1,4 @@
// -*- Mode:NS3 -*-
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
//
// Copyright (c) 2006 Georgia Tech Research Corporation
// All rights reserved.
@@ -32,16 +32,16 @@ class NetDevice;
class NetDeviceList {
public:
typedef std::vector<NetDevice *>::iterator Iterator;
typedef std::vector<NetDevice *>::const_iterator Iterator;
NetDeviceList();
~NetDeviceList();
// Manage the list
NetDevice* Add(const NetDevice&); // Add a new netdevice
void Add(NetDevice *device);
NetDeviceList::Iterator Begin () const;
NetDeviceList::Iterator End () const;
public:
typedef std::vector<NetDevice *>::iterator NetDevices_t;
typedef std::vector<NetDevice *> NetDevices_t;
NetDevices_t m_netdevices;
};
+5 -6
View File
@@ -30,7 +30,7 @@
namespace ns3 {
NetDevice::NetDevice(Node& node, const MacAddress& addr) :
NetDevice::NetDevice(Node *node, const MacAddress& addr) :
m_node (node),
m_name(""),
m_ifIndex (0),
@@ -40,8 +40,7 @@ NetDevice::NetDevice(Node& node, const MacAddress& addr) :
m_isBroadcast (false),
m_isMulticast (false),
m_isPointToPoint (false)
{
}
{}
MacAddress
NetDevice::GetAddress (void) const
@@ -172,9 +171,9 @@ NetDevice::ForwardUp (Packet& packet)
LlcSnapHeader llc;
packet.Peek (llc);
packet.Remove (llc);
if (GetNode().GetL3Demux() != 0)
if (GetNode()->GetL3Demux() != 0)
{
L3Protocol *target = GetNode().GetL3Demux()->Lookup(llc.GetType ());
L3Protocol *target = GetNode()->GetL3Demux()->Lookup(llc.GetType ());
if (target != 0)
{
target->Receive(packet, *this);
@@ -204,7 +203,7 @@ NetDevice::NotifyLinkDown (void)
}
}
Node&
Node *
NetDevice::GetNode (void) const
{
return m_node;
+3 -3
View File
@@ -56,7 +56,7 @@ class NetDevice {
/**
* \param node base class node pointer of device's node
*/
NetDevice(Node& node, const MacAddress& addr);
NetDevice(Node* node, const MacAddress& addr);
virtual ~NetDevice() {}
/**
* \return the current MacAddress of this interface.
@@ -177,7 +177,7 @@ class NetDevice {
* base class to print the nodeid for example, it can invoke
* this method.
*/
Node& GetNode (void) const;
Node* GetNode (void) const;
/**
* \param p packet sent from below up to Network Device
@@ -204,7 +204,7 @@ class NetDevice {
* MUST override this method.
*/
virtual bool SendTo (Packet& p, const MacAddress& dest) = 0;
Node& m_node;
Node* m_node;
std::string m_name;
uint16_t m_ifIndex;
MacAddress m_address;
+4 -1
View File
@@ -37,8 +37,11 @@ P2PChannel::P2PChannel(const Time& delay, double maxRate)
{
}
P2PChannel::~P2PChannel ()
{}
// Channels create compatible net devices
P2PNetDevice* P2PChannel::CreateNetDevice(Node &node, MacAddress address)
P2PNetDevice* P2PChannel::CreateNetDevice(Node *node, MacAddress address)
{
// Create a new point-to-point network device
P2PNetDevice* nd = new P2PNetDevice(node, address);
+1 -1
View File
@@ -40,7 +40,7 @@ public:
P2PChannel(const Time& delay, double maxRate /* bits/s */);
~P2PChannel();
P2PNetDevice* CreateNetDevice(Node &node, MacAddress address);
P2PNetDevice* CreateNetDevice(Node *node, MacAddress address);
void RemoveNetDevice (NetDevice *device);
void Send (P2PNetDevice *device, Packet&p, double rate /* bits/s */);
private:
+1 -1
View File
@@ -27,7 +27,7 @@
namespace ns3 {
P2PNetDevice::P2PNetDevice (Node &node, MacAddress const &addr)
P2PNetDevice::P2PNetDevice (Node *node, MacAddress const &addr)
: NetDevice (node, addr)
{}
+1 -1
View File
@@ -33,7 +33,7 @@ class P2PChannel;
class P2PNetDevice : public NetDevice {
public:
P2PNetDevice(Node &node, MacAddress const &addr);
P2PNetDevice(Node *node, MacAddress const &addr);
virtual ~P2PNetDevice();
void SetRate (double Rate);