diff options
Diffstat (limited to 'core/Lossless_UDP.c')
-rw-r--r-- | core/Lossless_UDP.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c index 080dc821..9d31a53b 100644 --- a/core/Lossless_UDP.c +++ b/core/Lossless_UDP.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #define BUFFER_PACKET_NUM (16-1) | 37 | #define BUFFER_PACKET_NUM (16-1) |
38 | 38 | ||
39 | //Lossless UDP connection timeout. | 39 | //Lossless UDP connection timeout. |
40 | #define CONNEXION_TIMEOUT 10 | 40 | #define CONNEXION_TIMEOUT 5 |
41 | 41 | ||
42 | //initial amount of sync/hanshake packets to send per second. | 42 | //initial amount of sync/hanshake packets to send per second. |
43 | #define SYNC_RATE 10 | 43 | #define SYNC_RATE 10 |
@@ -133,7 +133,13 @@ uint32_t handshake_id(IP_Port source) | |||
133 | } | 133 | } |
134 | return id; | 134 | return id; |
135 | } | 135 | } |
136 | 136 | //change the hnshake id associated with that ip_port | |
137 | //TODO: make this better | ||
138 | void change_handshake(IP_Port source) | ||
139 | { | ||
140 | uint8_t rand = random_int() % 4; | ||
141 | randtable[rand][((uint8_t *)&source)[rand]] = random_int(); | ||
142 | } | ||
137 | 143 | ||
138 | 144 | ||
139 | //initialize a new connection to ip_port | 145 | //initialize a new connection to ip_port |
@@ -152,6 +158,7 @@ int new_connection(IP_Port ip_port) | |||
152 | { | 158 | { |
153 | if(connections[i].status == 0) | 159 | if(connections[i].status == 0) |
154 | { | 160 | { |
161 | memset(&connections[i], 0, sizeof(Connection)); | ||
155 | connections[i].ip_port = ip_port; | 162 | connections[i].ip_port = ip_port; |
156 | connections[i].status = 1; | 163 | connections[i].status = 1; |
157 | connections[i].inbound = 0; | 164 | connections[i].inbound = 0; |
@@ -184,6 +191,7 @@ int new_inconnection(IP_Port ip_port) | |||
184 | { | 191 | { |
185 | if(connections[i].status == 0) | 192 | if(connections[i].status == 0) |
186 | { | 193 | { |
194 | memset(&connections[i], 0, sizeof(Connection)); | ||
187 | connections[i].ip_port = ip_port; | 195 | connections[i].ip_port = ip_port; |
188 | connections[i].status = 2; | 196 | connections[i].status = 2; |
189 | connections[i].inbound = 2; | 197 | connections[i].inbound = 2; |
@@ -223,6 +231,7 @@ int kill_connection(int connection_id) | |||
223 | if(connections[connection_id].status > 0) | 231 | if(connections[connection_id].status > 0) |
224 | { | 232 | { |
225 | connections[connection_id].status = 0; | 233 | connections[connection_id].status = 0; |
234 | change_handshake(connections[connection_id].ip_port); | ||
226 | return 0; | 235 | return 0; |
227 | } | 236 | } |
228 | } | 237 | } |