blob: 7268ee4d8d68e65f624e785d30a611bcf8a9b3f0 [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
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +000014Face::Face(const FaceUri& uri, 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)
Alexander Afanasyeva39b90b2014-03-05 15:31:00 +000017 , m_uri(uri)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070018{
19}
20
21Face::~Face()
22{
23}
24
Junxiao Shi8c8d2182014-01-30 22:33:00 -070025FaceId
26Face::getId() const
27{
28 return m_id;
29}
30
Alexander Afanasyev46f66472014-01-31 16:50:58 -080031// this method is private and should be used only by the Forwarder
32void
Junxiao Shi8c8d2182014-01-30 22:33:00 -070033Face::setId(FaceId faceId)
34{
35 m_id = faceId;
36}
37
Junxiao Shi32bfeb32014-01-25 18:22:02 -070038void
39Face::setDescription(const std::string& description)
40{
41 m_description = description;
42}
43
44const std::string&
45Face::getDescription() const
46{
47 return m_description;
48}
49
50bool
51Face::isMultiAccess() const
52{
53 return false;
54}
55
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080056bool
Davide Pesavento0ff10db2014-02-28 03:12:27 +010057Face::isUp() const
58{
59 return true;
60}
61
62bool
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080063Face::decodeAndDispatchInput(const Block& element)
Junxiao Shi32bfeb32014-01-25 18:22:02 -070064{
Alexander Afanasyevbd220a02014-02-20 00:29:56 -080065 /// \todo Ensure lazy field decoding process
66
67 if (element.type() == tlv::Interest)
68 {
69 shared_ptr<Interest> i = make_shared<Interest>();
70 i->wireDecode(element);
71 this->onReceiveInterest(*i);
72 }
73 else if (element.type() == tlv::Data)
74 {
75 shared_ptr<Data> d = make_shared<Data>();
76 d->wireDecode(element);
77 this->onReceiveData(*d);
78 }
79 else
80 return false;
81
82 return true;
Junxiao Shi16b8bc92014-02-17 22:24:55 -070083}
Junxiao Shi32bfeb32014-01-25 18:22:02 -070084
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080085} //namespace nfd