projects
/
tinc
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
ccbf70b
)
Allow testing the replay window with sptps_test.
author
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 30 Aug 2013 12:23:02 +0000
(14:23 +0200)
committer
Guus Sliepen
<guus@tinc-vpn.org>
Fri, 30 Aug 2013 12:23:02 +0000
(14:23 +0200)
src/sptps_test.c
patch
|
blob
|
history
diff --git
a/src/sptps_test.c
b/src/sptps_test.c
index
6f6be4b
..
98da73e
100644
(file)
--- a/
src/sptps_test.c
+++ b/
src/sptps_test.c
@@
-54,6
+54,7
@@
static bool receive_record(void *handle, uint8_t type, const char *data, uint16_
static struct option const long_options[] = {
{"datagram", no_argument, NULL, 'd'},
{"packet-loss", required_argument, NULL, 'l'},
static struct option const long_options[] = {
{"datagram", no_argument, NULL, 'd'},
{"packet-loss", required_argument, NULL, 'l'},
+ {"replay-window", required_argument, NULL, 'r'},
{"help", no_argument, NULL, 1},
{NULL, 0, NULL, 0}
};
{"help", no_argument, NULL, 1},
{NULL, 0, NULL, 0}
};
@@
-65,6
+66,7
@@
static void usage() {
fprintf(stderr, "Valid options are:\n"
" -d, --datagram Enable datagram mode.\n"
" -l, --packet-loss RATE Fake packet loss of RATE percent.\n"
fprintf(stderr, "Valid options are:\n"
" -d, --datagram Enable datagram mode.\n"
" -l, --packet-loss RATE Fake packet loss of RATE percent.\n"
+ " -r, --replay-window N Set replay window to N bytes.\n"
"\n");
fprintf(stderr, "Report bugs to tinc@tinc-vpn.org.\n");
}
"\n");
fprintf(stderr, "Report bugs to tinc@tinc-vpn.org.\n");
}
@@
-77,7
+79,7
@@
int main(int argc, char *argv[]) {
int r;
int option_index = 0;
int r;
int option_index = 0;
- while((r = getopt_long(argc, argv, "dl:", long_options, &option_index)) != EOF) {
+ while((r = getopt_long(argc, argv, "dl:
r:
", long_options, &option_index)) != EOF) {
switch (r) {
case 0: /* long option */
break;
switch (r) {
case 0: /* long option */
break;
@@
-90,6
+92,10
@@
int main(int argc, char *argv[]) {
packetloss = atoi(optarg);
break;
packetloss = atoi(optarg);
break;
+ case 'r': /* replay window size */
+ sptps_replaywin = atoi(optarg);
+ break;
+
case '?': /* wrong options */
usage();
return 1;
case '?': /* wrong options */
usage();
return 1;
@@
-228,6
+234,8
@@
int main(int argc, char *argv[]) {
}
if(len == 0)
break;
}
if(len == 0)
break;
+ if(buf[0] == '#')
+ s.outseqno = atoi(buf + 1);
if(buf[0] == '^')
sptps_send_record(&s, SPTPS_HANDSHAKE, NULL, 0);
else if(buf[0] == '$') {
if(buf[0] == '^')
sptps_send_record(&s, SPTPS_HANDSHAKE, NULL, 0);
else if(buf[0] == '$') {
@@
-256,7
+264,7
@@
int main(int argc, char *argv[]) {
fprintf(stderr, "Dropped.\n");
continue;
}
fprintf(stderr, "Dropped.\n");
continue;
}
- if(!sptps_receive_data(&s, buf, len))
+ if(!sptps_receive_data(&s, buf, len)
&& !datagram
)
return 1;
}
}
return 1;
}
}