link-service.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "link-service.hpp"
27 #include "face.hpp"
28 
29 namespace nfd {
30 namespace face {
31 
32 NFD_LOG_INIT("LinkService");
33 
35  : m_face(nullptr)
36  , m_transport(nullptr)
37 {
38 }
39 
41 {
42 }
43 
44 void
46 {
47  BOOST_ASSERT(m_face == nullptr);
48  BOOST_ASSERT(m_transport == nullptr);
49 
50  m_face = &face;
51  m_transport = &transport;
52 }
53 
54 void
55 LinkService::sendInterest(const Interest& interest)
56 {
57  BOOST_ASSERT(m_transport != nullptr);
58  NFD_LOG_FACE_TRACE(__func__);
59 
60  ++this->nOutInterests;
61 
62  doSendInterest(interest);
63 }
64 
65 void
66 LinkService::sendData(const Data& data)
67 {
68  BOOST_ASSERT(m_transport != nullptr);
69  NFD_LOG_FACE_TRACE(__func__);
70 
71  ++this->nOutData;
72 
73  doSendData(data);
74 }
75 
76 void
77 LinkService::sendNack(const ndn::lp::Nack& nack)
78 {
79  BOOST_ASSERT(m_transport != nullptr);
80  NFD_LOG_FACE_TRACE(__func__);
81 
82  ++this->nOutNacks;
83 
84  doSendNack(nack);
85 }
86 
87 void
88 LinkService::receiveInterest(const Interest& interest)
89 {
90  NFD_LOG_FACE_TRACE(__func__);
91 
92  ++this->nInInterests;
93 
94  afterReceiveInterest(interest);
95 }
96 
97 void
98 LinkService::receiveData(const Data& data)
99 {
100  NFD_LOG_FACE_TRACE(__func__);
101 
102  ++this->nInData;
103 
104  afterReceiveData(data);
105 }
106 
107 void
108 LinkService::receiveNack(const ndn::lp::Nack& nack)
109 {
110  NFD_LOG_FACE_TRACE(__func__);
111 
112  ++this->nInNacks;
113 
114  afterReceiveNack(nack);
115 }
116 
117 std::ostream&
118 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh)
119 {
120  const Face* face = flh.obj.getFace();
121  if (face == nullptr) {
122  os << "[id=0,local=unknown,remote=unknown] ";
123  }
124  else {
125  os << "[id=" << face->getId() << ",local=" << face->getLocalUri()
126  << ",remote=" << face->getRemoteUri() << "] ";
127  }
128  return os;
129 }
130 
131 } // namespace face
132 } // namespace nfd
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
Definition: face-log.hpp:79
FaceUri getRemoteUri() const
Definition: face.hpp:240
the lower part of a Face
Definition: transport.hpp:104
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
generalization of a network interface
Definition: face.hpp:67
FaceId getId() const
Definition: face.hpp:222
FaceUri getLocalUri() const
Definition: face.hpp:234
#define NFD_LOG_INIT(name)
Definition: logger.hpp:122