From e5026b003d4ce221af2e3505af499f4083d5ce65 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 22 Dec 2014 13:25:12 +0000 Subject: [PATCH] Pack fuzzy commands. --- config.h.in | 8 ++++++++ src/fuzzy_storage.h | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config.h.in b/config.h.in index 158140c9c..a699739de 100644 --- a/config.h.in +++ b/config.h.in @@ -90,6 +90,14 @@ # error "Undefined or unknown BYTE_ORDER" #endif +#ifdef _MSC_VER +# define RSPAMD_PACKED(name) \ + __pragma(pack(push, 1)) struct name __pragma(pack(pop)) +#elif defined(__GNUC__) +# define RSPAMD_PACKED(name) struct __attribute__((packed)) name +#else +# define RSPAMD_PACKED(name) +#endif #cmakedefine HAVE_SYS_QUEUE_H 1 diff --git a/src/fuzzy_storage.h b/src/fuzzy_storage.h index 1d1b05edb..93488914d 100644 --- a/src/fuzzy_storage.h +++ b/src/fuzzy_storage.h @@ -21,24 +21,26 @@ struct legacy_fuzzy_cmd { u_char hash[FUZZY_HASHLEN]; }; -struct rspamd_fuzzy_cmd { +RSPAMD_PACKED(rspamd_fuzzy_cmd) { guint8 version; guint8 cmd; guint8 shingles_count; guint8 flag; gint32 value; + guint32 tag; gchar digest[64]; }; -struct rspamd_fuzzy_shingle_cmd { +RSPAMD_PACKED(rspamd_fuzzy_shingle_cmd) { struct rspamd_fuzzy_cmd basic; struct rspamd_shingle sgl; }; -struct rspamd_fuzzy_reply { +RSPAMD_PACKED(rspamd_fuzzy_reply) { guint32 value; guint32 flag; - gdouble prob; + guint32 tag; + float prob; }; #endif -- 2.39.5