Ilya Moiseenko | 4e47348 | 2011-10-31 17:58:14 -0700 | [diff] [blame^] | 1 | /* -*- 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 | |
| 27 | NS_LOG_COMPONENT_DEFINE ("CcnxBestRouteStrategy"); |
| 28 | namespace __ccnx_private { |
| 29 | |
| 30 | struct CcnxFibFaceMetricByFace; |
| 31 | } |
| 32 | |
| 33 | namespace ns3 |
| 34 | { |
| 35 | |
| 36 | using namespace __ccnx_private; |
| 37 | |
| 38 | NS_OBJECT_ENSURE_REGISTERED (CcnxBestRouteStrategy); |
| 39 | |
| 40 | TypeId CcnxBestRouteStrategy::GetTypeId (void) |
| 41 | { |
| 42 | static TypeId tid = TypeId ("ns3::CcnxBestRouteStrategy") |
| 43 | .SetGroupName ("Ccnx") |
| 44 | .SetParent<Object> () |
| 45 | ; |
| 46 | return tid; |
| 47 | } |
| 48 | |
| 49 | CcnxBestRouteStrategy::CcnxBestRouteStrategy () |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | |
| 54 | bool |
| 55 | CcnxBestRouteStrategy::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 |