blob: 968f232bdb32466c7f6281c7df25b0072fe49d15 [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"
Alexander Afanasyeve289b532014-02-09 22:14:44 -080011#include "../security/key-chain.hpp"
12
13namespace ndn {
14
Alexander Afanasyeve289b532014-02-09 22:14:44 -080015namespace nfd {
16
17class FibManagementOptions;
hilataa99e37e2014-02-15 23:52:46 -060018class FaceManagementOptions;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080019
20class Controller : public ndn::Controller
21{
22public:
23 typedef function<void(const FibManagementOptions&)> FibCommandSucceedCallback;
hilataa99e37e2014-02-15 23:52:46 -060024 typedef function<void(const FaceManagementOptions&)> FaceCommandSucceedCallback;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080025
26 /**
27 * @brief Construct ndnd::Control object
28 */
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080029 Controller(Face& face);
Alexander Afanasyeve289b532014-02-09 22:14:44 -080030
31 virtual void
32 selfRegisterPrefix(const Name& prefixToRegister,
33 const SuccessCallback& onSuccess,
34 const FailCallback& onFail);
35
36 virtual void
37 selfDeregisterPrefix(const Name& prefixToRegister,
38 const SuccessCallback& onSuccess,
39 const FailCallback& onFail);
40
hilataa99e37e2014-02-15 23:52:46 -060041protected:
Alexander Afanasyeve289b532014-02-09 22:14:44 -080042 void
43 startFibCommand(const std::string& command,
44 const FibManagementOptions& options,
45 const FibCommandSucceedCallback& onSuccess,
46 const FailCallback& onFailure);
hilataa99e37e2014-02-15 23:52:46 -060047
48 void
49 startFaceCommand(const std::string& command,
50 const FaceManagementOptions& options,
51 const FaceCommandSucceedCallback& onSuccess,
52 const FailCallback& onFailure);
53
Alexander Afanasyeve289b532014-02-09 22:14:44 -080054private:
55 void
Alexander Afanasyev21abc102014-02-18 18:59:02 -080056 selfRegisterPrefixAddNextop(const FibManagementOptions& entry,
57 const SuccessCallback& onSuccess,
58 const FailCallback& onFail);
59
60 void
Alexander Afanasyeve289b532014-02-09 22:14:44 -080061 recordSelfRegisteredFaceId(const FibManagementOptions& entry,
62 const SuccessCallback& onSuccess);
63
Alexander Afanasyeve289b532014-02-09 22:14:44 -080064 void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080065 processFibCommandResponse(Data& data,
Alexander Afanasyeve289b532014-02-09 22:14:44 -080066 const FibCommandSucceedCallback& onSuccess,
67 const FailCallback& onFail);
hilataa99e37e2014-02-15 23:52:46 -060068
69 void
70 processFaceCommandResponse(Data& data,
71 const FaceCommandSucceedCallback& onSuccess,
72 const FailCallback& onFail);
73
74protected:
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080075 Face& m_face;
Alexander Afanasyeve289b532014-02-09 22:14:44 -080076 KeyChain m_keyChain;
77 uint64_t m_faceId; // internal face ID (needed for prefix de-registration)
78};
79
80} // namespace nfd
81} // namespace ndn
82
83#endif // NDN_MANAGEMENT_NFD_CONTROL_HPP