blob: b141e02f0081b72dc10ff698ca5cf16b1013e7f2 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Jeff Thompsonf309aa62013-10-31 17:03:54 -07002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -070020 *
21 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Jeff Thompsonf309aa62013-10-31 17:03:54 -070022 */
23
Yingdi Yu40587c02014-02-21 16:40:48 -080024#ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP
25#define NDN_SECURITY_VALIDATION_REQUEST_HPP
Jeff Thompsonf309aa62013-10-31 17:03:54 -070026
Yingdi Yu4f324632014-01-15 18:10:03 -080027#include "../interest.hpp"
Jeff Thompsonf309aa62013-10-31 17:03:54 -070028
29namespace ndn {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070030/// @brief Callback to report a successful Interest validation.
31typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070032
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070033/// @brief Callback to report a failed Interest validation.
34typedef function<void(const shared_ptr<const Interest>&,
35 const std::string&)> OnInterestValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080036
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070037/// @brief Callback to report a successful Data validation.
38typedef function<void(const shared_ptr<const Data>&)> OnDataValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070040/// @brief Callback to report a failed Data validation.
41typedef function<void(const shared_ptr<const Data>&,
42 const std::string&)> OnDataValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080043
Jeff Thompsonf309aa62013-10-31 17:03:54 -070044
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070045class ValidationRequest
46{
Jeff Thompsonf309aa62013-10-31 17:03:54 -070047public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070048 ValidationRequest(const Interest& interest,
49 const OnDataValidated& onValidated,
50 const OnDataValidationFailed& onDataValidated,
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070051 int nRetrials, int nSteps)
52 : m_interest(interest)
53 , m_onValidated(onValidated)
54 , m_onDataValidated(onDataValidated)
55 , m_nRetrials(nRetrials)
56 , m_nSteps(nSteps)
57 {
58 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070059
Jeff Thompsonf309aa62013-10-31 17:03:54 -070060 virtual
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070061 ~ValidationRequest()
62 {
63 }
Jeff Thompsonf309aa62013-10-31 17:03:54 -070064
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070065 Interest m_interest; // Interest for the requested data.
66 OnDataValidated m_onValidated; // Callback function on validated certificate.
67 OnDataValidationFailed m_onDataValidated; // Callback function on validation failure.
68 int m_nRetrials; // The number of retrials when interest timeout.
69 int m_nSteps; // The stepCount of next step.
Jeff Thompsonf309aa62013-10-31 17:03:54 -070070};
71
Yingdi Yu40587c02014-02-21 16:40:48 -080072} // namespace ndn
Jeff Thompsonf309aa62013-10-31 17:03:54 -070073
Yingdi Yu40587c02014-02-21 16:40:48 -080074#endif //NDN_SECURITY_VALIDATION_REQUEST_HPP