blob: 199441670e0436cc15060a203eab19d61ff9d697 [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{
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080030 ControlResponse response(code, text);
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070031 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,
Alexander Afanasyevd482fd32014-02-09 23:40:20 -080036 const ControlResponse& response)
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070037{
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 DiBenedetto86fce8e2014-03-06 12:16:20 -070045 shared_ptr<Data> responseData(make_shared<Data>(name));
46 responseData->setContent(encodedControl);
Steve DiBenedetto0b73f442014-02-05 22:02:03 -070047
Steve DiBenedetto86fce8e2014-03-06 12:16:20 -070048 m_face->sign(*responseData);
49 m_face->put(*responseData);
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070050}
51
52
53} // namespace nfd