diff options
author | Bart Polot <bart@net.in.tum.de> | 2011-08-04 15:29:25 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2011-08-04 15:29:25 +0000 |
commit | a7463441f1251ec3480d60c7b7816f24104a9b75 (patch) | |
tree | 3ac4d905c23e3811db5071534e6b4a2a8b6f2405 /src | |
parent | ceb6ebc2337fff55f9e01e4e3c5470684ce2319a (diff) | |
download | gnunet-a7463441f1251ec3480d60c7b7816f24104a9b75.tar.gz gnunet-a7463441f1251ec3480d60c7b7816f24104a9b75.zip |
Added handler for Path ACK messages
Diffstat (limited to 'src')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 75 | ||||
-rw-r--r-- | src/mesh/mesh_protocol.h | 5 |
2 files changed, 80 insertions, 0 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 02a78244f..f9961ffc0 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -1450,6 +1450,79 @@ handle_mesh_data_to_orig (void *cls, | |||
1450 | 1450 | ||
1451 | 1451 | ||
1452 | /** | 1452 | /** |
1453 | * Core handler for path ACKs | ||
1454 | * | ||
1455 | * @param cls closure | ||
1456 | * @param message message | ||
1457 | * @param peer peer identity this notification is about | ||
1458 | * @param atsi performance data | ||
1459 | * @return GNUNET_OK to keep the connection open, | ||
1460 | * GNUNET_SYSERR to close it (signal serious error) | ||
1461 | */ | ||
1462 | static int | ||
1463 | handle_mesh_path_ack (void *cls, | ||
1464 | const struct GNUNET_PeerIdentity *peer, | ||
1465 | const struct GNUNET_MessageHeader *message, | ||
1466 | const struct GNUNET_TRANSPORT_ATS_Information | ||
1467 | *atsi) | ||
1468 | { | ||
1469 | struct GNUNET_MESH_PathACK *msg; | ||
1470 | struct GNUNET_PeerIdentity id; | ||
1471 | struct MeshTunnel *t; | ||
1472 | struct MeshPeerInfo *peer_info; | ||
1473 | |||
1474 | msg = (struct GNUNET_MESH_PathACK *) message; | ||
1475 | t = retrieve_tunnel(&msg->oid, msg->tid); | ||
1476 | if (NULL == t) { | ||
1477 | /* TODO notify that we don't know the tunnel */ | ||
1478 | return GNUNET_OK; | ||
1479 | } | ||
1480 | |||
1481 | /* Message for us? */ | ||
1482 | if (GNUNET_PEER_search(&msg->oid) == myid) { | ||
1483 | struct GNUNET_MESH_PeerControl pc; | ||
1484 | if (NULL == t->client) { | ||
1485 | GNUNET_break(0); | ||
1486 | return GNUNET_OK; | ||
1487 | } | ||
1488 | peer_info = get_peer_info(&msg->peer_id); | ||
1489 | if (NULL == peer_info) { | ||
1490 | GNUNET_break_op(0); | ||
1491 | return GNUNET_OK; | ||
1492 | } | ||
1493 | peer_info->state = MESH_PEER_READY; | ||
1494 | pc.header.type = htons(GNUNET_MESSAGE_TYPE_MESH_LOCAL_PEER_CONNECTED); | ||
1495 | pc.header.size = htons(sizeof(struct GNUNET_MESH_PeerControl)); | ||
1496 | pc.tunnel_id = htonl(t->local_tid); | ||
1497 | GNUNET_PEER_resolve(peer_info->id, &pc.peer); | ||
1498 | GNUNET_SERVER_notification_context_unicast(nc, | ||
1499 | t->client->handle, | ||
1500 | &pc.header, | ||
1501 | GNUNET_NO); | ||
1502 | return GNUNET_OK; | ||
1503 | } | ||
1504 | |||
1505 | peer_info = get_peer_info(&msg->oid); | ||
1506 | if (NULL == peer_info) { | ||
1507 | /* If we know the tunnel, we should DEFINITELY know the peer */ | ||
1508 | GNUNET_break(0); | ||
1509 | return GNUNET_OK; | ||
1510 | } | ||
1511 | GNUNET_PEER_resolve(get_first_hop(peer_info->path), &id); | ||
1512 | msg = GNUNET_malloc(sizeof(struct GNUNET_MESH_PathACK)); | ||
1513 | memcpy(msg, message, sizeof(struct GNUNET_MESH_PathACK)); | ||
1514 | GNUNET_CORE_notify_transmit_ready(core_handle, | ||
1515 | 0, | ||
1516 | 0, | ||
1517 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1518 | &id, | ||
1519 | sizeof(struct GNUNET_MESH_PathACK), | ||
1520 | &send_core_data_raw, | ||
1521 | msg); | ||
1522 | } | ||
1523 | |||
1524 | |||
1525 | /** | ||
1453 | * Functions to handle messages from core | 1526 | * Functions to handle messages from core |
1454 | */ | 1527 | */ |
1455 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { | 1528 | static struct GNUNET_CORE_MessageHandler core_handlers[] = { |
@@ -1457,6 +1530,8 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { | |||
1457 | {&handle_mesh_data_unicast, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN, 0}, | 1530 | {&handle_mesh_data_unicast, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_FROM_ORIGIN, 0}, |
1458 | {&handle_mesh_data_multicast, GNUNET_MESSAGE_TYPE_DATA_MULTICAST, 0}, | 1531 | {&handle_mesh_data_multicast, GNUNET_MESSAGE_TYPE_DATA_MULTICAST, 0}, |
1459 | {&handle_mesh_data_to_orig, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN, 0}, | 1532 | {&handle_mesh_data_to_orig, GNUNET_MESSAGE_TYPE_DATA_MESSAGE_TO_ORIGIN, 0}, |
1533 | {&handle_mesh_path_ack, GNUNET_MESSAGE_TYPE_PATH_ACK, | ||
1534 | sizeof(struct GNUNET_MESH_PathACK)}, | ||
1460 | {NULL, 0, 0} | 1535 | {NULL, 0, 0} |
1461 | }; | 1536 | }; |
1462 | 1537 | ||
diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h index 8868d0c66..c23e3a1a6 100644 --- a/src/mesh/mesh_protocol.h +++ b/src/mesh/mesh_protocol.h | |||
@@ -172,6 +172,11 @@ struct GNUNET_MESH_PathACK | |||
172 | */ | 172 | */ |
173 | struct GNUNET_PeerIdentity oid; | 173 | struct GNUNET_PeerIdentity oid; |
174 | 174 | ||
175 | /** | ||
176 | * ID of the endpoint | ||
177 | */ | ||
178 | struct GNUNET_PeerIdentity peer_id; | ||
179 | |||
175 | /* TODO: signature */ | 180 | /* TODO: signature */ |
176 | }; | 181 | }; |
177 | 182 | ||