Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "face.hpp" |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 8 | #include "core/logger.hpp" |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 9 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 10 | namespace nfd { |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 11 | |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 12 | NFD_LOG_INIT("Face") |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 13 | |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 14 | Face::Face(bool isLocal) |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 15 | : m_id(INVALID_FACEID) |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 16 | , m_isLocal(isLocal) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 17 | { |
| 18 | } |
| 19 | |
| 20 | Face::~Face() |
| 21 | { |
| 22 | } |
| 23 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 24 | FaceId |
| 25 | Face::getId() const |
| 26 | { |
| 27 | return m_id; |
| 28 | } |
| 29 | |
Alexander Afanasyev | 46f6647 | 2014-01-31 16:50:58 -0800 | [diff] [blame] | 30 | // this method is private and should be used only by the Forwarder |
| 31 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 32 | Face::setId(FaceId faceId) |
| 33 | { |
| 34 | m_id = faceId; |
| 35 | } |
| 36 | |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 37 | void |
| 38 | Face::setDescription(const std::string& description) |
| 39 | { |
| 40 | m_description = description; |
| 41 | } |
| 42 | |
| 43 | const std::string& |
| 44 | Face::getDescription() const |
| 45 | { |
| 46 | return m_description; |
| 47 | } |
| 48 | |
| 49 | bool |
| 50 | Face::isMultiAccess() const |
| 51 | { |
| 52 | return false; |
| 53 | } |
| 54 | |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 55 | bool |
Davide Pesavento | 0ff10db | 2014-02-28 03:12:27 +0100 | [diff] [blame] | 56 | Face::isUp() const |
| 57 | { |
| 58 | return true; |
| 59 | } |
| 60 | |
| 61 | bool |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 62 | Face::decodeAndDispatchInput(const Block& element) |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 63 | { |
Alexander Afanasyev | bd220a0 | 2014-02-20 00:29:56 -0800 | [diff] [blame] | 64 | /// \todo Ensure lazy field decoding process |
| 65 | |
| 66 | if (element.type() == tlv::Interest) |
| 67 | { |
| 68 | shared_ptr<Interest> i = make_shared<Interest>(); |
| 69 | i->wireDecode(element); |
| 70 | this->onReceiveInterest(*i); |
| 71 | } |
| 72 | else if (element.type() == tlv::Data) |
| 73 | { |
| 74 | shared_ptr<Data> d = make_shared<Data>(); |
| 75 | d->wireDecode(element); |
| 76 | this->onReceiveData(*d); |
| 77 | } |
| 78 | else |
| 79 | return false; |
| 80 | |
| 81 | return true; |
Junxiao Shi | 16b8bc9 | 2014-02-17 22:24:55 -0700 | [diff] [blame] | 82 | } |
Junxiao Shi | 32bfeb3 | 2014-01-25 18:22:02 -0700 | [diff] [blame] | 83 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 84 | } //namespace nfd |