diff options
-rw-r--r-- | toxcore/TCP_server.c | 10 | ||||
-rw-r--r-- | toxcore/TCP_server.h | 2 | ||||
-rw-r--r-- | toxcore/list.c | 12 | ||||
-rw-r--r-- | toxcore/list.h | 12 | ||||
-rw-r--r-- | toxcore/net_crypto.c | 16 | ||||
-rw-r--r-- | toxcore/net_crypto.h | 2 |
6 files changed, 27 insertions, 27 deletions
diff --git a/toxcore/TCP_server.c b/toxcore/TCP_server.c index 2dcd6f50..d055215e 100644 --- a/toxcore/TCP_server.c +++ b/toxcore/TCP_server.c | |||
@@ -99,7 +99,7 @@ static int realloc_connection(TCP_Server *TCP_server, uint32_t num) | |||
99 | */ | 99 | */ |
100 | static int get_TCP_connection_index(TCP_Server *TCP_server, uint8_t *public_key) | 100 | static int get_TCP_connection_index(TCP_Server *TCP_server, uint8_t *public_key) |
101 | { | 101 | { |
102 | return list_find(&TCP_server->accepted_key_list, public_key); | 102 | return bs_list_find(&TCP_server->accepted_key_list, public_key); |
103 | } | 103 | } |
104 | 104 | ||
105 | 105 | ||
@@ -140,7 +140,7 @@ static int add_accepted(TCP_Server *TCP_server, TCP_Secure_Connection *con) | |||
140 | return -1; | 140 | return -1; |
141 | } | 141 | } |
142 | 142 | ||
143 | if (!list_add(&TCP_server->accepted_key_list, con->public_key, index)) | 143 | if (!bs_list_add(&TCP_server->accepted_key_list, con->public_key, index)) |
144 | return -1; | 144 | return -1; |
145 | 145 | ||
146 | memcpy(&TCP_server->accepted_connection_array[index], con, sizeof(TCP_Secure_Connection)); | 146 | memcpy(&TCP_server->accepted_connection_array[index], con, sizeof(TCP_Secure_Connection)); |
@@ -166,7 +166,7 @@ static int del_accepted(TCP_Server *TCP_server, int index) | |||
166 | if (TCP_server->accepted_connection_array[index].status == TCP_STATUS_NO_STATUS) | 166 | if (TCP_server->accepted_connection_array[index].status == TCP_STATUS_NO_STATUS) |
167 | return -1; | 167 | return -1; |
168 | 168 | ||
169 | if (!list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index)) | 169 | if (!bs_list_remove(&TCP_server->accepted_key_list, TCP_server->accepted_connection_array[index].public_key, index)) |
170 | return -1; | 170 | return -1; |
171 | 171 | ||
172 | memset(&TCP_server->accepted_connection_array[index], 0, sizeof(TCP_Secure_Connection)); | 172 | memset(&TCP_server->accepted_connection_array[index], 0, sizeof(TCP_Secure_Connection)); |
@@ -914,7 +914,7 @@ TCP_Server *new_TCP_server(uint8_t ipv6_enabled, uint16_t num_sockets, uint16_t | |||
914 | memcpy(temp->public_key, public_key, crypto_box_PUBLICKEYBYTES); | 914 | memcpy(temp->public_key, public_key, crypto_box_PUBLICKEYBYTES); |
915 | memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES); | 915 | memcpy(temp->secret_key, secret_key, crypto_box_SECRETKEYBYTES); |
916 | 916 | ||
917 | list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES); | 917 | bs_list_init(&temp->accepted_key_list, crypto_box_PUBLICKEYBYTES); |
918 | 918 | ||
919 | return temp; | 919 | return temp; |
920 | } | 920 | } |
@@ -1229,7 +1229,7 @@ void kill_TCP_server(TCP_Server *TCP_server) | |||
1229 | set_callback_handle_recv_1(TCP_server->onion, NULL, NULL); | 1229 | set_callback_handle_recv_1(TCP_server->onion, NULL, NULL); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | list_free(&TCP_server->accepted_key_list); | 1232 | bs_list_free(&TCP_server->accepted_key_list); |
1233 | 1233 | ||
1234 | #ifdef TCP_SERVER_USE_EPOLL | 1234 | #ifdef TCP_SERVER_USE_EPOLL |
1235 | close(TCP_server->efd); | 1235 | close(TCP_server->efd); |
diff --git a/toxcore/TCP_server.h b/toxcore/TCP_server.h index 1573d212..40984778 100644 --- a/toxcore/TCP_server.h +++ b/toxcore/TCP_server.h | |||
@@ -128,7 +128,7 @@ typedef struct { | |||
128 | 128 | ||
129 | uint64_t counter; | 129 | uint64_t counter; |
130 | 130 | ||
131 | LIST accepted_key_list; | 131 | BS_LIST accepted_key_list; |
132 | } TCP_Server; | 132 | } TCP_Server; |
133 | 133 | ||
134 | /* Create new TCP server instance. | 134 | /* Create new TCP server instance. |
diff --git a/toxcore/list.c b/toxcore/list.c index c7060146..ce3968fd 100644 --- a/toxcore/list.c +++ b/toxcore/list.c | |||
@@ -45,7 +45,7 @@ | |||
45 | * < 0 : no match, returns index (return value is INDEX(index)) where | 45 | * < 0 : no match, returns index (return value is INDEX(index)) where |
46 | * the data should be inserted | 46 | * the data should be inserted |
47 | */ | 47 | */ |
48 | static int find(LIST *list, void *data) | 48 | static int find(BS_LIST *list, void *data) |
49 | { | 49 | { |
50 | //should work well, but could be improved | 50 | //should work well, but could be improved |
51 | if (list->n == 0) { | 51 | if (list->n == 0) { |
@@ -106,7 +106,7 @@ static int find(LIST *list, void *data) | |||
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | void list_init(LIST *list, uint32_t element_size) | 109 | void bs_list_init(BS_LIST *list, uint32_t element_size) |
110 | { | 110 | { |
111 | //set initial values | 111 | //set initial values |
112 | list->n = 0; | 112 | list->n = 0; |
@@ -115,14 +115,14 @@ void list_init(LIST *list, uint32_t element_size) | |||
115 | list->ids = NULL; | 115 | list->ids = NULL; |
116 | } | 116 | } |
117 | 117 | ||
118 | void list_free(LIST *list) | 118 | void bs_list_free(BS_LIST *list) |
119 | { | 119 | { |
120 | //free both arrays | 120 | //free both arrays |
121 | free(list->data); | 121 | free(list->data); |
122 | free(list->ids); | 122 | free(list->ids); |
123 | } | 123 | } |
124 | 124 | ||
125 | int list_find(LIST *list, void *data) | 125 | int bs_list_find(BS_LIST *list, void *data) |
126 | { | 126 | { |
127 | int r = find(list, data); | 127 | int r = find(list, data); |
128 | 128 | ||
@@ -134,7 +134,7 @@ int list_find(LIST *list, void *data) | |||
134 | return list->ids[r]; | 134 | return list->ids[r]; |
135 | } | 135 | } |
136 | 136 | ||
137 | int list_add(LIST *list, void *data, int id) | 137 | int bs_list_add(BS_LIST *list, void *data, int id) |
138 | { | 138 | { |
139 | //find where the new element should be inserted | 139 | //find where the new element should be inserted |
140 | //see: return value of find() | 140 | //see: return value of find() |
@@ -180,7 +180,7 @@ int list_add(LIST *list, void *data, int id) | |||
180 | return 1; | 180 | return 1; |
181 | } | 181 | } |
182 | 182 | ||
183 | int list_remove(LIST *list, void *data, int id) | 183 | int bs_list_remove(BS_LIST *list, void *data, int id) |
184 | { | 184 | { |
185 | int i = find(list, data); | 185 | int i = find(list, data); |
186 | 186 | ||
diff --git a/toxcore/list.h b/toxcore/list.h index 299c010d..580cc51c 100644 --- a/toxcore/list.h +++ b/toxcore/list.h | |||
@@ -35,13 +35,13 @@ typedef struct { | |||
35 | uint32_t size; //size of the elements | 35 | uint32_t size; //size of the elements |
36 | void *data; //array of elements | 36 | void *data; //array of elements |
37 | int *ids; //array of element ids | 37 | int *ids; //array of element ids |
38 | } LIST; | 38 | } BS_LIST; |
39 | 39 | ||
40 | /* Initialize a list, element_size is the size of the elements in the list */ | 40 | /* Initialize a list, element_size is the size of the elements in the list */ |
41 | void list_init(LIST *list, uint32_t element_size); | 41 | void bs_list_init(BS_LIST *list, uint32_t element_size); |
42 | 42 | ||
43 | /* Free a list initiated with list_init */ | 43 | /* Free a list initiated with list_init */ |
44 | void list_free(LIST *list); | 44 | void bs_list_free(BS_LIST *list); |
45 | 45 | ||
46 | /* Retrieve the id of an element in the list | 46 | /* Retrieve the id of an element in the list |
47 | * | 47 | * |
@@ -49,7 +49,7 @@ void list_free(LIST *list); | |||
49 | * >= 0 : id associated with data | 49 | * >= 0 : id associated with data |
50 | * -1 : failure | 50 | * -1 : failure |
51 | */ | 51 | */ |
52 | int list_find(LIST *list, void *data); | 52 | int bs_list_find(BS_LIST *list, void *data); |
53 | 53 | ||
54 | /* Add an element with associated id to the list | 54 | /* Add an element with associated id to the list |
55 | * | 55 | * |
@@ -57,7 +57,7 @@ int list_find(LIST *list, void *data); | |||
57 | * 1 : success | 57 | * 1 : success |
58 | * 0 : failure (data already in list) | 58 | * 0 : failure (data already in list) |
59 | */ | 59 | */ |
60 | int list_add(LIST *list, void *data, int id); | 60 | int bs_list_add(BS_LIST *list, void *data, int id); |
61 | 61 | ||
62 | /* Remove element from the list | 62 | /* Remove element from the list |
63 | * | 63 | * |
@@ -65,6 +65,6 @@ int list_add(LIST *list, void *data, int id); | |||
65 | * 1 : success | 65 | * 1 : success |
66 | * 0 : failure (element not found or id does not match | 66 | * 0 : failure (element not found or id does not match |
67 | */ | 67 | */ |
68 | int list_remove(LIST *list, void *data, int id); | 68 | int bs_list_remove(BS_LIST *list, void *data, int id); |
69 | 69 | ||
70 | #endif | 70 | #endif |
diff --git a/toxcore/net_crypto.c b/toxcore/net_crypto.c index 811dbf1a..47b23d54 100644 --- a/toxcore/net_crypto.c +++ b/toxcore/net_crypto.c | |||
@@ -1329,10 +1329,10 @@ static int crypto_connection_add_source(Net_Crypto *c, int crypt_connection_id, | |||
1329 | 1329 | ||
1330 | if (source.ip.family == AF_INET || source.ip.family == AF_INET6) { | 1330 | if (source.ip.family == AF_INET || source.ip.family == AF_INET6) { |
1331 | if (!ipport_equal(&source, &conn->ip_port)) { | 1331 | if (!ipport_equal(&source, &conn->ip_port)) { |
1332 | if (!list_add(&c->ip_port_list, &source, crypt_connection_id)) | 1332 | if (!bs_list_add(&c->ip_port_list, &source, crypt_connection_id)) |
1333 | return -1; | 1333 | return -1; |
1334 | 1334 | ||
1335 | list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); | 1335 | bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); |
1336 | conn->ip_port = source; | 1336 | conn->ip_port = source; |
1337 | } | 1337 | } |
1338 | 1338 | ||
@@ -1609,8 +1609,8 @@ int set_direct_ip_port(Net_Crypto *c, int crypt_connection_id, IP_Port ip_port) | |||
1609 | return -1; | 1609 | return -1; |
1610 | 1610 | ||
1611 | if (!ipport_equal(&ip_port, &conn->ip_port)) { | 1611 | if (!ipport_equal(&ip_port, &conn->ip_port)) { |
1612 | if (list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) { | 1612 | if (bs_list_add(&c->ip_port_list, &ip_port, crypt_connection_id)) { |
1613 | list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); | 1613 | bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); |
1614 | conn->ip_port = ip_port; | 1614 | conn->ip_port = ip_port; |
1615 | conn->direct_lastrecv_time = 0; | 1615 | conn->direct_lastrecv_time = 0; |
1616 | return 0; | 1616 | return 0; |
@@ -2103,7 +2103,7 @@ int connection_lossy_data_handler(Net_Crypto *c, int crypt_connection_id, | |||
2103 | */ | 2103 | */ |
2104 | static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port) | 2104 | static int crypto_id_ip_port(Net_Crypto *c, IP_Port ip_port) |
2105 | { | 2105 | { |
2106 | return list_find(&c->ip_port_list, &ip_port); | 2106 | return bs_list_find(&c->ip_port_list, &ip_port); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | #define CRYPTO_MIN_PACKET_SIZE (1 + sizeof(uint16_t) + crypto_box_MACBYTES) | 2109 | #define CRYPTO_MIN_PACKET_SIZE (1 + sizeof(uint16_t) + crypto_box_MACBYTES) |
@@ -2426,7 +2426,7 @@ int crypto_kill(Net_Crypto *c, int crypt_connection_id) | |||
2426 | 2426 | ||
2427 | send_kill_packet(c, crypt_connection_id); | 2427 | send_kill_packet(c, crypt_connection_id); |
2428 | disconnect_peer_tcp(c, crypt_connection_id); | 2428 | disconnect_peer_tcp(c, crypt_connection_id); |
2429 | list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); | 2429 | bs_list_remove(&c->ip_port_list, &conn->ip_port, crypt_connection_id); |
2430 | return wipe_crypto_connection(c, crypt_connection_id); | 2430 | return wipe_crypto_connection(c, crypt_connection_id); |
2431 | } | 2431 | } |
2432 | 2432 | ||
@@ -2499,7 +2499,7 @@ Net_Crypto *new_net_crypto(DHT *dht) | |||
2499 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_HS, &udp_handle_packet, temp); | 2499 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_HS, &udp_handle_packet, temp); |
2500 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_DATA, &udp_handle_packet, temp); | 2500 | networking_registerhandler(dht->net, NET_PACKET_CRYPTO_DATA, &udp_handle_packet, temp); |
2501 | 2501 | ||
2502 | list_init(&temp->ip_port_list, sizeof(IP_Port)); | 2502 | bs_list_init(&temp->ip_port_list, sizeof(IP_Port)); |
2503 | return temp; | 2503 | return temp; |
2504 | } | 2504 | } |
2505 | 2505 | ||
@@ -2573,7 +2573,7 @@ void kill_net_crypto(Net_Crypto *c) | |||
2573 | kill_TCP_connection(c->tcp_connections[i]); | 2573 | kill_TCP_connection(c->tcp_connections[i]); |
2574 | } | 2574 | } |
2575 | 2575 | ||
2576 | list_free(&c->ip_port_list); | 2576 | bs_list_free(&c->ip_port_list); |
2577 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_REQUEST, NULL, NULL); | 2577 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_REQUEST, NULL, NULL); |
2578 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_RESPONSE, NULL, NULL); | 2578 | networking_registerhandler(c->dht->net, NET_PACKET_COOKIE_RESPONSE, NULL, NULL); |
2579 | networking_registerhandler(c->dht->net, NET_PACKET_CRYPTO_HS, NULL, NULL); | 2579 | networking_registerhandler(c->dht->net, NET_PACKET_CRYPTO_HS, NULL, NULL); |
diff --git a/toxcore/net_crypto.h b/toxcore/net_crypto.h index e2090542..a3c7e7db 100644 --- a/toxcore/net_crypto.h +++ b/toxcore/net_crypto.h | |||
@@ -189,7 +189,7 @@ typedef struct { | |||
189 | /* The current optimal sleep time */ | 189 | /* The current optimal sleep time */ |
190 | uint32_t current_sleep_time; | 190 | uint32_t current_sleep_time; |
191 | 191 | ||
192 | LIST ip_port_list; | 192 | BS_LIST ip_port_list; |
193 | } Net_Crypto; | 193 | } Net_Crypto; |
194 | 194 | ||
195 | 195 | ||