diff options
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r-- | toxcore/Messenger.c | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index e0ef5a28..bec3a250 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -1700,7 +1700,7 @@ int m_msi_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t len | |||
1700 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); | 1700 | return write_cryptpacket_id(m, friendnumber, PACKET_ID_MSI, data, length); |
1701 | } | 1701 | } |
1702 | 1702 | ||
1703 | static int handle_custom_user_packet(void *object, int friend_num, uint8_t *packet, uint16_t length) | 1703 | static int handle_custom_lossy_packet(void *object, int friend_num, uint8_t *packet, uint16_t length) |
1704 | { | 1704 | { |
1705 | Messenger *m = object; | 1705 | Messenger *m = object; |
1706 | 1706 | ||
@@ -1715,8 +1715,8 @@ static int handle_custom_user_packet(void *object, int friend_num, uint8_t *pack | |||
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | 1717 | ||
1718 | int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, | 1718 | int custom_lossy_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8_t byte, |
1719 | int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object) | 1719 | int (*packet_handler_callback)(void *object, uint8_t *data, uint32_t len), void *object) |
1720 | { | 1720 | { |
1721 | if (friend_not_valid(m, friendnumber)) | 1721 | if (friend_not_valid(m, friendnumber)) |
1722 | return -1; | 1722 | return -1; |
@@ -1732,7 +1732,7 @@ int custom_user_packet_registerhandler(Messenger *m, int32_t friendnumber, uint8 | |||
1732 | return 0; | 1732 | return 0; |
1733 | } | 1733 | } |
1734 | 1734 | ||
1735 | int send_custom_user_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length) | 1735 | int send_custom_lossy_packet(Messenger *m, int32_t friendnumber, uint8_t *data, uint32_t length) |
1736 | { | 1736 | { |
1737 | if (friend_not_valid(m, friendnumber)) | 1737 | if (friend_not_valid(m, friendnumber)) |
1738 | return -1; | 1738 | return -1; |
@@ -1782,7 +1782,7 @@ static int handle_new_connections(void *object, New_Connection *n_c) | |||
1782 | int id = accept_crypto_connection(m->net_crypto, n_c); | 1782 | int id = accept_crypto_connection(m->net_crypto, n_c); |
1783 | connection_status_handler(m->net_crypto, id, &handle_status, m, friend_id); | 1783 | connection_status_handler(m->net_crypto, id, &handle_status, m, friend_id); |
1784 | connection_data_handler(m->net_crypto, id, &handle_packet, m, friend_id); | 1784 | connection_data_handler(m->net_crypto, id, &handle_packet, m, friend_id); |
1785 | connection_lossy_data_handler(m->net_crypto, id, &handle_custom_user_packet, m, friend_id); | 1785 | connection_lossy_data_handler(m->net_crypto, id, &handle_custom_lossy_packet, m, friend_id); |
1786 | m->friendlist[friend_id].crypt_connection_id = id; | 1786 | m->friendlist[friend_id].crypt_connection_id = id; |
1787 | set_friend_status(m, friend_id, FRIEND_CONFIRMED); | 1787 | set_friend_status(m, friend_id, FRIEND_CONFIRMED); |
1788 | return 0; | 1788 | return 0; |
@@ -2208,7 +2208,7 @@ static int friend_new_connection(Messenger *m, int32_t friendnumber, uint8_t *re | |||
2208 | m->friendlist[friendnumber].crypt_connection_id = id; | 2208 | m->friendlist[friendnumber].crypt_connection_id = id; |
2209 | connection_status_handler(m->net_crypto, id, &handle_status, m, friendnumber); | 2209 | connection_status_handler(m->net_crypto, id, &handle_status, m, friendnumber); |
2210 | connection_data_handler(m->net_crypto, id, &handle_packet, m, friendnumber); | 2210 | connection_data_handler(m->net_crypto, id, &handle_packet, m, friendnumber); |
2211 | connection_lossy_data_handler(m->net_crypto, id, &handle_custom_user_packet, m, friendnumber); | 2211 | connection_lossy_data_handler(m->net_crypto, id, &handle_custom_lossy_packet, m, friendnumber); |
2212 | return 0; | 2212 | return 0; |
2213 | } | 2213 | } |
2214 | 2214 | ||
@@ -2229,7 +2229,7 @@ void do_friends(Messenger *m) | |||
2229 | m->friendlist[i].friendrequest_lastsent = temp_time; | 2229 | m->friendlist[i].friendrequest_lastsent = temp_time; |
2230 | } | 2230 | } |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | if (m->friendlist[i].status == FRIEND_REQUESTED | 2233 | if (m->friendlist[i].status == FRIEND_REQUESTED |
2234 | || m->friendlist[i].status == FRIEND_CONFIRMED) { /* friend is not online. */ | 2234 | || m->friendlist[i].status == FRIEND_CONFIRMED) { /* friend is not online. */ |
2235 | if (m->friendlist[i].status == FRIEND_REQUESTED) { | 2235 | if (m->friendlist[i].status == FRIEND_REQUESTED) { |
@@ -2341,7 +2341,7 @@ void do_messenger(Messenger *m) | |||
2341 | #ifdef LOGGING | 2341 | #ifdef LOGGING |
2342 | 2342 | ||
2343 | if (unix_time() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { | 2343 | if (unix_time() > lastdump + DUMPING_CLIENTS_FRIENDS_EVERY_N_SECONDS) { |
2344 | 2344 | ||
2345 | #ifdef ENABLE_ASSOC_DHT | 2345 | #ifdef ENABLE_ASSOC_DHT |
2346 | Assoc_status(m->dht->assoc); | 2346 | Assoc_status(m->dht->assoc); |
2347 | #endif | 2347 | #endif |
@@ -2371,11 +2371,11 @@ void do_messenger(Messenger *m) | |||
2371 | last_pinged = 999; | 2371 | last_pinged = 999; |
2372 | 2372 | ||
2373 | LOGGER_INFO("C[%2u] %s:%u [%3u] %s", | 2373 | LOGGER_INFO("C[%2u] %s:%u [%3u] %s", |
2374 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), | 2374 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), |
2375 | last_pinged, ID2String(cptr->client_id)); | 2375 | last_pinged, ID2String(cptr->client_id)); |
2376 | } | 2376 | } |
2377 | } | 2377 | } |
2378 | 2378 | ||
2379 | 2379 | ||
2380 | uint32_t friend, dhtfriend; | 2380 | uint32_t friend, dhtfriend; |
2381 | 2381 | ||
@@ -2425,8 +2425,8 @@ void do_messenger(Messenger *m) | |||
2425 | ping_lastrecv = 999; | 2425 | ping_lastrecv = 999; |
2426 | 2426 | ||
2427 | LOGGER_INFO("F[%2u:%2u] <%s> %02i [%03u] %s", | 2427 | LOGGER_INFO("F[%2u:%2u] <%s> %02i [%03u] %s", |
2428 | dht2m[friend], friend, msgfptr->name, msgfptr->crypt_connection_id, | 2428 | dht2m[friend], friend, msgfptr->name, msgfptr->crypt_connection_id, |
2429 | ping_lastrecv, ID2String(msgfptr->client_id)); | 2429 | ping_lastrecv, ID2String(msgfptr->client_id)); |
2430 | } else { | 2430 | } else { |
2431 | LOGGER_INFO("F[--:%2u] %s", friend, ID2String(dhtfptr->client_id)); | 2431 | LOGGER_INFO("F[--:%2u] %s", friend, ID2String(dhtfptr->client_id)); |
2432 | } | 2432 | } |
@@ -2442,15 +2442,16 @@ void do_messenger(Messenger *m) | |||
2442 | 2442 | ||
2443 | if (last_pinged > 999) | 2443 | if (last_pinged > 999) |
2444 | last_pinged = 999; | 2444 | last_pinged = 999; |
2445 | 2445 | ||
2446 | LOGGER_INFO("F[%2u] => C[%2u] %s:%u [%3u] %s", | 2446 | LOGGER_INFO("F[%2u] => C[%2u] %s:%u [%3u] %s", |
2447 | friend, client, ip_ntoa(&assoc->ip_port.ip), | 2447 | friend, client, ip_ntoa(&assoc->ip_port.ip), |
2448 | ntohs(assoc->ip_port.port), last_pinged, | 2448 | ntohs(assoc->ip_port.port), last_pinged, |
2449 | ID2String(cptr->client_id)); | 2449 | ID2String(cptr->client_id)); |
2450 | } | 2450 | } |
2451 | } | 2451 | } |
2452 | } | 2452 | } |
2453 | } | 2453 | } |
2454 | |||
2454 | #endif /* LOGGING */ | 2455 | #endif /* LOGGING */ |
2455 | } | 2456 | } |
2456 | 2457 | ||