A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-interface-address.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 University of Washington
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 */
18
19#ifndef IPV4_INTERFACE_ADDRESS_H
20#define IPV4_INTERFACE_ADDRESS_H
21
22#include "ns3/ipv4-address.h"
23
24#include <ostream>
25#include <stdint.h>
26
27namespace ns3
28{
29
45{
46 public:
52 {
55 GLOBAL
56 };
57
59
71
80 void SetLocal(Ipv4Address local);
81
89 void SetAddress(Ipv4Address address);
90
99 Ipv4Address GetLocal() const;
100
108 Ipv4Address GetAddress() const;
109
114 void SetMask(Ipv4Mask mask);
119 Ipv4Mask GetMask() const;
124 void SetBroadcast(Ipv4Address broadcast);
130
136
142
148 bool IsInSameSubnet(const Ipv4Address b) const;
149
156 bool IsSecondary() const;
157
161 void SetSecondary();
165 void SetPrimary();
166
167 private:
169 // Note: m_peer may be added in future when necessary
170 // Ipv4Address m_peer; // Peer destination address (in Linux: m_address)
173
176
184 friend bool operator==(const Ipv4InterfaceAddress& a, const Ipv4InterfaceAddress& b);
185
193 friend bool operator!=(const Ipv4InterfaceAddress& a, const Ipv4InterfaceAddress& b);
194};
195
203std::ostream& operator<<(std::ostream& os, const Ipv4InterfaceAddress& addr);
204
205inline bool
207{
208 return (a.m_local == b.m_local && a.m_mask == b.m_mask && a.m_broadcast == b.m_broadcast &&
209 a.m_scope == b.m_scope && a.m_secondary == b.m_secondary);
210}
211
212inline bool
214{
215 return (a.m_local != b.m_local || a.m_mask != b.m_mask || a.m_broadcast != b.m_broadcast ||
216 a.m_scope != b.m_scope || a.m_secondary != b.m_secondary);
217}
218
219} // namespace ns3
220
221#endif /* IPV4_ADDRESS_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to store IPv4 address information on an interface
Ipv4Mask GetMask() const
Get the network mask.
friend bool operator==(const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
Equal to operator.
void SetMask(Ipv4Mask mask)
Set the network mask.
void SetBroadcast(Ipv4Address broadcast)
Set the broadcast address.
void SetPrimary()
Make the address primary.
bool IsInSameSubnet(const Ipv4Address b) const
Checks if the address is in the same subnet.
Ipv4Address GetAddress() const
Get the local address.
Ipv4Address m_broadcast
Broadcast address.
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope() const
Get address scope.
bool m_secondary
For use in multihoming.
Ipv4Address GetLocal() const
Get the local address.
void SetLocal(Ipv4Address local)
Set local address.
friend bool operator!=(const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
Not equal to operator.
bool IsSecondary() const
Check if the address is a secondary address.
void SetScope(Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Set the scope.
Ipv4Address m_local
Interface address.
InterfaceAddressScope_e m_scope
Address scope.
void SetSecondary()
Make the address secondary (used for multihoming)
void SetAddress(Ipv4Address address)
Set local address.
Ipv4Address GetBroadcast() const
Get the broadcast address.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition: callback.h:676
bool operator==(const EventId &a, const EventId &b)
Definition: event-id.h:157
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129