#4260 "µTP not working on embedded device" -- apply the changes from https://github.com/ghazel/libutp rather than http://github.com/bittorrent/libutp
This commit is contained in:
parent
028cfcca5a
commit
5df3c77cf2
|
@ -19,6 +19,14 @@
|
||||||
#endif
|
#endif
|
||||||
#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
|
// Utility templates
|
||||||
#undef min
|
#undef min
|
||||||
#undef max
|
#undef max
|
||||||
|
@ -48,7 +56,7 @@ namespace aux
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct big_endian
|
struct PACKED_ATTRIBUTE big_endian
|
||||||
{
|
{
|
||||||
T operator=(T i) { m_integer = aux::host_to_network(i); return i; }
|
T operator=(T i) { m_integer = aux::host_to_network(i); return i; }
|
||||||
operator T() const { return aux::network_to_host(m_integer); }
|
operator T() const { return aux::network_to_host(m_integer); }
|
||||||
|
|
|
@ -94,7 +94,7 @@ char addrbuf2[65];
|
||||||
|
|
||||||
#pragma pack(push,1)
|
#pragma pack(push,1)
|
||||||
|
|
||||||
struct PackedSockAddr {
|
struct PACKED_ATTRIBUTE PackedSockAddr {
|
||||||
|
|
||||||
// The values are always stored here in network byte order
|
// The values are always stored here in network byte order
|
||||||
union {
|
union {
|
||||||
|
@ -192,7 +192,7 @@ struct PackedSockAddr {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RST_Info {
|
struct PACKED_ATTRIBUTE RST_Info {
|
||||||
PackedSockAddr addr;
|
PackedSockAddr addr;
|
||||||
uint32 connid;
|
uint32 connid;
|
||||||
uint32 timestamp;
|
uint32 timestamp;
|
||||||
|
@ -211,7 +211,7 @@ struct RST_Info {
|
||||||
#define PACKET_SIZE_BIG 1400
|
#define PACKET_SIZE_BIG 1400
|
||||||
#define PACKET_SIZE_HUGE_BUCKET 4
|
#define PACKET_SIZE_HUGE_BUCKET 4
|
||||||
|
|
||||||
struct PacketFormat {
|
struct PACKED_ATTRIBUTE PacketFormat {
|
||||||
// connection ID
|
// connection ID
|
||||||
uint32_big connid;
|
uint32_big connid;
|
||||||
uint32_big tv_sec;
|
uint32_big tv_sec;
|
||||||
|
@ -229,21 +229,21 @@ struct PacketFormat {
|
||||||
uint16_big ack_nr;
|
uint16_big ack_nr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketFormatAck {
|
struct PACKED_ATTRIBUTE PacketFormatAck {
|
||||||
PacketFormat pf;
|
PacketFormat pf;
|
||||||
byte ext_next;
|
byte ext_next;
|
||||||
byte ext_len;
|
byte ext_len;
|
||||||
byte acks[4];
|
byte acks[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketFormatExtensions {
|
struct PACKED_ATTRIBUTE PacketFormatExtensions {
|
||||||
PacketFormat pf;
|
PacketFormat pf;
|
||||||
byte ext_next;
|
byte ext_next;
|
||||||
byte ext_len;
|
byte ext_len;
|
||||||
byte extensions[8];
|
byte extensions[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketFormatV1 {
|
struct PACKED_ATTRIBUTE PacketFormatV1 {
|
||||||
// packet_type (4 high bits)
|
// packet_type (4 high bits)
|
||||||
// protocol version (4 low bits)
|
// protocol version (4 low bits)
|
||||||
byte ver_type;
|
byte ver_type;
|
||||||
|
@ -266,14 +266,14 @@ struct PacketFormatV1 {
|
||||||
uint16_big ack_nr;
|
uint16_big ack_nr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketFormatAckV1 {
|
struct PACKED_ATTRIBUTE PacketFormatAckV1 {
|
||||||
PacketFormatV1 pf;
|
PacketFormatV1 pf;
|
||||||
byte ext_next;
|
byte ext_next;
|
||||||
byte ext_len;
|
byte ext_len;
|
||||||
byte acks[4];
|
byte acks[4];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PacketFormatExtensionsV1 {
|
struct PACKED_ATTRIBUTE PacketFormatExtensionsV1 {
|
||||||
PacketFormatV1 pf;
|
PacketFormatV1 pf;
|
||||||
byte ext_next;
|
byte ext_next;
|
||||||
byte ext_len;
|
byte ext_len;
|
||||||
|
|
|
@ -36,7 +36,7 @@ typedef const char * cstr;
|
||||||
typedef char * str;
|
typedef char * str;
|
||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#include <stdbool.h>
|
typedef uint8 bool;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //__UTYPES_H__
|
#endif //__UTYPES_H__
|
||||||
|
|
Loading…
Reference in New Issue