blob: 136c38824f808c80264ccc6f91070b729695fbb0 [file] [log] [blame]
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2011-2015 Regents of the University of California.
Alexander Afanasyev4aac5572012-08-09 10:49:55 -07004 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08005 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
Alexander Afanasyev4aac5572012-08-09 10:49:55 -07007 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -08008 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070011 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080012 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070015 *
Alexander Afanasyev60a7b622014-12-20 17:04:07 -080016 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070019
Alexander Afanasyev0c395372014-12-20 15:54:02 -080020#include "ndn-global-router.hpp"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070021
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -080022#include "model/ndn-l3-protocol.hpp"
23#include "model/ndn-face.hpp"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070024
25#include "ns3/channel.h"
26
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070027namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070028namespace ndn {
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070029
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070030uint32_t GlobalRouter::m_idCounter = 0;
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070031
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080032NS_OBJECT_ENSURE_REGISTERED(GlobalRouter);
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080034TypeId
35GlobalRouter::GetTypeId()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070036{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080037 static TypeId tid = TypeId("ns3::ndn::GlobalRouter").SetGroupName("Ndn").SetParent<Object>();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070038 return tid;
39}
40
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080041GlobalRouter::GlobalRouter()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070042{
43 m_id = m_idCounter;
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080044 m_idCounter++;
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070045}
46
47void
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080048GlobalRouter::NotifyNewAggregate()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070049{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080050 if (m_ndn == 0) {
51 m_ndn = GetObject<L3Protocol>();
52 }
53 Object::NotifyNewAggregate();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070054}
55
56uint32_t
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080057GlobalRouter::GetId() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070058{
59 return m_id;
60}
61
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070062Ptr<L3Protocol>
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080063GlobalRouter::GetL3Protocol() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070064{
65 return m_ndn;
66}
67
68void
Spyridon Mastorakis53e922f2014-10-17 17:29:26 -070069GlobalRouter::AddLocalPrefix(shared_ptr<Name> prefix)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070070{
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080071 m_localPrefixes.push_back(prefix);
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070072}
73
74void
Spyridon Mastorakise4f0d3c2014-10-29 13:20:03 -070075GlobalRouter::AddIncidency(shared_ptr<Face> face, Ptr<GlobalRouter> gr)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070076{
Spyridon Mastorakis60f4b992014-11-07 15:51:38 -080077 m_incidencies.push_back(std::make_tuple(this, face, gr));
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070078}
79
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080080GlobalRouter::IncidencyList&
81GlobalRouter::GetIncidencies()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070082{
83 return m_incidencies;
84}
85
Alexander Afanasyevbe55cf62014-12-20 17:51:09 -080086const GlobalRouter::LocalPrefixList&
87GlobalRouter::GetLocalPrefixes() const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070088{
89 return m_localPrefixes;
90}
91
92// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070093// GlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070094// {
95// m_incidenciesChannel.push_back (make_tuple (face, channel));
96// }
97
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070098} // namespace ndn
99} // namespace ns3