summaryrefslogtreecommitdiff
path: root/core/DHT.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/DHT.h')
-rw-r--r--core/DHT.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/core/DHT.h b/core/DHT.h
index d89d0f76..c346608d 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -18,6 +18,10 @@
18 18
19#endif 19#endif
20 20
21//Current time, unix format
22#define unix_time() ((uint32_t)time(NULL))
23
24#define CLIENT_ID_SIZE 32
21 25
22typedef union 26typedef union
23{ 27{
@@ -36,7 +40,7 @@ typedef struct
36 40
37typedef struct 41typedef struct
38{ 42{
39 char client_id[32]; 43 char client_id[CLIENT_ID_SIZE];
40 IP_Port ip_port; 44 IP_Port ip_port;
41 uint32_t timestamp; 45 uint32_t timestamp;
42 46
@@ -45,7 +49,7 @@ typedef struct
45 49
46typedef struct 50typedef struct
47{ 51{
48 char client_id[32]; 52 char client_id[CLIENT_ID_SIZE];
49 Client_data client_list[8]; 53 Client_data client_list[8];
50 54
51}Friend; 55}Friend;
@@ -73,18 +77,18 @@ typedef struct
73 77
74 78
75//Add a new friend to the friends list 79//Add a new friend to the friends list
76//client_id must be 32 bytes long. 80//client_id must be CLIENT_ID_SIZE bytes long.
77void addfriend(char * client_id); 81void addfriend(char * client_id);
78 82
79//Delete a friend from the friends list 83//Delete a friend from the friends list
80//client_id must be 32 bytes long. 84//client_id must be CLIENT_ID_SIZE bytes long.
81//returns 0 if success 85//returns 0 if success
82//returns 1 if failure (client_id not in friends list) 86//returns 1 if failure (client_id not in friends list)
83char delfriend(char * client_id); 87char delfriend(char * client_id);
84 88
85 89
86//Get ip of friend 90//Get ip of friend
87//client_id must be 32 bytes long. 91//client_id must be CLIENT_ID_SIZE bytes long.
88//ip must be 4 bytes long. 92//ip must be 4 bytes long.
89//port must be 2 bytes long. 93//port must be 2 bytes long.
90//returns ip if success 94//returns ip if success
@@ -110,7 +114,7 @@ void bootstrap(IP_Port ip_port);
110//Global variables 114//Global variables
111 115
112//Our client id 116//Our client id
113char self_client_id[32]; 117char self_client_id[CLIENT_ID_SIZE];
114 118
115//Our UDP socket. 119//Our UDP socket.
116//We only use one so it's much easier to have it as a global variable 120//We only use one so it's much easier to have it as a global variable