blob: fbc92cef12bf2d59cbeee904fd23525fc6920b5a [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 NdnTrafficServer
13{
14public:
15
16 NdnTrafficServer( char* programName )
17 {
18 programName_ = programName;
19 contentDelayTime_ = getDefaultContentDelayTime();
20 prefix_ = "";
21 configurationFile_ = "";
22 }
23
24 NdnTrafficServer()
25 : keyChain_()
26 {
27 }
28
29 void
30 usage()
31 {
32 std::cout << "\nUsage: " << programName_ << " Printing Usage"
33 "\n\n";
34 exit(1);
35 }
36
37 int
38 getDefaultContentDelayTime()
39 {
40 return 0;
41 }
42
43 bool
44 isPrefixSet()
45 {
46 if (prefix_.length() > 0)
47 return true;
48 else
49 return false;
50 }
51
52 void
53 setContentDelayTime( int contentDelayTime )
54 {
55 if (contentDelayTime < 0)
56 usage();
57 contentDelayTime_ = contentDelayTime;
58 }
59
60 void
61 setPrefix( char* prefix )
62 {
63 prefix_ = prefix;
64 }
65
66 void
67 setConfigurationFile( char* configurationFile )
68 {
69 configurationFile_ = configurationFile;
70 }
71
72private:
73
74 KeyChain keyChain_;
75 std::string programName_;
76 int contentDelayTime_;
77 std::string prefix_;
78 std::string configurationFile_;
79
80};
81
82int main( int argc, char* argv[] )
83{
84 int option;
85 NdnTrafficServer ndnTrafficServer (argv[0]);
86 while ((option = getopt(argc, argv, "hd:p:")) != -1) {
87 switch (option) {
88 case 'h' :
89 ndnTrafficServer.usage();
90 break;
91 case 'd' :
92 ndnTrafficServer.setContentDelayTime(atoi(optarg));
93 break;
94 case 'p' :
95 ndnTrafficServer.setPrefix(optarg);
96 break;
97 default :
98 ndnTrafficServer.usage();
99 break;
100 }
101 }
102
103 argc -= optind;
104 argv += optind;
105
106 if (argv[0] == NULL && !ndnTrafficServer.isPrefixSet() )
107 ndnTrafficServer.usage();
108
109 ndnTrafficServer.setConfigurationFile(argv[0]);
110
111 return 0;
112}