summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-07-01 17:01:13 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-07-01 17:01:13 +0200
commita0be6d31b4da42e854ae1d05cffc193e8072223a (patch)
tree0905a71f3fb64e31daaa702186e1119d4724c8dc /src/fastd.h
parentcb74214fffc7b782f2868a74f834f0b72e0b984f (diff)
downloadfastd-a0be6d31b4da42e854ae1d05cffc193e8072223a.tar
fastd-a0be6d31b4da42e854ae1d05cffc193e8072223a.zip
Add support for multiple crypto methods without reconfiguration
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/fastd.h b/src/fastd.h
index e92f598..4d3d2a4 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -49,6 +49,10 @@
#define FASTD_VERSION "0.4"
+/* This must be adjusted when new methods are added */
+#define MAX_METHODS 3
+
+
struct _fastd_buffer {
void *base;
size_t base_len;
@@ -68,7 +72,7 @@ struct _fastd_protocol {
void (*peer_configure)(fastd_context *ctx, fastd_peer_config *peer_conf);
void (*handshake_init)(fastd_context *ctx, const fastd_peer_address *address, const fastd_peer_config *peer_conf);
- void (*handshake_handle)(fastd_context *ctx, const fastd_peer_address *address, const fastd_peer_config *peer_conf, const fastd_handshake *handshake);
+ void (*handshake_handle)(fastd_context *ctx, const fastd_peer_address *address, const fastd_peer_config *peer_conf, const fastd_handshake *handshake, const fastd_method *method);
void (*handle_recv)(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer);
void (*send)(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer);
@@ -152,7 +156,8 @@ struct _fastd_config {
bool forward;
const fastd_protocol *protocol;
- const fastd_method *method;
+ const fastd_method *methods[MAX_METHODS];
+ const fastd_method *method_default;
char *secret;
unsigned key_valid;
unsigned key_refresh;
@@ -318,6 +323,16 @@ static inline fastd_string_stack* fastd_string_stack_dup(const char *str) {
return ret;
}
+static inline fastd_string_stack* fastd_string_stack_dupn(const char *str, size_t len) {
+ size_t str_len = strnlen(str, len);
+ fastd_string_stack *ret = malloc(sizeof(fastd_string_stack) + str_len + 1);
+ ret->next = NULL;
+ strncpy(ret->str, str, str_len);
+ ret->str[str_len] = 0;
+
+ return ret;
+}
+
static inline fastd_string_stack* fastd_string_stack_push(fastd_string_stack *stack, const char *str) {
fastd_string_stack *ret = malloc(sizeof(fastd_string_stack) + strlen(str) + 1);
ret->next = stack;