aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuslan Sologub <ruslan@sologub.md>2016-11-15 15:47:08 +0200
committerRuslan Sologub <ruslan@sologub.md>2016-11-15 15:47:08 +0200
commit8761e3a8694cb94911f7af9f3709c6ddf6bc3a29 (patch)
tree9bb8ee7e20261ae304614c348bb892efbc7e6283 /src
parentb9a1eba15281aa5889faada8c7430bbe97b880c6 (diff)
Fix byte packing on Windows
Diffstat (limited to 'src')
-rw-r--r--src/lib/protocols/btlib.h54
1 files changed, 45 insertions, 9 deletions
diff --git a/src/lib/protocols/btlib.h b/src/lib/protocols/btlib.h
index db68370c9..b68adbad1 100644
--- a/src/lib/protocols/btlib.h
+++ b/src/lib/protocols/btlib.h
@@ -24,44 +24,81 @@
#define BDEC_MAXDEPT 8
+#ifdef WIN32
+#include "ndpi_win32.h"
+#endif
typedef struct b_elem_s {
const u_int8_t *s;
size_t l;
} b_elem_s_t;
-struct __attribute__ ((__packed__)) bt_nodes_data {
- u_int8_t id[20] ;
+#ifdef WIN32
+// enable 1 byte packing on Windows
+#include <pshpack1.h>
+#endif
+
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_nodes_data {
+ u_int8_t id[20];
u_int32_t ip;
u_int16_t port;
};
-struct __attribute__ ((__packed__)) bt_ipv4p {
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_ipv4p {
u_int32_t ip;
u_int16_t port;
};
-struct __attribute__ ((__packed__)) bt_ipv4p2 {
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_ipv4p2 {
struct bt_ipv4p d;
u_int8_t pad[2];
};
-struct __attribute__ ((__packed__)) bt_nodes6_data {
- u_int8_t id[20] ;
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_nodes6_data {
+ u_int8_t id[20];
u_int32_t ip[4];
u_int16_t port;
};
-struct __attribute__ ((__packed__)) bt_ipv6p {
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_ipv6p {
u_int32_t ip[4];
u_int16_t port;
};
-struct __attribute__ ((__packed__)) bt_ipv6p2 {
+struct
+#ifndef WIN32
+ __attribute__((__packed__))
+#endif
+ bt_ipv6p2 {
struct bt_ipv6p d;
u_int8_t pad[3];
};
+#ifdef WIN32
+// disable 1 byte packing
+#include <poppack.h>
+#endif
+
/*
a.id S r.id S
@@ -142,4 +179,3 @@ typedef struct bt_parse_data_cb {
extern int bt_parse_debug;
void dump_bt_proto_struct(struct bt_parse_protocol *p);
const u_int8_t *bt_decode(const u_int8_t *b, size_t *l, int *ret, bt_parse_data_cb_t *cbd);
-