From a0f08839bd134f3f964a6cccf1243cd42f15d4e5 Mon Sep 17 00:00:00 2001 From: "Coren[m]" Date: Sun, 20 Oct 2013 16:56:12 +0200 Subject: Main: Eliminate TOX_ENABLE_IPV6 (then always on), CLIENT_ONETOONE_IP (then always off). Additionally (besides cleanups): network.h/tox.h: - WIN32: fix a strange sa_family_t definition - WIN32: define EWOULDBLOCK to WSAEWOULDBLOCK - WIN32: kill macro for an existing function (IN6_ADDR_EQUAL) network.c: - use EWOULDBLOCK instead of EAGAIN (same value, but EWOULDBLOCK is more "popular") - new_networking(): only try to enable IPv4-in-IPv6 if it's not already enabled per default - inet_ntop()/inet_pton(): WIN32: remove partial initializers in favor of a simple memset() - ip_equal(): WIN32: use an existing function - logging: networking_wait_execute(): only dump result if not timeout - logging: loglogdata(): kill an unused variable LAN_discovery.c: - send_broadcasts(): re-enabled, can only support IPv4 by principle, split into fetch_broadcast_info() (to fetch the addresses once) and send_broadcasts() (actual sending) DHT.c: - DHT_load_state_callback(): enclosed a fprintf(stderr, ...) into #ifdef DEBUG Lossless_UDP.c: - change_handshake(): harden against strange sa_family_t definitions Messenger.c: - logging: fix ID to string conversion util.c: - logging: eliminate a signed-warning --- toxcore/Messenger.c | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) (limited to 'toxcore/Messenger.c') diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 44570742..6764dfe3 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c @@ -1700,7 +1700,7 @@ static char *ID2String(uint8_t *client_id) uint32_t i; for (i = 0; i < CLIENT_ID_SIZE; i++) - sprintf(&IDString[i], "%02X", client_id[i]); + sprintf(&IDString[i * 2], "%02X", client_id[i]); IDString[CLIENT_ID_SIZE * 2] = 0; return IDString; @@ -1730,24 +1730,20 @@ void doMessenger(Messenger *m) for (client = 0; client < LCLIENT_LIST; client++) { Client_data *cptr = &m->dht->close_clientlist[client]; IPPTsPng *assoc = NULL; -#ifdef CLIENT_ONETOONE_IP - assoc = &cptr->assoc; -#else uint32_t a; for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) -#endif - if (ip_isset(&assoc->ip_port.ip)) { - last_pinged = lastdump - assoc->last_pinged; + if (ip_isset(&assoc->ip_port.ip)) { + last_pinged = lastdump - assoc->last_pinged; - if (last_pinged > 999) - last_pinged = 999; + if (last_pinged > 999) + last_pinged = 999; - snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", - client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), - last_pinged, ID2String(cptr->client_id)); - loglog(logbuffer); - } + snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", + client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), + last_pinged, ID2String(cptr->client_id)); + loglog(logbuffer); + } } loglog(" = = = = = = = = \n"); @@ -1791,25 +1787,21 @@ void doMessenger(Messenger *m) for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { Client_data *cptr = &dhtfptr->client_list[client]; IPPTsPng *assoc = NULL; -#ifdef CLIENT_ONETOONE_IP - assoc = &cptr->assoc; -#else uint32_t a; for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) -#endif - if (ip_isset(&assoc->ip_port.ip)) { - last_pinged = lastdump - assoc->last_pinged; + if (ip_isset(&assoc->ip_port.ip)) { + last_pinged = lastdump - assoc->last_pinged; - if (last_pinged > 999) - last_pinged = 999; + if (last_pinged > 999) + last_pinged = 999; - snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", - friend, client, ip_ntoa(&assoc->ip_port.ip), - ntohs(assoc->ip_port.port), last_pinged, - ID2String(cptr->client_id)); - loglog(logbuffer); - } + snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", + friend, client, ip_ntoa(&assoc->ip_port.ip), + ntohs(assoc->ip_port.port), last_pinged, + ID2String(cptr->client_id)); + loglog(logbuffer); + } } } -- cgit v1.2.3