summaryrefslogtreecommitdiffstats
path: root/src/handshake.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-02 01:54:00 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-02 01:54:00 +0200
commitb56a383d4ceaaf9981d2305834d7b2003b9da48f (patch)
tree25a9b5e7e2b8269173510f818a0f0f49574740d8 /src/handshake.h
parent6df58e79890f05010ba41ce1adb1fc9f94e8a53b (diff)
downloadfastd-0.1-rc3.tar
fastd-0.1-rc3.zip
Warn on MTU mismatchv0.1-rc3
Diffstat (limited to 'src/handshake.h')
-rw-r--r--src/handshake.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/handshake.h b/src/handshake.h
index d540de0..a5b861e 100644
--- a/src/handshake.h
+++ b/src/handshake.h
@@ -42,6 +42,7 @@ typedef enum _fastd_handshake_record_type {
RECORD_PROTOCOL3,
RECORD_PROTOCOL4,
RECORD_PROTOCOL5,
+ RECORD_MTU,
RECORD_MAX,
} fastd_handshake_record_type;
@@ -101,5 +102,21 @@ static inline void fastd_handshake_add_uint8(fastd_context *ctx, fastd_buffer *b
buffer->len += 5;
}
+static inline void fastd_handshake_add_uint16(fastd_context *ctx, fastd_buffer *buffer, fastd_handshake_record_type type, uint16_t value) {
+ if ((uint8_t*)buffer->data + buffer->len + 6 > (uint8_t*)buffer->base + buffer->base_len)
+ exit_bug(ctx, "not enough buffer allocated for handshake");
+
+ uint8_t *dst = (uint8_t*)buffer->data + buffer->len;
+
+ dst[0] = type;
+ dst[1] = type >> 8;
+ dst[2] = 2;
+ dst[3] = 0;
+ dst[4] = value;
+ dst[5] = value >> 8;
+
+ buffer->len += 6;
+}
+
#endif /* _FASTD_HANDSHAKE_H_ */