summaryrefslogtreecommitdiffstats
path: root/src/handshake.h
diff options
context:
space:
mode:
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_ */