summaryrefslogtreecommitdiffstats
path: root/src/packet.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-03-08 01:47:34 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-03-08 01:47:34 +0100
commit5268f248c91fb03f2de2a942a1eb1f171be96123 (patch)
treebc6690ef31132800dda4594559b952bc52dc4379 /src/packet.h
parent4b707f3076d0208a860e8c4fa5e05a85e09a2102 (diff)
downloadfastd-5268f248c91fb03f2de2a942a1eb1f171be96123.tar
fastd-5268f248c91fb03f2de2a942a1eb1f171be96123.zip
New and improved handshake
Diffstat (limited to 'src/packet.h')
-rw-r--r--src/packet.h53
1 files changed, 21 insertions, 32 deletions
diff --git a/src/packet.h b/src/packet.h
index 12d15fc..9ae04f7 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -38,49 +38,38 @@ typedef enum _fastd_packet_type {
PACKET_DATA,
} fastd_packet_type;
+typedef enum _fastd_handshake_record_type {
+ RECORD_REPLY_CODE = 0,
+ RECORD_ERROR_DETAIL,
+ RECORD_FLAGS,
+ RECORD_PROTOCOL,
+ RECORD_METHOD_NAME,
+ RECORD_MAX,
+} fastd_handshake_record_type;
+
typedef enum _fastd_reply_code {
REPLY_SUCCESS = 0,
+ REPLY_MANDATORY_MISSING,
+ REPLY_UNACCEPTABLE_VALUE,
+ REPLY_MAX,
} fastd_reply_code;
+typedef struct _fastd_packet {
#if defined(__LITTLE_ENDIAN_BITFIELD)
-#define FASTD_PACKET_COMMON \
- unsigned req_id : 6; \
- unsigned cp : 1; \
- unsigned reply : 1; \
- uint8_t rsv
+ unsigned req_id : 6;
+ unsigned cp : 1;
+ unsigned reply : 1;
#elif defined (__BIG_ENDIAN_BITFIELD)
-#define FASTD_PACKET_COMMON \
- unsigned reply : 1; \
- unsigned cp : 1; \
- unsigned req_id : 6; \
- uint8_t rsv
+ unsigned reply : 1;
+ unsigned cp : 1;
+ unsigned req_id : 6;
#else
#error "Bitfield endianess not defined."
#endif
-
-typedef struct __attribute__ ((__packed__)) _fastd_packet_any {
- FASTD_PACKET_COMMON;
-} fastd_packet_any;
-
-typedef struct __attribute__ ((__packed__)) _fastd_packet_request {
- FASTD_PACKET_COMMON;
- uint8_t flags;
- uint8_t proto;
- uint8_t method_len;
- char method_name[];
-} fastd_packet_request;
-
-typedef struct __attribute__ ((__packed__)) _fastd_packet_reply {
- FASTD_PACKET_COMMON;
- uint8_t reply_code;
-} fastd_packet_reply;
-
-typedef union _fastd_packet {
- fastd_packet_any any;
- fastd_packet_request request;
- fastd_packet_reply reply;
+ uint16_t rsv;
+ uint8_t tlv_data[];
} fastd_packet;
#endif /* _FASTD_PACKET_H_ */