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
ipv4-static-routing.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2006 Georgia Tech Research Corporation
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: George F. Riley<riley@ece.gatech.edu>
19
* Gustavo Carneiro <gjc@inescporto.pt>
20
*/
21
22
#ifndef IPV4_STATIC_ROUTING_H
23
#define IPV4_STATIC_ROUTING_H
24
25
#include <list>
26
#include <utility>
27
#include <stdint.h>
28
#include "ns3/ipv4-address.h"
29
#include "ns3/ipv4-header.h"
30
#include "ns3/socket.h"
31
#include "ns3/ptr.h"
32
#include "ns3/ipv4.h"
33
#include "ns3/ipv4-routing-protocol.h"
34
35
namespace
ns3 {
36
37
class
Packet;
38
class
NetDevice;
39
class
Ipv4Interface;
40
class
Ipv4Address;
41
class
Ipv4Header;
42
class
Ipv4RoutingTableEntry;
43
class
Ipv4MulticastRoutingTableEntry;
44
class
Node;
45
69
class
Ipv4StaticRouting
:
public
Ipv4RoutingProtocol
70
{
71
public
:
72
static
TypeId
GetTypeId
(
void
);
73
74
Ipv4StaticRouting
();
75
virtual
~Ipv4StaticRouting
();
76
77
virtual
Ptr<Ipv4Route>
RouteOutput
(
Ptr<Packet>
p,
const
Ipv4Header
&header,
Ptr<NetDevice>
oif,
Socket::SocketErrno
&sockerr);
78
79
virtual
bool
RouteInput
(
Ptr<const Packet>
p,
const
Ipv4Header
&header,
Ptr<const NetDevice>
idev,
80
UnicastForwardCallback
ucb,
MulticastForwardCallback
mcb,
81
LocalDeliverCallback
lcb,
ErrorCallback
ecb);
82
83
virtual
void
NotifyInterfaceUp
(uint32_t interface);
84
virtual
void
NotifyInterfaceDown
(uint32_t interface);
85
virtual
void
NotifyAddAddress
(uint32_t interface,
Ipv4InterfaceAddress
address);
86
virtual
void
NotifyRemoveAddress
(uint32_t interface,
Ipv4InterfaceAddress
address);
87
virtual
void
SetIpv4
(
Ptr<Ipv4>
ipv4);
88
virtual
void
PrintRoutingTable
(
Ptr<OutputStreamWrapper>
stream)
const
;
89
102
void
AddNetworkRouteTo
(
Ipv4Address
network,
103
Ipv4Mask
networkMask,
104
Ipv4Address
nextHop,
105
uint32_t interface,
106
uint32_t metric = 0);
107
119
void
AddNetworkRouteTo
(
Ipv4Address
network,
120
Ipv4Mask
networkMask,
121
uint32_t interface,
122
uint32_t metric = 0);
123
135
void
AddHostRouteTo
(
Ipv4Address
dest,
136
Ipv4Address
nextHop,
137
uint32_t interface,
138
uint32_t metric = 0);
149
void
AddHostRouteTo
(
Ipv4Address
dest,
150
uint32_t interface,
151
uint32_t metric = 0);
171
void
SetDefaultRoute
(
Ipv4Address
nextHop,
172
uint32_t interface,
173
uint32_t metric = 0);
174
181
uint32_t
GetNRoutes
(
void
)
const
;
182
192
Ipv4RoutingTableEntry
GetDefaultRoute
(
void
);
193
207
Ipv4RoutingTableEntry
GetRoute
(uint32_t i)
const
;
208
216
uint32_t
GetMetric
(uint32_t index)
const
;
217
230
void
RemoveRoute
(uint32_t i);
231
275
void
AddMulticastRoute
(
Ipv4Address
origin,
276
Ipv4Address
group
,
277
uint32_t inputInterface,
278
std::vector<uint32_t> outputInterfaces);
279
304
void
SetDefaultMulticastRoute
(uint32_t outputInterface);
305
312
uint32_t
GetNMulticastRoutes
(
void
)
const
;
313
328
Ipv4MulticastRoutingTableEntry
GetMulticastRoute
(uint32_t i)
const
;
329
355
bool
RemoveMulticastRoute
(
Ipv4Address
origin,
356
Ipv4Address
group,
357
uint32_t inputInterface);
358
372
void
RemoveMulticastRoute
(uint32_t index);
373
374
protected
:
375
virtual
void
DoDispose
(
void
);
376
377
private
:
378
typedef
std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >
NetworkRoutes
;
379
typedef
std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::const_iterator
NetworkRoutesCI
;
380
typedef
std::list<std::pair <Ipv4RoutingTableEntry *, uint32_t> >::iterator
NetworkRoutesI
;
381
382
typedef
std::list<Ipv4MulticastRoutingTableEntry *>
MulticastRoutes
;
383
typedef
std::list<Ipv4MulticastRoutingTableEntry *>::const_iterator
MulticastRoutesCI
;
384
typedef
std::list<Ipv4MulticastRoutingTableEntry *>::iterator
MulticastRoutesI
;
385
386
Ptr<Ipv4Route>
LookupStatic
(
Ipv4Address
dest,
Ptr<NetDevice>
oif = 0);
387
Ptr<Ipv4MulticastRoute>
LookupStatic
(
Ipv4Address
origin,
Ipv4Address
group,
388
uint32_t interface);
389
390
Ipv4Address
SourceAddressSelection
(uint32_t interface,
Ipv4Address
dest);
391
392
NetworkRoutes
m_networkRoutes
;
393
MulticastRoutes
m_multicastRoutes
;
394
395
Ptr<Ipv4>
m_ipv4
;
396
};
397
398
}
// Namespace ns3
399
400
#endif
/* IPV4_STATIC_ROUTING_H */
src
internet
model
ipv4-static-routing.h
Generated on Fri Dec 21 2012 19:00:37 for ns-3 by
1.8.1.2