diff options
author | irungentoo <irungentoo@gmail.com> | 2013-08-20 19:37:05 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-08-20 19:37:05 -0400 |
commit | 128223d9d1c70afe0adb4cfe0cfda39204379c3a (patch) | |
tree | d8191c6a088bcaf8c908fbb5e81a22825712330f /core/DHT.h | |
parent | c7aafcfb4cff44a60fa54fa55cd9e3519b30e720 (diff) |
astyle --options=tools/astylerc -r ./*.{c,h}
Diffstat (limited to 'core/DHT.h')
-rw-r--r-- | core/DHT.h | 36 |
1 files changed, 18 insertions, 18 deletions
@@ -100,23 +100,23 @@ typedef struct { | |||
100 | Node_format toping[MAX_TOPING]; | 100 | Node_format toping[MAX_TOPING]; |
101 | uint64_t last_toping; | 101 | uint64_t last_toping; |
102 | uint64_t close_lastgetnodes; | 102 | uint64_t close_lastgetnodes; |
103 | void * ping; | 103 | void *ping; |
104 | } DHT; | 104 | } DHT; |
105 | /*----------------------------------------------------------------------------------*/ | 105 | /*----------------------------------------------------------------------------------*/ |
106 | 106 | ||
107 | Client_data *DHT_get_close_list(DHT * dht); | 107 | Client_data *DHT_get_close_list(DHT *dht); |
108 | 108 | ||
109 | /* Add a new friend to the friends list | 109 | /* Add a new friend to the friends list |
110 | client_id must be CLIENT_ID_SIZE bytes long. | 110 | client_id must be CLIENT_ID_SIZE bytes long. |
111 | returns 0 if success | 111 | returns 0 if success |
112 | returns 1 if failure (friends list is full) */ | 112 | returns 1 if failure (friends list is full) */ |
113 | int DHT_addfriend(DHT * dht, uint8_t *client_id); | 113 | int DHT_addfriend(DHT *dht, uint8_t *client_id); |
114 | 114 | ||
115 | /* Delete a friend from the friends list | 115 | /* Delete a friend from the friends list |
116 | client_id must be CLIENT_ID_SIZE bytes long. | 116 | client_id must be CLIENT_ID_SIZE bytes long. |
117 | returns 0 if success | 117 | returns 0 if success |
118 | returns 1 if failure (client_id not in friends list) */ | 118 | returns 1 if failure (client_id not in friends list) */ |
119 | int DHT_delfriend(DHT * dht, uint8_t *client_id); | 119 | int DHT_delfriend(DHT *dht, uint8_t *client_id); |
120 | 120 | ||
121 | /* Get ip of friend | 121 | /* Get ip of friend |
122 | client_id must be CLIENT_ID_SIZE bytes long. | 122 | client_id must be CLIENT_ID_SIZE bytes long. |
@@ -125,14 +125,14 @@ int DHT_delfriend(DHT * dht, uint8_t *client_id); | |||
125 | returns ip if success | 125 | returns ip if success |
126 | returns ip of 0 if failure (This means the friend is either offline or we have not found him yet.) | 126 | returns ip of 0 if failure (This means the friend is either offline or we have not found him yet.) |
127 | returns ip of 1 if friend is not in list. */ | 127 | returns ip of 1 if friend is not in list. */ |
128 | IP_Port DHT_getfriendip(DHT * dht, uint8_t *client_id); | 128 | IP_Port DHT_getfriendip(DHT *dht, uint8_t *client_id); |
129 | 129 | ||
130 | /* Run this function at least a couple times per second (It's the main loop) */ | 130 | /* Run this function at least a couple times per second (It's the main loop) */ |
131 | void do_DHT(DHT * dht); | 131 | void do_DHT(DHT *dht); |
132 | 132 | ||
133 | /* Use this function to bootstrap the client | 133 | /* Use this function to bootstrap the client |
134 | Sends a get nodes request to the given node with ip port and public_key */ | 134 | Sends a get nodes request to the given node with ip port and public_key */ |
135 | void DHT_bootstrap(DHT * dht, IP_Port ip_port, uint8_t *public_key); | 135 | void DHT_bootstrap(DHT *dht, IP_Port ip_port, uint8_t *public_key); |
136 | 136 | ||
137 | /* Add nodes to the toping list | 137 | /* Add nodes to the toping list |
138 | all nodes in this list are pinged every TIME_TOPING seconds | 138 | all nodes in this list are pinged every TIME_TOPING seconds |
@@ -142,17 +142,17 @@ void DHT_bootstrap(DHT * dht, IP_Port ip_port, uint8_t *public_key); | |||
142 | network while preventing amplification attacks. | 142 | network while preventing amplification attacks. |
143 | return 0 if node was added | 143 | return 0 if node was added |
144 | return -1 if node was not added */ | 144 | return -1 if node was not added */ |
145 | int add_toping(DHT * dht, uint8_t *client_id, IP_Port ip_port); | 145 | int add_toping(DHT *dht, uint8_t *client_id, IP_Port ip_port); |
146 | 146 | ||
147 | /* ROUTING FUNCTIONS */ | 147 | /* ROUTING FUNCTIONS */ |
148 | 148 | ||
149 | /* send the given packet to node with client_id | 149 | /* send the given packet to node with client_id |
150 | returns -1 if failure */ | 150 | returns -1 if failure */ |
151 | int route_packet(DHT * dht, uint8_t *client_id, uint8_t *packet, uint32_t length); | 151 | int route_packet(DHT *dht, uint8_t *client_id, uint8_t *packet, uint32_t length); |
152 | 152 | ||
153 | /* Send the following packet to everyone who tells us they are connected to friend_id | 153 | /* Send the following packet to everyone who tells us they are connected to friend_id |
154 | returns the number of nodes it sent the packet to */ | 154 | returns the number of nodes it sent the packet to */ |
155 | int route_tofriend(DHT * dht, uint8_t *friend_id, uint8_t *packet, uint32_t length); | 155 | int route_tofriend(DHT *dht, uint8_t *friend_id, uint8_t *packet, uint32_t length); |
156 | 156 | ||
157 | /* NAT PUNCHING FUNCTIONS */ | 157 | /* NAT PUNCHING FUNCTIONS */ |
158 | 158 | ||
@@ -160,31 +160,31 @@ int route_tofriend(DHT * dht, uint8_t *friend_id, uint8_t *packet, uint32_t leng | |||
160 | ip_portlist must be at least MAX_FRIEND_CLIENTS big | 160 | ip_portlist must be at least MAX_FRIEND_CLIENTS big |
161 | returns the number of ips returned | 161 | returns the number of ips returned |
162 | returns -1 if no such friend*/ | 162 | returns -1 if no such friend*/ |
163 | int friend_ips(DHT * dht, IP_Port *ip_portlist, uint8_t *friend_id); | 163 | int friend_ips(DHT *dht, IP_Port *ip_portlist, uint8_t *friend_id); |
164 | 164 | ||
165 | /* SAVE/LOAD functions */ | 165 | /* SAVE/LOAD functions */ |
166 | 166 | ||
167 | /* get the size of the DHT (for saving) */ | 167 | /* get the size of the DHT (for saving) */ |
168 | uint32_t DHT_size(DHT * dht); | 168 | uint32_t DHT_size(DHT *dht); |
169 | 169 | ||
170 | /* save the DHT in data where data is an array of size DHT_size() */ | 170 | /* save the DHT in data where data is an array of size DHT_size() */ |
171 | void DHT_save(DHT * dht, uint8_t *data); | 171 | void DHT_save(DHT *dht, uint8_t *data); |
172 | 172 | ||
173 | /* init DHT */ | 173 | /* init DHT */ |
174 | DHT * new_DHT(Net_Crypto *c); | 174 | DHT *new_DHT(Net_Crypto *c); |
175 | 175 | ||
176 | void kill_DHT(DHT * dht); | 176 | void kill_DHT(DHT *dht); |
177 | 177 | ||
178 | /* load the DHT from data of size size; | 178 | /* load the DHT from data of size size; |
179 | return -1 if failure | 179 | return -1 if failure |
180 | return 0 if success */ | 180 | return 0 if success */ |
181 | int DHT_load(DHT * dht, uint8_t *data, uint32_t size); | 181 | int DHT_load(DHT *dht, uint8_t *data, uint32_t size); |
182 | 182 | ||
183 | /* returns 0 if we are not connected to the DHT | 183 | /* returns 0 if we are not connected to the DHT |
184 | returns 1 if we are */ | 184 | returns 1 if we are */ |
185 | int DHT_isconnected(DHT * dht); | 185 | int DHT_isconnected(DHT *dht); |
186 | 186 | ||
187 | void addto_lists(DHT * dht, IP_Port ip_port, uint8_t *client_id); | 187 | void addto_lists(DHT *dht, IP_Port ip_port, uint8_t *client_id); |
188 | 188 | ||
189 | #ifdef __cplusplus | 189 | #ifdef __cplusplus |
190 | } | 190 | } |