blob: 850c72d20b6a5bb65f97521cfd38c6ef8ed18958 [file] [log] [blame]
Alexander Afanasyeve289b532014-02-09 22:14:44 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_MANAGEMENT_NFD_CONTROL_HPP
8#define NDN_MANAGEMENT_NFD_CONTROL_HPP
9
Alexander Afanasyeve289b532014-02-09 22:14:44 -080010#include "controller.hpp"
11
Alexander Afanasyeve289b532014-02-09 22:14:44 -080012#include "../security/key-chain.hpp"
13
14namespace ndn {
15
Alexander Afanasyeve289b532014-02-09 22:14:44 -080016namespace nfd {
17
18class FibManagementOptions;
hilataa99e37e2014-02-15 23:52:46 -060019class FaceManagementOptions;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080020
21class Controller : public ndn::Controller
22{
23public:
24 typedef function<void(const FibManagementOptions&)> FibCommandSucceedCallback;
hilataa99e37e2014-02-15 23:52:46 -060025 typedef function<void(const FaceManagementOptions&)> FaceCommandSucceedCallback;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080026
27 /**
28 * @brief Construct ndnd::Control object
29 */
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080030 Controller(Face& face);
Alexander Afanasyeve289b532014-02-09 22:14:44 -080031
32 virtual void
33 selfRegisterPrefix(const Name& prefixToRegister,
34 const SuccessCallback& onSuccess,
35 const FailCallback& onFail);
36
37 virtual void
38 selfDeregisterPrefix(const Name& prefixToRegister,
39 const SuccessCallback& onSuccess,
40 const FailCallback& onFail);
41
hilataa99e37e2014-02-15 23:52:46 -060042protected:
Alexander Afanasyeve289b532014-02-09 22:14:44 -080043 void
44 startFibCommand(const std::string& command,
45 const FibManagementOptions& options,
46 const FibCommandSucceedCallback& onSuccess,
47 const FailCallback& onFailure);
hilataa99e37e2014-02-15 23:52:46 -060048
49 void
50 startFaceCommand(const std::string& command,
51 const FaceManagementOptions& options,
52 const FaceCommandSucceedCallback& onSuccess,
53 const FailCallback& onFailure);
54
Alexander Afanasyeve289b532014-02-09 22:14:44 -080055private:
56 void
57 recordSelfRegisteredFaceId(const FibManagementOptions& entry,
58 const SuccessCallback& onSuccess);
59
Alexander Afanasyeve289b532014-02-09 22:14:44 -080060 void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080061 processFibCommandResponse(Data& data,
Alexander Afanasyeve289b532014-02-09 22:14:44 -080062 const FibCommandSucceedCallback& onSuccess,
63 const FailCallback& onFail);
hilataa99e37e2014-02-15 23:52:46 -060064
65 void
66 processFaceCommandResponse(Data& data,
67 const FaceCommandSucceedCallback& onSuccess,
68 const FailCallback& onFail);
69
70protected:
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080071 Face& m_face;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080072 KeyChain m_keyChain;
73 uint64_t m_faceId; // internal face ID (needed for prefix de-registration)
74};
75
76} // namespace nfd
77} // namespace ndn
78
79#endif // NDN_MANAGEMENT_NFD_CONTROL_HPP