blob: bc3ba92ad1a03048062625d1d0f4a7e6943010ed [file] [log] [blame]
Jeff Thompsonf309aa62013-10-31 17:03:54 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
11 *
12 * @author Yingdi Yu <http://irl.cs.ucla.edu/~yingdi/>
Jeff Thompsonf309aa62013-10-31 17:03:54 -070013 */
14
Yingdi Yu40587c02014-02-21 16:40:48 -080015#ifndef NDN_SECURITY_VALIDATION_REQUEST_HPP
16#define NDN_SECURITY_VALIDATION_REQUEST_HPP
Jeff Thompsonf309aa62013-10-31 17:03:54 -070017
Yingdi Yu4f324632014-01-15 18:10:03 -080018#include "../interest.hpp"
Jeff Thompsonf309aa62013-10-31 17:03:54 -070019
20namespace ndn {
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070021/// @brief Callback to report a successful Interest validation.
22typedef function<void(const shared_ptr<const Interest>&)> OnInterestValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070023
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070024/// @brief Callback to report a failed Interest validation.
25typedef function<void(const shared_ptr<const Interest>&,
26 const std::string&)> OnInterestValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080027
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070028/// @brief Callback to report a successful Data validation.
29typedef function<void(const shared_ptr<const Data>&)> OnDataValidated;
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070030
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070031/// @brief Callback to report a failed Data validation.
32typedef function<void(const shared_ptr<const Data>&,
33 const std::string&)> OnDataValidationFailed;
Yingdi Yu6ac97982014-01-30 14:49:21 -080034
Jeff Thompsonf309aa62013-10-31 17:03:54 -070035
Alexander Afanasyev2a7f7202014-04-23 14:25:29 -070036class ValidationRequest
37{
Jeff Thompsonf309aa62013-10-31 17:03:54 -070038public:
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070039 ValidationRequest(const Interest& interest,
40 const OnDataValidated& onValidated,
41 const OnDataValidationFailed& onDataValidated,
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070042 int nRetrials, int nSteps)
43 : m_interest(interest)
44 , m_onValidated(onValidated)
45 , m_onDataValidated(onDataValidated)
46 , m_nRetrials(nRetrials)
47 , m_nSteps(nSteps)
48 {
49 }
Alexander Afanasyevfdbfc6d2014-04-14 15:12:11 -070050
Jeff Thompsonf309aa62013-10-31 17:03:54 -070051 virtual
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070052 ~ValidationRequest()
53 {
54 }
Jeff Thompsonf309aa62013-10-31 17:03:54 -070055
Yingdi Yu4b8c6a22014-04-15 23:00:54 -070056 Interest m_interest; // Interest for the requested data.
57 OnDataValidated m_onValidated; // Callback function on validated certificate.
58 OnDataValidationFailed m_onDataValidated; // Callback function on validation failure.
59 int m_nRetrials; // The number of retrials when interest timeout.
60 int m_nSteps; // The stepCount of next step.
Jeff Thompsonf309aa62013-10-31 17:03:54 -070061};
62
Yingdi Yu40587c02014-02-21 16:40:48 -080063} // namespace ndn
Jeff Thompsonf309aa62013-10-31 17:03:54 -070064
Yingdi Yu40587c02014-02-21 16:40:48 -080065#endif //NDN_SECURITY_VALIDATION_REQUEST_HPP