A Discrete-Event Network Simulator
API
ipv4-address-helper.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 University of Washington
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 
19 #ifndef IPV4_ADDRESS_HELPER_H
20 #define IPV4_ADDRESS_HELPER_H
21 
22 #include "ns3/ipv4-address.h"
23 #include "ns3/net-device-container.h"
25 
26 namespace ns3 {
27 
48 {
49 public:
55 
64  Ipv4AddressHelper (Ipv4Address network, Ipv4Mask mask,
65  Ipv4Address base = "0.0.0.1");
66 
96  void SetBase (Ipv4Address network, Ipv4Mask mask,
97  Ipv4Address base = "0.0.0.1");
98 
125  Ipv4Address NewNetwork (void);
126 
151  Ipv4Address NewAddress (void);
152 
182 
183 private:
189  uint32_t NumAddressBits (uint32_t maskbits) const;
190 
191  uint32_t m_network;
192  uint32_t m_mask;
193  uint32_t m_address;
194  uint32_t m_base;
195  uint32_t m_shift;
196  uint32_t m_max;
197 };
198 
199 } // namespace ns3
200 
201 #endif /* IPV4_ADDRESS_HELPER_H */
uint32_t m_max
maximum allowed address
holds a vector of std::pair of Ptr and interface index.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
uint32_t m_mask
network mask
uint32_t m_base
base address
uint32_t m_shift
shift, equivalent to the number of bits in the hostpart
Ipv4Address NewAddress(void)
Increment the IP address counter used to allocate IP addresses.
Ipv4AddressHelper()
Construct a helper class to make life easier while doing simple IPv4 address assignment in scripts...
holds a vector of ns3::NetDevice pointers
uint32_t m_network
network address
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t NumAddressBits(uint32_t maskbits) const
Returns the number of address bits (hostpart) for a given netmask.