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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
ipv6-interface-address.cc
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
99
{
100
m_scope
=
GLOBAL
;
101
}
102
}
103
104
Ipv6Prefix
Ipv6InterfaceAddress::GetPrefix
()
const
105
{
106
NS_LOG_FUNCTION_NOARGS
();
107
return
m_prefix
;
108
}
109
110
void
Ipv6InterfaceAddress::SetState
(
Ipv6InterfaceAddress::State_e
state)
111
{
112
NS_LOG_FUNCTION
(
this
<< state);
113
m_state
= state;
114
}
115
116
Ipv6InterfaceAddress::State_e
Ipv6InterfaceAddress::GetState
()
const
117
{
118
NS_LOG_FUNCTION_NOARGS
();
119
return
m_state
;
120
}
121
122
void
Ipv6InterfaceAddress::SetScope
(
Ipv6InterfaceAddress::Scope_e
scope)
123
{
124
NS_LOG_FUNCTION
(
this
<< scope);
125
m_scope
= scope;
126
}
127
128
Ipv6InterfaceAddress::Scope_e
Ipv6InterfaceAddress::GetScope
()
const
129
{
130
NS_LOG_FUNCTION_NOARGS
();
131
return
m_scope
;
132
}
133
134
std::ostream&
operator<<
(std::ostream& os,
const
Ipv6InterfaceAddress
&addr)
135
{
136
os <<
"address="
<< addr.
GetAddress
() <<
"; prefix="
<<
137
addr.
GetPrefix
() <<
"; scope="
<< addr.
GetScope
();
138
return
os;
139
}
140
141
uint32_t
Ipv6InterfaceAddress::GetNsDadUid
()
const
142
{
143
NS_LOG_FUNCTION_NOARGS
();
144
return
m_nsDadUid
;
145
}
146
147
void
Ipv6InterfaceAddress::SetNsDadUid
(uint32_t nsDadUid)
148
{
149
NS_LOG_FUNCTION
(
this
<< nsDadUid);
150
m_nsDadUid
= nsDadUid;
151
}
152
153
#if 0
154
void
Ipv6InterfaceAddress::StartDadTimer (
Ptr<Ipv6Interface>
interface)
155
{
156
NS_LOG_FUNCTION
(
this
<< interface);
157
m_dadTimer.SetFunction (&
Icmpv6L4Protocol::FunctionDadTimeout
);
158
m_dadTimer.SetArguments (interface,
m_address
);
159
m_dadTimer.Schedule (
Seconds
(1));
160
m_dadId =
Simulator::Schedule
(
Seconds
(1.), &
Icmpv6L4Protocol::FunctionDadTimeout
, interface,
m_address
);
161
}
162
163
void
Ipv6InterfaceAddress::StopDadTimer ()
164
{
165
NS_LOG_FUNCTION_NOARGS
();
166
m_dadTimer.Cancel ();
167
Simulator::Cancel
(m_dadId);
168
}
169
#endif
170
171
}
/* namespace ns3 */
172
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:122
ns3::Ipv6InterfaceAddress::GetNsDadUid
uint32_t GetNsDadUid() const
Get the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:141
ns3::Ptr< Ipv6Interface >
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:311
ns3::Ipv6Address::IsLinkLocal
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
Definition:
ipv6-address.cc:615
ns3::Ipv6InterfaceAddress::SetNsDadUid
void SetNsDadUid(uint32_t uid)
Set the latest DAD probe packet UID.
Definition:
ipv6-interface-address.cc:147
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Definition:
log.h:122
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:267
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:820
ns3::Icmpv6L4Protocol::FunctionDadTimeout
static void FunctionDadTimeout(Ptr< Icmpv6L4Protocol > icmpv6, Ipv6Interface *interface, Ipv6Address addr)
Function called when DAD timeout.
Definition:
icmpv6-l4-protocol.cc:1309
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
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:110
ns3::Ipv6InterfaceAddress::GetPrefix
Ipv6Prefix GetPrefix() const
Get the IPv6 prefix.
Definition:
ipv6-interface-address.cc:104
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:116
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:44
ns3::Ipv6InterfaceAddress::SetAddress
void SetAddress(Ipv6Address address)
Set IPv6 address (and scope).
Definition:
ipv6-interface-address.cc:81
ns3::Seconds
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Definition:
nstime.h:586
ns3::Ipv6InterfaceAddress::GetScope
Ipv6InterfaceAddress::Scope_e GetScope() const
Get address scope.
Definition:
ipv6-interface-address.cc:128
ns3::Ipv6InterfaceAddress::m_prefix
Ipv6Prefix m_prefix
The IPv6 prefix.
Definition:
ipv6-interface-address.h:170
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:326
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
ns3::Ipv6Address::IsLocalhost
bool IsLocalhost() const
If the IPv6 address is localhost (::1).
Definition:
ipv6-address.cc:421
src
internet
model
ipv6-interface-address.cc
Generated on Sun Mar 16 2014 11:25:04 for ns-3 by
1.8.6