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-l3-protocol.h
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
#ifndef IPV6_L3_PROTOCOL_H
22
#define IPV6_L3_PROTOCOL_H
23
24
#include <list>
25
26
#include "ns3/traced-callback.h"
27
#include "ns3/net-device.h"
28
#include "ns3/ipv6.h"
29
#include "ns3/ipv6-address.h"
30
#include "ns3/ipv6-header.h"
31
32
namespace
ns3
33
{
34
35
class
Node;
36
class
Ipv6Interface;
37
class
IpL4Protocol;
38
class
Ipv6Route;
39
class
Ipv6MulticastRoute;
40
class
Ipv6RawSocketImpl;
41
class
Icmpv6L4Protocol;
42
class
Ipv6AutoconfiguredPrefix;
43
58
class
Ipv6L3Protocol
:
public
Ipv6
59
{
60
public
:
65
static
TypeId
GetTypeId
();
66
70
static
const
uint16_t
PROT_NUMBER
;
71
76
enum
DropReason
77
{
78
DROP_TTL_EXPIRED
= 1,
79
DROP_NO_ROUTE
,
80
DROP_INTERFACE_DOWN
,
81
DROP_ROUTE_ERROR
,
82
DROP_UNKNOWN_PROTOCOL
,
83
};
84
88
Ipv6L3Protocol
();
89
93
virtual
~Ipv6L3Protocol
();
94
99
void
SetNode
(
Ptr<Node>
node);
100
105
void
Insert
(
Ptr<IpL4Protocol>
protocol);
106
111
void
Remove
(
Ptr<IpL4Protocol>
protocol);
112
118
Ptr<IpL4Protocol>
GetProtocol
(
int
protocolNumber)
const
;
119
124
Ptr<Socket>
CreateRawSocket
();
125
130
void
DeleteRawSocket
(
Ptr<Socket>
socket);
131
136
void
SetDefaultTtl
(uint8_t ttl);
137
149
void
Receive
(
Ptr<NetDevice>
device,
Ptr<const Packet>
p, uint16_t protocol,
const
Address
&from,
const
Address
&to,
NetDevice::PacketType
packetType);
150
161
void
Send
(
Ptr<Packet>
packet,
Ipv6Address
source,
Ipv6Address
destination, uint8_t protocol,
Ptr<Ipv6Route>
route);
162
167
void
SetRoutingProtocol
(
Ptr<Ipv6RoutingProtocol>
routingProtocol);
168
173
Ptr<Ipv6RoutingProtocol>
GetRoutingProtocol
()
const
;
174
180
uint32_t
AddInterface
(
Ptr<NetDevice>
device);
181
187
Ptr<Ipv6Interface>
GetInterface
(uint32_t i)
const
;
188
193
uint32_t
GetNInterfaces
()
const
;
194
200
int32_t
GetInterfaceForAddress
(
Ipv6Address
addr)
const
;
201
208
int32_t
GetInterfaceForPrefix
(
Ipv6Address
addr,
Ipv6Prefix
mask)
const
;
209
214
int32_t
GetInterfaceForDevice
(
Ptr<const NetDevice>
device)
const
;
215
221
bool
AddAddress
(uint32_t i,
Ipv6InterfaceAddress
address);
222
229
Ipv6InterfaceAddress
GetAddress
(uint32_t interfaceIndex, uint32_t addressIndex)
const
;
230
236
uint32_t
GetNAddresses
(uint32_t interface)
const
;
237
243
bool
RemoveAddress
(uint32_t interfaceIndex, uint32_t addressIndex);
244
250
void
SetMetric
(uint32_t i, uint16_t metric);
251
257
uint16_t
GetMetric
(uint32_t i)
const
;
258
264
uint16_t
GetMtu
(uint32_t i)
const
;
265
270
bool
IsUp
(uint32_t i)
const
;
271
276
void
SetUp
(uint32_t i);
277
282
void
SetDown
(uint32_t i);
283
288
bool
IsForwarding
(uint32_t i)
const
;
289
295
void
SetForwarding
(uint32_t i,
bool
val);
296
302
Ptr<NetDevice>
GetNetDevice
(uint32_t i);
303
308
Ptr<Icmpv6L4Protocol>
GetIcmpv6
()
const
;
309
320
void
AddAutoconfiguredAddress
(uint32_t interface,
Ipv6Address
network,
Ipv6Prefix
mask, uint8_t flags, uint32_t validTime, uint32_t preferredTime,
Ipv6Address
defaultRouter =
Ipv6Address::GetZero
());
321
331
void
RemoveAutoconfiguredAddress
(uint32_t interface,
Ipv6Address
network,
Ipv6Prefix
mask,
Ipv6Address
defaultRouter);
332
336
virtual
void
RegisterExtensions
();
337
341
virtual
void
RegisterOptions
();
342
343
protected
:
347
virtual
void
DoDispose
();
348
354
virtual
void
NotifyNewAggregate
();
355
356
private
:
357
/* for unit-tests */
358
friend
class
Ipv6L3ProtocolTestCase
;
359
friend
class
Ipv6ExtensionLooseRouting
;
360
361
typedef
std::list<Ptr<Ipv6Interface> >
Ipv6InterfaceList
;
362
typedef
std::list<Ptr<Ipv6RawSocketImpl> >
SocketList
;
363
typedef
std::list<Ptr<IpL4Protocol> >
L4List_t
;
364
365
typedef
std::list< Ptr<Ipv6AutoconfiguredPrefix> >
Ipv6AutoconfiguredPrefixList
;
366
typedef
std::list< Ptr<Ipv6AutoconfiguredPrefix> >::iterator
Ipv6AutoconfiguredPrefixListI
;
367
371
TracedCallback<Ptr<const Packet>
,
Ptr<Ipv6>
, uint32_t>
m_txTrace
;
372
376
TracedCallback<Ptr<const Packet>
,
Ptr<Ipv6>
, uint32_t>
m_rxTrace
;
377
381
TracedCallback<const Ipv6Header &, Ptr<const Packet>
,
DropReason
,
Ptr<Ipv6>
, uint32_t>
m_dropTrace
;
382
387
Ipv6L3Protocol
(
const
Ipv6L3Protocol
& o);
388
393
Ipv6L3Protocol
&
operator =
(
const
Ipv6L3Protocol
& o);
394
404
Ipv6Header
BuildHeader
(
Ipv6Address
src,
Ipv6Address
dst, uint8_t protocol,
405
uint16_t payloadSize, uint8_t ttl);
406
413
void
SendRealOut
(
Ptr<Ipv6Route>
route,
Ptr<Packet>
packet,
Ipv6Header
const
& ipHeader);
414
421
void
IpForward
(
Ptr<Ipv6Route>
rtentry,
Ptr<const Packet>
p,
const
Ipv6Header
& header);
422
429
void
IpMulticastForward
(
Ptr<Ipv6MulticastRoute>
mrtentry,
Ptr<const Packet>
p,
const
Ipv6Header
& header);
430
437
void
LocalDeliver
(
Ptr<const Packet>
p,
Ipv6Header
const
& ip, uint32_t iif);
438
445
void
RouteInputError
(
Ptr<const Packet>
p,
const
Ipv6Header
& ipHeader,
Socket::SocketErrno
sockErrno);
446
452
uint32_t
AddIpv6Interface
(
Ptr<Ipv6Interface>
interface);
453
457
void
SetupLoopback
();
458
463
virtual
void
SetIpForward
(
bool
forward);
464
469
virtual
bool
GetIpForward
()
const
;
470
475
virtual
void
SetSendIcmpv6Redirect
(
bool
sendIcmpv6Redirect);
476
481
virtual
bool
GetSendIcmpv6Redirect
()
const
;
482
486
Ptr<Node>
m_node
;
487
491
bool
m_ipForward
;
492
496
L4List_t
m_protocols
;
497
501
Ipv6InterfaceList
m_interfaces
;
502
506
uint32_t
m_nInterfaces
;
507
511
uint8_t
m_defaultTtl
;
512
516
Ptr<Ipv6RoutingProtocol>
m_routingProtocol
;
517
521
SocketList
m_sockets
;
522
526
Ipv6AutoconfiguredPrefixList
m_prefixes
;
527
531
bool
m_sendIcmpv6Redirect
;
532
};
533
534
}
/* namespace ns3 */
535
536
#endif
/* IPV6_L3_PROTOCOL_H */
537
src
internet
model
ipv6-l3-protocol.h
Generated on Tue Nov 13 2012 10:32:15 for ns-3 by
1.8.1.2