blob: 5bb4647c9826328ad47a0bea71976cba5288315c [file] [log] [blame]
Ilya Moiseenko25f7d4d2011-09-29 18:41:06 -07001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 University of California, Los Angeles
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: Ilya Moiseenko <iliamo@cs.ucla.edu>
19 */
20
21#include "ccnx-flooding-strategy.h"
22#include "ns3/assert.h"
23
24#include "ccnx-route.h"
25
26NS_LOG_COMPONENT_DEFINE ("CcnxFloodingStrategy");
27
28namespace ns3
29{
30
31NS_OBJECT_ENSURE_REGISTERED (CcnxFloodingStrategy);
32
33TypeId CcnxFloodingStrategy::GetTypeId (void)
34{
35 static TypeId tid = TypeId ("ns3::CcnxFloodingStrategy")
36 .SetGroupName ("Ccnx")
37 .SetParent<Object> ()
38 ;
39 return tid;
40}
41
42CcnxFloodingStrategy::CcnxFloodingStrategy ()
43{
44}
45
46
47bool
48CcnxFloodingStrategy::PropagateInterest (const Ptr<CcnxFace> &incomingFace,
49 Ptr<CcnxInterestHeader> &header,
50 const Ptr<const Packet> &packet,
51 SendCallback ucb)
52{
53 //CcnxFibEntryContainer::type::iterator fibEntryArray = GetFib()->LongestPrefixMatch(*header);
54 NS_LOG_FUNCTION(this);
55
56 CcnxFibEntryContainer::type::iterator fibEntryArray = GetCcnx()->GetObject<CcnxFib>()->LongestPrefixMatch(*header);
57 NS_LOG_INFO(*fibEntryArray);
58
59 int count = 0;
60 for(CcnxFibFaceMetricContainer::type::iterator face = fibEntryArray->m_faces.begin ();
61 face != fibEntryArray->m_faces.end ();
62 face++)
63 {
64 if(face->m_face == incomingFace)
65 continue;
66
67 NS_LOG_INFO("count="<<count);
68 ucb (face->m_face, header, packet->Copy());
69 count++;
70 }
71
72 /*const CcnxFibEntryContainer& s,
73
74 for (CcnxFibEntryContainer::type::iterator entry = fibEntryArray.begin ();
75 entry != fibEntryArray.end ();
76 entry++)
77 {
78
79 const typename boost::multi_index::index<CcnxFibEntryContainer, Tag>::type& i = get<Tag>(s);
80
81 typedef typename CcnxFibEntryContainer::value_type value_type;
82
83 for(const CcnxFibEntryContainer& c = i.begin(); c != i.end (); c++)
84 {
85 c->
86 }
87
88 for(nth_index<CcnxFibEntryContainer,1>::type::iterator it1=get<i_prefix>(entry).begin();
89 it1!=get<i_prefix>(entry).end();++it1)
90 {
91 //std::cout<<it1->name()<<std::endl;
92
93 CcnxFibFaceMetricContainer faceContainer = it1->m_faces;
94
95 const typename boost::multi_index::index<CcnxFibFaceMetricContainer, __ccnx_private::i_face>::type& i = get<__ccnx_private::i_face>(faceContainer);
96
97 //typedef typename CcnxFibEntryContainer::value_type value_type;
98
99 for(const CcnxFibFaceMetricContainer& c = i.begin(); c != i.end (); c++)
100 {
101 Ptr<CcnxFace> face = c->m_face;
102
103 typedef
104 Callback<void, const Ptr<CcnxFace> &, const Ptr<CcnxInterestHeader> &, const Ptr<Packet> &>
105 SendCallback;
106
107 ucb (face, header, packet);
108 }
109
110 }
111
112
113 // obtain a reference to the index tagged by Tag
114
115 const typename boost::multi_index::index<MultiIndexContainer,Tag>::type& i=
116 get<Tag>(s);
117
118 typedef typename MultiIndexContainer::value_type value_type;
119
120 // dump the elements of the index to cout
121
122 std::copy(i.begin(),i.end(),std::ostream_iterator<value_type>(std::cout));
123 */
124
125 if(count == 0)
126 return false;
127 else
128 return true;
129}
130
131} //namespace ns3