blob: 8020f43718beefab57ca492daf750e7983e49951 [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
21#include "ndn-global-router.h"
22
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070023#include "ns3/ndn-l3-protocol.h"
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070024#include "ns3/ndn-face.h"
25#include "ns3/ndn-name-components.h"
26
27#include "ns3/channel.h"
28
29using namespace boost;
30
31namespace ns3 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070032namespace ndn {
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070033
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070034uint32_t GlobalRouter::m_idCounter = 0;
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070035
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070036NS_OBJECT_ENSURE_REGISTERED (GlobalRouter);
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070037
38TypeId
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070039GlobalRouter::GetTypeId ()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070040{
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070041 static TypeId tid = TypeId ("ns3::ndn::GlobalRouter")
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070042 .SetGroupName ("Ndn")
43 .SetParent<Object> ()
44 ;
45 return tid;
46}
47
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070048GlobalRouter::GlobalRouter ()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070049{
50 m_id = m_idCounter;
51 m_idCounter ++;
52}
53
54void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070055GlobalRouter::NotifyNewAggregate ()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070056{
57 if (m_ndn == 0)
58 {
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070059 m_ndn = GetObject<L3Protocol> ();
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070060 }
61 Object::NotifyNewAggregate ();
62}
63
64uint32_t
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070065GlobalRouter::GetId () const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070066{
67 return m_id;
68}
69
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070070Ptr<L3Protocol>
71GlobalRouter::GetL3Protocol () const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070072{
73 return m_ndn;
74}
75
76void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070077GlobalRouter::AddLocalPrefix (Ptr< NameComponents > prefix)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070078{
79 m_localPrefixes.push_back (prefix);
80}
81
82void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070083GlobalRouter::AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > gr)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070084{
85 m_incidencies.push_back (make_tuple (this, face, gr));
86}
87
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070088GlobalRouter::IncidencyList &
89GlobalRouter::GetIncidencies ()
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070090{
91 return m_incidencies;
92}
93
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -070094const GlobalRouter::LocalPrefixList &
95GlobalRouter::GetLocalPrefixes () const
Alexander Afanasyev4aac5572012-08-09 10:49:55 -070096{
97 return m_localPrefixes;
98}
99
100// void
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700101// GlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
Alexander Afanasyev4aac5572012-08-09 10:49:55 -0700102// {
103// m_incidenciesChannel.push_back (make_tuple (face, channel));
104// }
105
Alexander Afanasyev2b4c9472012-08-09 15:00:38 -0700106} // namespace ndn
107} // namespace ns3