summaryrefslogtreecommitdiff
path: root/trackerlogic.h
diff options
context:
space:
mode:
Diffstat (limited to 'trackerlogic.h')
-rw-r--r--trackerlogic.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/trackerlogic.h b/trackerlogic.h
index 81bd97a..1705928 100644
--- a/trackerlogic.h
+++ b/trackerlogic.h
@@ -11,6 +11,15 @@
11#include <time.h> 11#include <time.h>
12#include <stdint.h> 12#include <stdint.h>
13 13
14/* Libowfat */
15#include <uint16.h>
16#include <uint32.h>
17
18#define READ16(addr,offs) ((int16_t)uint16_read((offs)+(uint8_t*)(addr)))
19#define READ32(addr,offs) ((int32_t)uint32_read((offs)+(uint8_t*)(addr)))
20#define WRITE16(addr,offs,val) uint16_pack((offs)+(uint8_t*)(addr),(val))
21#define WRITE32(addr,offs,val) uint32_pack((offs)+(uint8_t*)(addr),(val))
22
14typedef uint8_t ot_hash[20]; 23typedef uint8_t ot_hash[20];
15typedef time_t ot_time; 24typedef time_t ot_time;
16 25
@@ -55,10 +64,10 @@ static const uint8_t PEER_FLAG_STOPPED = 0x20;
55static const uint8_t PEER_FLAG_FROM_SYNC = 0x10; 64static const uint8_t PEER_FLAG_FROM_SYNC = 0x10;
56static const uint8_t PEER_FLAG_LEECHING = 0x00; 65static const uint8_t PEER_FLAG_LEECHING = 0x00;
57 66
58#define OT_SETIP( peer, ip ) memmove((peer),(ip),4); 67#define OT_SETIP(peer,ip) WRITE32((peer),0,READ32((ip),0))
59#define OT_SETPORT( peer, port ) memmove(((uint8_t*)peer)+4,(port),2); 68#define OT_SETPORT(peer,port) WRITE16((peer),4,READ16((port),0))
60#define OT_FLAG(peer) (((uint8_t*)(peer))[6]) 69#define OT_PEERFLAG(peer) (((uint8_t*)(peer))[6])
61#define OT_PEERTIME(peer) (((uint8_t*)(peer))[7]) 70#define OT_PEERTIME(peer) (((uint8_t*)(peer))[7])
62 71
63#define OT_PEER_COMPARE_SIZE ((size_t)6) 72#define OT_PEER_COMPARE_SIZE ((size_t)6)
64#define OT_HASH_COMPARE_SIZE (sizeof(ot_hash)) 73#define OT_HASH_COMPARE_SIZE (sizeof(ot_hash))