summaryrefslogtreecommitdiffstats
path: root/src/method_null.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-02-28 01:05:32 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-02-28 01:05:32 +0100
commitac8a726ad658e35cf73d4a62646cbe5ba3e38da4 (patch)
tree51e034f82db30cd0572d188ae9a2611df18404f1 /src/method_null.c
parentc0f7708f4a36074817556d0966aeb54cc64a5b88 (diff)
downloadfastd-ac8a726ad658e35cf73d4a62646cbe5ba3e38da4.tar
fastd-ac8a726ad658e35cf73d4a62646cbe5ba3e38da4.zip
Make simple handshake work
Diffstat (limited to 'src/method_null.c')
-rw-r--r--src/method_null.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/method_null.c b/src/method_null.c
index 34d1cce..75e74de 100644
--- a/src/method_null.c
+++ b/src/method_null.c
@@ -32,16 +32,24 @@ static size_t null_max_packet_size(fastd_context *ctx) {
return fastd_max_packet_size(ctx);
}
-static void null_init(fastd_context *ctx, const fastd_peer *peer) {
+static void null_init(fastd_context *ctx, fastd_peer *peer) {
fastd_buffer buffer = { .base = NULL, .len = 0, .free = NULL, .free_p = NULL };
fastd_task_put_send(ctx, peer, buffer);
}
-static void null_handle_recv(fastd_context *ctx, const fastd_peer *peer, fastd_buffer buffer) {
- fastd_task_put_handle_recv(ctx, peer, buffer);
+static void null_handle_recv(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) {
+ if (peer->state != STATE_ESTABLISHED) {
+ pr_info(ctx, "Connection established.");
+ peer->state = STATE_ESTABLISHED;
+ }
+
+ if (buffer.len)
+ fastd_task_put_handle_recv(ctx, peer, buffer);
+ else
+ fastd_buffer_free(buffer);
}
-static void null_send(fastd_context *ctx, const fastd_peer *peer, fastd_buffer buffer) {
+static void null_send(fastd_context *ctx, fastd_peer *peer, fastd_buffer buffer) {
fastd_task_put_send(ctx, peer, buffer);
}