A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
dhcp-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 UPB
3 * Copyright (c) 2017 NITK Surathkal
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Radu Lupu <rlupu@elcom.pub.ro>
19 * Ankit Deepak <adadeepak8@gmail.com>
20 * Deepti Rajagopal <deeptir96@gmail.com>
21 *
22 */
23
24#ifndef DHCP_HELPER_H
25#define DHCP_HELPER_H
26
27#include "ns3/application-container.h"
28#include "ns3/ipv4-address.h"
29#include "ns3/ipv4-interface-container.h"
30#include "ns3/net-device-container.h"
31#include "ns3/object-factory.h"
32
33#include <stdint.h>
34
35namespace ns3
36{
37
38/**
39 * \ingroup dhcp
40 *
41 * \class DhcpHelper
42 * \brief The helper class used to configure and install DHCP applications on nodes
43 */
45{
46 public:
47 DhcpHelper();
48
49 /**
50 * \brief Set DHCP client attributes
51 * \param name Name of the attribute
52 * \param value Value to be set
53 */
54 void SetClientAttribute(std::string name, const AttributeValue& value);
55
56 /**
57 * \brief Set DHCP server attributes
58 * \param name Name of the attribute
59 * \param value Value to be set
60 */
61 void SetServerAttribute(std::string name, const AttributeValue& value);
62
63 /**
64 * \brief Install DHCP client of a nodes / NetDevice
65 * \param netDevice The NetDevice that the DHCP client will use
66 * \return The application container with DHCP client installed
67 */
69
70 /**
71 * \brief Install DHCP client of a set of nodes / NetDevices
72 * \param netDevices The NetDevices that the DHCP client will use
73 * \return The application container with DHCP client installed
74 */
76
77 /**
78 * \brief Install DHCP server of a node / NetDevice
79 *
80 * Note: the server address must be coherent with the pool address, because
81 * DHCP relays are not yet supported.
82 *
83 * \param netDevice The NetDevice on which DHCP server application has to be installed
84 * \param serverAddr The Ipv4Address of the server
85 * \param poolAddr The Ipv4Address (network part) of the allocated pool
86 * \param poolMask The mask of the allocated pool
87 * \param minAddr The lower bound of the Ipv4Address pool
88 * \param maxAddr The upper bound of the Ipv4Address pool
89 * \param gateway The Ipv4Address of default gateway (optional)
90 * \return The application container with DHCP server installed
91 */
93 Ipv4Address serverAddr,
94 Ipv4Address poolAddr,
95 Ipv4Mask poolMask,
96 Ipv4Address minAddr,
97 Ipv4Address maxAddr,
98 Ipv4Address gateway = Ipv4Address());
99 /**
100 * \brief Assign a fixed IP addresses to a net device.
101 * \param netDevice The NetDevice on which the address has to be installed
102 * \param addr The Ipv4Address
103 * \param mask The network mask
104 * \return the Ipv4 interface container
105 */
107 Ipv4Address addr,
108 Ipv4Mask mask);
109
110 private:
111 /**
112 * \brief Function to install DHCP client on a node
113 * \param netDevice The NetDevice on which DHCP client application has to be installed
114 * \return The pointer to the installed DHCP client
115 */
117 ObjectFactory m_clientFactory; //!< DHCP client factory
118 ObjectFactory m_serverFactory; //!< DHCP server factory
119 std::list<Ipv4Address> m_fixedAddresses; //!< list of fixed addresses already allocated.
120 std::list<std::pair<Ipv4Address, Ipv4Address>> m_addressPools; //!< list of address pools.
121};
122
123} // namespace ns3
124
125#endif /* DHCP_HELPER_H */
holds a vector of ns3::Application pointers.
Hold a value for an Attribute.
Definition: attribute.h:70
The helper class used to configure and install DHCP applications on nodes.
Definition: dhcp-helper.h:45
ObjectFactory m_serverFactory
DHCP server factory.
Definition: dhcp-helper.h:118
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
Definition: dhcp-helper.h:120
std::list< Ipv4Address > m_fixedAddresses
list of fixed addresses already allocated.
Definition: dhcp-helper.h:119
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
Definition: dhcp-helper.cc:203
ApplicationContainer InstallDhcpServer(Ptr< NetDevice > netDevice, Ipv4Address serverAddr, Ipv4Address poolAddr, Ipv4Mask poolMask, Ipv4Address minAddr, Ipv4Address maxAddr, Ipv4Address gateway=Ipv4Address())
Install DHCP server of a node / NetDevice.
Definition: dhcp-helper.cc:129
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
Definition: dhcp-helper.cc:61
void SetClientAttribute(std::string name, const AttributeValue &value)
Set DHCP client attributes.
Definition: dhcp-helper.cc:49
void SetServerAttribute(std::string name, const AttributeValue &value)
Set DHCP server attributes.
Definition: dhcp-helper.cc:55
Ptr< Application > InstallDhcpClientPriv(Ptr< NetDevice > netDevice) const
Function to install DHCP client on a node.
Definition: dhcp-helper.cc:78
ObjectFactory m_clientFactory
DHCP client factory.
Definition: dhcp-helper.h:117
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
holds a vector of ns3::NetDevice pointers
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.