blob: a497da24df1e25107fffaadcd69a56661762bff0 [file] [log] [blame]
Junxiao Shi85d90832016-08-04 03:19:46 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shid701e5b2017-07-26 01:30:41 +00002/*
3 * Copyright (c) 2013-2017 Regents of the University of California.
Junxiao Shi85d90832016-08-04 03:19:46 +00004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * 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.
20 */
21
22#include "make-interest-data.hpp"
23#include "security/signature-sha256-with-rsa.hpp"
24
25namespace ndn {
26namespace tests {
27
28shared_ptr<Interest>
29makeInterest(const Name& name, uint32_t nonce)
30{
31 auto interest = make_shared<Interest>(name);
32 if (nonce != 0) {
33 interest->setNonce(nonce);
34 }
35 return interest;
36}
37
38shared_ptr<Data>
39makeData(const Name& name)
40{
41 auto data = make_shared<Data>(name);
42 return signData(data);
43}
44
45Data&
46signData(Data& data)
47{
48 ndn::SignatureSha256WithRsa fakeSignature;
49 fakeSignature.setValue(ndn::encoding::makeEmptyBlock(tlv::SignatureValue));
50 data.setSignature(fakeSignature);
51 data.wireEncode();
52 return data;
53}
54
Junxiao Shi85d90832016-08-04 03:19:46 +000055lp::Nack
56makeNack(const Interest& interest, lp::NackReason reason)
57{
58 lp::Nack nack(interest);
59 nack.setReason(reason);
60 return nack;
61}
62
63lp::Nack
64makeNack(const Name& name, uint32_t nonce, lp::NackReason reason)
65{
66 Interest interest(name);
67 interest.setNonce(nonce);
68 return makeNack(interest, reason);
69}
70
71} // namespace tests
72} // namespace ndn