A Discrete-Event Network Simulator
API
ping6-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2009 Strasbourg University
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18  */
19 
20 #include "ping6-helper.h"
21 
22 #include "ns3/ping6.h"
23 #include "ns3/uinteger.h"
24 #include "ns3/warnings.h"
25 
26 namespace ns3
27 {
28 
30  : m_ifIndex(0)
31 {
33  m_factory.SetTypeId(Ping6::GetTypeId());
35 }
36 
37 void
39 {
40  m_localIp = ip;
41 }
42 
43 void
45 {
46  m_remoteIp = ip;
47 }
48 
49 void
51 {
52  m_factory.Set(name, value);
53 }
54 
57 {
58 #pragma GCC diagnostic push
59 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
60 
62  for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i)
63  {
64  Ptr<Node> node = *i;
65  Ptr<Ping6> client = m_factory.Create<Ping6>();
66  client->SetLocal(m_localIp);
67  client->SetRemote(m_remoteIp);
68  client->SetIfIndex(m_ifIndex);
69  client->SetRouters(m_routers);
70  node->AddApplication(client);
71  apps.Add(client);
72  }
73  return apps;
74 
75 #pragma GCC diagnostic pop
76 }
77 
78 void
79 Ping6Helper::SetIfIndex(uint32_t ifIndex)
80 {
81  m_ifIndex = ifIndex;
82 }
83 
84 void
85 Ping6Helper::SetRoutersAddress(std::vector<Ipv6Address> routers)
86 {
87  m_routers = routers;
88 }
89 
90 } /* namespace ns3 */
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Hold a value for an Attribute.
Definition: attribute.h:70
Describes an IPv6 address.
Definition: ipv6-address.h:50
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:169
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
void SetRemote(Ipv6Address ip)
Set the remote IPv6 address.
Definition: ping6-helper.cc:44
ObjectFactory m_factory
An object factory.
Definition: ping6-helper.h:91
ApplicationContainer Install(NodeContainer c)
Install the application in Nodes.
Definition: ping6-helper.cc:56
uint32_t m_ifIndex
Out interface index.
Definition: ping6-helper.h:106
std::vector< Ipv6Address > m_routers
Routers addresses.
Definition: ping6-helper.h:111
void SetRoutersAddress(std::vector< Ipv6Address > routers)
Set routers addresses for routing type 0.
Definition: ping6-helper.cc:85
void SetAttribute(std::string name, const AttributeValue &value)
Set some attributes.
Definition: ping6-helper.cc:50
void SetLocal(Ipv6Address ip)
Set the local IPv6 address.
Definition: ping6-helper.cc:38
Ping6Helper()
Constructor.
Definition: ping6-helper.cc:29
Ipv6Address m_remoteIp
The remote IPv6 address.
Definition: ping6-helper.h:101
void SetIfIndex(uint32_t ifIndex)
Set the out interface index.
Definition: ping6-helper.cc:79
Ipv6Address m_localIp
The local IPv6 address.
Definition: ping6-helper.h:96
#define NS_WARNING_POP
Pops the diagnostic warning list from the stack, restoring it to the previous state.
Definition: warnings.h:78
#define NS_WARNING_PUSH_DEPRECATED
Save the current warning list and disables the ones about deprecated functions and classes.
Definition: warnings.h:82
Every class exported by the ns3 library is enclosed in the ns3 namespace.
value
Definition: second.py:41