blob: b718689a72b1f6abfac9611f638b6158e7324d23 [file] [log] [blame]
Alexander Afanasyev4aac5572012-08-09 10:49:55 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2011 UCLA
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: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20
Alexander Afanasyev0c395372014-12-20 15:54:02 -080021#include "ndn-global-router.hpp"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070022
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070023#include "ndn-l3-protocol.hpp"
24#include "ndn-face.hpp"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070025
26#include "ns3/channel.h"
27
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070028namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070029namespace ndn {
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070030
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070031uint32_t GlobalRouter::m_idCounter = 0;
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070032
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080033NS_OBJECT_ENSURE_REGISTERED(GlobalRouter);
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070034
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080035TypeId
36GlobalRouter::GetTypeId()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080038 static TypeId tid = TypeId("ns3::ndn::GlobalRouter").SetGroupName("Ndn").SetParent<Object>();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070039 return tid;
40}
41
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080042GlobalRouter::GlobalRouter()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070043{
44 m_id = m_idCounter;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080045 m_idCounter++;
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070046}
47
48void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080049GlobalRouter::NotifyNewAggregate()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070050{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080051 if (m_ndn == 0) {
52 m_ndn = GetObject<L3Protocol>();
53 }
54 Object::NotifyNewAggregate();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070055}
56
57uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080058GlobalRouter::GetId() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070059{
60 return m_id;
61}
62
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070063Ptr<L3Protocol>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080064GlobalRouter::GetL3Protocol() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070065{
66 return m_ndn;
67}
68
69void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070070GlobalRouter::AddLocalPrefix(shared_ptr<Name> prefix)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070071{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080072 m_localPrefixes.push_back(prefix);
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070073}
74
75void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070076GlobalRouter::AddIncidency(shared_ptr<Face> face, Ptr<GlobalRouter> gr)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070077{
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070078 m_incidencies.push_back(boost::make_tuple(this, face, gr));
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070079}
80
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080081GlobalRouter::IncidencyList&
82GlobalRouter::GetIncidencies()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070083{
84 return m_incidencies;
85}
86
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080087const GlobalRouter::LocalPrefixList&
88GlobalRouter::GetLocalPrefixes() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070089{
90 return m_localPrefixes;
91}
92
93// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070094// GlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070095// {
96// m_incidenciesChannel.push_back (make_tuple (face, channel));
97// }
98
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070099} // namespace ndn
100} // namespace ns3