blob: a689d2870605be4da81f1aa32f592142fbd123a7 [file] [log] [blame]
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -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
Alexander Afanasyeve289b532014-02-09 22:14:44 -08007#ifndef NDN_MANAGEMENT_NDND_CONTROLLER_HPP
8#define NDN_MANAGEMENT_NDND_CONTROLLER_HPP
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -08009
Alexander Afanasyeve289b532014-02-09 22:14:44 -080010#include "controller.hpp"
11
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080012namespace ndn {
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080013namespace ndnd {
14
15class FaceInstance;
16class ForwardingEntry;
17
18/*
19 * @brief Class implementing Face and Prefix management operations for ndnd-tlv
20 *
21 * ndnd::Control should be used when connecting to ndnd-tlv daemon
22 */
Alexander Afanasyeve289b532014-02-09 22:14:44 -080023class Controller : public ndn::Controller
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080024{
25public:
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080026 typedef function<void(const ForwardingEntry&)> PrefixOperationSucceedCallback;
27 typedef function<void(const FaceInstance&)> FaceOperationSucceedCallback;
28
29 /**
30 * @brief Construct ndnd::Control object
31 */
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080032 Controller(Face& face);
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080033
Alexander Afanasyeve289b532014-02-09 22:14:44 -080034 virtual void
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080035 selfRegisterPrefix(const Name& prefixToRegister,
36 const SuccessCallback& onSuccess,
37 const FailCallback& onFail);
38
Alexander Afanasyeve289b532014-02-09 22:14:44 -080039 virtual void
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080040 selfDeregisterPrefix(const Name& prefixToRegister,
41 const SuccessCallback& onSuccess,
42 const FailCallback& onFail);
43
44protected:
45 void
46 startFaceAction(const FaceInstance& entry,
47 const FaceOperationSucceedCallback& onSuccess,
48 const FailCallback& onFailure);
49
50 void
51 startPrefixAction(const ForwardingEntry& entry,
52 const PrefixOperationSucceedCallback& onSuccess,
53 const FailCallback& onFailure);
54
55private:
56 void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080057 onNdnidFetched(const Interest& interest, Data& data);
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080058
59 void
60 recordSelfRegisteredFaceId(const ForwardingEntry& entry,
61 const SuccessCallback& onSuccess);
62
63 void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080064 processFaceActionResponse(Data& data,
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080065 const FaceOperationSucceedCallback& onSuccess,
66 const FailCallback& onFail);
67
68 void
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080069 processPrefixActionResponse(Data& data,
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080070 const PrefixOperationSucceedCallback& onSuccess,
71 const FailCallback& onFail);
72
73private:
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080074 Face& m_face;
Alexander Afanasyevc8823bc2014-02-09 19:33:33 -080075 Block m_ndndId;
76 int64_t m_faceId; // internal face ID (needed for prefix de-registration)
77
78 struct FilterRequest
79 {
80 FilterRequest(const Name& prefixToRegister,
81 const SuccessCallback& onSuccess,
82 const FailCallback& onFailure)
83 : m_prefixToRegister(prefixToRegister)
84 , m_onSuccess(onSuccess)
85 , m_onFailure(onFailure)
86 {
87 }
88
89 Name m_prefixToRegister;
90 SuccessCallback m_onSuccess;
91 FailCallback m_onFailure;
92 };
93
94 typedef std::list<FilterRequest> FilterRequestList;
95 FilterRequestList m_filterRequests;
96};
97
98} // namespace ndnd
99} // namespace ndn
100
Alexander Afanasyeve289b532014-02-09 22:14:44 -0800101#endif // NDN_MANAGEMENT_NDND_CONTROLLER_HPP