summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-11-20 02:17:15 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-11-20 02:17:15 +0100
commitc6cce0f5aac6640d5946c7ba7a258a04deac9423 (patch)
treed3ecc15e3de49b4e8327f4c5b3e5272c2119a4ea /src/fastd.h
parentb5112ff67f3dd5bb263f5ca6283f170906acaab6 (diff)
downloadfastd-c6cce0f5aac6640d5946c7ba7a258a04deac9423.tar
fastd-c6cce0f5aac6640d5946c7ba7a258a04deac9423.zip
Replace max_packet_size functions by a max_overhead field
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 2536e71..66dd06f 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -81,7 +81,7 @@ struct fastd_protocol {
struct fastd_method {
bool (*provides)(const char *name);
- size_t (*max_packet_size)(fastd_context_t *ctx);
+ size_t max_overhead;
size_t min_encrypt_head_space;
size_t min_decrypt_head_space;
size_t min_encrypt_tail_space;
@@ -240,7 +240,7 @@ struct fastd_config {
const fastd_protocol_t *protocol;
fastd_string_stack_t *methods;
- size_t max_packet_size;
+ size_t max_overhead;
size_t min_encrypt_head_space;
size_t min_decrypt_head_space;
size_t min_encrypt_tail_space;
@@ -468,7 +468,7 @@ static inline void fastd_buffer_push_head(const fastd_context_t *ctx, fastd_buff
buffer->len -= len;
}
-static inline size_t fastd_max_packet_size(const fastd_context_t *ctx) {
+static inline size_t fastd_max_inner_packet(const fastd_context_t *ctx) {
switch (ctx->conf->mode) {
case MODE_TAP:
return ctx->conf->mtu+ETH_HLEN;
@@ -479,6 +479,10 @@ static inline size_t fastd_max_packet_size(const fastd_context_t *ctx) {
}
}
+static inline size_t fastd_max_outer_packet(const fastd_context_t *ctx) {
+ return PACKET_TYPE_LEN + fastd_max_inner_packet(ctx) + ctx->conf->max_overhead;
+}
+
static inline fastd_string_stack_t* fastd_string_stack_dup(const char *str) {
fastd_string_stack_t *ret = malloc(alignto(sizeof(fastd_string_stack_t) + strlen(str) + 1, 8));
ret->next = NULL;