A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
27
namespace
ns3
28
{
29
44
class
Ipv4InterfaceAddress
45
{
46
public
:
51
enum
InterfaceAddressScope_e
52
{
53
HOST
,
54
LINK
,
55
GLOBAL
56
};
57
58
Ipv4InterfaceAddress
();
59
65
Ipv4InterfaceAddress
(
Ipv4Address
local,
Ipv4Mask
mask);
70
Ipv4InterfaceAddress
(
const
Ipv4InterfaceAddress
& o);
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);
129
Ipv4Address
GetBroadcast
()
const
;
130
135
void
SetScope
(
Ipv4InterfaceAddress::InterfaceAddressScope_e
scope);
136
141
Ipv4InterfaceAddress::InterfaceAddressScope_e
GetScope
()
const
;
142
148
bool
IsInSameSubnet
(
const
Ipv4Address
b)
const
;
149
156
bool
IsSecondary
()
const
;
157
161
void
SetSecondary
();
165
void
SetPrimary
();
166
167
private
:
168
Ipv4Address
m_local
;
169
// Note: m_peer may be added in future when necessary
170
// Ipv4Address m_peer; // Peer destination address (in Linux: m_address)
171
Ipv4Mask
m_mask
;
172
Ipv4Address
m_broadcast
;
173
174
InterfaceAddressScope_e
m_scope
;
175
bool
m_secondary
;
176
184
friend
bool
operator==
(
const
Ipv4InterfaceAddress
& a,
const
Ipv4InterfaceAddress
& b);
185
193
friend
bool
operator!=
(
const
Ipv4InterfaceAddress
& a,
const
Ipv4InterfaceAddress
& b);
194
};
195
203
std::ostream&
operator<<
(std::ostream& os,
const
Ipv4InterfaceAddress
& addr);
204
205
inline
bool
206
operator==
(
const
Ipv4InterfaceAddress
& a,
const
Ipv4InterfaceAddress
& b)
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
212
inline
bool
213
operator!=
(
const
Ipv4InterfaceAddress
& a,
const
Ipv4InterfaceAddress
& b)
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 */
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:42
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition:
ipv4-interface-address.h:45
ns3::Ipv4InterfaceAddress::GetMask
Ipv4Mask GetMask() const
Get the network mask.
Definition:
ipv4-interface-address.cc:95
ns3::Ipv4InterfaceAddress::operator==
friend bool operator==(const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
Equal to operator.
Definition:
ipv4-interface-address.h:206
ns3::Ipv4InterfaceAddress::SetMask
void SetMask(Ipv4Mask mask)
Set the network mask.
Definition:
ipv4-interface-address.cc:88
ns3::Ipv4InterfaceAddress::SetBroadcast
void SetBroadcast(Ipv4Address broadcast)
Set the broadcast address.
Definition:
ipv4-interface-address.cc:102
ns3::Ipv4InterfaceAddress::InterfaceAddressScope_e
InterfaceAddressScope_e
Address scope.
Definition:
ipv4-interface-address.h:52
ns3::Ipv4InterfaceAddress::LINK
@ LINK
Definition:
ipv4-interface-address.h:54
ns3::Ipv4InterfaceAddress::HOST
@ HOST
Definition:
ipv4-interface-address.h:53
ns3::Ipv4InterfaceAddress::GLOBAL
@ GLOBAL
Definition:
ipv4-interface-address.h:55
ns3::Ipv4InterfaceAddress::SetPrimary
void SetPrimary()
Make the address primary.
Definition:
ipv4-interface-address.cc:155
ns3::Ipv4InterfaceAddress::IsInSameSubnet
bool IsInSameSubnet(const Ipv4Address b) const
Checks if the address is in the same subnet.
Definition:
ipv4-interface-address.cc:130
ns3::Ipv4InterfaceAddress::GetAddress
Ipv4Address GetAddress() const
Get the local address.
Definition:
ipv4-interface-address.cc:82
ns3::Ipv4InterfaceAddress::m_broadcast
Ipv4Address m_broadcast
Broadcast address.
Definition:
ipv4-interface-address.h:172
ns3::Ipv4InterfaceAddress::GetScope
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope() const
Get address scope.
Definition:
ipv4-interface-address.cc:123
ns3::Ipv4InterfaceAddress::m_secondary
bool m_secondary
For use in multihoming.
Definition:
ipv4-interface-address.h:175
ns3::Ipv4InterfaceAddress::m_mask
Ipv4Mask m_mask
Network mask.
Definition:
ipv4-interface-address.h:171
ns3::Ipv4InterfaceAddress::GetLocal
Ipv4Address GetLocal() const
Get the local address.
Definition:
ipv4-interface-address.cc:75
ns3::Ipv4InterfaceAddress::SetLocal
void SetLocal(Ipv4Address local)
Set local address.
Definition:
ipv4-interface-address.cc:62
ns3::Ipv4InterfaceAddress::operator!=
friend bool operator!=(const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
Not equal to operator.
Definition:
ipv4-interface-address.h:213
ns3::Ipv4InterfaceAddress::IsSecondary
bool IsSecondary() const
Check if the address is a secondary address.
Definition:
ipv4-interface-address.cc:141
ns3::Ipv4InterfaceAddress::SetScope
void SetScope(Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Set the scope.
Definition:
ipv4-interface-address.cc:116
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress
Ipv4InterfaceAddress()
Definition:
ipv4-interface-address.cc:30
ns3::Ipv4InterfaceAddress::m_local
Ipv4Address m_local
Interface address.
Definition:
ipv4-interface-address.h:168
ns3::Ipv4InterfaceAddress::m_scope
InterfaceAddressScope_e m_scope
Address scope.
Definition:
ipv4-interface-address.h:174
ns3::Ipv4InterfaceAddress::SetSecondary
void SetSecondary()
Make the address secondary (used for multihoming)
Definition:
ipv4-interface-address.cc:148
ns3::Ipv4InterfaceAddress::SetAddress
void SetAddress(Ipv4Address address)
Set local address.
Definition:
ipv4-interface-address.cc:69
ns3::Ipv4InterfaceAddress::GetBroadcast
Ipv4Address GetBroadcast() const
Get the broadcast address.
Definition:
ipv4-interface-address.cc:109
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition:
ipv4-address.h:257
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator!=
bool operator!=(Callback< R, Args... > a, Callback< R, Args... > b)
Inequality test.
Definition:
callback.h:676
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.h:157
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:129
src
internet
model
ipv4-interface-address.h
Generated on Sun Jul 2 2023 18:21:39 for ns-3 by
1.9.6