summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fastd.h4
-rw-r--r--src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c13
-rw-r--r--src/status.c15
3 files changed, 30 insertions, 2 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 5aff8e2..26fd371 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -109,6 +109,10 @@ struct fastd_protocol {
fastd_peer_t * (*find_peer)(const fastd_protocol_key_t *key);
+ /** Retrieves information about the currently used encyption/authentication method of a connection with a peer */
+ const fastd_method_info_t * (*get_current_method)(const fastd_peer_t *peer);
+
+
/** Generates a new keypair and outputs it */
void (*generate_key)(void);
diff --git a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
index 8533c2b..60947b3 100644
--- a/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
+++ b/src/protocols/ec25519_fhmqvc/ec25519_fhmqvc.c
@@ -200,6 +200,17 @@ void fastd_protocol_ec25519_fhmqvc_send_empty(fastd_peer_t *peer, protocol_sessi
session_send(peer, fastd_buffer_alloc(0, alignto(session->method->provider->min_encrypt_head_space, 8), session->method->provider->min_encrypt_tail_space), session);
}
+/** get_current_method implementation for ec25519-fhmqvp */
+const fastd_method_info_t * protocol_get_current_method(const fastd_peer_t *peer) {
+ if (!peer->protocol_state || !fastd_peer_is_established(peer))
+ return NULL;
+
+ if (peer->protocol_state->session.method->provider->session_is_initiator(peer->protocol_state->session.method_state) && is_session_valid(&peer->protocol_state->old_session))
+ return peer->protocol_state->old_session.method;
+ else
+ return peer->protocol_state->session.method;
+}
+
/** The \em ec25519-fhmqvc protocol definition */
const fastd_protocol_t fastd_protocol_ec25519_fhmqvc = {
@@ -224,6 +235,8 @@ const fastd_protocol_t fastd_protocol_ec25519_fhmqvc = {
.check_peer = protocol_check_peer,
.find_peer = fastd_protocol_ec25519_fhmqvc_find_peer,
+ .get_current_method = protocol_get_current_method,
+
.generate_key = fastd_protocol_ec25519_fhmqvc_generate_key,
.show_key = fastd_protocol_ec25519_fhmqvc_show_key,
diff --git a/src/status.c b/src/status.c
index 4b4131d..8049f59 100644
--- a/src/status.c
+++ b/src/status.c
@@ -30,14 +30,16 @@
*/
-#include "peer.h"
+#include "types.h"
#ifdef WITH_STATUS_SOCKET
-#include <sys/un.h>
+#include "method.h"
+#include "peer.h"
#include <json.h>
+#include <sys/un.h>
/** Argument for dump_thread */
@@ -98,6 +100,15 @@ static json_object * dump_peer(const fastd_peer_t *peer) {
if (fastd_peer_is_established(peer)) {
connection = json_object_new_object();
+ struct json_object *method = NULL;
+
+ const fastd_method_info_t *method_info = conf.protocol->get_current_method(peer);
+
+ if (method_info)
+ method = json_object_new_string(method_info->name);
+
+ json_object_object_add(connection, "method", method);
+
if (conf.mode == MODE_TAP) {
struct json_object *mac_addresses = json_object_new_array();
json_object_object_add(connection, "mac_addresses", mac_addresses);