ns-3 Direct Code Execution
Home
Tutorials ▼
Docs ▼
Wiki
Manual
Develop ▼
API
Bugs
API
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
ipv4-dce-routing.cc
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
#define NS_LOG_APPEND_CONTEXT \
22
if (m_ipv4 && m_ipv4->GetObject < Node > ()) { \
23
std::clog << Simulator::Now ().GetSeconds () \
24
<< " [node " << m_ipv4->GetObject < Node > ()->GetId () << "] "; }
25
26
#include <iomanip>
27
#include "ns3/log.h"
28
#include "ns3/names.h"
29
#include "ns3/packet.h"
30
#include "ns3/node.h"
31
#include "ns3/simulator.h"
32
#include "ns3/ipv4-route.h"
33
#include "ns3/output-stream-wrapper.h"
34
#include "ns3/ipv4-routing-table-entry.h"
35
#include "
ipv4-dce-routing.h
"
36
#include "../netlink/netlink-socket.h"
37
38
39
NS_LOG_COMPONENT_DEFINE
(
"Ipv4DceRouting"
);
40
41
using
std::make_pair;
42
43
namespace
ns3 {
44
45
NS_OBJECT_ENSURE_REGISTERED
(Ipv4DceRouting);
46
47
TypeId
48
Ipv4DceRouting::GetTypeId
(
void
)
49
{
50
static
TypeId tid = TypeId (
"ns3::Ipv4DceRouting"
)
51
.SetParent<Ipv4StaticRouting> ()
52
.AddConstructor<Ipv4DceRouting> ()
53
;
54
return
tid;
55
}
56
57
Ipv4DceRouting::Ipv4DceRouting
()
58
{
59
NS_LOG_FUNCTION (
this
);
60
}
61
62
Ipv4DceRouting::~Ipv4DceRouting
()
63
{
64
}
65
66
void
67
Ipv4DceRouting::NotifyInterfaceUp
(uint32_t i)
68
{
69
NS_LOG_FUNCTION (
this
<< i);
70
71
Ipv4StaticRouting::NotifyInterfaceUp
(i);
72
73
m_netlink
->NotifyIfLinkMessage (
m_ipv4
->GetNetDevice (i)->GetIfIndex ());
74
}
75
76
void
77
Ipv4DceRouting::NotifyInterfaceDown
(uint32_t i)
78
{
79
NS_LOG_FUNCTION (
this
<< i);
80
81
Ipv4StaticRouting::NotifyInterfaceDown
(i);
82
83
m_netlink
->NotifyIfLinkMessage (
m_ipv4
->GetNetDevice (i)->GetIfIndex ());
84
}
85
86
void
87
Ipv4DceRouting::NotifyAddAddress
(uint32_t interface, Ipv4InterfaceAddress address)
88
{
89
NS_LOG_FUNCTION (
this
<< interface <<
" "
<< address.GetLocal ());
90
91
Ipv4StaticRouting::NotifyAddAddress
(interface, address);
92
// NS_LOG_DEBUG ("Not implemented yet");
93
}
94
void
95
Ipv4DceRouting::NotifyRemoveAddress
(uint32_t interface, Ipv4InterfaceAddress address)
96
{
97
NS_LOG_FUNCTION (
this
<< interface <<
" "
<< address.GetLocal ());
98
99
Ipv4StaticRouting::NotifyRemoveAddress
(interface, address);
100
// NS_LOG_DEBUG ("Not implemented yet");
101
}
102
103
void
104
Ipv4DceRouting::SetIpv4
(Ptr<Ipv4> ipv4)
105
{
106
// do some other stuff
107
m_ipv4
= ipv4;
108
m_netlink
= CreateObject<NetlinkSocket> ();
109
m_netlink
->SetNode (ipv4->GetObject<Node> ());
110
m_netlink
->Bind ();
// not really necessary to do this
111
112
Ipv4StaticRouting::SetIpv4
(ipv4);
113
}
114
115
void
116
Ipv4DceRouting::PrintRoutingTable
(Ptr<OutputStreamWrapper> stream)
const
117
{
118
*stream->GetStream () << std::endl;
119
*stream->GetStream () <<
"Time: "
<< Simulator::Now ().GetSeconds () <<
"s"
<< std::endl;
120
Ipv4StaticRouting::PrintRoutingTable
(stream);
121
}
122
123
}
// namespace ns3
model
ipv4-dce-routing.cc
Generated on Fri Aug 30 2013 13:57:55 for ns-3-dce by
1.8.1.2