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::SetPeer
(
Ipv6Address
addr, uint16_t
port
)
82
{
83
m_peerAddr
= addr;
84
m_peerPort
=
port
;
85
}
86
87
void
Ipv6EndPoint::SetRxCallback
(
Callback
<
void
,
Ptr<Packet>
,
Ipv6Address
,
Ipv6Address
, uint16_t> callback)
88
{
89
m_rxCallback
= callback;
90
}
91
92
void
Ipv6EndPoint::SetIcmpCallback
(
Callback<void,Ipv6Address,uint8_t,uint8_t,uint8_t,uint32_t>
callback)
93
{
94
m_icmpCallback
= callback;
95
}
96
97
void
Ipv6EndPoint::SetDestroyCallback
(
Callback<void>
callback)
98
{
99
m_destroyCallback
= callback;
100
}
101
102
void
Ipv6EndPoint::ForwardUp
(
Ptr<Packet>
p,
Ipv6Address
srcAddr,
Ipv6Address
dstAddr, uint16_t
port
)
103
{
104
if
(!
m_rxCallback
.
IsNull
())
105
{
106
m_rxCallback
(p, srcAddr, dstAddr, port);
107
}
108
}
109
110
void
Ipv6EndPoint::ForwardIcmp
(
Ipv6Address
src, uint8_t ttl, uint8_t type,
111
uint8_t code, uint32_t info)
112
{
113
if
(!
m_icmpCallback
.
IsNull
())
114
{
115
Simulator::ScheduleNow
(&
Ipv6EndPoint::DoForwardIcmp
,
this
,
116
src, ttl, type, code, info);
117
}
118
}
119
120
void
Ipv6EndPoint::DoForwardUp
(
Ptr<Packet>
p,
Ipv6Address
saddr,
Ipv6Address
daddr, uint16_t sport)
121
{
122
m_rxCallback
(p, saddr, daddr, sport);
123
}
124
125
void
Ipv6EndPoint::DoForwardIcmp
(
Ipv6Address
src, uint8_t ttl, uint8_t type,
126
uint8_t code, uint32_t info)
127
{
128
m_icmpCallback
(src, ttl, type, code, info);
129
}
130
131
}
/* namespace ns3 */
132
src
internet
model
ipv6-end-point.cc
Generated on Tue Oct 9 2012 16:45:38 for ns-3 by
1.8.1.2