summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-26 06:05:36 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-26 06:05:36 +0200
commite89cfb2f0b8159f602ecae6b53c0ee59b112601d (patch)
tree886aa6782bd795683c1ad214543e48b4af4a190b /src/fastd.h
parenta02fb0711ba496877c111b118b78d404151a8b8d (diff)
downloadfastd-e89cfb2f0b8159f602ecae6b53c0ee59b112601d.tar
fastd-e89cfb2f0b8159f602ecae6b53c0ee59b112601d.zip
Implement encrypted send/receive
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index 8bd04ec..873da61 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -62,6 +62,8 @@ struct _fastd_protocol {
void (*init)(fastd_context *ctx);
size_t (*max_packet_size)(fastd_context *ctx);
+ size_t (*min_encrypt_head_space)(fastd_context *ctx);
+ size_t (*min_decrypt_head_space)(fastd_context *ctx);
char* (*peer_str)(const fastd_context *ctx, const fastd_peer *peer);
@@ -161,6 +163,22 @@ static inline void fastd_buffer_free(fastd_buffer buffer) {
free(buffer.base);
}
+static inline void fastd_buffer_pull_head(fastd_buffer *buffer, size_t len) {
+ buffer->data -= len;
+ buffer->len += len;
+
+ if (buffer->data < buffer->base)
+ abort();
+}
+
+static inline void fastd_buffer_push_head(fastd_buffer *buffer, size_t len) {
+ if (buffer->len < len)
+ abort();
+
+ buffer->data += len;
+ buffer->len -= len;
+}
+
static inline size_t fastd_max_packet_size(const fastd_context *ctx) {
switch (ctx->conf->mode) {
case MODE_TAP: