diff options
author | Coren[m] <Break@Ocean> | 2013-10-20 16:56:12 +0200 |
---|---|---|
committer | Coren[m] <Break@Ocean> | 2013-10-20 16:56:12 +0200 |
commit | a0f08839bd134f3f964a6cccf1243cd42f15d4e5 (patch) | |
tree | a313feee4c0d2a251cb460b9afe3766ca2422d5f /toxcore/Messenger.c | |
parent | 8abad7bc822a548d4f6e73203e8d4f640c1217ae (diff) |
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
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 48 |
1 files changed, 20 insertions, 28 deletions
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) | |||
1700 | uint32_t i; | 1700 | uint32_t i; |
1701 | 1701 | ||
1702 | for (i = 0; i < CLIENT_ID_SIZE; i++) | 1702 | for (i = 0; i < CLIENT_ID_SIZE; i++) |
1703 | sprintf(&IDString[i], "%02X", client_id[i]); | 1703 | sprintf(&IDString[i * 2], "%02X", client_id[i]); |
1704 | 1704 | ||
1705 | IDString[CLIENT_ID_SIZE * 2] = 0; | 1705 | IDString[CLIENT_ID_SIZE * 2] = 0; |
1706 | return IDString; | 1706 | return IDString; |
@@ -1730,24 +1730,20 @@ void doMessenger(Messenger *m) | |||
1730 | for (client = 0; client < LCLIENT_LIST; client++) { | 1730 | for (client = 0; client < LCLIENT_LIST; client++) { |
1731 | Client_data *cptr = &m->dht->close_clientlist[client]; | 1731 | Client_data *cptr = &m->dht->close_clientlist[client]; |
1732 | IPPTsPng *assoc = NULL; | 1732 | IPPTsPng *assoc = NULL; |
1733 | #ifdef CLIENT_ONETOONE_IP | ||
1734 | assoc = &cptr->assoc; | ||
1735 | #else | ||
1736 | uint32_t a; | 1733 | uint32_t a; |
1737 | 1734 | ||
1738 | for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) | 1735 | for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) |
1739 | #endif | 1736 | if (ip_isset(&assoc->ip_port.ip)) { |
1740 | if (ip_isset(&assoc->ip_port.ip)) { | 1737 | last_pinged = lastdump - assoc->last_pinged; |
1741 | last_pinged = lastdump - assoc->last_pinged; | ||
1742 | 1738 | ||
1743 | if (last_pinged > 999) | 1739 | if (last_pinged > 999) |
1744 | last_pinged = 999; | 1740 | last_pinged = 999; |
1745 | 1741 | ||
1746 | snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", | 1742 | snprintf(logbuffer, sizeof(logbuffer), "C[%2u] %s:%u [%3u] %s\n", |
1747 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), | 1743 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), |
1748 | last_pinged, ID2String(cptr->client_id)); | 1744 | last_pinged, ID2String(cptr->client_id)); |
1749 | loglog(logbuffer); | 1745 | loglog(logbuffer); |
1750 | } | 1746 | } |
1751 | } | 1747 | } |
1752 | 1748 | ||
1753 | loglog(" = = = = = = = = \n"); | 1749 | loglog(" = = = = = = = = \n"); |
@@ -1791,25 +1787,21 @@ void doMessenger(Messenger *m) | |||
1791 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { | 1787 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { |
1792 | Client_data *cptr = &dhtfptr->client_list[client]; | 1788 | Client_data *cptr = &dhtfptr->client_list[client]; |
1793 | IPPTsPng *assoc = NULL; | 1789 | IPPTsPng *assoc = NULL; |
1794 | #ifdef CLIENT_ONETOONE_IP | ||
1795 | assoc = &cptr->assoc; | ||
1796 | #else | ||
1797 | uint32_t a; | 1790 | uint32_t a; |
1798 | 1791 | ||
1799 | for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) | 1792 | for (a = 0, assoc = &cptr->assoc4; a < 2; a++, assoc = &cptr->assoc6) |
1800 | #endif | 1793 | if (ip_isset(&assoc->ip_port.ip)) { |
1801 | if (ip_isset(&assoc->ip_port.ip)) { | 1794 | last_pinged = lastdump - assoc->last_pinged; |
1802 | last_pinged = lastdump - assoc->last_pinged; | ||
1803 | 1795 | ||
1804 | if (last_pinged > 999) | 1796 | if (last_pinged > 999) |
1805 | last_pinged = 999; | 1797 | last_pinged = 999; |
1806 | 1798 | ||
1807 | snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", | 1799 | snprintf(logbuffer, sizeof(logbuffer), "F[%2u] => C[%2u] %s:%u [%3u] %s\n", |
1808 | friend, client, ip_ntoa(&assoc->ip_port.ip), | 1800 | friend, client, ip_ntoa(&assoc->ip_port.ip), |
1809 | ntohs(assoc->ip_port.port), last_pinged, | 1801 | ntohs(assoc->ip_port.port), last_pinged, |
1810 | ID2String(cptr->client_id)); | 1802 | ID2String(cptr->client_id)); |
1811 | loglog(logbuffer); | 1803 | loglog(logbuffer); |
1812 | } | 1804 | } |
1813 | } | 1805 | } |
1814 | } | 1806 | } |
1815 | 1807 | ||