A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ipv6-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) 2007-2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
*/
20
21
#include <iostream>
22
23
#include "ns3/log.h"
24
#include "ns3/assert.h"
25
26
#include "
ipv6-interface-address.h
"
27
28
namespace
ns3
29
{
30
31
NS_LOG_COMPONENT_DEFINE
(
"Ipv6InterfaceAddress"
);
32
33
Ipv6InterfaceAddress::Ipv6InterfaceAddress
()
34
: m_address (
Ipv6Address
()),
35
m_prefix (
Ipv6Prefix
()),
36
m_state (TENTATIVE_OPTIMISTIC),
37
m_scope (HOST),
38
m_nsDadUid (0)
39
{
40
NS_LOG_FUNCTION
(
this
);
41
}
42
43
Ipv6InterfaceAddress::Ipv6InterfaceAddress
(
Ipv6Address
address
)
44
{
45
NS_LOG_FUNCTION
(
this
<< address);
46
m_prefix
=
Ipv6Prefix
(64);
47
SetAddress
(address);
48
SetState
(
TENTATIVE_OPTIMISTIC
);
49
m_nsDadUid
= 0;
50
}
51
52
Ipv6InterfaceAddress::Ipv6InterfaceAddress
(
Ipv6Address
address
,
Ipv6Prefix
prefix)
53
{
54
NS_LOG_FUNCTION
(
this
<< address << prefix);
55
m_prefix
= prefix;
56
SetAddress
(address);
57
SetState
(
TENTATIVE_OPTIMISTIC
);
58
m_nsDadUid
= 0;
59
}
60
61
Ipv6InterfaceAddress::Ipv6InterfaceAddress
(
const
Ipv6InterfaceAddress
& o)
62
: m_address (o.m_address),
63
m_prefix (o.m_prefix),
64
m_state (o.m_state),
65
m_scope (o.m_scope),
66
m_nsDadUid (o.m_nsDadUid)
67
{
68
}
69
70
Ipv6InterfaceAddress::~Ipv6InterfaceAddress
()
71
{
72
NS_LOG_FUNCTION_NOARGS
();
73
}
74
75
Ipv6Address
Ipv6InterfaceAddress::GetAddress
()
const
76
{
77
NS_LOG_FUNCTION_NOARGS
();
78
return
m_address
;
79
}
80
81
void
Ipv6InterfaceAddress::SetAddress
(
Ipv6Address
address
)
82
{
83
NS_LOG_FUNCTION
(
this
<< address);
84
m_address
=
address
;
85
86
if
(address.
IsLocalhost
())
87
{
88
m_scope
=
HOST
;
89
/* localhost address is always /128 prefix */
90
m_prefix
=
Ipv6Prefix
(128);
91
}
92
else
if
(address.
IsLinkLocal
())
93
{
94
m_scope
=
LINKLOCAL
;
95
/* link-local address is always /64 prefix */
96
m_prefix
=
Ipv6Prefix
(64);
97
}
98
else
if
(address.
IsLinkLocalMulticast
())
99
{
100
m_scope
=
LINKLOCAL
;
101
/* link-local multicast address is always /16 prefix */
102
m_prefix
=
Ipv6Prefix
(16);
103
}
104
else
105
{
106
m_scope
=
GLOBAL
;
107
}
108
}
109
110
Ipv6Prefix
Ipv6InterfaceAddress::GetPrefix
()
const
111
{
112
NS_LOG_FUNCTION_NOARGS
();
113
return
m_prefix
;
114
}
115
116
void
Ipv6InterfaceAddress::SetState
(
Ipv6InterfaceAddress::State_e
state)
117
{
118
NS_LOG_FUNCTION
(
this
<< state);
119
m_state
= state;
120
}
121
122
Ipv6InterfaceAddress::State_e
Ipv6InterfaceAddress::GetState
()
const
123
{
124
NS_LOG_FUNCTION_NOARGS
();
125
return
m_state
;
126
}
127
128
void
Ipv6InterfaceAddress::SetScope
(
Ipv6InterfaceAddress::Scope_e
scope)
129
{
130
NS_LOG_FUNCTION
(
this
<< scope);
131
m_scope
= scope;
132
}
133
134
Ipv6InterfaceAddress::Scope_e
Ipv6InterfaceAddress::GetScope
()
const
135
{
136
NS_LOG_FUNCTION_NOARGS
();
137
return
m_scope
;
138
}
139
140
std::ostream&
operator<<
(std::ostream& os,
const
Ipv6InterfaceAddress
&addr)
141
{
142
os <<
"address="
<< addr.
GetAddress
() <<
"; prefix="
<<
143
addr.
GetPrefix
() <<
"; scope="
<< addr.
GetScope
();
144
return
os;
145
}
146
147
uint32_t
Ipv6InterfaceAddress::GetNsDadUid
()
const
148
{
149
NS_LOG_FUNCTION_NOARGS
();
150
return
m_nsDadUid
;
151
}
152
153
void
Ipv6InterfaceAddress::SetNsDadUid
(uint32_t nsDadUid)
154
{
155
NS_LOG_FUNCTION
(
this
<< nsDadUid);
156
m_nsDadUid
= nsDadUid;
157
}
158
159
#if 0
160
void
Ipv6InterfaceAddress::StartDadTimer (
Ptr<Ipv6Interface>
interface)
161
{
162
NS_LOG_FUNCTION
(
this
<< interface);
163
m_dadTimer.SetFunction (&
Icmpv6L4Protocol::FunctionDadTimeout
);
164
m_dadTimer.SetArguments (interface,
m_address
);
165
m_dadTimer.Schedule (Seconds (1));
166
m_dadId =
Simulator::Schedule
(Seconds (1.), &
Icmpv6L4Protocol::FunctionDadTimeout
, interface,
m_address
);
167
}
168
169
void
Ipv6InterfaceAddress::StopDadTimer ()
170
{
171
NS_LOG_FUNCTION_NOARGS
();
172
m_dadTimer.Cancel ();
173
Simulator::Cancel
(m_dadId);
174
}
175
#endif
176
177
}
/* namespace ns3 */
178
ns3::Ipv6InterfaceAddress::m_state
State_e m_state
State of the address.
Definition:
ipv6-interface-address.h:175
ns3::Ipv6InterfaceAddress::SetScope
void SetScope(Ipv6InterfaceAddress::Scope_e scope)
Set the scope.
Definition:
ipv6-interface-address.cc:128
ns3::Ipv6InterfaceAddress::GetNsDadUid
uint32_t GetNsDadUid() const
Get the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:147
ns3::Ptr< Ipv6Interface >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::Ipv6Address::IsLinkLocalMulticast
bool IsLinkLocalMulticast() const
If the IPv6 address is link-local multicast (ff02::/16).
Definition:
ipv6-address.cc:512
ns3::Ipv6Address::IsLinkLocal
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
Definition:
ipv6-address.cc:702
ns3::Ipv6InterfaceAddress::SetNsDadUid
void SetNsDadUid(uint32_t uid)
Set the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:153
ns3::Ipv6InterfaceAddress
IPv6 address associated with an interface.
Definition:
ipv6-interface-address.h:36
ns3::Ipv6InterfaceAddress::LINKLOCAL
Definition:
ipv6-interface-address.h:61
ns3::Ipv6InterfaceAddress::m_nsDadUid
uint32_t m_nsDadUid
Last DAD probe packet UID.
Definition:
ipv6-interface-address.h:188
ns3::Simulator::Cancel
static void Cancel(const EventId &id)
Definition:
simulator.cc:268
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Definition:
log.h:275
ns3::Simulator::Schedule
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition:
simulator.h:824
ns3::Icmpv6L4Protocol::FunctionDadTimeout
static void FunctionDadTimeout(Ptr< Icmpv6L4Protocol > icmpv6, Ipv6Interface *interface, Ipv6Address addr)
Function called when DAD timeout.
Definition:
icmpv6-l4-protocol.cc:1383
ns3::Ipv6InterfaceAddress::GetAddress
Ipv6Address GetAddress() const
Get the IPv6 address.
Definition:
ipv6-interface-address.cc:75
ns3::Ipv6InterfaceAddress::Ipv6InterfaceAddress
Ipv6InterfaceAddress()
Default constructor.
Definition:
ipv6-interface-address.cc:33
ns3::Ipv6InterfaceAddress::m_address
Ipv6Address m_address
The IPv6 address.
Definition:
ipv6-interface-address.h:165
ipv6-interface-address.h
ns3::Ipv6InterfaceAddress::HOST
Definition:
ipv6-interface-address.h:60
ns3::Ipv6InterfaceAddress::SetState
void SetState(Ipv6InterfaceAddress::State_e state)
Set the state.
Definition:
ipv6-interface-address.cc:116
ns3::Ipv6InterfaceAddress::GetPrefix
Ipv6Prefix GetPrefix() const
Get the IPv6 prefix.
Definition:
ipv6-interface-address.cc:110
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition:
angles.cc:43
ns3::Ipv6InterfaceAddress::GLOBAL
Definition:
ipv6-interface-address.h:62
ns3::Ipv6InterfaceAddress::GetState
Ipv6InterfaceAddress::State_e GetState() const
Get the address state.
Definition:
ipv6-interface-address.cc:122
ns3::Ipv6InterfaceAddress::Scope_e
Scope_e
Scope of address.
Definition:
ipv6-interface-address.h:58
ns3::Ipv6InterfaceAddress::~Ipv6InterfaceAddress
~Ipv6InterfaceAddress()
Destructor.
Definition:
ipv6-interface-address.cc:70
ns3::Ipv6Address
Describes an IPv6 address.
Definition:
ipv6-address.h:46
ns3::Ipv6InterfaceAddress::SetAddress
void SetAddress(Ipv6Address address)
Set IPv6 address (and scope).
Definition:
ipv6-interface-address.cc:81
ns3::Ipv6InterfaceAddress::GetScope
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
Definition:
ipv6-interface-address.cc:134
ns3::Ipv6InterfaceAddress::m_prefix
Ipv6Prefix m_prefix
The IPv6 prefix.
Definition:
ipv6-interface-address.h:170
ns3::NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
ns3::Ipv6InterfaceAddress::State_e
State_e
State of an address associated with an interface.
Definition:
ipv6-interface-address.h:43
ns3::Ipv6Prefix
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask.
Definition:
ipv6-address.h:364
ns3::Ipv6InterfaceAddress::m_scope
Scope_e m_scope
Scope of the address.
Definition:
ipv6-interface-address.h:180
ns3::Ipv6InterfaceAddress::TENTATIVE_OPTIMISTIC
Definition:
ipv6-interface-address.h:50
first.address
tuple address
Definition:
first.py:37
ns3::Ipv6Address::IsLocalhost
bool IsLocalhost() const
If the IPv6 address is localhost (::1).
Definition:
ipv6-address.cc:495
src
internet
model
ipv6-interface-address.cc
Generated on Sat Nov 16 2013 16:17:41 for ns-3 by
1.8.5