diff options
author | Coren[m] <Break@Ocean> | 2013-09-27 03:27:52 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-09-27 03:27:52 +0200 |
commit | 9de295374decd78fd676574bd38243479dfd6054 (patch) | |
tree | a614006e1919e1c16f67fe0c90b16114d0b47aab /toxcore/Messenger.c | |
parent | beff2b6de659a708ed366a9ae925eab8c4ca0ddd (diff) |
expanded Client_data to hold two addresses (IPv4, IPv6) instead of one
Compilerflag: CLIENT_ONETOONE_IP (to define in DHT.h, default unset i.e. NEW case: two addresses)
Every function in DHT{_test}.c working on Client_data has been rewritten to store IPv4 addresses in assoc4, IPv6 addresses in assoc6.
Loading/Storing of states defined with other compiler switch is transparently adjusting to the differences.
DHT.h, DHT.c:
- introduction and handling of the structure changes
DHT_test.c, Messenger.c:
- logging adapted to new structures
util.h:
- LOGGING isn't undefined per default anymore
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index f22a8d57..8ad15bc1 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1296,18 +1296,23 @@ void doMessenger(Messenger *m) | |||
1296 | 1296 | ||
1297 | for (client = 0; client < LCLIENT_LIST; client++) { | 1297 | for (client = 0; client < LCLIENT_LIST; client++) { |
1298 | Client_data *cptr = &m->dht->close_clientlist[client]; | 1298 | Client_data *cptr = &m->dht->close_clientlist[client]; |
1299 | IPPTsPng *assoc = NULL; | ||
1300 | #ifdef CLIENT_ONETOONE_IP | ||
1301 | assoc = &cptr->assoc; | ||
1302 | #else | ||
1303 | for (assoc = &cptr->assoc4; assoc != &cptr->assoc6; assoc = &cptr->assoc6) | ||
1304 | #endif | ||
1305 | if (ip_isset(&assoc->ip_port.ip)) { | ||
1306 | last_pinged = lastdump - assoc->last_pinged; | ||
1299 | 1307 | ||
1300 | if (ip_isset(&cptr->ip_port.ip)) { | 1308 | if (last_pinged > 999) |
1301 | last_pinged = lastdump - cptr->last_pinged; | 1309 | last_pinged = 999; |
1302 | |||
1303 | if (last_pinged > 999) | ||
1304 | last_pinged = 999; | ||
1305 | 1310 | ||
1306 | snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", | 1311 | snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", |
1307 | client, ip_ntoa(&cptr->ip_port.ip), ntohs(cptr->ip_port.port), | 1312 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), |
1308 | last_pinged, ID2String(cptr->client_id)); | 1313 | last_pinged, ID2String(cptr->client_id)); |
1309 | loglog(logbuffer); | 1314 | loglog(logbuffer); |
1310 | } | 1315 | } |
1311 | } | 1316 | } |
1312 | 1317 | ||
1313 | loglog(" = = = = = = = = \n"); | 1318 | loglog(" = = = = = = = = \n"); |
@@ -1350,16 +1355,24 @@ void doMessenger(Messenger *m) | |||
1350 | 1355 | ||
1351 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { | 1356 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { |
1352 | Client_data *cptr = &dhtfptr->client_list[client]; | 1357 | Client_data *cptr = &dhtfptr->client_list[client]; |
1353 | last_pinged = lastdump - cptr->last_pinged; | 1358 | IPPTsPng *assoc = NULL; |
1359 | #ifdef CLIENT_ONETOONE_IP | ||
1360 | assoc = &cptr->assoc; | ||
1361 | #else | ||
1362 | for (assoc = &cptr->assoc4; assoc != &cptr->assoc6; assoc = &cptr->assoc6) | ||
1363 | #endif | ||
1364 | if (ip_isset(&assoc->ip_port.ip)) { | ||
1365 | last_pinged = lastdump - assoc->last_pinged; | ||
1354 | 1366 | ||
1355 | if (last_pinged > 999) | 1367 | if (last_pinged > 999) |
1356 | last_pinged = 999; | 1368 | last_pinged = 999; |
1357 | 1369 | ||
1358 | snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", | 1370 | snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", |
1359 | friend, client, ip_ntoa(&cptr->ip_port.ip), | 1371 | friend, client, ip_ntoa(&assoc->ip_port.ip), |
1360 | ntohs(cptr->ip_port.port), last_pinged, | 1372 | ntohs(assoc->ip_port.port), last_pinged, |
1361 | ID2String(cptr->client_id)); | 1373 | ID2String(cptr->client_id)); |
1362 | loglog(logbuffer); | 1374 | loglog(logbuffer); |
1375 | } | ||
1363 | } | 1376 | } |
1364 | } | 1377 | } |
1365 | 1378 | ||