A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
internet
model
ipv4-interface-address.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005 INRIA
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
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "ns3/log.h"
22
#include "ns3/assert.h"
23
#include "
ipv4-interface-address.h
"
24
25
namespace
ns3
{
26
27
NS_LOG_COMPONENT_DEFINE
(
"Ipv4InterfaceAddress"
);
28
29
Ipv4InterfaceAddress::Ipv4InterfaceAddress
()
30
: m_scope (GLOBAL),
31
m_secondary (false)
32
{
33
NS_LOG_FUNCTION
(
this
);
34
}
35
36
Ipv4InterfaceAddress::Ipv4InterfaceAddress
(
Ipv4Address
local,
Ipv4Mask
mask)
37
: m_scope (GLOBAL),
38
m_secondary (false)
39
{
40
NS_LOG_FUNCTION
(
this
<< local << mask);
41
m_local
= local;
42
m_mask
= mask;
43
m_broadcast
=
Ipv4Address
(local.
Get
() | (~mask.
Get
()));
44
}
45
46
Ipv4InterfaceAddress::Ipv4InterfaceAddress
(
const
Ipv4InterfaceAddress
&o)
47
: m_local (o.m_local),
48
m_mask (o.m_mask),
49
m_broadcast (o.m_broadcast),
50
m_scope (o.m_scope),
51
m_secondary (o.m_secondary)
52
{
53
NS_LOG_FUNCTION
(
this
<< &o);
54
}
55
56
void
57
Ipv4InterfaceAddress::SetLocal
(
Ipv4Address
local)
58
{
59
NS_LOG_FUNCTION
(
this
<< local);
60
m_local
= local;
61
}
62
63
Ipv4Address
64
Ipv4InterfaceAddress::GetLocal
(
void
)
const
65
{
66
NS_LOG_FUNCTION
(
this
);
67
return
m_local
;
68
}
69
70
void
71
Ipv4InterfaceAddress::SetMask
(
Ipv4Mask
mask)
72
{
73
NS_LOG_FUNCTION
(
this
<< mask);
74
m_mask
= mask;
75
}
76
77
Ipv4Mask
78
Ipv4InterfaceAddress::GetMask
(
void
)
const
79
{
80
NS_LOG_FUNCTION
(
this
);
81
return
m_mask
;
82
}
83
84
void
85
Ipv4InterfaceAddress::SetBroadcast
(
Ipv4Address
broadcast)
86
{
87
NS_LOG_FUNCTION
(
this
<< broadcast);
88
m_broadcast
= broadcast;
89
}
90
91
Ipv4Address
92
Ipv4InterfaceAddress::GetBroadcast
(
void
)
const
93
{
94
NS_LOG_FUNCTION
(
this
);
95
return
m_broadcast
;
96
}
97
98
void
99
Ipv4InterfaceAddress::SetScope
(
Ipv4InterfaceAddress::InterfaceAddressScope_e
scope)
100
{
101
NS_LOG_FUNCTION
(
this
<< scope);
102
m_scope
= scope;
103
}
104
105
Ipv4InterfaceAddress::InterfaceAddressScope_e
106
Ipv4InterfaceAddress::GetScope
(
void
)
const
107
{
108
NS_LOG_FUNCTION
(
this
);
109
return
m_scope
;
110
}
111
112
bool
113
Ipv4InterfaceAddress::IsSecondary
(
void
)
const
114
{
115
NS_LOG_FUNCTION
(
this
);
116
return
m_secondary
;
117
}
118
119
void
120
Ipv4InterfaceAddress::SetSecondary
(
void
)
121
{
122
NS_LOG_FUNCTION
(
this
);
123
m_secondary
=
true
;
124
}
125
126
void
127
Ipv4InterfaceAddress::SetPrimary
(
void
)
128
{
129
NS_LOG_FUNCTION
(
this
);
130
m_secondary
=
false
;
131
}
132
133
std::ostream&
operator<<
(std::ostream& os,
const
Ipv4InterfaceAddress
&addr)
134
{
135
os <<
"m_local="
<< addr.
GetLocal
() <<
"; m_mask="
<<
136
addr.
GetMask
() <<
"; m_broadcast="
<< addr.
GetBroadcast
() <<
"; m_scope="
<< addr.
GetScope
() <<
137
"; m_secondary="
<< addr.
IsSecondary
();
138
return
os;
139
}
140
141
}
// namespace ns3
ns3::Ipv4InterfaceAddress::m_mask
Ipv4Mask m_mask
Network mask.
Definition:
ipv4-interface-address.h:135
ns3::Ipv4InterfaceAddress::m_scope
InterfaceAddressScope_e m_scope
Address scope.
Definition:
ipv4-interface-address.h:138
ns3::Ipv4InterfaceAddress::InterfaceAddressScope_e
InterfaceAddressScope_e
Address scope.
Definition:
ipv4-interface-address.h:50
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Definition:
log-macros-enabled.h:213
ns3::Ipv4InterfaceAddress::m_secondary
bool m_secondary
For use in multihoming.
Definition:
ipv4-interface-address.h:139
ns3::Ipv4Mask
a class to represent an Ipv4 address mask
Definition:
ipv4-address.h:258
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::Ipv4InterfaceAddress::m_local
Ipv4Address m_local
Interface address.
Definition:
ipv4-interface-address.h:132
ns3::Ipv4InterfaceAddress::GetBroadcast
Ipv4Address GetBroadcast(void) const
Get the broadcast address.
Definition:
ipv4-interface-address.cc:92
ns3::Ipv4InterfaceAddress::SetSecondary
void SetSecondary(void)
Make the address secondary (used for multihoming)
Definition:
ipv4-interface-address.cc:120
ns3::Ipv4InterfaceAddress::SetPrimary
void SetPrimary(void)
Make the address primary.
Definition:
ipv4-interface-address.cc:127
ns3::Ipv4InterfaceAddress::GetMask
Ipv4Mask GetMask(void) const
Get the network mask.
Definition:
ipv4-interface-address.cc:78
ipv4-interface-address.h
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition:
angles.cc:42
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Ipv4InterfaceAddress::m_broadcast
Ipv4Address m_broadcast
Broadcast address.
Definition:
ipv4-interface-address.h:136
ns3::Ipv4InterfaceAddress::GetScope
Ipv4InterfaceAddress::InterfaceAddressScope_e GetScope(void) const
Get address scope.
Definition:
ipv4-interface-address.cc:106
ns3::Ipv4InterfaceAddress::SetBroadcast
void SetBroadcast(Ipv4Address broadcast)
Set the broadcast address.
Definition:
ipv4-interface-address.cc:85
ns3::Ipv4InterfaceAddress::SetMask
void SetMask(Ipv4Mask mask)
Set the network mask.
Definition:
ipv4-interface-address.cc:71
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition:
ipv4-address.h:40
ns3::Ipv4Mask::Get
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
Definition:
ipv4-address.cc:135
ns3::Ipv4InterfaceAddress
a class to store IPv4 address information on an interface
Definition:
ipv4-interface-address.h:43
ns3::Ipv4InterfaceAddress::SetScope
void SetScope(Ipv4InterfaceAddress::InterfaceAddressScope_e scope)
Set the scope.
Definition:
ipv4-interface-address.cc:99
ns3::Ipv4InterfaceAddress::Ipv4InterfaceAddress
Ipv4InterfaceAddress()
Definition:
ipv4-interface-address.cc:29
ns3::Ipv4InterfaceAddress::IsSecondary
bool IsSecondary(void) const
Check if the address is a secondary address.
Definition:
ipv4-interface-address.cc:113
ns3::Ipv4InterfaceAddress::GetLocal
Ipv4Address GetLocal(void) const
Get the local address.
Definition:
ipv4-interface-address.cc:64
ns3::Ipv4Address::Get
uint32_t Get(void) const
Get the host-order 32-bit IP address.
Definition:
ipv4-address.cc:218
ns3::Ipv4InterfaceAddress::SetLocal
void SetLocal(Ipv4Address local)
Set local address.
Definition:
ipv4-interface-address.cc:57
Generated on Wed Nov 7 2018 10:01:54 for ns-3 by
1.8.14