aboutsummaryrefslogtreecommitdiff
path: root/src/mesh
diff options
context:
space:
mode:
authorPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:44 +0000
committerPhilipp Tölke <toelke@in.tum.de>2011-06-15 07:15:44 +0000
commit6b1ec4f8b29779514a8001f7b46e79af4eb00aba (patch)
treed6f28e2fa3997c3068a9f2c31528d6a7f7a10972 /src/mesh
parent89ee30fc0e5b3091905e2cf4bf02bb5419b95152 (diff)
downloadgnunet-6b1ec4f8b29779514a8001f7b46e79af4eb00aba.tar.gz
gnunet-6b1ec4f8b29779514a8001f7b46e79af4eb00aba.zip
allow more than one mesh-hello-packet to persist
Diffstat (limited to 'src/mesh')
-rw-r--r--src/mesh/mesh_api.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c
index 3e480d250..9c822eae5 100644
--- a/src/mesh/mesh_api.c
+++ b/src/mesh/mesh_api.c
@@ -88,15 +88,18 @@ struct tunnel_list
88 struct tunnel_list_element *head, *tail; 88 struct tunnel_list_element *head, *tail;
89}; 89};
90 90
91struct type_list_element
92{
93 GNUNET_MESH_ApplicationType type;
94 struct type_list_element *next, *prev;
95};
96
91struct peer_list_element 97struct peer_list_element
92{ 98{
93 struct GNUNET_PeerIdentity peer; 99 struct GNUNET_PeerIdentity peer;
94 100
95 /* how many Message-Types can this peer receive */ 101 /* list of application-types */
96 unsigned int num_types; 102 struct type_list_element *type_head, *type_tail;
97
98 /* array of message-types */
99 GNUNET_MESH_ApplicationType *types;
100 103
101 struct GNUNET_TRANSPORT_ATS_Information atsi; 104 struct GNUNET_TRANSPORT_ATS_Information atsi;
102 struct peer_list_element *next, *prev; 105 struct peer_list_element *next, *prev;
@@ -280,7 +283,12 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
280 { 283 {
281 GNUNET_CONTAINER_DLL_remove (handle->connected_peers.head, 284 GNUNET_CONTAINER_DLL_remove (handle->connected_peers.head,
282 handle->connected_peers.tail, element); 285 handle->connected_peers.tail, element);
283 GNUNET_free_non_null(element->types); 286 while (element->type_head != NULL)
287 {
288 struct type_list_element* tail = element->type_tail;
289 GNUNET_CONTAINER_DLL_remove(element->type_head, element->type_tail, tail);
290 GNUNET_free(tail);
291 }
284 GNUNET_free (element); 292 GNUNET_free (element);
285 } 293 }
286 294
@@ -341,12 +349,12 @@ receive_hello (void *cls,
341 element = element->next; 349 element = element->next;
342 } 350 }
343 351
344 /* TODO: add, not replace! */
345 element->num_types = *num;
346 element->types = GNUNET_malloc (*num * sizeof (GNUNET_MESH_ApplicationType));
347
348 for (i = 0; i < *num; i++) 352 for (i = 0; i < *num; i++)
349 element->types[i] = (GNUNET_MESH_ApplicationType)ntohs (ports[i]); 353 {
354 struct type_list_element* new_type = GNUNET_malloc(sizeof *new_type);
355 new_type->type = (GNUNET_MESH_ApplicationType)ntohs (ports[i]);
356 GNUNET_CONTAINER_DLL_insert(element->type_head, element->type_tail, new_type);
357 }
350 358
351 struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head; 359 struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head;
352 while (tunnel != NULL) 360 while (tunnel != NULL)
@@ -472,9 +480,9 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Handle *handle,
472 struct peer_list_element *element = handle->connected_peers.head; 480 struct peer_list_element *element = handle->connected_peers.head;
473 while (element != NULL) 481 while (element != NULL)
474 { 482 {
475 unsigned int i; 483 struct type_list_element* i;
476 for (i = 0; i < element->num_types; i++) 484 for (i = element->type_head; i != NULL; i = i->next)
477 if (application_type == element->types[i]) 485 if (application_type == i->type)
478 return GNUNET_MESH_peer_request_connect_all (handle, timeout, 1, 486 return GNUNET_MESH_peer_request_connect_all (handle, timeout, 1,
479 &handle->myself, 487 &handle->myself,
480 connect_handler, 488 connect_handler,
@@ -747,7 +755,12 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle)
747 while (element != NULL) 755 while (element != NULL)
748 { 756 {
749 struct peer_list_element *next = element->next; 757 struct peer_list_element *next = element->next;
750 GNUNET_free_non_null(element->types); 758 while (element->type_head != NULL)
759 {
760 struct type_list_element* tail = element->type_tail;
761 GNUNET_CONTAINER_DLL_remove(element->type_head, element->type_tail, tail);
762 GNUNET_free(tail);
763 }
751 GNUNET_free (element); 764 GNUNET_free (element);
752 element = next; 765 element = next;
753 } 766 }