aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2013-05-10 10:49:56 +0000
committerBart Polot <bart@net.in.tum.de>2013-05-10 10:49:56 +0000
commit50fb4ba813b41e436823f6fda964f2652ac4acd4 (patch)
tree498f41cc93fa0b5f884e80d209812bf2d473e12b /src
parent2310773fc8a783042345202855d7be6f88320ef9 (diff)
downloadgnunet-50fb4ba813b41e436823f6fda964f2652ac4acd4.tar.gz
gnunet-50fb4ba813b41e436823f6fda964f2652ac4acd4.zip
- change internal API to use short IDs
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh-new.c55
1 files changed, 23 insertions, 32 deletions
diff --git a/src/mesh/gnunet-service-mesh-new.c b/src/mesh/gnunet-service-mesh-new.c
index 0c3253eef..a56daf1f6 100644
--- a/src/mesh/gnunet-service-mesh-new.c
+++ b/src/mesh/gnunet-service-mesh-new.c
@@ -1430,10 +1430,11 @@ send_core_data_raw (void *cls, size_t size, void *buf)
1430 */ 1430 */
1431static void 1431static void
1432send_prebuilt_message (const struct GNUNET_MessageHeader *message, 1432send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1433 const struct GNUNET_PeerIdentity *peer, 1433 GNUNET_PEER_Id peer,
1434 struct MeshTunnel *t) 1434 struct MeshTunnel *t)
1435{ 1435{
1436 struct MeshTransmissionDescriptor *info; 1436 struct MeshTransmissionDescriptor *info;
1437 struct GNUNET_PeerIdentity id;
1437 struct MeshPeerInfo *neighbor; 1438 struct MeshPeerInfo *neighbor;
1438 struct MeshPeerPath *p; 1439 struct MeshPeerPath *p;
1439 size_t size; 1440 size_t size;
@@ -1441,6 +1442,9 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1441 1442
1442// GNUNET_TRANSPORT_try_connect(); FIXME use? 1443// GNUNET_TRANSPORT_try_connect(); FIXME use?
1443 1444
1445 if (0 == peer)
1446 return;
1447
1444 size = ntohs (message->size); 1448 size = ntohs (message->size);
1445 info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor)); 1449 info = GNUNET_malloc (sizeof (struct MeshTransmissionDescriptor));
1446 info->data = GNUNET_malloc (size); 1450 info->data = GNUNET_malloc (size);
@@ -1461,7 +1465,8 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1461 to->pid = htonl(t->bck_pid); 1465 to->pid = htonl(t->bck_pid);
1462 } 1466 }
1463 info->data_len = size; 1467 info->data_len = size;
1464 neighbor = peer_get (peer); 1468 GNUNET_PEER_resolve (peer, &id);
1469 neighbor = peer_get (&id);
1465 for (p = neighbor->path_head; NULL != p; p = p->next) 1470 for (p = neighbor->path_head; NULL != p; p = p->next)
1466 { 1471 {
1467 if (2 >= p->length) 1472 if (2 >= p->length)
@@ -1474,10 +1479,10 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1474#if MESH_DEBUG 1479#if MESH_DEBUG
1475 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1480 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1476 " %s IS NOT DIRECTLY CONNECTED\n", 1481 " %s IS NOT DIRECTLY CONNECTED\n",
1477 GNUNET_i2s(peer)); 1482 GNUNET_i2s(&id));
1478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1479 " PATHS TO %s:\n", 1484 " PATHS TO %s:\n",
1480 GNUNET_i2s(peer)); 1485 GNUNET_i2s(&id));
1481 for (p = neighbor->path_head; NULL != p; p = p->next) 1486 for (p = neighbor->path_head; NULL != p; p = p->next)
1482 { 1487 {
1483 struct GNUNET_PeerIdentity debug_id; 1488 struct GNUNET_PeerIdentity debug_id;
@@ -1498,7 +1503,7 @@ send_prebuilt_message (const struct GNUNET_MessageHeader *message,
1498 GNUNET_break (0); // FIXME sometimes fails (testing disconnect?) 1503 GNUNET_break (0); // FIXME sometimes fails (testing disconnect?)
1499 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1504 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1500 " no direct connection to %s\n", 1505 " no direct connection to %s\n",
1501 GNUNET_i2s (peer)); 1506 GNUNET_i2s (&id));
1502 GNUNET_free (info->data); 1507 GNUNET_free (info->data);
1503 GNUNET_free (info); 1508 GNUNET_free (info);
1504 return; 1509 return;
@@ -2371,7 +2376,7 @@ send_local_ack (struct MeshTunnel *t, struct MeshClient *c, uint32_t ack)
2371 * @param ack Value of the ACK. 2376 * @param ack Value of the ACK.
2372 */ 2377 */
2373static void 2378static void
2374send_ack (struct MeshTunnel *t, struct GNUNET_PeerIdentity *peer, uint32_t ack) 2379send_ack (struct MeshTunnel *t, GNUNET_PEER_Id peer, uint32_t ack)
2375{ 2380{
2376 struct GNUNET_MESH_ACK msg; 2381 struct GNUNET_MESH_ACK msg;
2377 2382
@@ -2429,7 +2434,6 @@ tunnel_send_client_fwd_ack (struct MeshTunnel *t)
2429static void 2434static void
2430tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type) 2435tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
2431{ 2436{
2432 struct GNUNET_PeerIdentity id;
2433 uint32_t ack; 2437 uint32_t ack;
2434 2438
2435 if (NULL != t->owner) 2439 if (NULL != t->owner)
@@ -2485,8 +2489,7 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
2485 } 2489 }
2486 2490
2487 t->last_fwd_ack = ack; 2491 t->last_fwd_ack = ack;
2488 GNUNET_PEER_resolve (t->prev_hop, &id); 2492 send_ack (t, t->prev_hop, ack);
2489 send_ack (t, &id, ack);
2490 debug_fwd_ack++; 2493 debug_fwd_ack++;
2491 t->force_ack = GNUNET_NO; 2494 t->force_ack = GNUNET_NO;
2492} 2495}
@@ -2500,12 +2503,10 @@ tunnel_send_fwd_ack (struct MeshTunnel *t, uint16_t type)
2500 */ 2503 */
2501static void 2504static void
2502tunnel_send_child_bck_ack (struct MeshTunnel *t, 2505tunnel_send_child_bck_ack (struct MeshTunnel *t,
2503 GNUNET_PEER_Id id) 2506 GNUNET_PEER_Id peer)
2504{ 2507{
2505 struct GNUNET_PeerIdentity peer;
2506 uint32_t ack = 0; // FIXME 2508 uint32_t ack = 0; // FIXME
2507 2509
2508 GNUNET_PEER_resolve (id, &peer);
2509// ack = cinfo->bck_pid + t->bck_queue_max - t->bck_queue_n; 2510// ack = cinfo->bck_pid + t->bck_queue_max - t->bck_queue_n;
2510// 2511//
2511// if (cinfo->bck_ack == ack && GNUNET_NO == t->force_ack) 2512// if (cinfo->bck_ack == ack && GNUNET_NO == t->force_ack)
@@ -2519,7 +2520,7 @@ tunnel_send_child_bck_ack (struct MeshTunnel *t,
2519// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2520// GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2520// " Sending BCK ACK %u (last sent: %u)\n", 2521// " Sending BCK ACK %u (last sent: %u)\n",
2521// ack, cinfo->bck_ack); 2522// ack, cinfo->bck_ack);
2522 send_ack (t, &peer, ack); 2523 send_ack (t, peer, ack);
2523} 2524}
2524 2525
2525 2526
@@ -2698,9 +2699,9 @@ tunnel_send_destroy (struct MeshTunnel *t)
2698 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " child: %u\n", t->next_hop); 2699 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " child: %u\n", t->next_hop);
2699 GNUNET_PEER_resolve (t->next_hop, &id); 2700 GNUNET_PEER_resolve (t->next_hop, &id);
2700 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2701 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2701 " sending back to %s\n", 2702 " sending forward to %s\n",
2702 GNUNET_i2s (&id)); 2703 GNUNET_i2s (&id));
2703 send_prebuilt_message (&msg.header, &id, t); 2704 send_prebuilt_message (&msg.header, t->next_hop, t);
2704 } 2705 }
2705 if (0 != t->prev_hop) 2706 if (0 != t->prev_hop)
2706 { 2707 {
@@ -2709,7 +2710,7 @@ tunnel_send_destroy (struct MeshTunnel *t)
2709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2710 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2710 " sending back to %s\n", 2711 " sending back to %s\n",
2711 GNUNET_i2s (&id)); 2712 GNUNET_i2s (&id));
2712 send_prebuilt_message (&msg.header, &id, t); 2713 send_prebuilt_message (&msg.header, t->prev_hop, t);
2713 } 2714 }
2714} 2715}
2715 2716
@@ -3809,7 +3810,7 @@ handle_mesh_path_destroy (void *cls, const struct GNUNET_PeerIdentity *peer,
3809 } 3810 }
3810 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos); 3811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " Own position: %u\n", own_pos);
3811 if (own_pos < path->length - 1) 3812 if (own_pos < path->length - 1)
3812 send_prebuilt_message (message, &pi[own_pos + 1], t); 3813 send_prebuilt_message (message, path->peers[own_pos + 1], t);
3813 else 3814 else
3814 send_client_tunnel_disconnect(t, NULL); 3815 send_client_tunnel_disconnect(t, NULL);
3815 3816
@@ -3929,7 +3930,6 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
3929 const struct GNUNET_MessageHeader *message) 3930 const struct GNUNET_MessageHeader *message)
3930{ 3931{
3931 struct GNUNET_MESH_Unicast *msg; 3932 struct GNUNET_MESH_Unicast *msg;
3932 struct GNUNET_PeerIdentity neighbor;
3933 struct MeshTunnel *t; 3933 struct MeshTunnel *t;
3934 GNUNET_PEER_Id dest_id; 3934 GNUNET_PEER_Id dest_id;
3935 uint32_t pid; 3935 uint32_t pid;
@@ -4008,8 +4008,6 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4008 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4008 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4009 " not for us, retransmitting...\n"); 4009 " not for us, retransmitting...\n");
4010 4010
4011 GNUNET_PEER_resolve (t->next_hop, &neighbor);
4012
4013/* cinfo->fwd_pid = pid; FIXME 4011/* cinfo->fwd_pid = pid; FIXME
4014 4012
4015 if (GNUNET_YES == t->nobuffer && 4013 if (GNUNET_YES == t->nobuffer &&
@@ -4020,7 +4018,7 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer,
4020 GNUNET_break_op (0); 4018 GNUNET_break_op (0);
4021 return GNUNET_OK; 4019 return GNUNET_OK;
4022 }*/ 4020 }*/
4023 send_prebuilt_message (message, &neighbor, t); 4021 send_prebuilt_message (message, t->next_hop, t);
4024 GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO); 4022 GNUNET_STATISTICS_update (stats, "# unicast forwarded", 1, GNUNET_NO);
4025 return GNUNET_OK; 4023 return GNUNET_OK;
4026} 4024}
@@ -4041,7 +4039,6 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
4041 const struct GNUNET_MessageHeader *message) 4039 const struct GNUNET_MessageHeader *message)
4042{ 4040{
4043 struct GNUNET_MESH_ToOrigin *msg; 4041 struct GNUNET_MESH_ToOrigin *msg;
4044 struct GNUNET_PeerIdentity id;
4045 struct MeshPeerInfo *peer_info; 4042 struct MeshPeerInfo *peer_info;
4046 struct MeshTunnel *t; 4043 struct MeshTunnel *t;
4047 size_t size; 4044 size_t size;
@@ -4136,8 +4133,7 @@ handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer,
4136 GNUNET_i2s (&msg->oid), ntohl(msg->tid)); 4133 GNUNET_i2s (&msg->oid), ntohl(msg->tid));
4137 return GNUNET_OK; 4134 return GNUNET_OK;
4138 } 4135 }
4139 GNUNET_PEER_resolve (t->prev_hop, &id); 4136 send_prebuilt_message (message, t->prev_hop, t);
4140 send_prebuilt_message (message, &id, t);
4141 GNUNET_STATISTICS_update (stats, "# to origin forwarded", 1, GNUNET_NO); 4137 GNUNET_STATISTICS_update (stats, "# to origin forwarded", 1, GNUNET_NO);
4142 4138
4143 return GNUNET_OK; 4139 return GNUNET_OK;
@@ -4267,7 +4263,6 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
4267 const struct GNUNET_MessageHeader *message) 4263 const struct GNUNET_MessageHeader *message)
4268{ 4264{
4269 struct GNUNET_MESH_PathACK *msg; 4265 struct GNUNET_MESH_PathACK *msg;
4270 struct GNUNET_PeerIdentity id;
4271 struct MeshPeerInfo *peer_info; 4266 struct MeshPeerInfo *peer_info;
4272 struct MeshPeerPath *p; 4267 struct MeshPeerPath *p;
4273 struct MeshTunnel *t; 4268 struct MeshTunnel *t;
@@ -4323,9 +4318,8 @@ handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
4323 4318
4324 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4325 " not for us, retransmitting...\n"); 4320 " not for us, retransmitting...\n");
4326 GNUNET_PEER_resolve (t->prev_hop, &id);
4327 peer_info = peer_get (&msg->oid); 4321 peer_info = peer_get (&msg->oid);
4328 send_prebuilt_message (message, &id, t); 4322 send_prebuilt_message (message, t->prev_hop, t);
4329 return GNUNET_OK; 4323 return GNUNET_OK;
4330} 4324}
4331 4325
@@ -4346,7 +4340,6 @@ handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
4346 const struct GNUNET_MessageHeader *message) 4340 const struct GNUNET_MessageHeader *message)
4347{ 4341{
4348 struct GNUNET_MESH_TunnelKeepAlive *msg; 4342 struct GNUNET_MESH_TunnelKeepAlive *msg;
4349 struct GNUNET_PeerIdentity id;
4350 struct MeshTunnel *t; 4343 struct MeshTunnel *t;
4351 4344
4352 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n", 4345 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a keepalive packet from %s\n",
@@ -4366,7 +4359,7 @@ handle_mesh_keepalive (void *cls, const struct GNUNET_PeerIdentity *peer,
4366 tunnel_reset_timeout (t); 4359 tunnel_reset_timeout (t);
4367 4360
4368 GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO); 4361 GNUNET_STATISTICS_update (stats, "# keepalives forwarded", 1, GNUNET_NO);
4369 send_prebuilt_message (message, NULL, t); 4362 send_prebuilt_message (message, t->next_hop, t);
4370 return GNUNET_OK; 4363 return GNUNET_OK;
4371 } 4364 }
4372 4365
@@ -4452,7 +4445,6 @@ static void
4452path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 4445path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4453{ 4446{
4454 struct MeshTunnel *t = cls; 4447 struct MeshTunnel *t = cls;
4455 struct GNUNET_PeerIdentity id;
4456 struct GNUNET_MESH_TunnelKeepAlive *msg; 4448 struct GNUNET_MESH_TunnelKeepAlive *msg;
4457 size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive); 4449 size_t size = sizeof (struct GNUNET_MESH_TunnelKeepAlive);
4458 char cbuf[size]; 4450 char cbuf[size];
@@ -4472,8 +4464,7 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4472 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE); 4464 msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_PATH_KEEPALIVE);
4473 msg->oid = my_full_id; 4465 msg->oid = my_full_id;
4474 msg->tid = htonl (t->id.tid); 4466 msg->tid = htonl (t->id.tid);
4475 GNUNET_PEER_resolve (t->next_hop, &id); 4467 send_prebuilt_message (&msg->header, t->next_hop, t);
4476 send_prebuilt_message (&msg->header, &id, t);
4477 4468
4478 t->path_refresh_task = 4469 t->path_refresh_task =
4479 GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t); 4470 GNUNET_SCHEDULER_add_delayed (refresh_path_time, &path_refresh, t);