blob: 4969617939c838f2c8a837382e9ed1a40ff38ff7 [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompson3b3aabf2013-06-21 16:50:20 -07004 */
5
6#include <cstdlib>
7#include <sstream>
8#include <iostream>
Jeff Thompson53412192013-08-06 13:35:50 -07009#include <ndn-cpp/interest.hpp>
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070010
11using namespace std;
12using namespace ndn;
13
Jeff Thompson22552902013-07-07 21:26:20 -070014unsigned char Interest1[] = {
Jeff Thompson7afc98e2013-06-27 14:33:53 -0700150x01, 0xd2,
16 0xf2, 0xfa, 0x9d, 0x6e, 0x64, 0x6e, 0x00, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0x00,
Jeff Thompson06f824a2013-07-08 17:14:30 -070017 0x05, 0x9a, 0x9e, 0x31, 0x32, 0x33, 0x00,
Jeff Thompson7afc98e2013-06-27 14:33:53 -070018 0x05, 0xa2, 0x8e, 0x34, 0x00,
19 0x03, 0xe2,
20 0x02, 0x85, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
21 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
22 0x00,
Jeff Thompson22552902013-07-07 21:26:20 -070023 0x02, 0xda, 0xfa, 0x9d, 0x61, 0x62, 0x63, 0x00, 0xea, 0x00, 0x00,
Jeff Thompson22552902013-07-07 21:26:20 -070024 0x05, 0xaa, 0x8e, 0x31, 0x00,
25 0x02, 0xfa, 0x8e, 0x34, 0x00,
26 0x02, 0xd2, 0x8e, 0x32, 0x00,
27 0x03, 0x82, 0x9d, 0x01, 0xe0, 0x00, 0x00,
28 0x02, 0xca, 0xb5, 0x61, 0x62, 0x61, 0x62, 0x61, 0x62, 0x00,
290x00,
Jeff Thompson7afc98e2013-06-27 14:33:53 -0700301
31};
32
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070033/*
34 *
35 */
Jeff Thompson7afc98e2013-06-27 14:33:53 -070036int main(int argc, char** argv)
37{
38 try {
Jeff Thompson22552902013-07-07 21:26:20 -070039 Interest interest;
Jeff Thompson67e9e0a2013-08-02 19:16:19 -070040 interest.wireDecode(Interest1, sizeof(Interest1));
Jeff Thompson22552902013-07-07 21:26:20 -070041 cout << "Interest name " << interest.getName().to_uri() << endl;
Jeff Thompson06f824a2013-07-08 17:14:30 -070042 cout << "Interest minSuffixComponents " << interest.getMinSuffixComponents() << endl;
Jeff Thompson8238d002013-07-10 11:56:49 -070043 cout << "Interest publisherPublicKeyDigest length " << interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
Jeff Thompsonfe556862013-07-09 13:52:55 -070044 cout << "Interest excludeEntryCount " << interest.getExclude().getEntryCount() << endl;
Jeff Thompson5a5e8b72013-07-11 14:28:03 -070045 cout << "InterestLifetimeMilliseconds " << interest.getInterestLifetimeMilliseconds() << endl;
Jeff Thompson2fb4b1b2013-07-01 15:10:43 -070046
Jeff Thompson67e9e0a2013-08-02 19:16:19 -070047 ptr_lib::shared_ptr<vector<unsigned char> > encoding = interest.wireEncode();
Jeff Thompsoned4f3732013-08-15 17:34:34 -070048 cout << endl << "Re-encoded interest " << toHex(*encoding) << endl;
Jeff Thompson0d567da2013-07-14 22:10:21 -070049
Jeff Thompson06f824a2013-07-08 17:14:30 -070050 Interest reDecodedInterest;
Jeff Thompson67e9e0a2013-08-02 19:16:19 -070051 reDecodedInterest.wireDecode(*encoding);
Jeff Thompson06f824a2013-07-08 17:14:30 -070052 cout << "Re-decoded Interest name " << reDecodedInterest.getName().to_uri() << endl;
53 cout << "Re-decoded Interest minSuffixComponents " << reDecodedInterest.getMinSuffixComponents() << endl;
Jeff Thompson8238d002013-07-10 11:56:49 -070054 cout << "Re-decoded Interest publisherPublicKeyDigest length " << reDecodedInterest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
Jeff Thompsonfe556862013-07-09 13:52:55 -070055 cout << "Re-decoded Interest excludeEntryCount " << reDecodedInterest.getExclude().getEntryCount() << endl;
Jeff Thompson5a5e8b72013-07-11 14:28:03 -070056 cout << "Re-decoded InterestLifetimeMilliseconds " << reDecodedInterest.getInterestLifetimeMilliseconds() << endl;
Jeff Thompson7afc98e2013-06-27 14:33:53 -070057 } catch (exception &e) {
Jeff Thompson8b666002013-07-08 01:16:26 -070058 cout << "exception: " << e.what() << endl;
Jeff Thompson7afc98e2013-06-27 14:33:53 -070059 }
Jeff Thompson3b3aabf2013-06-21 16:50:20 -070060 return 0;
61}