blob: 8e81217fe3753726963226d03f83462b3ca24005 [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
Davide Pesavento0ff10db2014-02-28 03:12:27 +010012NFD_LOG_INIT("Face")
Junxiao Shi16b8bc92014-02-17 22:24:55 -070013
Davide Pesavento0ff10db2014-02-28 03:12:27 +010014Face::Face(bool isLocal)
Junxiao Shi8c8d2182014-01-30 22:33:00 -070015 : m_id(INVALID_FACEID)
Davide Pesavento0ff10db2014-02-28 03:12:27 +010016 , m_isLocal(isLocal)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070017{
18}
19
20Face::~Face()
21{
22}
23
Junxiao Shi8c8d2182014-01-30 22:33:00 -070024FaceId
25Face::getId() const
26{
27 return m_id;
28}
29
Alexander Afanasyev46f66472014-01-31 16:50:58 -080030// this method is private and should be used only by the Forwarder
31void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070032Face::setId(FaceId faceId)
33{
34 m_id = faceId;
35}
36
Junxiao Shi32bfeb32014-01-25 18:22:02 -070037void
38Face::setDescription(const std::string& description)
39{
40 m_description = description;
41}
42
43const std::string&
44Face::getDescription() const
45{
46 return m_description;
47}
48
49bool
50Face::isMultiAccess() const
51{
52 return false;
53}
54
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080055bool
Davide Pesavento0ff10db2014-02-28 03:12:27 +010056Face::isUp() const
57{
58 return true;
59}
60
61bool
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080062Face::decodeAndDispatchInput(const Block& element)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070063{
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080064 /// \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 Shi16b8bc92014-02-17 22:24:55 -070082}
Junxiao Shi32bfeb32014-01-25 18:22:02 -070083
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080084} //namespace nfd