summaryrefslogtreecommitdiff
path: root/toxcore
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore')
-rw-r--r--toxcore/DHT.h3
-rw-r--r--toxcore/Messenger.c15
-rw-r--r--toxcore/Messenger.h14
-rw-r--r--toxcore/group.c223
-rw-r--r--toxcore/group.h54
-rw-r--r--toxcore/network.h12
6 files changed, 269 insertions, 52 deletions
diff --git a/toxcore/DHT.h b/toxcore/DHT.h
index ae1bcc72..b37e2f01 100644
--- a/toxcore/DHT.h
+++ b/toxcore/DHT.h
@@ -135,8 +135,7 @@ typedef struct {
135 NAT nat; 135 NAT nat;
136} DHT_Friend; 136} DHT_Friend;
137 137
138typedef struct 138typedef struct {
139{
140 uint8_t client_id[CLIENT_ID_SIZE]; 139 uint8_t client_id[CLIENT_ID_SIZE];
141 IP_Port ip_port; 140 IP_Port ip_port;
142} 141}
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index edb34364..67f7b34f 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -1014,22 +1014,20 @@ static int write_cryptpacket_id(const Messenger *m, int32_t friendnumber, uint8_
1014 1014
1015/* Set the callback for group invites. 1015/* Set the callback for group invites.
1016 * 1016 *
1017 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, uint32_t number) 1017 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
1018 */ 1018 */
1019void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t), uint32_t number) 1019void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t))
1020{ 1020{
1021 m->group_invite = function; 1021 m->group_invite = function;
1022 m->group_invite_number = number;
1023} 1022}
1024 1023
1025/* Set the callback for group messages. 1024/* Set the callback for group messages.
1026 * 1025 *
1027 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, uint32_t number) 1026 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
1028 */ 1027 */
1029void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t), uint32_t number) 1028void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t))
1030{ 1029{
1031 m->group_message = function; 1030 m->group_message = function;
1032 m->group_message_number = number;
1033} 1031}
1034 1032
1035/* Send a group invite packet. 1033/* Send a group invite packet.
@@ -2179,7 +2177,7 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
2179 break; 2177 break;
2180 2178
2181 if (m->group_invite) 2179 if (m->group_invite)
2182 (*m->group_invite)(m, i, temp, len, m->group_invite_number); 2180 (*m->group_invite)(m, i, data, data_length);
2183 2181
2184 break; 2182 break;
2185 } 2183 }
@@ -2189,7 +2187,8 @@ static int handle_packet(void *object, int i, uint8_t *temp, uint16_t len)
2189 break; 2187 break;
2190 2188
2191 if (m->group_message) 2189 if (m->group_message)
2192 (*m->group_message)(m, i, temp, len, m->group_message_number); 2190 (*m->group_message)(m, i, data, data_length);
2191
2193 break; 2192 break;
2194 } 2193 }
2195 2194
diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h
index 82edd17f..665e2620 100644
--- a/toxcore/Messenger.h
+++ b/toxcore/Messenger.h
@@ -300,10 +300,8 @@ typedef struct Messenger {
300 void (*avatar_data_recv)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint8_t *, uint32_t, void *); 300 void (*avatar_data_recv)(struct Messenger *m, int32_t, uint8_t, uint8_t *, uint8_t *, uint32_t, void *);
301 301
302 void *group_chat_object; /* Set by new_groupchats()*/ 302 void *group_chat_object; /* Set by new_groupchats()*/
303 void (*group_invite)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t); 303 void (*group_invite)(struct Messenger *m, int32_t, const uint8_t *, uint16_t);
304 uint32_t group_invite_number; 304 void (*group_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t);
305 void (*group_message)(struct Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t);
306 uint32_t group_message_number;
307 305
308 void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t, void *); 306 void (*file_sendrequest)(struct Messenger *m, int32_t, uint8_t, uint64_t, const uint8_t *, uint16_t, void *);
309 void *file_sendrequest_userdata; 307 void *file_sendrequest_userdata;
@@ -735,15 +733,15 @@ void m_callback_avatar_data(Messenger *m, void (*function)(Messenger *m, int32_t
735 733
736/* Set the callback for group invites. 734/* Set the callback for group invites.
737 * 735 *
738 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, uint32_t number) 736 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
739 */ 737 */
740void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t), uint32_t number); 738void m_callback_group_invite(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t));
741 739
742/* Set the callback for group messages. 740/* Set the callback for group messages.
743 * 741 *
744 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length, uint32_t number) 742 * Function(Messenger *m, int32_t friendnumber, uint8_t *data, uint16_t length)
745 */ 743 */
746void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t, uint32_t), uint32_t number); 744void m_callback_group_message(Messenger *m, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t));
747 745
748/* Send a group invite packet. 746/* Send a group invite packet.
749 * 747 *
diff --git a/toxcore/group.c b/toxcore/group.c
index 65ae078c..d3652e17 100644
--- a/toxcore/group.c
+++ b/toxcore/group.c
@@ -24,7 +24,7 @@
24#ifdef HAVE_CONFIG_H 24#ifdef HAVE_CONFIG_H
25#include "config.h" 25#include "config.h"
26#endif 26#endif
27 27
28#include "group.h" 28#include "group.h"
29#include "util.h" 29#include "util.h"
30 30
@@ -249,6 +249,25 @@ static int peer_in_chat(const Group_c *chat, const uint8_t *client_id)
249} 249}
250 250
251/* 251/*
252 * check if group with identifier is in group array.
253 *
254 * return group number if peer is in list.
255 * return -1 if group is not in list.
256 *
257 * TODO: make this more efficient and maybe use constant time comparisons?
258 */
259static int get_group_num(const Group_Chats *g_c, const uint8_t *identifier)
260{
261 uint32_t i;
262
263 for (i = 0; i < g_c->num_chats; ++i)
264 if (memcmp(g_c->chats[i].identifier, identifier, GROUP_IDENTIFIER_LENGTH) == 0)
265 return i;
266
267 return -1;
268}
269
270/*
252 * Add a peer to the group chat. 271 * Add a peer to the group chat.
253 * 272 *
254 * return peernum if success or peer already in chat. 273 * return peernum if success or peer already in chat.
@@ -287,20 +306,162 @@ static int addpeer(Group_c *chat, const uint8_t *client_id)
287 * return group number on success. 306 * return group number on success.
288 * return -1 on failure. 307 * return -1 on failure.
289 */ 308 */
290int temp_c_add_groupchat(Group_Chats *g_c) 309int add_groupchat(Group_Chats *g_c)
291{ 310{
292 int groupnumber = create_group_chat(g_c); 311 int groupnumber = create_group_chat(g_c);
293 312
294 Group_c *g = get_group_c(g_c, groupnumber); 313 Group_c *g = get_group_c(g_c, groupnumber);
295 314
296 if (!g) { 315 if (!g)
297 return -1; 316 return -1;
298 }
299 317
300 g->status = GROUPCHAT_STATUS_VALID; 318 g->status = GROUPCHAT_STATUS_VALID;
319 new_symmetric_key(g->identifier);
301 return groupnumber; 320 return groupnumber;
302} 321}
303 322
323#define INVITE_PACKET_SIZE (1 + sizeof(uint16_t) + GROUP_IDENTIFIER_LENGTH)
324#define INVITE_ID 0
325
326#define INVITE_RESPONSE_PACKET_SIZE (1 + sizeof(uint16_t) * 2 + GROUP_IDENTIFIER_LENGTH)
327#define INVITE_RESPONSE_ID 1
328
329/* invite friendnumber to groupnumber
330 * return 0 on success
331 * return -1 on failure
332 */
333int invite_friend(Group_Chats *g_c, int32_t friendnumber, int groupnumber)
334{
335 Group_c *g = get_group_c(g_c, groupnumber);
336
337 if (!g)
338 return -1;
339
340 uint8_t invite[INVITE_PACKET_SIZE];
341 invite[0] = INVITE_ID;
342 uint16_t groupchat_num = htons((uint16_t)groupnumber);
343 memcpy(invite + 1, &groupchat_num, sizeof(groupchat_num));
344 memcpy(invite + 1 + sizeof(groupchat_num), g->identifier, GROUP_IDENTIFIER_LENGTH);
345
346 if (send_group_invite_packet(g_c->m, friendnumber, invite, sizeof(invite))) {
347 return 0;
348 } else {
349 wipe_group_chat(g_c, groupnumber);
350 return -1;
351 }
352}
353
354/* Join a group (you need to have been invited first.)
355 *
356 * returns group number on success
357 * returns -1 on failure.
358 */
359int join_groupchat(Group_Chats *g_c, int32_t friendnumber, uint8_t *data, uint16_t length)
360{
361 if (length != sizeof(uint16_t) + GROUP_IDENTIFIER_LENGTH)
362 return -1;
363
364 int groupnumber = create_group_chat(g_c);
365
366 Group_c *g = get_group_c(g_c, groupnumber);
367
368 if (!g)
369 return -1;
370
371 uint16_t group_num = htons(groupnumber);
372 g->status = GROUPCHAT_STATUS_VALID;
373 uint8_t response[INVITE_RESPONSE_PACKET_SIZE];
374 response[0] = INVITE_RESPONSE_ID;
375 memcpy(response + 1, &group_num, sizeof(uint16_t));
376 memcpy(response + 1 + sizeof(uint16_t), data, sizeof(uint16_t) + GROUP_IDENTIFIER_LENGTH);
377
378 if (send_group_invite_packet(g_c->m, friendnumber, response, sizeof(response))) {
379 uint16_t other_groupnum;
380 memcpy(&other_groupnum, data, sizeof(other_groupnum));
381 other_groupnum = htons(other_groupnum);
382 //TODO add_friend_to_groupchat(g_c, friendnumber, groupnumber, other_groupnum);
383 return groupnumber;
384 } else {
385 return -1;
386 }
387}
388
389/* Set the callback for group invites.
390 *
391 * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
392 *
393 * data of length is what needs to be passed to join_groupchat().
394 */
395void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t,
396 void *), void *userdata)
397{
398 g_c->invite_callback = function;
399 g_c->invite_callback_userdata = userdata;
400}
401
402/* Set the callback for group messages.
403 *
404 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
405 */
406void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t,
407 void *), void *userdata)
408{
409 g_c->message_callback = function;
410 g_c->message_callback_userdata = userdata;
411}
412
413static void handle_friend_invite_packet(Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length)
414{
415 Group_Chats *g_c = m->group_chat_object;
416
417 if (length <= 1)
418 return;
419
420 const uint8_t *invite_data = data + 1;
421 uint16_t invite_length = length - 1;
422
423 switch (data[0]) {
424 case INVITE_ID: {
425 if (length != INVITE_PACKET_SIZE)
426 return;
427
428 int groupnumber = get_group_num(g_c, data + 1 + sizeof(uint16_t));
429
430 if (groupnumber == -1) {
431 g_c->invite_callback(m, friendnumber, invite_data, invite_length, g_c->invite_callback_userdata);
432 return;
433 } else {
434 //TODO
435 }
436
437 break;
438 }
439
440 case INVITE_RESPONSE_ID: {
441 if (length != INVITE_RESPONSE_PACKET_SIZE)
442 return;
443
444 int groupnumber = get_group_num(g_c, data + 1 + sizeof(uint16_t));
445
446 if (groupnumber == -1) {
447 return;
448 } else {
449 //TODO add_friend_to_groupchat(g_c, friendnumber, groupnumber, other_groupnum);
450 }
451
452 break;
453 }
454
455 default:
456 return;
457 }
458}
459
460static void handle_friend_message_packet(Messenger *m, int32_t friendnumber, const uint8_t *data, uint16_t length)
461{
462
463}
464
304/* Create new groupchat instance. */ 465/* Create new groupchat instance. */
305Group_Chats *new_groupchats(Messenger *m) 466Group_Chats *new_groupchats(Messenger *m)
306{ 467{
@@ -313,6 +474,9 @@ Group_Chats *new_groupchats(Messenger *m)
313 return NULL; 474 return NULL;
314 475
315 temp->m = m; 476 temp->m = m;
477 m->group_chat_object = temp;
478 m_callback_group_invite(m, &handle_friend_invite_packet);
479
316 return temp; 480 return temp;
317} 481}
318 482
@@ -326,6 +490,57 @@ void do_groupchats(Group_Chats *g_c)
326void kill_groupchats(Group_Chats *g_c) 490void kill_groupchats(Group_Chats *g_c)
327{ 491{
328 //TODO 492 //TODO
493 g_c->m->group_chat_object = 0;
329 free(g_c); 494 free(g_c);
330} 495}
331 496
497/* Return the number of chats in the instance m.
498 * You should use this to determine how much memory to allocate
499 * for copy_chatlist. */
500/*
501uint32_t count_chatlist(const Messenger *m)
502{
503 uint32_t ret = 0;
504 uint32_t i;
505
506 for (i = 0; i < m->numchats; i++) {
507 if (m->chats[i]) {
508 ret++;
509 }
510 }
511
512 return ret;
513}*/
514
515/* Copy a list of valid chat IDs into the array out_list.
516 * If out_list is NULL, returns 0.
517 * Otherwise, returns the number of elements copied.
518 * If the array was too small, the contents
519 * of out_list will be truncated to list_size. */
520/*
521uint32_t copy_chatlist(const Messenger *m, int *out_list, uint32_t list_size)
522{
523 if (!out_list)
524 return 0;
525
526 if (m->numchats == 0) {
527 return 0;
528 }
529
530 uint32_t i;
531 uint32_t ret = 0;
532
533 for (i = 0; i < m->numchats; i++) {
534 if (ret >= list_size) {
535 break; *//* Abandon ship *//*
536 }
537
538 if (m->chats[i]) {
539 out_list[ret] = i;
540 ret++;
541 }
542 }
543
544 return ret;
545}
546*/ \ No newline at end of file
diff --git a/toxcore/group.h b/toxcore/group.h
index 1ad9460f..544fbdb7 100644
--- a/toxcore/group.h
+++ b/toxcore/group.h
@@ -36,7 +36,7 @@ enum {
36 GROUPCON_STATUS_NONE, 36 GROUPCON_STATUS_NONE,
37 GROUPCON_STATUS_VALID 37 GROUPCON_STATUS_VALID
38}; 38};
39/* 39
40typedef struct { 40typedef struct {
41 uint8_t client_id[crypto_box_PUBLICKEYBYTES]; 41 uint8_t client_id[crypto_box_PUBLICKEYBYTES];
42 uint64_t pingid; 42 uint64_t pingid;
@@ -47,15 +47,16 @@ typedef struct {
47 uint64_t last_recv_msgping; 47 uint64_t last_recv_msgping;
48 uint32_t last_message_number; 48 uint32_t last_message_number;
49 49
50 uint8_t nick[MAX_NICK_BYTES]; 50 uint8_t nick[MAX_NAME_LENGTH];
51 uint16_t nick_len; 51 uint16_t nick_len;
52 52
53 uint8_t deleted; 53 uint8_t deleted;
54 uint64_t deleted_time; 54 uint64_t deleted_time;
55} Group_Peer; 55} Group_Peer;
56*/ 56
57 57
58#define MAX_GROUP_CONNECTIONS 4 58#define MAX_GROUP_CONNECTIONS 4
59#define GROUP_IDENTIFIER_LENGTH crypto_box_KEYBYTES /* So we can use new_symmetric_key(...) to fill it */
59 60
60typedef struct { 61typedef struct {
61 uint8_t status; 62 uint8_t status;
@@ -67,6 +68,8 @@ typedef struct {
67 uint8_t type; 68 uint8_t type;
68 uint32_t number; 69 uint32_t number;
69 } close[MAX_GROUP_CONNECTIONS]; 70 } close[MAX_GROUP_CONNECTIONS];
71
72 uint8_t identifier[GROUP_IDENTIFIER_LENGTH];
70} Group_c; 73} Group_c;
71 74
72typedef struct { 75typedef struct {
@@ -78,31 +81,38 @@ typedef struct {
78 81
79 Group_c *chats; 82 Group_c *chats;
80 uint32_t num_chats; 83 uint32_t num_chats;
81 84
82 Group_Connection *cons; 85 Group_Connection *cons;
83 uint32_t num_cons; 86 uint32_t num_cons;
87
88 void (*invite_callback)(Messenger *m, int32_t, const uint8_t *, uint16_t, void *);
89 void *invite_callback_userdata;
90 void (*message_callback)(Messenger *m, int, int, const uint8_t *, uint16_t, void *);
91 void *message_callback_userdata;
84} Group_Chats; 92} Group_Chats;
85 93
86/* Set the callback for group invites. 94/* Set the callback for group invites.
87 * 95 *
88 * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t *group_public_key, void *userdata) 96 * Function(Group_Chats *g_c, int32_t friendnumber, uint8_t *data, uint16_t length, void *userdata)
97 *
98 * data of length is what needs to be passed to join_groupchat().
89 */ 99 */
90void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, int32_t, const uint8_t *, void *), 100void g_callback_group_invite(Group_Chats *g_c, void (*function)(Messenger *m, int32_t, const uint8_t *, uint16_t,
91 void *userdata); 101 void *), void *userdata);
92 102
93/* Set the callback for group messages. 103/* Set the callback for group messages.
94 * 104 *
95 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata) 105 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
96 */ 106 */
97void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *), 107void g_callback_group_message(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t,
98 void *userdata); 108 void *), void *userdata);
99 109
100/* Set the callback for group actions. 110/* Set the callback for group actions.
101 * 111 *
102 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata) 112 * Function(Group_Chats *g_c, int groupnumber, int friendgroupnumber, uint8_t * message, uint16_t length, void *userdata)
103 */ 113 */
104void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t, void *), 114void g_callback_group_action(Group_Chats *g_c, void (*function)(Messenger *m, int, int, const uint8_t *, uint16_t,
105 void *userdata); 115 void *), void *userdata);
106 116
107/* Set callback function for peer name list changes. 117/* Set callback function for peer name list changes.
108 * 118 *
@@ -117,56 +127,56 @@ void g_callback_group_namelistchange(Group_Chats *g_c, void (*function)(Messenge
117 * return group number on success. 127 * return group number on success.
118 * return -1 on failure. 128 * return -1 on failure.
119 */ 129 */
120int temp_c_add_groupchat(Group_Chats *g_c); 130int add_groupchat(Group_Chats *g_c);
121 131
122/* Delete a groupchat from the chats array. 132/* Delete a groupchat from the chats array.
123 * 133 *
124 * return 0 on success. 134 * return 0 on success.
125 * return -1 if failure. 135 * return -1 if failure.
126 */ 136 */
127int temp_c_del_groupchat(Group_Chats *g_c, int groupnumber); 137int del_groupchat(Group_Chats *g_c, int groupnumber);
128 138
129/* Copy the name of peernumber who is in groupnumber to name. 139/* Copy the name of peernumber who is in groupnumber to name.
130 * name must be at least MAX_NICK_BYTES long. 140 * name must be at least MAX_NAME_LENGTH long.
131 * 141 *
132 * return length of name if success 142 * return length of name if success
133 * return -1 if failure 143 * return -1 if failure
134 */ 144 */
135int temp_c_m_group_peername(const Group_Chats *g_c, int groupnumber, int peernumber, uint8_t *name); 145int group_peername(const Group_Chats *g_c, int groupnumber, int peernumber, uint8_t *name);
136 146
137/* invite friendnumber to groupnumber 147/* invite friendnumber to groupnumber
138 * return 0 on success 148 * return 0 on success
139 * return -1 on failure 149 * return -1 on failure
140 */ 150 */
141int temp_c_invite_friend(Group_Chats *g_c, int32_t friendnumber, int groupnumber); 151int invite_friend(Group_Chats *g_c, int32_t friendnumber, int groupnumber);
142 152
143/* Join a group (you need to have been invited first.) 153/* Join a group (you need to have been invited first.)
144 * 154 *
145 * returns group number on success 155 * returns group number on success
146 * returns -1 on failure. 156 * returns -1 on failure.
147 */ 157 */
148int temp_c_join_groupchat(Group_Chats *g_c, int32_t friendnumber, const uint8_t *friend_group_public_key); 158int join_groupchat(Group_Chats *g_c, int32_t friendnumber, uint8_t *data, uint16_t length);
149 159
150/* send a group message 160/* send a group message
151 * return 0 on success 161 * return 0 on success
152 * return -1 on failure 162 * return -1 on failure
153 */ 163 */
154int temp_c_group_message_send(const Group_Chats *g_c, int groupnumber, const uint8_t *message, uint32_t length); 164int group_message_send(const Group_Chats *g_c, int groupnumber, const uint8_t *message, uint32_t length);
155 165
156/* send a group action 166/* send a group action
157 * return 0 on success 167 * return 0 on success
158 * return -1 on failure 168 * return -1 on failure
159 */ 169 */
160int temp_c_group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint32_t length); 170int group_action_send(const Group_Chats *g_c, int groupnumber, const uint8_t *action, uint32_t length);
161 171
162/* Return the number of peers in the group chat on success. 172/* Return the number of peers in the group chat on success.
163 * return -1 on failure 173 * return -1 on failure
164 */ 174 */
165int temp_c_group_number_peers(const Group_Chats *g_c, int groupnumber); 175int group_number_peers(const Group_Chats *g_c, int groupnumber);
166 176
167/* List all the peers in the group chat. 177/* List all the peers in the group chat.
168 * 178 *
169 * Copies the names of the peers to the name[length][MAX_NICK_BYTES] array. 179 * Copies the names of the peers to the name[length][MAX_NAME_LENGTH] array.
170 * 180 *
171 * Copies the lengths of the names to lengths[length] 181 * Copies the lengths of the names to lengths[length]
172 * 182 *
@@ -174,7 +184,7 @@ int temp_c_group_number_peers(const Group_Chats *g_c, int groupnumber);
174 * 184 *
175 * return -1 on failure. 185 * return -1 on failure.
176 */ 186 */
177int temp_c_group_names(const Group_Chats *g_c, int groupnumber, uint8_t names[][MAX_NICK_BYTES], uint16_t lengths[], 187int group_names(const Group_Chats *g_c, int groupnumber, uint8_t names[][MAX_NAME_LENGTH], uint16_t lengths[],
178 uint16_t length); 188 uint16_t length);
179 189
180/* Create new groupchat instance. */ 190/* Create new groupchat instance. */
diff --git a/toxcore/network.h b/toxcore/network.h
index b42bfbf4..2c090aef 100644
--- a/toxcore/network.h
+++ b/toxcore/network.h
@@ -134,8 +134,7 @@ typedef int sock_t;
134#define TCP_INET6 (AF_INET6 + 3) 134#define TCP_INET6 (AF_INET6 + 3)
135#define TCP_FAMILY (AF_INET6 + 4) 135#define TCP_FAMILY (AF_INET6 + 4)
136 136
137typedef union 137typedef union {
138{
139 uint8_t uint8[4]; 138 uint8_t uint8[4];
140 uint16_t uint16[2]; 139 uint16_t uint16[2];
141 uint32_t uint32; 140 uint32_t uint32;
@@ -143,8 +142,7 @@ typedef union
143} 142}
144IP4; 143IP4;
145 144
146typedef union 145typedef union {
147{
148 uint8_t uint8[16]; 146 uint8_t uint8[16];
149 uint16_t uint16[8]; 147 uint16_t uint16[8];
150 uint32_t uint32[4]; 148 uint32_t uint32[4];
@@ -153,8 +151,7 @@ typedef union
153} 151}
154IP6; 152IP6;
155 153
156typedef struct 154typedef struct {
157{
158 uint8_t family; 155 uint8_t family;
159 union { 156 union {
160 IP4 ip4; 157 IP4 ip4;
@@ -163,8 +160,7 @@ typedef struct
163} 160}
164IP; 161IP;
165 162
166typedef struct 163typedef struct {
167{
168 IP ip; 164 IP ip;
169 uint16_t port; 165 uint16_t port;
170} 166}