aggregate PacketSocketFactory when requested to.
This commit is contained in:
17
src/helper/packet-socket-helper.cc
Normal file
17
src/helper/packet-socket-helper.cc
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "packet-socket-helper.h"
|
||||
#include "ns3/packet-socket-factory.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
void
|
||||
PacketSocketHelper::Build (NodeContainer c)
|
||||
{
|
||||
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
|
||||
{
|
||||
Ptr<Node> node = *i;
|
||||
Ptr<PacketSocketFactory> factory = CreateObject<PacketSocketFactory> ();
|
||||
node->AggregateObject (factory);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
25
src/helper/packet-socket-helper.h
Normal file
25
src/helper/packet-socket-helper.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef PACKET_SOCKET_HELPER_H
|
||||
#define PACKET_SOCKET_HELPER_H
|
||||
|
||||
#include "ns3/node-container.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* \brief Give ns3::PacketSocket powers to ns3::Node.
|
||||
*/
|
||||
class PacketSocketHelper
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* \param c container of node pointers
|
||||
*
|
||||
* For each node in the input container, aggregate a ns3::PacketSocketFactory
|
||||
* object instance.
|
||||
*/
|
||||
void Build (NodeContainer c);
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* PACKET_SOCKET_HELPER_H */
|
||||
Reference in New Issue
Block a user