A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
ipv4-interface-address.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
20
#ifndef IPV4_INTERFACE_ADDRESS_H
21
#define IPV4_INTERFACE_ADDRESS_H
22
23
#include <stdint.h>
24
#include <ostream>
25
#include "ns3/ipv4-address.h"
26
27
namespace
ns3
{
28
43
class
Ipv4InterfaceAddress
44
{
45
public
:
50
enum
InterfaceAddressScope_e
{
51
HOST
,
52
LINK
,
53
GLOBAL
54
};
55
56
Ipv4InterfaceAddress
();
57
63
Ipv4InterfaceAddress
(
Ipv4Address
local,
Ipv4Mask
mask);
68
Ipv4InterfaceAddress
(
const
Ipv4InterfaceAddress
&o);
69
78
void
SetLocal
(
Ipv4Address
local);
79
87
void
SetAddress
(
Ipv4Address
address
);
88
97
Ipv4Address
GetLocal
(
void
)
const
;
98
106
Ipv4Address
GetAddress
(
void
)
const
;
107
112
void
SetMask
(
Ipv4Mask
mask);
117
Ipv4Mask
GetMask
(
void
)
const
;
122
void
SetBroadcast
(
Ipv4Address
broadcast);
127
Ipv4Address
GetBroadcast
(
void
)
const
;
128
133
void
SetScope
(
Ipv4InterfaceAddress::InterfaceAddressScope_e
scope);
134
139
Ipv4InterfaceAddress::InterfaceAddressScope_e
GetScope
(
void
)
const
;
140
146
bool
IsInSameSubnet
(
const
Ipv4Address
b)
const
;
147
154
bool
IsSecondary
(
void
)
const
;
155
159
void
SetSecondary
(
void
);
163
void
SetPrimary
(
void
);
164
165
private
:
166
167
Ipv4Address
m_local
;
168
// Note: m_peer may be added in future when necessary
169
// Ipv4Address m_peer; // Peer destination address (in Linux: m_address)
170
Ipv4Mask
m_mask
;
171
Ipv4Address
m_broadcast
;
172
173
InterfaceAddressScope_e
m_scope
;
174
bool
m_secondary
;
175
183
friend
bool
operator ==
(
Ipv4InterfaceAddress
const
&a,
Ipv4InterfaceAddress
const
&b);
184
192
friend
bool
operator !=
(
Ipv4InterfaceAddress
const
&a,
Ipv4InterfaceAddress
const
&b);
193
};
194
202
std::ostream&
operator<<
(std::ostream& os,
const
Ipv4InterfaceAddress
&addr);
203
204
inline
bool
operator ==
(
const
Ipv4InterfaceAddress
&a,
const
Ipv4InterfaceAddress
&b)
205
{
206
return
(a.
m_local
== b.
m_local
&& a.
m_mask
== b.
m_mask
&&
207
a.
m_broadcast
== b.
m_broadcast
&& a.
m_scope
== b.
m_scope
&& a.
m_secondary
== b.
m_secondary
);
208
}
209
inline
bool
operator !=
(
const
Ipv4InterfaceAddress
&a,
const
Ipv4InterfaceAddress
&b)
210
{
211
return
(a.
m_local
!= b.
m_local
|| a.
m_mask
!= b.
m_mask
||
212
a.
m_broadcast
!= b.
m_broadcast
|| a.
m_scope
!= b.
m_scope
|| a.
m_secondary
!= b.
m_secondary
);
213
}
214
215
216
}
// namespace ns3
217
218
#endif
/* IPV4_ADDRESS_H */
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:41
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition:
ipv4-interface-address.h:44
ns3::Ipv4InterfaceAddress::SetMask
void SetMask(Ipv4Mask mask)
Set the network mask.
Definition:
ipv4-interface-address.cc:87
ns3::Ipv4InterfaceAddress::GetBroadcast
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
Definition:
ipv4-interface-address.cc:108
ns3::Ipv4InterfaceAddress::SetSecondary
void SetSecondary(void)
Make the address secondary (used for multihoming)
Definition:
ipv4-interface-address.cc:146
ns3::Ipv4InterfaceAddress::SetBroadcast
void SetBroadcast(Ipv4Address broadcast)
Set the broadcast address.
Definition:
ipv4-interface-address.cc:101
ns3::Ipv4InterfaceAddress::GetScope
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
Definition:
ipv4-interface-address.cc:122
ns3::Ipv4InterfaceAddress::InterfaceAddressScope_e
InterfaceAddressScope_e
Address scope.
Definition:
ipv4-interface-address.h:50
ns3::Ipv4InterfaceAddress::LINK
@ LINK
Definition:
ipv4-interface-address.h:52
ns3::Ipv4InterfaceAddress::HOST
@ HOST
Definition:
ipv4-interface-address.h:51
ns3::Ipv4InterfaceAddress::GLOBAL
@ GLOBAL
Definition:
ipv4-interface-address.h:53
ns3::Ipv4InterfaceAddress::IsInSameSubnet
bool IsInSameSubnet(const Ipv4Address b) const
Checks if the address is in the same subnet.
Definition:
ipv4-interface-address.cc:128
ns3::Ipv4InterfaceAddress::m_broadcast
Ipv4Address m_broadcast
Broadcast address.
Definition:
ipv4-interface-address.h:171
ns3::Ipv4InterfaceAddress::m_secondary
bool m_secondary
For use in multihoming.
Definition:
ipv4-interface-address.h:174
ns3::Ipv4InterfaceAddress::m_mask
Ipv4Mask m_mask
Network mask.
Definition:
ipv4-interface-address.h:170
ns3::Ipv4InterfaceAddress::SetLocal
void SetLocal(Ipv4Address local)
Set local address.
Definition:
ipv4-interface-address.cc:61
ns3::Ipv4InterfaceAddress::GetMask
Ipv4Mask GetMask(void) const
Get the network mask.
Definition:
ipv4-interface-address.cc:94
ns3::Ipv4InterfaceAddress::GetLocal
Ipv4Address GetLocal(void) const
Get the local address.
Definition:
ipv4-interface-address.cc:74
ns3::Ipv4InterfaceAddress::IsSecondary
bool IsSecondary(void) const
Check if the address is a secondary address.
Definition:
ipv4-interface-address.cc:139
ns3::Ipv4InterfaceAddress::SetScope
void SetScope(Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Set the scope.
Definition:
ipv4-interface-address.cc:115
ns3::Ipv4InterfaceAddress::operator!=
friend bool operator!=(Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b)
Not equal to operator.
Definition:
ipv4-interface-address.h:209
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress
Ipv4InterfaceAddress()
Definition:
ipv4-interface-address.cc:29
ns3::Ipv4InterfaceAddress::m_local
Ipv4Address m_local
Interface address.
Definition:
ipv4-interface-address.h:167
ns3::Ipv4InterfaceAddress::m_scope
InterfaceAddressScope_e m_scope
Address scope.
Definition:
ipv4-interface-address.h:173
ns3::Ipv4InterfaceAddress::operator==
friend bool operator==(Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b)
Equal to operator.
Definition:
ipv4-interface-address.h:204
ns3::Ipv4InterfaceAddress::GetAddress
Ipv4Address GetAddress(void) const
Get the local address.
Definition:
ipv4-interface-address.cc:81
ns3::Ipv4InterfaceAddress::SetAddress
void SetAddress(Ipv4Address address)
Set local address.
Definition:
ipv4-interface-address.cc:68
ns3::Ipv4InterfaceAddress::SetPrimary
void SetPrimary(void)
Make the address primary.
Definition:
ipv4-interface-address.cc:153
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition:
ipv4-address.h:256
first.address
address
Definition:
first.py:44
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator==
bool operator==(const EventId &a, const EventId &b)
Definition:
event-id.h:158
ns3::operator!=
bool operator!=(Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > a, Callback< R, T1, T2, T3, T4, T5, T6, T7, T8, T9 > b)
Inequality test.
Definition:
callback.h:1612
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:139
src
internet
model
ipv4-interface-address.h
Generated on Tue Feb 6 2024 19:21:19 for ns-3 by
1.9.1