jeraldabraham | f9543a4 | 2014-02-11 06:37:34 -0700 | [diff] [blame^] | 1 | /**
|
| 2 | *
|
| 3 | * Copyright (C) 2013 University of Arizona.
|
| 4 | * @author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu>
|
| 5 | *
|
| 6 | */
|
| 7 |
|
| 8 | #include <ndn-cpp-dev/security/key-chain.hpp>
|
| 9 |
|
| 10 | using namespace ndn;
|
| 11 |
|
| 12 | class NdnTrafficClient
|
| 13 | {
|
| 14 | public:
|
| 15 |
|
| 16 | NdnTrafficClient( char* programName )
|
| 17 | {
|
| 18 | programName_ = programName;
|
| 19 | interestInterval_ = getDefaultInterestInterval();
|
| 20 | interestCount_ = getDefaultInterestCount();
|
| 21 | prefix_ = "";
|
| 22 | configurationFile_ = "";
|
| 23 | }
|
| 24 |
|
| 25 | NdnTrafficClient()
|
| 26 | : keyChain_()
|
| 27 | {
|
| 28 | }
|
| 29 |
|
| 30 | void
|
| 31 | usage()
|
| 32 | {
|
| 33 | std::cout << "\nUsage: " << programName_ << " Printing Usage"
|
| 34 | "\n\n";
|
| 35 | exit(1);
|
| 36 | }
|
| 37 |
|
| 38 | int
|
| 39 | getDefaultInterestInterval()
|
| 40 | {
|
| 41 | return -1;
|
| 42 | }
|
| 43 |
|
| 44 | int
|
| 45 | getDefaultInterestCount()
|
| 46 | {
|
| 47 | return -1;
|
| 48 | }
|
| 49 |
|
| 50 | bool
|
| 51 | isPrefixSet()
|
| 52 | {
|
| 53 | if ( prefix_.length() > 0 )
|
| 54 | return true;
|
| 55 | else
|
| 56 | return false;
|
| 57 | }
|
| 58 |
|
| 59 | void
|
| 60 | setInterestInterval( int interestInterval )
|
| 61 | {
|
| 62 | if (interestInterval < 0)
|
| 63 | usage();
|
| 64 | interestInterval_ = interestInterval;
|
| 65 | }
|
| 66 |
|
| 67 | void
|
| 68 | setInterestCount( int interestCount )
|
| 69 | {
|
| 70 | if (interestCount < 0)
|
| 71 | usage();
|
| 72 | interestCount_ = interestCount;
|
| 73 | }
|
| 74 |
|
| 75 | void
|
| 76 | setPrefix( char* prefix )
|
| 77 | {
|
| 78 | prefix_ = prefix;
|
| 79 | }
|
| 80 |
|
| 81 | void
|
| 82 | setConfigurationFile( char* configurationFile )
|
| 83 | {
|
| 84 | configurationFile_ = configurationFile;
|
| 85 | }
|
| 86 |
|
| 87 | private:
|
| 88 |
|
| 89 | KeyChain keyChain_;
|
| 90 | std::string programName_;
|
| 91 | int interestInterval_;
|
| 92 | int interestCount_;
|
| 93 | std::string prefix_;
|
| 94 | std::string configurationFile_;
|
| 95 |
|
| 96 | };
|
| 97 |
|
| 98 | int main( int argc, char* argv[] )
|
| 99 | {
|
| 100 | int option;
|
| 101 | NdnTrafficClient ndnTrafficClient (argv[0]);
|
| 102 | while ((option = getopt(argc, argv, "hi:c:p:")) != -1) {
|
| 103 | switch (option) {
|
| 104 | case 'h' :
|
| 105 | ndnTrafficClient.usage();
|
| 106 | break;
|
| 107 | case 'i' :
|
| 108 | ndnTrafficClient.setInterestInterval(atoi(optarg));
|
| 109 | break;
|
| 110 | case 'c' :
|
| 111 | ndnTrafficClient.setInterestCount(atoi(optarg));
|
| 112 | break;
|
| 113 | case 'p' :
|
| 114 | ndnTrafficClient.setPrefix(optarg);
|
| 115 | break;
|
| 116 | default :
|
| 117 | ndnTrafficClient.usage();
|
| 118 | break;
|
| 119 | }
|
| 120 | }
|
| 121 |
|
| 122 | argc -= optind;
|
| 123 | argv += optind;
|
| 124 |
|
| 125 | if (argv[0] == NULL && !ndnTrafficClient.isPrefixSet() )
|
| 126 | ndnTrafficClient.usage();
|
| 127 |
|
| 128 | ndnTrafficClient.setConfigurationFile(argv[0]);
|
| 129 |
|
| 130 | return 0;
|
| 131 | }
|