diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-06-23 17:16:28 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-06-24 19:17:32 +0000 |
commit | 8e00294b3cb9808ce55160240454359638178275 (patch) | |
tree | 095a7708b3fe3566951ebe7b068ee66a8beed3c1 /toxcore/network.c | |
parent | 5a8790eab0ed9421445adce40526462b9e6742c3 (diff) |
Add Logger to various net_crypto functions.
In preparation for adding log statements.
Also, fix an uninitialised variable warning in cppcheck.
Diffstat (limited to 'toxcore/network.c')
-rw-r--r-- | toxcore/network.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 44ca2dee..30c3bb6c 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -495,7 +495,7 @@ static uint32_t data_1(uint16_t buflen, const uint8_t *buffer) | |||
495 | return buflen > 7 ? net_ntohl(*(const uint32_t *)&buffer[5]) : 0; | 495 | return buflen > 7 ? net_ntohl(*(const uint32_t *)&buffer[5]) : 0; |
496 | } | 496 | } |
497 | 497 | ||
498 | static void loglogdata(Logger *log, const char *message, const uint8_t *buffer, | 498 | static void loglogdata(const Logger *log, const char *message, const uint8_t *buffer, |
499 | uint16_t buflen, IP_Port ip_port, int res) | 499 | uint16_t buflen, IP_Port ip_port, int res) |
500 | { | 500 | { |
501 | char ip_str[IP_NTOA_LEN]; | 501 | char ip_str[IP_NTOA_LEN]; |
@@ -527,7 +527,7 @@ typedef struct { | |||
527 | } Packet_Handler; | 527 | } Packet_Handler; |
528 | 528 | ||
529 | struct Networking_Core { | 529 | struct Networking_Core { |
530 | Logger *log; | 530 | const Logger *log; |
531 | Packet_Handler packethandlers[256]; | 531 | Packet_Handler packethandlers[256]; |
532 | 532 | ||
533 | Family family; | 533 | Family family; |
@@ -616,7 +616,7 @@ int sendpacket(Networking_Core *net, IP_Port ip_port, const uint8_t *data, uint1 | |||
616 | * Packet data is put into data. | 616 | * Packet data is put into data. |
617 | * Packet length is put into length. | 617 | * Packet length is put into length. |
618 | */ | 618 | */ |
619 | static int receivepacket(Logger *log, Socket sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) | 619 | static int receivepacket(const Logger *log, Socket sock, IP_Port *ip_port, uint8_t *data, uint32_t *length) |
620 | { | 620 | { |
621 | memset(ip_port, 0, sizeof(IP_Port)); | 621 | memset(ip_port, 0, sizeof(IP_Port)); |
622 | struct sockaddr_storage addr; | 622 | struct sockaddr_storage addr; |
@@ -766,7 +766,7 @@ static void at_shutdown(void) | |||
766 | /* Initialize networking. | 766 | /* Initialize networking. |
767 | * Added for reverse compatibility with old new_networking calls. | 767 | * Added for reverse compatibility with old new_networking calls. |
768 | */ | 768 | */ |
769 | Networking_Core *new_networking(Logger *log, IP ip, uint16_t port) | 769 | Networking_Core *new_networking(const Logger *log, IP ip, uint16_t port) |
770 | { | 770 | { |
771 | return new_networking_ex(log, ip, port, port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM), nullptr); | 771 | return new_networking_ex(log, ip, port, port + (TOX_PORTRANGE_TO - TOX_PORTRANGE_FROM), nullptr); |
772 | } | 772 | } |
@@ -781,7 +781,7 @@ Networking_Core *new_networking(Logger *log, IP ip, uint16_t port) | |||
781 | * | 781 | * |
782 | * If error is non NULL it is set to 0 if no issues, 1 if socket related error, 2 if other. | 782 | * If error is non NULL it is set to 0 if no issues, 1 if socket related error, 2 if other. |
783 | */ | 783 | */ |
784 | Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error) | 784 | Networking_Core *new_networking_ex(const Logger *log, IP ip, uint16_t port_from, uint16_t port_to, unsigned int *error) |
785 | { | 785 | { |
786 | /* If both from and to are 0, use default port range | 786 | /* If both from and to are 0, use default port range |
787 | * If one is 0 and the other is non-0, use the non-0 value as only port | 787 | * If one is 0 and the other is non-0, use the non-0 value as only port |
@@ -996,7 +996,7 @@ Networking_Core *new_networking_ex(Logger *log, IP ip, uint16_t port_from, uint1 | |||
996 | return nullptr; | 996 | return nullptr; |
997 | } | 997 | } |
998 | 998 | ||
999 | Networking_Core *new_networking_no_udp(Logger *log) | 999 | Networking_Core *new_networking_no_udp(const Logger *log) |
1000 | { | 1000 | { |
1001 | /* this is the easiest way to completely disable UDP without changing too much code. */ | 1001 | /* this is the easiest way to completely disable UDP without changing too much code. */ |
1002 | Networking_Core *net = (Networking_Core *)calloc(1, sizeof(Networking_Core)); | 1002 | Networking_Core *net = (Networking_Core *)calloc(1, sizeof(Networking_Core)); |