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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Radu Lupu <rlupu@elcom.pub.ro>
8 * Ankit Deepak <adadeepak8@gmail.com>
9 * Deepti Rajagopal <deeptir96@gmail.com>
10 *
11 */
12
13#ifndef DHCP_HELPER_H
14#define DHCP_HELPER_H
15
16#include "ns3/application-container.h"
17#include "ns3/ipv4-address.h"
18#include "ns3/ipv4-interface-container.h"
19#include "ns3/net-device-container.h"
20#include "ns3/object-factory.h"
21
22#include <stdint.h>
23
24namespace ns3
25{
26
27/**
28 * \ingroup dhcp
29 *
30 * \class DhcpHelper
31 * \brief The helper class used to configure and install DHCP applications on nodes
32 */
34{
35 public:
36 DhcpHelper();
37
38 /**
39 * \brief Set DHCP client attributes
40 * \param name Name of the attribute
41 * \param value Value to be set
42 */
43 void SetClientAttribute(std::string name, const AttributeValue& value);
44
45 /**
46 * \brief Set DHCP server attributes
47 * \param name Name of the attribute
48 * \param value Value to be set
49 */
50 void SetServerAttribute(std::string name, const AttributeValue& value);
51
52 /**
53 * \brief Install DHCP client of a nodes / NetDevice
54 * \param netDevice The NetDevice that the DHCP client will use
55 * \return The application container with DHCP client installed
56 */
58
59 /**
60 * \brief Install DHCP client of a set of nodes / NetDevices
61 * \param netDevices The NetDevices that the DHCP client will use
62 * \return The application container with DHCP client installed
63 */
65
66 /**
67 * \brief Install DHCP server of a node / NetDevice
68 *
69 * Note: the server address must be coherent with the pool address, because
70 * DHCP relays are not yet supported.
71 *
72 * \param netDevice The NetDevice on which DHCP server application has to be installed
73 * \param serverAddr The Ipv4Address of the server
74 * \param poolAddr The Ipv4Address (network part) of the allocated pool
75 * \param poolMask The mask of the allocated pool
76 * \param minAddr The lower bound of the Ipv4Address pool
77 * \param maxAddr The upper bound of the Ipv4Address pool
78 * \param gateway The Ipv4Address of default gateway (optional)
79 * \return The application container with DHCP server installed
80 */
82 Ipv4Address serverAddr,
83 Ipv4Address poolAddr,
84 Ipv4Mask poolMask,
85 Ipv4Address minAddr,
86 Ipv4Address maxAddr,
87 Ipv4Address gateway = Ipv4Address());
88 /**
89 * \brief Assign a fixed IP addresses to a net device.
90 * \param netDevice The NetDevice on which the address has to be installed
91 * \param addr The Ipv4Address
92 * \param mask The network mask
93 * \return the Ipv4 interface container
94 */
96 Ipv4Address addr,
97 Ipv4Mask mask);
98
99 private:
100 /**
101 * \brief Function to install DHCP client on a node
102 * \param netDevice The NetDevice on which DHCP client application has to be installed
103 * \return The pointer to the installed DHCP client
104 */
106 ObjectFactory m_clientFactory; //!< DHCP client factory
107 ObjectFactory m_serverFactory; //!< DHCP server factory
108 std::list<Ipv4Address> m_fixedAddresses; //!< list of fixed addresses already allocated.
109 std::list<std::pair<Ipv4Address, Ipv4Address>> m_addressPools; //!< list of address pools.
110};
111
112} // namespace ns3
113
114#endif /* DHCP_HELPER_H */
holds a vector of ns3::Application pointers.
Hold a value for an Attribute.
Definition attribute.h:59
The helper class used to configure and install DHCP applications on nodes.
Definition dhcp-helper.h:34
ObjectFactory m_serverFactory
DHCP server factory.
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
std::list< Ipv4Address > m_fixedAddresses
list of fixed addresses already allocated.
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
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.
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
void SetClientAttribute(std::string name, const AttributeValue &value)
Set DHCP client attributes.
void SetServerAttribute(std::string name, const AttributeValue &value)
Set DHCP server attributes.
Ptr< Application > InstallDhcpClientPriv(Ptr< NetDevice > netDevice) const
Function to install DHCP client on a node.
ObjectFactory m_clientFactory
DHCP client factory.
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
holds a vector of ns3::NetDevice pointers
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.