NS-3 based Named Data Networking (NDN) simulator
ndnSIM: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ndn-global-router.cc
1 /* -*- 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 
23 #include "ns3/ndn-l3-protocol.h"
24 #include "ns3/ndn-face.h"
25 #include "ns3/ndn-name.h"
26 
27 #include "ns3/channel.h"
28 
29 using namespace boost;
30 
31 namespace ns3 {
32 namespace ndn {
33 
34 uint32_t GlobalRouter::m_idCounter = 0;
35 
36 NS_OBJECT_ENSURE_REGISTERED (GlobalRouter);
37 
38 TypeId
39 GlobalRouter::GetTypeId ()
40 {
41  static TypeId tid = TypeId ("ns3::ndn::GlobalRouter")
42  .SetGroupName ("Ndn")
43  .SetParent<Object> ()
44  ;
45  return tid;
46 }
47 
48 GlobalRouter::GlobalRouter ()
49 {
50  m_id = m_idCounter;
51  m_idCounter ++;
52 }
53 
54 void
55 GlobalRouter::NotifyNewAggregate ()
56 {
57  if (m_ndn == 0)
58  {
59  m_ndn = GetObject<L3Protocol> ();
60  }
61  Object::NotifyNewAggregate ();
62 }
63 
64 uint32_t
65 GlobalRouter::GetId () const
66 {
67  return m_id;
68 }
69 
70 Ptr<L3Protocol>
71 GlobalRouter::GetL3Protocol () const
72 {
73  return m_ndn;
74 }
75 
76 void
77 GlobalRouter::AddLocalPrefix (Ptr< Name > prefix)
78 {
79  m_localPrefixes.push_back (prefix);
80 }
81 
82 void
83 GlobalRouter::AddIncidency (Ptr< Face > face, Ptr< GlobalRouter > gr)
84 {
85  m_incidencies.push_back (make_tuple (this, face, gr));
86 }
87 
89 GlobalRouter::GetIncidencies ()
90 {
91  return m_incidencies;
92 }
93 
95 GlobalRouter::GetLocalPrefixes () const
96 {
97  return m_localPrefixes;
98 }
99 
100 // void
101 // GlobalRouter::AddIncidencyChannel (Ptr< NdnFace > face, Ptr< Channel > channel)
102 // {
103 // m_incidenciesChannel.push_back (make_tuple (face, channel));
104 // }
105 
106 } // namespace ndn
107 } // namespace ns3
std::list< Ptr< Name > > LocalPrefixList
List of locally exported prefixes.
std::list< Incidency > IncidencyList
List of graph edges.