diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-06-15 07:15:45 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-06-15 07:15:45 +0000 |
commit | c5e809eb24fdf71bda7523d2aa3b5c077a08cb4c (patch) | |
tree | ecd470f54c304588043203505b1197f41f378e0d /src/mesh/mesh_api.c | |
parent | 1dce323f4f6bb8a9ba2d43db206386bbfe044138 (diff) | |
download | gnunet-c5e809eb24fdf71bda7523d2aa3b5c077a08cb4c.tar.gz gnunet-c5e809eb24fdf71bda7523d2aa3b5c077a08cb4c.zip |
receive the mesh-hello correctly
i.e. nbo
Diffstat (limited to 'src/mesh/mesh_api.c')
-rw-r--r-- | src/mesh/mesh_api.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 4de75fb61..125ca0500 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -335,10 +335,10 @@ receive_hello (void *cls, | |||
335 | { | 335 | { |
336 | struct GNUNET_MESH_Handle *handle = cls; | 336 | struct GNUNET_MESH_Handle *handle = cls; |
337 | uint16_t *num = (uint16_t *) (message + 1); | 337 | uint16_t *num = (uint16_t *) (message + 1); |
338 | uint16_t *ports = num + 1; | 338 | GNUNET_MESH_ApplicationType *ports = (GNUNET_MESH_ApplicationType*) (num + 1); |
339 | unsigned int i; | 339 | unsigned int i; |
340 | 340 | ||
341 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "The peer %s tells us he supports %d application-types.\n", GNUNET_i2s(other), *num); | 341 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "The peer %s tells us he supports %d application-types.\n", GNUNET_i2s(other), ntohs(*num)); |
342 | 342 | ||
343 | struct peer_list_element *element = handle->connected_peers.head; | 343 | struct peer_list_element *element = handle->connected_peers.head; |
344 | while (element != NULL) | 344 | while (element != NULL) |
@@ -349,18 +349,28 @@ receive_hello (void *cls, | |||
349 | element = element->next; | 349 | element = element->next; |
350 | } | 350 | } |
351 | 351 | ||
352 | for (i = 0; i < *num; i++) | 352 | GNUNET_assert(NULL != element); |
353 | |||
354 | for (i = 0; i < ntohs(*num); i++) | ||
353 | { | 355 | { |
356 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "The peer %s newly supports the application-type %d\n", GNUNET_i2s(other), ntohs(ports[i])); | ||
357 | if (GNUNET_APPLICATION_TYPE_END == ntohs(ports[i])) continue; | ||
354 | struct type_list_element* new_type = GNUNET_malloc(sizeof *new_type); | 358 | struct type_list_element* new_type = GNUNET_malloc(sizeof *new_type); |
355 | new_type->type = (GNUNET_MESH_ApplicationType)ntohs (ports[i]); | 359 | new_type->type = (GNUNET_MESH_ApplicationType)ntohs (ports[i]); |
356 | GNUNET_CONTAINER_DLL_insert(element->type_head, element->type_tail, new_type); | 360 | GNUNET_CONTAINER_DLL_insert(element->type_head, element->type_tail, new_type); |
357 | } | 361 | } |
358 | 362 | ||
363 | struct type_list_element *type; | ||
364 | for (type = element->type_head; type != NULL; type = type->next) | ||
365 | { | ||
366 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "The peer %s supports the application-type %d\n", GNUNET_i2s(other), type->type); | ||
367 | } | ||
368 | |||
359 | struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head; | 369 | struct tunnel_list_element *tunnel = handle->pending_by_type_tunnels.head; |
360 | while (tunnel != NULL) | 370 | while (tunnel != NULL) |
361 | { | 371 | { |
362 | struct tunnel_list_element *next = tunnel->next; | 372 | struct tunnel_list_element *next = tunnel->next; |
363 | for (i = 0; i < *num; i++) | 373 | for (i = 0; i < ntohs(*num); i++) |
364 | { | 374 | { |
365 | if (ntohs (ports[i]) == tunnel->tunnel.application_type) | 375 | if (ntohs (ports[i]) == tunnel->tunnel.application_type) |
366 | { | 376 | { |