blob: e27564ee01add2d6a34e2eb2393c7cebb7b959e7 [file] [log] [blame]
Ilya Moiseenko4e473482011-10-31 17:58:14 -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-bestroute-strategy.h"
22#include "ns3/assert.h"
23
24#include "ccnx-route.h"
25
26
27NS_LOG_COMPONENT_DEFINE ("CcnxBestRouteStrategy");
28namespace __ccnx_private {
29
30 struct CcnxFibFaceMetricByFace;
31}
32
33namespace ns3
34{
35
36using namespace __ccnx_private;
37
38NS_OBJECT_ENSURE_REGISTERED (CcnxBestRouteStrategy);
39
40TypeId CcnxBestRouteStrategy::GetTypeId (void)
41{
42 static TypeId tid = TypeId ("ns3::CcnxBestRouteStrategy")
43 .SetGroupName ("Ccnx")
44 .SetParent<Object> ()
45 ;
46 return tid;
47}
48
49CcnxBestRouteStrategy::CcnxBestRouteStrategy ()
50{
51}
52
53
54bool
55CcnxBestRouteStrategy::PropagateInterest (CcnxPitEntryContainer::type::iterator pitEntry,
56 CcnxFibEntryContainer::type::iterator fibEntry,
57 const Ptr<CcnxFace> &incomingFace,
58 Ptr<CcnxInterestHeader> &header,
59 const Ptr<const Packet> &packet,
60 SendCallback ucb)
61{
62 NS_LOG_FUNCTION(this);
63 NS_LOG_INFO(*fibEntry);
64
65 Ptr<CcnxFace> bestFace = fibEntry->FindBestCandidate(0);
66
67 if( bestFace == NULL )
68 {
69 return false;
70 }
71 else
72 {
73 bool tryResult = GetPit ()->TryAddOutgoing (pitEntry, bestFace);
74 if (tryResult == false)
75 {
76 return false;
77 }
78
79 ucb (bestFace, header, packet->Copy());
80 }
81
82 return true;
83}
84
85} //namespace ns3