diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-05-10 10:18:34 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-05-10 10:18:34 +0000 |
commit | 914ffe0165ed4456c676c76a4231cb8e84d6705b (patch) | |
tree | 692a4493031721cdf677f74ee26165b9da48195d | |
parent | 6d7655f42cbec2163209ff6b445e1d1f96f3b719 (diff) | |
download | gnunet-914ffe0165ed4456c676c76a4231cb8e84d6705b.tar.gz gnunet-914ffe0165ed4456c676c76a4231cb8e84d6705b.zip |
- adapt path keepalive to unicast
-rw-r--r-- | src/mesh/gnunet-service-mesh-new.c | 62 |
1 files changed, 11 insertions, 51 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c index f0583fbd4..9578dee98 100644 --- a/src/mesh/gnunet-service-mesh-new.c +++ b/src/mesh/gnunet-service-mesh-new.c | |||
@@ -2154,6 +2154,7 @@ tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p) | |||
2154 | GNUNET_break (0); | 2154 | GNUNET_break (0); |
2155 | return; | 2155 | return; |
2156 | } | 2156 | } |
2157 | |||
2157 | if (i < p->length - 1) | 2158 | if (i < p->length - 1) |
2158 | t->next_hop = p->peers[i + 1]; | 2159 | t->next_hop = p->peers[i + 1]; |
2159 | else | 2160 | else |
@@ -2162,9 +2163,13 @@ tunnel_use_path (struct MeshTunnel *t, struct MeshPeerPath *p) | |||
2162 | t->prev_hop = p->peers[i - 1]; | 2163 | t->prev_hop = p->peers[i - 1]; |
2163 | else | 2164 | else |
2164 | t->prev_hop = 0; | 2165 | t->prev_hop = 0; |
2166 | |||
2165 | if (NULL != t->path) | 2167 | if (NULL != t->path) |
2166 | path_destroy (t->path); | 2168 | path_destroy (t->path); |
2167 | t->path = path_duplicate (p); | 2169 | t->path = path_duplicate (p); |
2170 | if (GNUNET_SCHEDULER_NO_TASK == t->path_refresh_task) | ||
2171 | t->path_refresh_task = | ||
2172 | GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t); | ||
2168 | } | 2173 | } |
2169 | 2174 | ||
2170 | 2175 | ||
@@ -3117,51 +3122,6 @@ send_core_path_create (void *cls, size_t size, void *buf) | |||
3117 | 3122 | ||
3118 | 3123 | ||
3119 | /** | 3124 | /** |
3120 | * Fill the core buffer | ||
3121 | * | ||
3122 | * @param cls closure (data itself) | ||
3123 | * @param size number of bytes available in buf | ||
3124 | * @param buf where the callee should write the message | ||
3125 | * | ||
3126 | * @return number of bytes written to buf | ||
3127 | */ | ||
3128 | static size_t | ||
3129 | send_core_data_multicast (void *cls, size_t size, void *buf) | ||
3130 | { | ||
3131 | struct MeshTransmissionDescriptor *info = cls; | ||
3132 | size_t total_size; | ||
3133 | |||
3134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Multicast callback.\n"); | ||
3135 | GNUNET_assert (NULL != info); | ||
3136 | GNUNET_assert (NULL != info->peer); | ||
3137 | total_size = info->data_len; | ||
3138 | GNUNET_assert (total_size < GNUNET_SERVER_MAX_MESSAGE_SIZE); | ||
3139 | |||
3140 | if (total_size > size) | ||
3141 | { | ||
3142 | GNUNET_break (0); | ||
3143 | return 0; | ||
3144 | } | ||
3145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " copying data...\n"); | ||
3146 | memcpy (buf, info->data, total_size); | ||
3147 | #if MESH_DEBUG | ||
3148 | { | ||
3149 | struct GNUNET_MessageHeader *mh; | ||
3150 | |||
3151 | mh = buf; | ||
3152 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " type %s\n", | ||
3153 | GNUNET_MESH_DEBUG_M2S (ntohs (mh->type))); | ||
3154 | } | ||
3155 | #endif | ||
3156 | GNUNET_free (info->data); | ||
3157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "freeing info...\n"); | ||
3158 | GNUNET_free (info); | ||
3159 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "return %u\n", total_size); | ||
3160 | return total_size; | ||
3161 | } | ||
3162 | |||
3163 | |||
3164 | /** | ||
3165 | * Creates a path ack message in buf and frees all unused resources. | 3125 | * Creates a path ack message in buf and frees all unused resources. |
3166 | * | 3126 | * |
3167 | * @param cls closure (MeshTransmissionDescriptor) | 3127 | * @param cls closure (MeshTransmissionDescriptor) |
@@ -3417,6 +3377,7 @@ queue_send (void *cls, size_t size, void *buf) | |||
3417 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: | 3377 | case GNUNET_MESSAGE_TYPE_MESH_PATH_BROKEN: |
3418 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: | 3378 | case GNUNET_MESSAGE_TYPE_MESH_PATH_DESTROY: |
3419 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: | 3379 | case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: |
3380 | case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE: | ||
3420 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3381 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3421 | "********* raw: %s\n", | 3382 | "********* raw: %s\n", |
3422 | GNUNET_MESH_DEBUG_M2S (queue->type)); | 3383 | GNUNET_MESH_DEBUG_M2S (queue->type)); |
@@ -3445,10 +3406,6 @@ queue_send (void *cls, size_t size, void *buf) | |||
3445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n"); | 3406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path ack\n"); |
3446 | data_size = send_core_path_ack (queue->cls, size, buf); | 3407 | data_size = send_core_path_ack (queue->cls, size, buf); |
3447 | break; | 3408 | break; |
3448 | case GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE: | ||
3449 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "********* path keepalive\n"); | ||
3450 | data_size = send_core_data_multicast (queue->cls, size, buf); | ||
3451 | break; | ||
3452 | default: | 3409 | default: |
3453 | GNUNET_break (0); | 3410 | GNUNET_break (0); |
3454 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3411 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -4496,6 +4453,7 @@ static void | |||
4496 | path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 4453 | path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
4497 | { | 4454 | { |
4498 | struct MeshTunnel *t = cls; | 4455 | struct MeshTunnel *t = cls; |
4456 | struct GNUNET_PeerIdentity id; | ||
4499 | struct GNUNET_MESH_TunnelKeepAlive *msg; | 4457 | struct GNUNET_MESH_TunnelKeepAlive *msg; |
4500 | size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); | 4458 | size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); |
4501 | char cbuf[size]; | 4459 | char cbuf[size]; |
@@ -4511,14 +4469,16 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4511 | 4469 | ||
4512 | msg = (struct GNUNET_MESH_TunnelKeepAlive *) cbuf; | 4470 | msg = (struct GNUNET_MESH_TunnelKeepAlive *) cbuf; |
4513 | msg->header.size = htons (size); | 4471 | msg->header.size = htons (size); |
4472 | // FIXME change to tunnel keepalive | ||
4514 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE); | 4473 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE); |
4515 | msg->oid = my_full_id; | 4474 | msg->oid = my_full_id; |
4516 | msg->tid = htonl (t->id.tid); | 4475 | msg->tid = htonl (t->id.tid); |
4517 | /* FIXME tunnel_send_multicast (t, &msg->header); */ | 4476 | GNUNET_PEER_resolve (t->next_hop, &id); |
4477 | send_prebuilt_message (&msg->header, &id, t); | ||
4518 | 4478 | ||
4519 | t->path_refresh_task = | 4479 | t->path_refresh_task = |
4520 | GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t); | 4480 | GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t); |
4521 | tunnel_reset_timeout(t); | 4481 | tunnel_reset_timeout (t); |
4522 | } | 4482 | } |
4523 | 4483 | ||
4524 | 4484 | ||