merge
This commit is contained in:
182
src/node/channel-list.cc
Normal file
182
src/node/channel-list.cc
Normal file
@@ -0,0 +1,182 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include "ns3/simulator.h"
|
||||
#include "ns3/object-vector.h"
|
||||
#include "ns3/config.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "channel-list.h"
|
||||
#include "channel.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("ChannelList");
|
||||
|
||||
/**
|
||||
* \brief private implementation detail of the ChannelList API.
|
||||
*/
|
||||
class ChannelListPriv : public Object
|
||||
{
|
||||
public:
|
||||
static TypeId GetTypeId (void);
|
||||
ChannelListPriv ();
|
||||
~ChannelListPriv ();
|
||||
|
||||
uint32_t Add (Ptr<Channel> channel);
|
||||
|
||||
ChannelList::Iterator Begin (void) const;
|
||||
ChannelList::Iterator End (void) const;
|
||||
|
||||
Ptr<Channel> GetChannel (uint32_t n);
|
||||
uint32_t GetNChannels (void);
|
||||
|
||||
static Ptr<ChannelListPriv> Get (void);
|
||||
|
||||
private:
|
||||
static Ptr<ChannelListPriv> *DoGet (void);
|
||||
static void Delete (void);
|
||||
std::vector<Ptr<Channel> > m_channels;
|
||||
};
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (ChannelListPriv);
|
||||
|
||||
TypeId
|
||||
ChannelListPriv::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::ChannelListPriv")
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("ChannelList", "The list of all channels created during the simulation.",
|
||||
ObjectVectorValue (),
|
||||
MakeObjectVectorAccessor (&ChannelListPriv::m_channels),
|
||||
MakeObjectVectorChecker<Channel> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
Ptr<ChannelListPriv>
|
||||
ChannelListPriv::Get (void)
|
||||
{
|
||||
return *DoGet ();
|
||||
}
|
||||
|
||||
Ptr<ChannelListPriv> *
|
||||
ChannelListPriv::DoGet (void)
|
||||
{
|
||||
static Ptr<ChannelListPriv> ptr = 0;
|
||||
if (ptr == 0)
|
||||
{
|
||||
ptr = CreateObject<ChannelListPriv> ();
|
||||
Config::RegisterRootNamespaceObject (ptr);
|
||||
Simulator::ScheduleDestroy (&ChannelListPriv::Delete);
|
||||
}
|
||||
return &ptr;
|
||||
}
|
||||
|
||||
void
|
||||
ChannelListPriv::Delete (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Config::UnregisterRootNamespaceObject (Get ());
|
||||
(*DoGet ()) = 0;
|
||||
}
|
||||
|
||||
ChannelListPriv::ChannelListPriv ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
ChannelListPriv::~ChannelListPriv ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
for (std::vector<Ptr<Channel> >::iterator i = m_channels.begin ();
|
||||
i != m_channels.end (); i++)
|
||||
{
|
||||
Ptr<Channel> channel = *i;
|
||||
channel->Dispose ();
|
||||
*i = 0;
|
||||
}
|
||||
m_channels.erase (m_channels.begin (), m_channels.end ());
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ChannelListPriv::Add (Ptr<Channel> channel)
|
||||
{
|
||||
uint32_t index = m_channels.size ();
|
||||
m_channels.push_back (channel);
|
||||
return index;
|
||||
|
||||
}
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelListPriv::Begin (void) const
|
||||
{
|
||||
return m_channels.begin ();
|
||||
}
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelListPriv::End (void) const
|
||||
{
|
||||
return m_channels.end ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ChannelListPriv::GetNChannels (void)
|
||||
{
|
||||
return m_channels.size ();
|
||||
}
|
||||
|
||||
Ptr<Channel>
|
||||
ChannelListPriv::GetChannel (uint32_t n)
|
||||
{
|
||||
NS_ASSERT_MSG (n < m_channels.size (), "Channel index " << n <<
|
||||
" is out of range (only have " << m_channels.size () << " channels).");
|
||||
return m_channels[n];
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ChannelList::Add (Ptr<Channel> channel)
|
||||
{
|
||||
return ChannelListPriv::Get ()->Add (channel);
|
||||
}
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::Begin (void)
|
||||
{
|
||||
return ChannelListPriv::Get ()->Begin ();
|
||||
}
|
||||
|
||||
ChannelList::Iterator
|
||||
ChannelList::End (void)
|
||||
{
|
||||
return ChannelListPriv::Get ()->End ();
|
||||
}
|
||||
|
||||
Ptr<Channel>
|
||||
ChannelList::GetChannel (uint32_t n)
|
||||
{
|
||||
return ChannelListPriv::Get ()->GetChannel (n);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ChannelList::GetNChannels (void)
|
||||
{
|
||||
return ChannelListPriv::Get ()->GetNChannels ();
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
74
src/node/channel-list.h
Normal file
74
src/node/channel-list.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2009 University of Washington
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef CHANNEL_LIST_H
|
||||
#define CHANNEL_LIST_H
|
||||
|
||||
#include <vector>
|
||||
#include "ns3/ptr.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Channel;
|
||||
class CallbackBase;
|
||||
|
||||
|
||||
/**
|
||||
* \ingroup node
|
||||
*
|
||||
* \brief the list of simulation channels.
|
||||
*
|
||||
* Every Channel created is automatically added to this list.
|
||||
*/
|
||||
class ChannelList
|
||||
{
|
||||
public:
|
||||
typedef std::vector< Ptr<Channel> >::const_iterator Iterator;
|
||||
|
||||
/**
|
||||
* \param channel channel to add
|
||||
* \returns index of channel in list.
|
||||
*
|
||||
* This method is called automatically from Channel::Channel so
|
||||
* the user has little reason to call it himself.
|
||||
*/
|
||||
static uint32_t Add (Ptr<Channel> channel);
|
||||
/**
|
||||
* \returns a C++ iterator located at the beginning of this
|
||||
* list.
|
||||
*/
|
||||
static Iterator Begin (void);
|
||||
/**
|
||||
* \returns a C++ iterator located at the end of this
|
||||
* list.
|
||||
*/
|
||||
static Iterator End (void);
|
||||
/**
|
||||
* \param n index of requested channel.
|
||||
* \returns the Channel associated to index n.
|
||||
*/
|
||||
static Ptr<Channel> GetChannel (uint32_t n);
|
||||
/**
|
||||
* \returns the number of channels currently in the list.
|
||||
*/
|
||||
static uint32_t GetNChannels (void);
|
||||
};
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
#endif /* CHANNEL_LIST_H */
|
||||
@@ -16,10 +16,13 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "channel.h"
|
||||
#include "channel-list.h"
|
||||
#include "net-device.h"
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Channel");
|
||||
|
||||
namespace ns3 {
|
||||
@@ -30,19 +33,31 @@ TypeId
|
||||
Channel::GetTypeId (void)
|
||||
{
|
||||
static TypeId tid = TypeId ("ns3::Channel")
|
||||
.SetParent<Object> ();
|
||||
.SetParent<Object> ()
|
||||
.AddAttribute ("Id", "The id (unique integer) of this Channel.",
|
||||
TypeId::ATTR_GET,
|
||||
UintegerValue (0),
|
||||
MakeUintegerAccessor (&Channel::m_id),
|
||||
MakeUintegerChecker<uint32_t> ());
|
||||
return tid;
|
||||
}
|
||||
|
||||
Channel::Channel ()
|
||||
: m_id(0)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_id = ChannelList::Add (this);
|
||||
}
|
||||
|
||||
|
||||
Channel::~Channel ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Channel::GetId (void) const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -45,6 +45,14 @@ public:
|
||||
Channel ();
|
||||
virtual ~Channel ();
|
||||
|
||||
/**
|
||||
* \returns the unique id of this channel
|
||||
*
|
||||
* This unique id happens to be also the index of the Channel into
|
||||
* the ChannelList.
|
||||
*/
|
||||
uint32_t GetId (void) const;
|
||||
|
||||
/**
|
||||
* \returns the number of NetDevices connected to this Channel.
|
||||
*
|
||||
@@ -59,6 +67,8 @@ public:
|
||||
*/
|
||||
virtual Ptr<NetDevice> GetDevice (uint32_t i) const = 0;
|
||||
|
||||
private:
|
||||
uint32_t m_id; // Channel id for this channel
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
@@ -87,6 +87,7 @@ public:
|
||||
void SetIpv4 (Ipv4Address address);
|
||||
|
||||
/**
|
||||
* \param address address to test
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
|
||||
@@ -18,10 +18,12 @@
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#include "inet6-socket-address.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
#include "inet6-socket-address.h"
|
||||
|
||||
namespace ns3
|
||||
{
|
||||
|
||||
Inet6SocketAddress::Inet6SocketAddress (Ipv6Address ipv6, uint16_t port)
|
||||
: m_ipv6(ipv6),
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
#ifndef INET6_SOCKET_ADDRESS_H
|
||||
#define INET6_SOCKET_ADDRESS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "address.h"
|
||||
#include "ipv6-address.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ public:
|
||||
*/
|
||||
Ipv4Mask ();
|
||||
/**
|
||||
* param mask bitwise integer representation of the mask
|
||||
* \param mask bitwise integer representation of the mask
|
||||
*
|
||||
* For example, the integer input 0xffffff00 yields a 24-bit mask
|
||||
*/
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <iomanip>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ipv6-address.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "mac48-address.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include "mac48-address.h"
|
||||
#include "ipv6-address.h"
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("Ipv6Address");
|
||||
|
||||
|
||||
@@ -26,9 +26,10 @@
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "address.h"
|
||||
#include "ns3/attribute-helper.h"
|
||||
|
||||
#include "address.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv6Prefix;
|
||||
@@ -213,7 +214,8 @@ class Ipv6Address
|
||||
operator Address () const;
|
||||
|
||||
/**
|
||||
* \brief Convert the Address object into an Ipv6Address one.
|
||||
* \brief Convert the Address object into an Ipv6Address ones.
|
||||
* \param address address to convert
|
||||
* \return an Ipv6Address
|
||||
*/
|
||||
static Ipv6Address ConvertFrom (const Address& address);
|
||||
@@ -402,13 +404,13 @@ class Ipv6Prefix
|
||||
|
||||
/**
|
||||
* \class ns3::Ipv6AddressValue
|
||||
* \brief hold objects of type ns3::Ipv6Address
|
||||
* \brief Hold objects of type ns3::Ipv6Address
|
||||
*/
|
||||
ATTRIBUTE_HELPER_HEADER (Ipv6Address);
|
||||
|
||||
/**
|
||||
* \class ns3::Ipv6PrefixValue
|
||||
* \brief hold objects of type ns3::Ipv6Prefix
|
||||
* \brief Hold objects of type ns3::Ipv6Prefix
|
||||
*/
|
||||
ATTRIBUTE_HELPER_HEADER (Ipv6Prefix);
|
||||
|
||||
@@ -432,9 +434,17 @@ inline bool operator < (const Ipv6Address& a, const Ipv6Address& b)
|
||||
return (memcmp (a.m_address, b.m_address, 16) < 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* \class Ipv6AddressHash
|
||||
* \brief Hash function class for IPv6 addresses.
|
||||
*/
|
||||
class Ipv6AddressHash : public std::unary_function<Ipv6Address, size_t>
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \brief Unary operator to hash IPv6 address.
|
||||
* \param x IPv6 address to hash
|
||||
*/
|
||||
size_t operator () (Ipv6Address const &x) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/header.h"
|
||||
|
||||
#include "address-utils.h"
|
||||
#include "ipv6-header.h"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ipv6-interface-address.h"
|
||||
|
||||
namespace ns3
|
||||
|
||||
@@ -190,7 +190,7 @@ class Ipv6InterfaceAddress
|
||||
|
||||
std::ostream& operator<< (std::ostream& os, const Ipv6InterfaceAddress &addr);
|
||||
|
||||
/* follow Ipv6InterfaceAddress way, maybe not inline them */
|
||||
/* follow Ipv4InterfaceAddress way, maybe not inline them */
|
||||
inline bool operator == (const Ipv6InterfaceAddress& a, const Ipv6InterfaceAddress& b)
|
||||
{
|
||||
return (a.m_address == b.m_address && a.m_prefix == b.m_prefix &&
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
|
||||
#include "ipv6-raw-socket-factory.h"
|
||||
#include "ns3/uinteger.h"
|
||||
|
||||
#include "ipv6-raw-socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Ipv6RawSocketFactory);
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "net-device.h"
|
||||
|
||||
#include "ipv6-route.h"
|
||||
|
||||
namespace ns3
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ostream>
|
||||
|
||||
#include "ns3/ref-count-base.h"
|
||||
|
||||
#include "ipv6-address.h"
|
||||
|
||||
namespace ns3
|
||||
@@ -176,22 +177,26 @@ class Ipv6MulticastRoute : public RefCountBase
|
||||
Ipv6Address GetOrigin (void) const;
|
||||
|
||||
/**
|
||||
* \brief Set parent for this route.
|
||||
* \param iif Parent (input interface) for this route
|
||||
*/
|
||||
void SetParent (uint32_t iif);
|
||||
|
||||
/**
|
||||
* \brief Get parent for this route.
|
||||
* \return Parent (input interface) for this route
|
||||
*/
|
||||
uint32_t GetParent (void) const;
|
||||
|
||||
/**
|
||||
* \brief set output TTL for this route.
|
||||
* \param oif Outgoing interface index
|
||||
* \param ttl time-to-live for this route
|
||||
*/
|
||||
void SetOutputTtl (uint32_t oif, uint32_t ttl);
|
||||
|
||||
/**
|
||||
* \brief Get output TTL.
|
||||
* \brief Get output TTL for this route.
|
||||
* \param oif outgoing interface
|
||||
* \return TTL for this route
|
||||
*/
|
||||
@@ -214,7 +219,7 @@ class Ipv6MulticastRoute : public RefCountBase
|
||||
uint32_t m_parent;
|
||||
|
||||
/**
|
||||
* \brief TTLs;
|
||||
* \brief TTLs.
|
||||
*/
|
||||
std::vector<uint32_t> m_ttls;
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
/* taken from src/node/ipv4-routing-protocol.cc and adapted to IPv6 */
|
||||
|
||||
#include "ns3/assert.h"
|
||||
|
||||
#include "ipv6-route.h"
|
||||
#include "ipv6-routing-protocol.h"
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "ns3/callback.h"
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
|
||||
#include "ipv6-header.h"
|
||||
#include "ipv6-interface-address.h"
|
||||
#include "ipv6.h"
|
||||
@@ -39,6 +40,7 @@ class NetDevice;
|
||||
* \ingroup node
|
||||
* \defgroup ipv6Routing Ipv6RoutingProtocol
|
||||
*/
|
||||
|
||||
/**
|
||||
* \ingroup ipv6Routing
|
||||
* \brief Abstract base class for Ipv6 routing protocols.
|
||||
@@ -102,37 +104,42 @@ public:
|
||||
LocalDeliverCallback lcb, ErrorCallback ecb) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \brief Notify when specified interface goes UP.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*/
|
||||
virtual void NotifyInterfaceUp (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \brief Notify when specified interface goes DOWN.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified of the state change of
|
||||
* an interface in a node.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
*/
|
||||
virtual void NotifyInterfaceDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
* \brief Notify when specified interface add an address.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is added to an interface. Typically used to add a 'network route' on an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*/
|
||||
virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
* \brief Notify when specified interface add an address.
|
||||
*
|
||||
* Protocols are expected to implement this method to be notified whenever
|
||||
* a new address is removed from an interface. Typically used to remove the 'network route' of an
|
||||
* interface. Can be invoked on an up or down interface.
|
||||
* \param interface the index of the interface we are being notified about
|
||||
* \param address a new address being added to an interface
|
||||
*/
|
||||
virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
@@ -160,9 +167,8 @@ public:
|
||||
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ()) = 0;
|
||||
|
||||
/**
|
||||
* \brief Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol
|
||||
* \param ipv6 the ipv6 object this routing protocol is being associated with
|
||||
*
|
||||
* Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol
|
||||
*/
|
||||
virtual void SetIpv6 (Ptr<Ipv6> ipv6) = 0;
|
||||
};
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/node.h"
|
||||
#include "ns3/boolean.h"
|
||||
|
||||
#include "ipv6.h"
|
||||
|
||||
namespace ns3
|
||||
|
||||
@@ -24,9 +24,11 @@
|
||||
#define IPV6_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ns3/object.h"
|
||||
#include "ns3/socket.h"
|
||||
#include "ns3/callback.h"
|
||||
|
||||
#include "ipv6-address.h"
|
||||
#include "ipv6-interface-address.h"
|
||||
|
||||
@@ -108,17 +110,19 @@ public:
|
||||
virtual Ptr<Ipv6RoutingProtocol> GetRoutingProtocol (void) const = 0;
|
||||
|
||||
/**
|
||||
* \param device device to add to the list of IPv6 interfaces
|
||||
* which can be used as output interfaces during packet forwarding.
|
||||
* \returns the index of the IPv6 interface added.
|
||||
* \brief Add a NetDevice interface.
|
||||
*
|
||||
* Once a device has been added, it can never be removed: if you want
|
||||
* to disable it, you can invoke Ipv6::SetDown which will
|
||||
* make sure that it is never used during packet forwarding.
|
||||
* \param device device to add to the list of IPv6 interfaces
|
||||
* which can be used as output interfaces during packet forwarding.
|
||||
* \returns the index of the IPv6 interface added.
|
||||
*/
|
||||
virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get number of interfaces.
|
||||
* \returns the number of interfaces added by the user.
|
||||
*/
|
||||
virtual uint32_t GetNInterfaces (void) const = 0;
|
||||
@@ -159,18 +163,21 @@ public:
|
||||
Ipv6Prefix mask) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the NetDevice of the specified interface number.
|
||||
* \param interface The interface number of an IPv6 interface.
|
||||
* \returns The NetDevice associated with the IPv6 interface number.
|
||||
*/
|
||||
virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get the interface index of the specified NetDevice.
|
||||
* \param device The NetDevice for an Ipv6Interface
|
||||
* \returns The interface number of an IPv6 interface or -1 if not found.
|
||||
*/
|
||||
virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Add an address on the specified IPv6 interface.
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \param address Ipv6InterfaceAddress address to associate with the underlying IPv6 interface
|
||||
* \returns true if the operation succeeded
|
||||
@@ -178,12 +185,15 @@ public:
|
||||
virtual bool AddAddress (uint32_t interface, Ipv6InterfaceAddress address) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get number of addresses on specified IPv6 interface.
|
||||
* \param interface Interface number of an IPv6 interface
|
||||
* \returns the number of Ipv6InterfaceAddress entries for the interface.
|
||||
*/
|
||||
virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get IPv6 address on specified IPv6 interface.
|
||||
*
|
||||
* Because addresses can be removed, the addressIndex is not guaranteed
|
||||
* to be static across calls to this method.
|
||||
*
|
||||
@@ -194,6 +204,8 @@ public:
|
||||
virtual Ipv6InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Remove an address on specified IPv6 interface.
|
||||
*
|
||||
* Remove the address at addressIndex on named interface. The addressIndex
|
||||
* for all higher indices will decrement by one after this method is called;
|
||||
* so, for example, to remove 5 addresses from an interface i, one could
|
||||
@@ -206,6 +218,8 @@ public:
|
||||
virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
|
||||
|
||||
/**
|
||||
* \brief Set metric on specified Ipv6 interface.
|
||||
*
|
||||
* \param interface The interface number of an IPv6 interface
|
||||
* \param metric routing metric (cost) associated to the underlying
|
||||
* IPv6 interface
|
||||
@@ -213,6 +227,8 @@ public:
|
||||
virtual void SetMetric (uint32_t interface, uint16_t metric) = 0;
|
||||
|
||||
/**
|
||||
* \brief Get metric for the specified IPv6 interface.
|
||||
*
|
||||
* \param interface The interface number of an IPv6 interface
|
||||
* \returns routing metric (cost) associated to the underlying
|
||||
* IPv6 interface
|
||||
@@ -220,6 +236,7 @@ public:
|
||||
virtual uint16_t GetMetric (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Get MTU for the specified IPv6 interface.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns the Maximum Transmission Unit (in bytes) associated
|
||||
* to the underlying IPv6 interface
|
||||
@@ -227,6 +244,7 @@ public:
|
||||
virtual uint16_t GetMtu (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief If the specified interface index is in "up" state.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns true if the underlying interface is in the "up" state,
|
||||
* false otherwise.
|
||||
@@ -234,28 +252,30 @@ public:
|
||||
virtual bool IsUp (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Set the interface into the "up" state.
|
||||
*
|
||||
* In this state, it is considered valid during IPv6 forwarding.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
*
|
||||
* Set the interface into the "up" state. In this state, it is
|
||||
* considered valid during IPv6 forwarding.
|
||||
*/
|
||||
virtual void SetUp (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \brief Set the interface into the "down" state.
|
||||
*
|
||||
* Set the interface into the "down" state. In this state, it is
|
||||
* ignored during IPv6 forwarding.
|
||||
* In this state, it is ignored during IPv6 forwarding.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
*/
|
||||
virtual void SetDown (uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \brief If the specified IPv6 interface has forwarding enabled.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \returns true if IPv6 forwarding enabled for input datagrams on this device
|
||||
*/
|
||||
virtual bool IsForwarding (uint32_t interface) const = 0;
|
||||
|
||||
/**
|
||||
* \brief Set forwarding on specified IPv6 interface.
|
||||
* \param interface Interface number of IPv6 interface
|
||||
* \param val Value to set the forwarding flag
|
||||
*
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
*/
|
||||
static Mac48Address ConvertFrom (const Address &address);
|
||||
/**
|
||||
* \param address address to test
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
@@ -102,12 +103,14 @@ public:
|
||||
static Mac48Address GetBroadcast (void);
|
||||
|
||||
/**
|
||||
* \param address base IPv4 address
|
||||
* \returns a multicast address
|
||||
*/
|
||||
static Mac48Address GetMulticast (Ipv4Address address);
|
||||
|
||||
/**
|
||||
* \brief Get multicast address from IPv6 address.
|
||||
* \param address base IPv6 address
|
||||
* \returns a multicast address
|
||||
*/
|
||||
static Mac48Address GetMulticast (Ipv6Address address);
|
||||
|
||||
@@ -73,6 +73,7 @@ public:
|
||||
*/
|
||||
static Mac64Address ConvertFrom (const Address &address);
|
||||
/**
|
||||
* \param address address to test
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
|
||||
@@ -99,6 +99,7 @@ public:
|
||||
|
||||
/**
|
||||
* Set the address of this interface
|
||||
* \param address address to set
|
||||
*/
|
||||
virtual void SetAddress (Address address) = 0;
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ class PacketSocketAddress
|
||||
*/
|
||||
static PacketSocketAddress ConvertFrom (const Address &address);
|
||||
/**
|
||||
* \param address address to test
|
||||
* \returns true if the address matches, false otherwise.
|
||||
*/
|
||||
static bool IsMatchingType (const Address &address);
|
||||
|
||||
3830
src/node/packetbb-test-suite.cc
Normal file
3830
src/node/packetbb-test-suite.cc
Normal file
File diff suppressed because it is too large
Load Diff
2873
src/node/packetbb.cc
Normal file
2873
src/node/packetbb.cc
Normal file
File diff suppressed because it is too large
Load Diff
1754
src/node/packetbb.h
Normal file
1754
src/node/packetbb.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@ public:
|
||||
bool IsEmpty (void) const;
|
||||
/**
|
||||
* Place a packet into the rear of the Queue
|
||||
* \param p packet to enqueue
|
||||
* \return True if the operation was successful; false otherwise
|
||||
*/
|
||||
bool Enqueue (Ptr<Packet> p);
|
||||
|
||||
@@ -487,8 +487,9 @@ public:
|
||||
*/
|
||||
int RecvFrom (uint8_t* buf, uint32_t size, uint32_t flags,
|
||||
Address &fromAddress);
|
||||
/**
|
||||
* \returns the address name this socket is associated with.
|
||||
/**
|
||||
* \param address the address name this socket is associated with.
|
||||
* \returns 0 if success, -1 otherwise
|
||||
*/
|
||||
virtual int GetSockName (Address &address) const = 0;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ def build(bld):
|
||||
'drop-tail-queue.cc',
|
||||
'channel.cc',
|
||||
'node-list.cc',
|
||||
'channel-list.cc',
|
||||
'socket.cc',
|
||||
'socket-factory.cc',
|
||||
'packet-socket-factory.cc',
|
||||
@@ -45,6 +46,8 @@ def build(bld):
|
||||
'ipv6.cc',
|
||||
'ipv6-raw-socket-factory.cc',
|
||||
'ipv6-routing-protocol.cc',
|
||||
'packetbb.cc',
|
||||
'packetbb-test-suite.cc',
|
||||
]
|
||||
|
||||
headers = bld.new_task_gen('ns3header')
|
||||
@@ -71,6 +74,7 @@ def build(bld):
|
||||
'ethernet-trailer.h',
|
||||
'channel.h',
|
||||
'node-list.h',
|
||||
'channel-list.h',
|
||||
'socket.h',
|
||||
'socket-factory.h',
|
||||
'packet-socket-factory.h',
|
||||
@@ -91,4 +95,5 @@ def build(bld):
|
||||
'ipv6.h',
|
||||
'ipv6-raw-socket-factory.h',
|
||||
'ipv6-routing-protocol.h',
|
||||
'packetbb.h',
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user