blob: 8ab06e8652e70ad7190aa77eb0c6a8221fedc25e [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -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 "manager-base.hpp"
8#include "mgmt/app-face.hpp"
9
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070010namespace nfd {
11
Steve DiBenedetto3970c892014-01-31 23:31:13 -070012NFD_LOG_INIT("ManagerBase");
13
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070014ManagerBase::ManagerBase(shared_ptr<AppFace> face)
15 : m_face(face)
16{
17
18}
19
20ManagerBase::~ManagerBase()
21{
22
23}
24
25void
26ManagerBase::sendResponse(const Name& name,
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070027 uint32_t code,
28 const std::string& text)
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070029{
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070030 ndn::ControlResponse response(code, text);
31 sendResponse(name, response);
32}
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070033
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070034void
35ManagerBase::sendResponse(const Name& name,
36 const ndn::ControlResponse& response)
37{
38 NFD_LOG_DEBUG("responding"
39 << " name: " << name
40 << " code: " << response.getCode()
41 << " text: " << response.getText());
Steve DiBenedetto3970c892014-01-31 23:31:13 -070042
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070043 const Block& encodedControl = response.wireEncode();
Steve DiBenedetto3970c892014-01-31 23:31:13 -070044
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070045 Data responseData(name);
46 responseData.setContent(encodedControl);
47
48 m_face->sign(responseData);
49 m_face->put(responseData);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070050}
51
52
53} // namespace nfd