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-end-point.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 "ns3/packet.h"
22
#include "ns3/log.h"
23
#include "ns3/simulator.h"
24
25
#include "
ipv6-end-point.h
"
26
27
namespace
ns3
28
{
29
30
NS_LOG_COMPONENT_DEFINE
(
"Ipv6EndPoint"
);
31
32
Ipv6EndPoint::Ipv6EndPoint
(
Ipv6Address
addr, uint16_t
port
)
33
: m_localAddr (addr),
34
m_localPort (port),
35
m_peerAddr (
Ipv6Address
::GetAny ()),
36
m_peerPort (0)
37
{
38
}
39
40
Ipv6EndPoint::~Ipv6EndPoint
()
41
{
42
if
(!
m_destroyCallback
.
IsNull
())
43
{
44
m_destroyCallback
();
45
}
46
m_rxCallback
.
Nullify
();
47
m_icmpCallback
.
Nullify
();
48
m_destroyCallback
.
Nullify
();
49
}
50
51
Ipv6Address
Ipv6EndPoint::GetLocalAddress
()
52
{
53
return
m_localAddr
;
54
}
55
56
void
Ipv6EndPoint::SetLocalAddress
(
Ipv6Address
addr)
57
{
58
m_localAddr
= addr;
59
}
60
61
uint16_t
Ipv6EndPoint::GetLocalPort
()
62
{
63
return
m_localPort
;
64
}
65
66
void
Ipv6EndPoint::SetLocalPort
(uint16_t
port
)
67
{
68
m_localPort
=
port
;
69
}
70
71
Ipv6Address
Ipv6EndPoint::GetPeerAddress
()
72
{
73
return
m_peerAddr
;
74
}
75
76
uint16_t
Ipv6EndPoint::GetPeerPort
()
77
{
78
return
m_peerPort
;
79
}
80
81
void
Ipv6EndPoint::BindToNetDevice
(
Ptr<NetDevice>
netdevice)
82
{
83
m_boundnetdevice
= netdevice;
84
return
;
85
}
86
87
Ptr<NetDevice>
Ipv6EndPoint::GetBoundNetDevice
(
void
)
88
{
89
return
m_boundnetdevice
;
90
}
91
92
void
Ipv6EndPoint::SetPeer
(
Ipv6Address
addr, uint16_t
port
)
93
{
94
m_peerAddr
= addr;
95
m_peerPort
=
port
;
96
}
97
98
void
Ipv6EndPoint::SetRxCallback
(
Callback
<
void
,
Ptr<Packet>
,
Ipv6Header
, uint16_t> callback)
99
{
100
m_rxCallback
= callback;
101
}
102
103
void
Ipv6EndPoint::SetIcmpCallback
(
Callback<void,Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t>
callback)
104
{
105
m_icmpCallback
= callback;
106
}
107
108
void
Ipv6EndPoint::SetDestroyCallback
(
Callback<void>
callback)
109
{
110
m_destroyCallback
= callback;
111
}
112
113
void
Ipv6EndPoint::ForwardUp
(
Ptr<Packet>
p,
Ipv6Header
header, uint16_t
port
)
114
{
115
if
(!
m_rxCallback
.
IsNull
())
116
{
117
m_rxCallback
(p, header, port);
118
}
119
}
120
121
void
Ipv6EndPoint::ForwardIcmp
(
Ipv6Address
src, uint8_t ttl, uint8_t type,
122
uint8_t code, uint32_t info)
123
{
124
if
(!
m_icmpCallback
.
IsNull
())
125
{
126
Simulator::ScheduleNow
(&
Ipv6EndPoint::DoForwardIcmp
,
this
,
127
src, ttl, type, code, info);
128
}
129
}
130
131
void
Ipv6EndPoint::DoForwardUp
(
Ptr<Packet>
p,
Ipv6Header
header, uint16_t sport)
132
{
133
m_rxCallback
(p, header, sport);
134
}
135
136
void
Ipv6EndPoint::DoForwardIcmp
(
Ipv6Address
src, uint8_t ttl, uint8_t type,
137
uint8_t code, uint32_t info)
138
{
139
m_icmpCallback
(src, ttl, type, code, info);
140
}
141
142
}
/* namespace ns3 */
143
src
internet
model
ipv6-end-point.cc
Generated on Tue May 14 2013 11:08:22 for ns-3 by
1.8.1.2