Junxiao Shi | 85d9083 | 2016-08-04 03:19:46 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | d701e5b | 2017-07-26 01:30:41 +0000 | [diff] [blame^] | 2 | /* |
| 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Junxiao Shi | 85d9083 | 2016-08-04 03:19:46 +0000 | [diff] [blame] | 4 | * |
| 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 | |
| 25 | namespace ndn { |
| 26 | namespace tests { |
| 27 | |
| 28 | shared_ptr<Interest> |
| 29 | makeInterest(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 | |
| 38 | shared_ptr<Data> |
| 39 | makeData(const Name& name) |
| 40 | { |
| 41 | auto data = make_shared<Data>(name); |
| 42 | return signData(data); |
| 43 | } |
| 44 | |
| 45 | Data& |
| 46 | signData(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 Shi | 85d9083 | 2016-08-04 03:19:46 +0000 | [diff] [blame] | 55 | lp::Nack |
| 56 | makeNack(const Interest& interest, lp::NackReason reason) |
| 57 | { |
| 58 | lp::Nack nack(interest); |
| 59 | nack.setReason(reason); |
| 60 | return nack; |
| 61 | } |
| 62 | |
| 63 | lp::Nack |
| 64 | makeNack(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 |