summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/DHT.c12
-rw-r--r--core/DHT.h4
-rw-r--r--core/LAN_discovery.c2
-rw-r--r--core/Lossless_UDP.c14
-rw-r--r--core/Lossless_UDP.h4
-rw-r--r--core/Messenger.c12
-rw-r--r--core/Messenger.h6
-rw-r--r--core/net_crypto.c12
-rw-r--r--core/net_crypto.h6
-rw-r--r--core/network.c6
-rw-r--r--core/network.h6
11 files changed, 42 insertions, 42 deletions
diff --git a/core/DHT.c b/core/DHT.c
index 68ec95d7..6375b86b 100644
--- a/core/DHT.c
+++ b/core/DHT.c
@@ -873,7 +873,7 @@ IP_Port DHT_getfriendip(uint8_t * client_id)
873/* Ping each client in the "friends" list every 60 seconds. Send a get nodes request 873/* Ping each client in the "friends" list every 60 seconds. Send a get nodes request
874 * every 20 seconds to a random good node for each "friend" in our "friends" list. 874 * every 20 seconds to a random good node for each "friend" in our "friends" list.
875 */ 875 */
876void doDHTFriends() 876static void doDHTFriends(void)
877{ 877{
878 uint32_t i, j; 878 uint32_t i, j;
879 uint64_t temp_time = unix_time(); 879 uint64_t temp_time = unix_time();
@@ -912,7 +912,7 @@ static uint64_t close_lastgetnodes;
912/* Ping each client in the close nodes list every 60 seconds. 912/* Ping each client in the close nodes list every 60 seconds.
913 * Send a get nodes request every 20 seconds to a random good node in the list. 913 * Send a get nodes request every 20 seconds to a random good node in the list.
914 */ 914 */
915void doClose() 915static void doClose(void)
916{ 916{
917 uint32_t i; 917 uint32_t i;
918 uint64_t temp_time = unix_time(); 918 uint64_t temp_time = unix_time();
@@ -1211,7 +1211,7 @@ static void punch_holes(IP ip, uint16_t * port_list, uint16_t numports, uint16_t
1211 friends_list[friend_num].punching_index = i; 1211 friends_list[friend_num].punching_index = i;
1212} 1212}
1213 1213
1214static void doNAT() 1214static void doNAT(void)
1215{ 1215{
1216 uint32_t i; 1216 uint32_t i;
1217 uint64_t temp_time = unix_time(); 1217 uint64_t temp_time = unix_time();
@@ -1275,7 +1275,7 @@ int DHT_handlepacket(uint8_t * packet, uint32_t length, IP_Port source)
1275 return 0; 1275 return 0;
1276} 1276}
1277 1277
1278void doDHT() 1278void doDHT(void)
1279{ 1279{
1280 doClose(); 1280 doClose();
1281 doDHTFriends(); 1281 doDHTFriends();
@@ -1283,7 +1283,7 @@ void doDHT()
1283} 1283}
1284 1284
1285/* get the size of the DHT (for saving) */ 1285/* get the size of the DHT (for saving) */
1286uint32_t DHT_size() 1286uint32_t DHT_size(void)
1287{ 1287{
1288 return sizeof(close_clientlist) + sizeof(Friend) * num_friends; 1288 return sizeof(close_clientlist) + sizeof(Friend) * num_friends;
1289} 1289}
@@ -1341,7 +1341,7 @@ int DHT_load(uint8_t * data, uint32_t size)
1341/* returns 0 if we are not connected to the DHT 1341/* returns 0 if we are not connected to the DHT
1342 * returns 1 if we are 1342 * returns 1 if we are
1343 */ 1343 */
1344int DHT_isconnected() 1344int DHT_isconnected(void)
1345{ 1345{
1346 uint32_t i; 1346 uint32_t i;
1347 uint64_t temp_time = unix_time(); 1347 uint64_t temp_time = unix_time();
diff --git a/core/DHT.h b/core/DHT.h
index 36670ed5..0edaebf3 100644
--- a/core/DHT.h
+++ b/core/DHT.h
@@ -58,7 +58,7 @@ int DHT_delfriend(uint8_t *client_id);
58IP_Port DHT_getfriendip(uint8_t *client_id); 58IP_Port DHT_getfriendip(uint8_t *client_id);
59 59
60/* Run this function at least a couple times per second (It's the main loop) */ 60/* Run this function at least a couple times per second (It's the main loop) */
61void doDHT(); 61void doDHT(void);
62 62
63/* if we receive a DHT packet we call this function so it can be handled. 63/* if we receive a DHT packet we call this function so it can be handled.
64 return 0 if packet is handled correctly. 64 return 0 if packet is handled correctly.
@@ -90,7 +90,7 @@ int friend_ips(IP_Port *ip_portlist, uint8_t *friend_id);
90/* SAVE/LOAD functions */ 90/* SAVE/LOAD functions */
91 91
92/* get the size of the DHT (for saving) */ 92/* get the size of the DHT (for saving) */
93uint32_t DHT_size(); 93uint32_t DHT_size(void);
94 94
95/* save the DHT in data where data is an array of size DHT_size() */ 95/* save the DHT in data where data is an array of size DHT_size() */
96void DHT_save(uint8_t *data); 96void DHT_save(uint8_t *data);
diff --git a/core/LAN_discovery.c b/core/LAN_discovery.c
index 67cbfe9a..55953685 100644
--- a/core/LAN_discovery.c
+++ b/core/LAN_discovery.c
@@ -76,7 +76,7 @@ static uint32_t get_broadcast(void)
76#endif 76#endif
77 77
78/* Return the broadcast ip */ 78/* Return the broadcast ip */
79static IP broadcast_ip() 79static IP broadcast_ip(void)
80{ 80{
81 IP ip; 81 IP ip;
82 #ifdef __linux 82 #ifdef __linux
diff --git a/core/Lossless_UDP.c b/core/Lossless_UDP.c
index 8538f76c..3a289735 100644
--- a/core/Lossless_UDP.c
+++ b/core/Lossless_UDP.c
@@ -284,7 +284,7 @@ static int new_inconnection(IP_Port ip_port)
284 * Returns an integer corresponding to the next connection in our incoming connection list. 284 * Returns an integer corresponding to the next connection in our incoming connection list.
285 * Return -1 if there are no new incoming connections in the list. 285 * Return -1 if there are no new incoming connections in the list.
286 */ 286 */
287int incoming_connection() 287int incoming_connection(void)
288{ 288{
289 uint32_t i; 289 uint32_t i;
290 for (i = 0; i < MAX_CONNECTIONS; ++i) { 290 for (i = 0; i < MAX_CONNECTIONS; ++i) {
@@ -298,7 +298,7 @@ int incoming_connection()
298} 298}
299 299
300/* Try to free some memory from the connections array. */ 300/* Try to free some memory from the connections array. */
301static void free_connections() 301static void free_connections(void)
302{ 302{
303 uint32_t i; 303 uint32_t i;
304 for(i = connections_length; i != 0; --i) 304 for(i = connections_length; i != 0; --i)
@@ -793,7 +793,7 @@ int LosslessUDP_handlepacket(uint8_t *packet, uint32_t length, IP_Port source)
793 * Send handshake requests 793 * Send handshake requests
794 * handshake packets are sent at the same rate as SYNC packets 794 * handshake packets are sent at the same rate as SYNC packets
795 */ 795 */
796static void doNew() 796static void doNew(void)
797{ 797{
798 uint32_t i; 798 uint32_t i;
799 uint64_t temp_time = current_time(); 799 uint64_t temp_time = current_time();
@@ -817,7 +817,7 @@ static void doNew()
817 } 817 }
818} 818}
819 819
820static void doSYNC() 820static void doSYNC(void)
821{ 821{
822 uint32_t i; 822 uint32_t i;
823 uint64_t temp_time = current_time(); 823 uint64_t temp_time = current_time();
@@ -830,7 +830,7 @@ static void doSYNC()
830 } 830 }
831} 831}
832 832
833static void doData() 833static void doData(void)
834{ 834{
835 uint32_t i; 835 uint32_t i;
836 uint64_t j; 836 uint64_t j;
@@ -851,7 +851,7 @@ static void doData()
851 * 851 *
852 * TODO: flow control. 852 * TODO: flow control.
853 */ 853 */
854static void adjustRates() 854static void adjustRates(void)
855{ 855{
856 uint32_t i; 856 uint32_t i;
857 uint64_t temp_time = current_time(); 857 uint64_t temp_time = current_time();
@@ -871,7 +871,7 @@ static void adjustRates()
871} 871}
872 872
873/* Call this function a couple times per second It's the main loop. */ 873/* Call this function a couple times per second It's the main loop. */
874void doLossless_UDP() 874void doLossless_UDP(void)
875{ 875{
876 doNew(); 876 doNew();
877 doSYNC(); 877 doSYNC();
diff --git a/core/Lossless_UDP.h b/core/Lossless_UDP.h
index 75ef273e..b4cb186a 100644
--- a/core/Lossless_UDP.h
+++ b/core/Lossless_UDP.h
@@ -52,7 +52,7 @@ int getconnection_id(IP_Port ip_port);
52 * Returns an int corresponding to the next connection in our imcoming connection list 52 * Returns an int corresponding to the next connection in our imcoming connection list
53 * Return -1 if there are no new incoming connections in the list. 53 * Return -1 if there are no new incoming connections in the list.
54 */ 54 */
55int incoming_connection(); 55int incoming_connection(void);
56 56
57/* 57/*
58 * Return -1 if it could not kill the connection. 58 * Return -1 if it could not kill the connection.
@@ -110,7 +110,7 @@ uint32_t recvqueue(int connection_id);
110int is_connected(int connection_id); 110int is_connected(int connection_id);
111 111
112/* Call this function a couple times per second It's the main loop. */ 112/* Call this function a couple times per second It's the main loop. */
113void doLossless_UDP(); 113void doLossless_UDP(void);
114 114
115/* 115/*
116 * If we receive a Lossless_UDP packet, call this function so it can be handled. 116 * If we receive a Lossless_UDP packet, call this function so it can be handled.
diff --git a/core/Messenger.c b/core/Messenger.c
index c768633e..dee6eefc 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -363,7 +363,7 @@ void m_callback_userstatus(void (*function)(int, uint8_t *, uint16_t))
363 363
364#define PORT 33445 364#define PORT 33445
365/* run this at startup */ 365/* run this at startup */
366int initMessenger() 366int initMessenger(void)
367{ 367{
368 new_keys(); 368 new_keys();
369 m_set_userstatus((uint8_t*)"Online", sizeof("Online")); 369 m_set_userstatus((uint8_t*)"Online", sizeof("Online"));
@@ -378,7 +378,7 @@ int initMessenger()
378} 378}
379 379
380//TODO: make this function not suck. 380//TODO: make this function not suck.
381static void doFriends() 381static void doFriends(void)
382{ 382{
383 /* TODO: add incoming connections and some other stuff. */ 383 /* TODO: add incoming connections and some other stuff. */
384 uint32_t i; 384 uint32_t i;
@@ -464,7 +464,7 @@ static void doFriends()
464 } 464 }
465} 465}
466 466
467static void doInbound() 467static void doInbound(void)
468{ 468{
469 uint8_t secret_nonce[crypto_box_NONCEBYTES]; 469 uint8_t secret_nonce[crypto_box_NONCEBYTES];
470 uint8_t public_key[crypto_box_PUBLICKEYBYTES]; 470 uint8_t public_key[crypto_box_PUBLICKEYBYTES];
@@ -488,7 +488,7 @@ static void doInbound()
488static uint64_t last_LANdiscovery; 488static uint64_t last_LANdiscovery;
489 489
490/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/ 490/*Send a LAN discovery packet every LAN_DISCOVERY_INTERVAL seconds*/
491static void LANdiscovery() 491static void LANdiscovery(void)
492{ 492{
493 if (last_LANdiscovery + LAN_DISCOVERY_INTERVAL < unix_time()) { 493 if (last_LANdiscovery + LAN_DISCOVERY_INTERVAL < unix_time()) {
494 send_LANdiscovery(htons(PORT)); 494 send_LANdiscovery(htons(PORT));
@@ -498,7 +498,7 @@ static void LANdiscovery()
498 498
499 499
500/* the main loop that needs to be run at least 200 times per second. */ 500/* the main loop that needs to be run at least 200 times per second. */
501void doMessenger() 501void doMessenger(void)
502{ 502{
503 IP_Port ip_port; 503 IP_Port ip_port;
504 uint8_t data[MAX_UDP_PACKET_SIZE]; 504 uint8_t data[MAX_UDP_PACKET_SIZE];
@@ -532,7 +532,7 @@ void doMessenger()
532} 532}
533 533
534/* returns the size of the messenger data (for saving) */ 534/* returns the size of the messenger data (for saving) */
535uint32_t Messenger_size() 535uint32_t Messenger_size(void)
536{ 536{
537 return crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES 537 return crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES
538 + sizeof(uint32_t) + DHT_size() + sizeof(uint32_t) + sizeof(Friend) * numfriends; 538 + sizeof(uint32_t) + DHT_size() + sizeof(uint32_t) + sizeof(Friend) * numfriends;
diff --git a/core/Messenger.h b/core/Messenger.h
index acf62a32..20b38caa 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -160,15 +160,15 @@ void m_callback_userstatus(void (*function)(int, uint8_t *, uint16_t));
160/* run this at startup 160/* run this at startup
161 returns 0 if no connection problems 161 returns 0 if no connection problems
162 returns -1 if there are problems */ 162 returns -1 if there are problems */
163int initMessenger(); 163int initMessenger(void);
164 164
165/* the main loop that needs to be run at least 200 times per second */ 165/* the main loop that needs to be run at least 200 times per second */
166void doMessenger(); 166void doMessenger(void);
167 167
168/* SAVING AND LOADING FUNCTIONS: */ 168/* SAVING AND LOADING FUNCTIONS: */
169 169
170/* returns the size of the messenger data (for saving) */ 170/* returns the size of the messenger data (for saving) */
171uint32_t Messenger_size(); 171uint32_t Messenger_size(void);
172 172
173/* save the messenger in data (must be allocated memory of size Messenger_size()) */ 173/* save the messenger in data (must be allocated memory of size Messenger_size()) */
174void Messenger_save(uint8_t *data); 174void Messenger_save(uint8_t *data);
diff --git a/core/net_crypto.c b/core/net_crypto.c
index 4ce173c5..1c56b95a 100644
--- a/core/net_crypto.c
+++ b/core/net_crypto.c
@@ -440,7 +440,7 @@ int is_cryptoconnected(int crypt_connection_id)
440 440
441/* Generate our public and private keys 441/* Generate our public and private keys
442 Only call this function the first time the program starts. */ 442 Only call this function the first time the program starts. */
443void new_keys() 443void new_keys(void)
444{ 444{
445 crypto_box_keypair(self_public_key,self_secret_key); 445 crypto_box_keypair(self_public_key,self_secret_key);
446} 446}
@@ -479,7 +479,7 @@ static int new_incoming(int id)
479 479
480/* TODO: optimize this 480/* TODO: optimize this
481 handle all new incoming connections. */ 481 handle all new incoming connections. */
482static void handle_incomings() 482static void handle_incomings(void)
483{ 483{
484 int income; 484 int income;
485 while (1) { 485 while (1) {
@@ -490,7 +490,7 @@ static void handle_incomings()
490} 490}
491 491
492/* handle received packets for not yet established crypto connections. */ 492/* handle received packets for not yet established crypto connections. */
493static void receive_crypto() 493static void receive_crypto(void)
494{ 494{
495 uint32_t i; 495 uint32_t i;
496 for (i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i) { 496 for (i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i) {
@@ -547,7 +547,7 @@ static void receive_crypto()
547 547
548/* run this to (re)initialize net_crypto 548/* run this to (re)initialize net_crypto
549 sets all the global connection variables to their default values. */ 549 sets all the global connection variables to their default values. */
550void initNetCrypto() 550void initNetCrypto(void)
551{ 551{
552 memset(crypto_connections, 0 ,sizeof(crypto_connections)); 552 memset(crypto_connections, 0 ,sizeof(crypto_connections));
553 memset(incoming_connections, -1 ,sizeof(incoming_connections)); 553 memset(incoming_connections, -1 ,sizeof(incoming_connections));
@@ -556,7 +556,7 @@ void initNetCrypto()
556 crypto_connections[i].number = ~0; 556 crypto_connections[i].number = ~0;
557} 557}
558 558
559static void killTimedout() 559static void killTimedout(void)
560{ 560{
561 uint32_t i; 561 uint32_t i;
562 for (i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i) { 562 for (i = 0; i < MAX_CRYPTO_CONNECTIONS; ++i) {
@@ -570,7 +570,7 @@ static void killTimedout()
570} 570}
571 571
572/* main loop */ 572/* main loop */
573void doNetCrypto() 573void doNetCrypto(void)
574{ 574{
575 /* TODO:check if friend requests were sent correctly 575 /* TODO:check if friend requests were sent correctly
576 handle new incoming connections 576 handle new incoming connections
diff --git a/core/net_crypto.h b/core/net_crypto.h
index 0e7284c9..66634d45 100644
--- a/core/net_crypto.h
+++ b/core/net_crypto.h
@@ -110,7 +110,7 @@ int is_cryptoconnected(int crypt_connection_id);
110 110
111/* Generate our public and private keys 111/* Generate our public and private keys
112 Only call this function the first time the program starts. */ 112 Only call this function the first time the program starts. */
113void new_keys(); 113void new_keys(void);
114 114
115/* save the public and private keys to the keys array 115/* save the public and private keys to the keys array
116 Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES */ 116 Length must be crypto_box_PUBLICKEYBYTES + crypto_box_SECRETKEYBYTES */
@@ -122,10 +122,10 @@ void load_keys(uint8_t * keys);
122 122
123/* run this to (re)initialize net_crypto 123/* run this to (re)initialize net_crypto
124 sets all the global connection variables to their default values. */ 124 sets all the global connection variables to their default values. */
125void initNetCrypto(); 125void initNetCrypto(void);
126 126
127/* main loop */ 127/* main loop */
128void doNetCrypto(); 128void doNetCrypto(void);
129 129
130#ifdef __cplusplus 130#ifdef __cplusplus
131} 131}
diff --git a/core/network.c b/core/network.c
index c58549bf..8c6fa7b6 100644
--- a/core/network.c
+++ b/core/network.c
@@ -24,7 +24,7 @@
24#include "network.h" 24#include "network.h"
25 25
26/* returns current UNIX time in microseconds (us). */ 26/* returns current UNIX time in microseconds (us). */
27uint64_t current_time() 27uint64_t current_time(void)
28{ 28{
29 uint64_t time; 29 uint64_t time;
30#ifdef WIN32 30#ifdef WIN32
@@ -46,7 +46,7 @@ uint64_t current_time()
46 46
47/* return a random number 47/* return a random number
48 NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary */ 48 NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary */
49uint32_t random_int() 49uint32_t random_int(void)
50{ 50{
51#ifndef VANILLA_NACL 51#ifndef VANILLA_NACL
52 //NOTE: this function comes from libsodium 52 //NOTE: this function comes from libsodium
@@ -153,7 +153,7 @@ int init_networking(IP ip, uint16_t port)
153} 153}
154 154
155/* function to cleanup networking stuff */ 155/* function to cleanup networking stuff */
156void shutdown_networking() 156void shutdown_networking(void)
157{ 157{
158#ifdef WIN32 158#ifdef WIN32
159 closesocket(sock); 159 closesocket(sock);
diff --git a/core/network.h b/core/network.h
index a7559ebe..d246a9d1 100644
--- a/core/network.h
+++ b/core/network.h
@@ -90,11 +90,11 @@ typedef struct {
90} ADDR; 90} ADDR;
91 91
92/* returns current time in milleseconds since the epoch. */ 92/* returns current time in milleseconds since the epoch. */
93uint64_t current_time(); 93uint64_t current_time(void);
94 94
95/* return a random number 95/* return a random number
96 NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary */ 96 NOTE: this function should probably not be used where cryptographic randomness is absolutely necessary */
97uint32_t random_int(); 97uint32_t random_int(void);
98 98
99/* Basic network functions: */ 99/* Basic network functions: */
100 100
@@ -115,7 +115,7 @@ int receivepacket(IP_Port *ip_port, uint8_t *data, uint32_t *length);
115int init_networking(IP ip, uint16_t port); 115int init_networking(IP ip, uint16_t port);
116 116
117/* function to cleanup networking stuff(doesn't do much right now) */ 117/* function to cleanup networking stuff(doesn't do much right now) */
118void shutdown_networking(); 118void shutdown_networking(void);
119 119
120/* 120/*
121 resolve_addr(): 121 resolve_addr():