summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fastd.c2
-rw-r--r--src/handshake.c16
-rw-r--r--src/handshake.h1
-rw-r--r--src/protocol_ec25519_fhmqvc.c13
4 files changed, 27 insertions, 5 deletions
diff --git a/src/fastd.c b/src/fastd.c
index aa7ed44..9e5e528 100644
--- a/src/fastd.c
+++ b/src/fastd.c
@@ -715,6 +715,8 @@ int main(int argc, char *argv[]) {
update_time(&ctx);
+ pr_info(&ctx, "fastd " FASTD_VERSION " starting");
+
init_sockets(&ctx);
init_tuntap(&ctx);
diff --git a/src/handshake.c b/src/handshake.c
index eb33f4f..393fad4 100644
--- a/src/handshake.c
+++ b/src/handshake.c
@@ -46,6 +46,7 @@ static const char const *RECORD_TYPES[RECORD_MAX] = {
"(protocol specific 5)",
"MTU",
"method name",
+ "version name",
};
static const char const *REPLY_TYPES[REPLY_MAX] = {
@@ -61,11 +62,13 @@ static const char const *REPLY_TYPES[REPLY_MAX] = {
fastd_buffer fastd_handshake_new_init(fastd_context *ctx, size_t tail_space) {
size_t protocol_len = strlen(ctx->conf->protocol->name);
size_t method_len = strlen(ctx->conf->method->name);
+ size_t version_len = strlen(FASTD_VERSION);
fastd_buffer buffer = fastd_buffer_alloc(sizeof(fastd_packet), 0,
2*5 + /* handshake type, mode */
6 + /* MTU */
4+protocol_len + /* protocol name */
4+method_len + /* method name */
+ 4+version_len + /* version name */
tail_space
);
fastd_packet *request = buffer.data;
@@ -79,20 +82,23 @@ fastd_buffer fastd_handshake_new_init(fastd_context *ctx, size_t tail_space) {
fastd_handshake_add(ctx, &buffer, RECORD_PROTOCOL_NAME, protocol_len, ctx->conf->protocol->name);
fastd_handshake_add(ctx, &buffer, RECORD_METHOD_NAME, method_len, ctx->conf->method->name);
+ fastd_handshake_add(ctx, &buffer, RECORD_VERSION_NAME, version_len, FASTD_VERSION);
return buffer;
}
fastd_buffer fastd_handshake_new_reply(fastd_context *ctx, const fastd_handshake *handshake, size_t tail_space) {
bool first = (AS_UINT8(handshake->records[RECORD_HANDSHAKE_TYPE]) == 1);
- size_t mtu_size = 0;
+ size_t version_len = strlen(FASTD_VERSION);
+ size_t extra_size = 0;
if (first)
- mtu_size = 6;
+ extra_size = 6 + /* MTU */
+ 4+version_len; /* version name */
fastd_buffer buffer = fastd_buffer_alloc(sizeof(fastd_packet), 0,
2*5 + /* handshake type, reply code */
- mtu_size +
+ extra_size +
tail_space
);
fastd_packet *request = buffer.data;
@@ -103,8 +109,10 @@ fastd_buffer fastd_handshake_new_reply(fastd_context *ctx, const fastd_handshake
fastd_handshake_add_uint8(ctx, &buffer, RECORD_HANDSHAKE_TYPE, AS_UINT8(handshake->records[RECORD_HANDSHAKE_TYPE])+1);
fastd_handshake_add_uint8(ctx, &buffer, RECORD_REPLY_CODE, 0);
- if (first)
+ if (first) {
fastd_handshake_add_uint16(ctx, &buffer, RECORD_MTU, ctx->conf->mtu);
+ fastd_handshake_add(ctx, &buffer, RECORD_VERSION_NAME, version_len, FASTD_VERSION);
+ }
return buffer;
}
diff --git a/src/handshake.h b/src/handshake.h
index 5e7ee1d..2e26194 100644
--- a/src/handshake.h
+++ b/src/handshake.h
@@ -44,6 +44,7 @@ typedef enum _fastd_handshake_record_type {
RECORD_PROTOCOL5,
RECORD_MTU,
RECORD_METHOD_NAME,
+ RECORD_VERSION_NAME,
RECORD_MAX,
} fastd_handshake_record_type;
diff --git a/src/protocol_ec25519_fhmqvc.c b/src/protocol_ec25519_fhmqvc.c
index c889d23..29fe280 100644
--- a/src/protocol_ec25519_fhmqvc.c
+++ b/src/protocol_ec25519_fhmqvc.c
@@ -519,6 +519,7 @@ static inline bool has_field(const fastd_handshake *handshake, uint8_t type, siz
static void protocol_handshake_handle(fastd_context *ctx, const fastd_peer_address *address, const fastd_peer_config *peer_conf, const fastd_handshake *handshake) {
handshake_key *handshake_key;
+ char *peer_version_name = NULL;
maintenance(ctx);
@@ -568,6 +569,12 @@ static void protocol_handshake_handle(fastd_context *ctx, const fastd_peer_addre
switch(handshake->type) {
case 1:
+ if (handshake->records[RECORD_VERSION_NAME].data)
+ peer_version_name = strndup(handshake->records[RECORD_VERSION_NAME].data, handshake->records[RECORD_VERSION_NAME].length);
+
+ pr_debug(ctx, "received handshake from %P[%I] using fastd %s", peer, address, peer_version_name);
+ free(peer_version_name);
+
respond_handshake(ctx, address, peer, &ctx->protocol_state->handshake_key, handshake->records[RECORD_SENDER_HANDSHAKE_KEY].data, handshake);
break;
@@ -583,7 +590,11 @@ static void protocol_handshake_handle(fastd_context *ctx, const fastd_peer_addre
return;
}
- pr_debug(ctx, "received handshake response from %P[%I]", peer, address);
+ if (handshake->records[RECORD_VERSION_NAME].data)
+ peer_version_name = strndup(handshake->records[RECORD_VERSION_NAME].data, handshake->records[RECORD_VERSION_NAME].length);
+
+ pr_debug(ctx, "received handshake response from %P[%I] using fastd %s", peer, address, peer_version_name);
+ free(peer_version_name);
finish_handshake(ctx, address, peer, handshake_key, handshake->records[RECORD_SENDER_HANDSHAKE_KEY].data, handshake);
break;