34 cout <<
"-- dtnsend (IBR-DTN) --" << endl;
35 cout <<
"Syntax: dtnsend [options] <dst> <filename>" << endl;
36 cout <<
" <dst> Set the destination eid (e.g. dtn://node/filetransfer)" << endl;
37 cout <<
" <filename> The file to transfer" << endl << endl;
38 cout <<
"* optional parameters *" << endl;
39 cout <<
" -h|--help Display this text" << endl;
40 cout <<
" --src <name> Set the source application name (e.g. filetransfer)" << endl;
41 cout <<
" -p <0..2> Set the bundle priority (0 = low, 1 = normal, 2 = high)" << endl;
42 cout <<
" -g Receiver is a destination group" << endl;
43 cout <<
" --lifetime <seconds>" << endl;
44 cout <<
" Set the lifetime of outgoing bundles; default: 3600" << endl;
45 cout <<
" -U <socket> Connect to UNIX domain socket API" << endl;
46 cout <<
" -n <copies> Create <copies> bundle copies" << endl;
47 cout <<
" --encrypt Request encryption on the bundle layer" << endl;
48 cout <<
" --sign Request signature on the bundle layer" << endl;
49 cout <<
" --custody Request custody transfer of the bundle" << endl;
50 cout <<
" --compression Request compression of the payload" << endl;
54 int main(
int argc,
char *argv[])
57 string file_destination =
"dtn://local/filetransfer";
58 string file_source =
"";
59 unsigned int lifetime = 3600;
60 bool use_stdin =
false;
65 bool bundle_encryption =
false;
66 bool bundle_signed =
false;
67 bool bundle_custody =
false;
68 bool bundle_compression =
false;
69 bool bundle_group =
false;
74 std::list<std::string> arglist;
76 for (
int i = 0; i < argc; ++i)
78 if (argv[i][0] ==
'-')
80 std::string arg = argv[i];
83 if (arg ==
"-h" || arg ==
"--help")
88 else if (arg ==
"--encrypt")
90 bundle_encryption =
true;
92 else if (arg ==
"--sign")
96 else if (arg ==
"--custody")
98 bundle_custody =
true;
100 else if (arg ==
"--compression")
102 bundle_compression =
true;
104 else if (arg ==
"--src" && argc > i)
108 std::cout <<
"argument missing!" << std::endl;
112 file_source = argv[i];
114 else if (arg ==
"--lifetime" && argc > i)
118 std::cout <<
"argument missing!" << std::endl;
122 stringstream data; data << argv[i];
125 else if (arg ==
"-p" && argc > i)
129 std::cout <<
"argument missing!" << std::endl;
132 stringstream data; data << argv[i];
135 else if (arg ==
"-U" && argc > i)
139 std::cout <<
"argument missing!" << std::endl;
145 else if (arg ==
"-n" && argc > i)
149 std::cout <<
"argument missing!" << std::endl;
153 stringstream data; data << argv[i];
157 std::cout <<
"invalid number of bundle copies!" << std::endl;
161 else if (arg ==
"-g")
167 std::cout <<
"invalid argument " << arg << std::endl;
173 arglist.push_back(argv[i]);
177 if (arglist.size() <= 1)
181 }
else if (arglist.size() == 2)
183 std::list<std::string>::iterator iter = arglist.begin(); ++iter;
186 file_destination = (*iter);
190 else if (arglist.size() > 2)
192 std::list<std::string>::iterator iter = arglist.begin(); ++iter;
195 file_destination = (*iter); ++iter;
230 EID addr =
EID(file_destination);
235 cout <<
"Transfer stdin to " << addr.
getString() << endl;
243 for(
int u=0; u<copies; ++u){
262 if (bundle_custody) {
281 std::cout <<
"sent copy #" << (u+1) << std::endl;
287 cout <<
"Transfer file \"" << filename <<
"\" to " << addr.
getString() << endl;
292 for(
int u=0; u<copies; ++u){
312 if (bundle_custody) {
331 std::cout <<
"sent copy #" << (u+1) << std::endl;
339 std::cerr <<
"Error while sending bundle." << std::endl;
340 std::cerr <<
"\t" << ex.
what() << std::endl;
348 cout <<
"Error: " << ex.
what() << endl;
356 }
catch (
const std::exception &ex) {
357 cout <<
"Error: " << ex.what() << endl;
361 if (error)
return -1;