#endif
#endif
+#ifdef __GNUC__
+// Used for gcc tool chains accepting but not supporting pragma pack
+// See http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html
+#define PACKED_ATTRIBUTE __attribute__((__packed__))
+#else
+#define PACKED_ATTRIBUTE
+#endif
+
// Utility templates
#undef min
#undef max
}
template <class T>
-struct big_endian
+struct PACKED_ATTRIBUTE big_endian
{
T operator=(T i) { m_integer = aux::host_to_network(i); return i; }
operator T() const { return aux::network_to_host(m_integer); }
#pragma pack(push,1)
-struct PackedSockAddr {
+struct PACKED_ATTRIBUTE PackedSockAddr {
// The values are always stored here in network byte order
union {
}
};
-struct RST_Info {
+struct PACKED_ATTRIBUTE RST_Info {
PackedSockAddr addr;
uint32 connid;
uint32 timestamp;
#define PACKET_SIZE_BIG 1400
#define PACKET_SIZE_HUGE_BUCKET 4
-struct PacketFormat {
+struct PACKED_ATTRIBUTE PacketFormat {
// connection ID
uint32_big connid;
uint32_big tv_sec;
uint16_big ack_nr;
};
-struct PacketFormatAck {
+struct PACKED_ATTRIBUTE PacketFormatAck {
PacketFormat pf;
byte ext_next;
byte ext_len;
byte acks[4];
};
-struct PacketFormatExtensions {
+struct PACKED_ATTRIBUTE PacketFormatExtensions {
PacketFormat pf;
byte ext_next;
byte ext_len;
byte extensions[8];
};
-struct PacketFormatV1 {
+struct PACKED_ATTRIBUTE PacketFormatV1 {
// packet_type (4 high bits)
// protocol version (4 low bits)
byte ver_type;
uint16_big ack_nr;
};
-struct PacketFormatAckV1 {
+struct PACKED_ATTRIBUTE PacketFormatAckV1 {
PacketFormatV1 pf;
byte ext_next;
byte ext_len;
byte acks[4];
};
-struct PacketFormatExtensionsV1 {
+struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 {
PacketFormatV1 pf;
byte ext_next;
byte ext_len;