blob: ed243befe0bf3ba1b33ab12d656c42915ed284fd [file] [log] [blame]
jeraldabrahamf9543a42014-02-11 06:37:34 -07001/**
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
10using namespace ndn;
11
12class NdnTrafficClient
13{
14public:
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
87private:
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
98int 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}