blob: cc4fba83873e1e5ad211a8b2a52768b96c403866 [file] [log] [blame]
Junxiao Shi32bfeb32014-01-25 18:22:02 -07001/* -*- 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 Shi16b8bc92014-02-17 22:24:55 -07008#include "core/logger.hpp"
Junxiao Shi32bfeb32014-01-25 18:22:02 -07009
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080010namespace nfd {
Junxiao Shi32bfeb32014-01-25 18:22:02 -070011
Junxiao Shi16b8bc92014-02-17 22:24:55 -070012NFD_LOG_INIT("Face");
13
Junxiao Shi8c8d2182014-01-30 22:33:00 -070014Face::Face()
15 : m_id(INVALID_FACEID)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070016{
17}
18
19Face::~Face()
20{
21}
22
Junxiao Shi8c8d2182014-01-30 22:33:00 -070023FaceId
24Face::getId() const
25{
26 return m_id;
27}
28
Alexander Afanasyev46f66472014-01-31 16:50:58 -080029// this method is private and should be used only by the Forwarder
30void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070031Face::setId(FaceId faceId)
32{
33 m_id = faceId;
34}
35
Junxiao Shi32bfeb32014-01-25 18:22:02 -070036bool
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080037Face::isLocal() const
38{
39 return m_isLocal;
40}
41
42// this method is protected and can be used only in derived class
43// to set localhost scope
44void
45Face::setLocal(bool isLocal)
46{
47 m_isLocal = isLocal;
48}
49
50bool
Junxiao Shi32bfeb32014-01-25 18:22:02 -070051Face::isUp() const
52{
53 return true;
54}
55
56void
57Face::setDescription(const std::string& description)
58{
59 m_description = description;
60}
61
62const std::string&
63Face::getDescription() const
64{
65 return m_description;
66}
67
68bool
69Face::isMultiAccess() const
70{
71 return false;
72}
73
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080074bool
75Face::decodeAndDispatchInput(const Block& element)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070076{
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080077 /// \todo Ensure lazy field decoding process
78
79 if (element.type() == tlv::Interest)
80 {
81 shared_ptr<Interest> i = make_shared<Interest>();
82 i->wireDecode(element);
83 this->onReceiveInterest(*i);
84 }
85 else if (element.type() == tlv::Data)
86 {
87 shared_ptr<Data> d = make_shared<Data>();
88 d->wireDecode(element);
89 this->onReceiveData(*d);
90 }
91 else
92 return false;
93
94 return true;
Junxiao Shi16b8bc92014-02-17 22:24:55 -070095}
Junxiao Shi32bfeb32014-01-25 18:22:02 -070096
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080097} //namespace nfd