diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 21:29:34 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-03-06 21:29:34 +0100 |
commit | 1d18f972554c8bad0f08b3ff6727c87586e97094 (patch) | |
tree | ae3fc39553ecd87ed85b22860640d2859e9aa092 /src/packet.h | |
parent | d4686dd79799c09faee49e1645f9b3c39ce1e993 (diff) | |
download | fastd-1d18f972554c8bad0f08b3ff6727c87586e97094.tar fastd-1d18f972554c8bad0f08b3ff6727c87586e97094.zip |
Reorganized type definitions
Diffstat (limited to 'src/packet.h')
-rw-r--r-- | src/packet.h | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/src/packet.h b/src/packet.h index b014f2b..12d15fc 100644 --- a/src/packet.h +++ b/src/packet.h @@ -32,40 +32,40 @@ #include <stdint.h> +typedef enum _fastd_packet_type { + PACKET_UNKNOWN = 0, + PACKET_HANDSHAKE, + PACKET_DATA, +} fastd_packet_type; + typedef enum _fastd_reply_code { REPLY_SUCCESS = 0, } fastd_reply_code; -typedef struct __attribute__ ((__packed__)) _fastd_packet_any { + #if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned req_id : 6; - unsigned cp : 1; - unsigned reply : 1; +#define FASTD_PACKET_COMMON \ + unsigned req_id : 6; \ + unsigned cp : 1; \ + unsigned reply : 1; \ + uint8_t rsv #elif defined (__BIG_ENDIAN_BITFIELD) - unsigned reply : 1; - unsigned cp : 1; - unsigned req_id : 6; +#define FASTD_PACKET_COMMON \ + unsigned reply : 1; \ + unsigned cp : 1; \ + unsigned req_id : 6; \ + uint8_t rsv #else #error "Bitfield endianess not defined." #endif - uint8_t rsv; + +typedef struct __attribute__ ((__packed__)) _fastd_packet_any { + FASTD_PACKET_COMMON; } fastd_packet_any; typedef struct __attribute__ ((__packed__)) _fastd_packet_request { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned req_id : 6; - unsigned cp : 1; - unsigned reply : 1; -#elif defined (__BIG_ENDIAN_BITFIELD) - unsigned reply : 1; - unsigned cp : 1; - unsigned req_id : 6; -#else -#error "Bitfield endianess not defined." -#endif - - uint8_t rsv; + FASTD_PACKET_COMMON; uint8_t flags; uint8_t proto; uint8_t method_len; @@ -73,19 +73,7 @@ typedef struct __attribute__ ((__packed__)) _fastd_packet_request { } fastd_packet_request; typedef struct __attribute__ ((__packed__)) _fastd_packet_reply { -#if defined(__LITTLE_ENDIAN_BITFIELD) - unsigned req_id : 6; - unsigned cp : 1; - unsigned reply : 1; -#elif defined (__BIG_ENDIAN_BITFIELD) - unsigned reply : 1; - unsigned cp : 1; - unsigned req_id : 6; -#else -#error "Bitfield endianess not defined." -#endif - - uint8_t rsv; + FASTD_PACKET_COMMON; uint8_t reply_code; } fastd_packet_reply; |