projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add datagram mode to the SPTPS protocol.
[tinc]
/
src
/
sptps_test.c
diff --git
a/src/sptps_test.c
b/src/sptps_test.c
index
866159e
..
3ee7ab6
100644
(file)
--- a/
src/sptps_test.c
+++ b/
src/sptps_test.c
@@
-25,6
+25,12
@@
#include "sptps.h"
#include "utils.h"
#include "sptps.h"
#include "utils.h"
+// Symbols necessary to link with logger.o
+char *logfilename;
+char *connection_tree;
+char *send_request;
+char *send_meta;
+
ecdsa_t mykey, hiskey;
static bool send_data(void *handle, const char *data, size_t len) {
ecdsa_t mykey, hiskey;
static bool send_data(void *handle, const char *data, size_t len) {
@@
-45,9
+51,16
@@
static bool receive_record(void *handle, uint8_t type, const char *data, uint16_
int main(int argc, char *argv[]) {
bool initiator = false;
int main(int argc, char *argv[]) {
bool initiator = false;
+ bool datagram = false;
+
+ if(argc > 1 && !strcmp(argv[1], "-d")) {
+ datagram = true;
+ argc--;
+ argv++;
+ }
- if(argc <
3
) {
- fprintf(stderr, "Usage: %s my_ecdsa_key_file his_ecdsa_key_file [host] port\n", argv[0]);
+ if(argc <
4
) {
+ fprintf(stderr, "Usage: %s
[-d]
my_ecdsa_key_file his_ecdsa_key_file [host] port\n", argv[0]);
return 1;
}
return 1;
}
@@
-117,7
+130,7
@@
int main(int argc, char *argv[]) {
fprintf(stderr, "Keys loaded\n");
sptps_t s;
fprintf(stderr, "Keys loaded\n");
sptps_t s;
- if(!s
tart_sptps(&s, &sock, initiator
, mykey, hiskey, "sptps_test", 10, send_data, receive_record))
+ if(!s
ptps_start(&s, &sock, initiator, datagram
, mykey, hiskey, "sptps_test", 10, send_data, receive_record))
return 1;
while(true) {
return 1;
while(true) {
@@
-140,11
+153,11
@@
int main(int argc, char *argv[]) {
if(len == 0)
break;
if(buf[0] == '^')
if(len == 0)
break;
if(buf[0] == '^')
- send_record(&s, SPTPS_HANDSHAKE, NULL, 0);
+ s
ptps_s
end_record(&s, SPTPS_HANDSHAKE, NULL, 0);
else if(buf[0] == '$')
else if(buf[0] == '$')
- force_kex(&s);
+
sptps_
force_kex(&s);
else
else
- if(!send_record(&s, buf[0] == '!' ? 1 : 0, buf, buf[0] == '\n' ? 0 : buf[0] == '*' ? sizeof buf : len))
+ if(!s
ptps_s
end_record(&s, buf[0] == '!' ? 1 : 0, buf, buf[0] == '\n' ? 0 : buf[0] == '*' ? sizeof buf : len))
return 1;
}
return 1;
}
@@
-161,10
+174,13
@@
int main(int argc, char *argv[]) {
char hex[len * 2 + 1];
bin2hex(buf, hex, len);
fprintf(stderr, "Received %zd bytes of data:\n%s\n", len, hex);
char hex[len * 2 + 1];
bin2hex(buf, hex, len);
fprintf(stderr, "Received %zd bytes of data:\n%s\n", len, hex);
- if(!receive_data(&s, buf, len))
+ if(!
sptps_
receive_data(&s, buf, len))
return 1;
}
}
return 1;
}
}
+ if(!sptps_stop(&s))
+ return 1;
+
return 0;
}
return 0;
}