From: Bart Polot Date: Fri, 20 Jul 2012 17:59:58 +0000 (+0000) Subject: - fixes, new message X-Git-Tag: initial-import-from-subversion-38251~12398 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=7f2aed62fe8506e0f7a2f551875f7eb16326e9ad;p=oweals%2Fgnunet.git - fixes, new message --- diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 8d4f70e34..4a323b7f7 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -1966,6 +1966,13 @@ send_message (const struct GNUNET_MessageHeader *message, info->mesh_data = GNUNET_malloc (sizeof (struct MeshData)); info->mesh_data->data = GNUNET_malloc (size); memcpy (info->mesh_data->data, message, size); + if (ntohs(message->type) == GNUNET_MESSAGE_TYPE_MESH_UNICAST) + { + struct GNUNET_MESH_Unicast *m; + + m = (struct GNUNET_MESH_Unicast *) info->mesh_data->data; + m->ttl--; + } info->mesh_data->data_len = size; info->mesh_data->reference_counter = GNUNET_malloc (sizeof (unsigned int)); *info->mesh_data->reference_counter = 1; @@ -3958,7 +3965,8 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, { struct GNUNET_MESH_Unicast *msg; struct MeshTunnel *t; - GNUNET_PEER_Id pid; + uint32_t pid; + uint32_t ttl; size_t size; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got a unicast packet from %s\n", @@ -4005,6 +4013,14 @@ handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, send_subscribed_clients (message, (struct GNUNET_MessageHeader *) &msg[1]); return GNUNET_OK; } + ttl = ntohl (msg->ttl); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " ttl: %u\n", ttl); + if (ttl == 0) + { + /* FIXME: ttl is 0, log dropping */ + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n"); + return GNUNET_OK; + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " not for us, retransmitting...\n"); send_message (message, tree_get_first_hop (t->tree, pid), t); diff --git a/src/mesh/mesh_protocol.h b/src/mesh/mesh_protocol.h index f01cb7d98..c09efe669 100644 --- a/src/mesh/mesh_protocol.h +++ b/src/mesh/mesh_protocol.h @@ -175,6 +175,36 @@ struct GNUNET_MESH_ToOrigin }; +/** + * Message to acknowledte mesh data traffic. + */ +struct GNUNET_MESH_ACK +{ + /** + * Type: GNUNET_MESSAGE_TYPE_MESH_ACK + */ + struct GNUNET_MessageHeader header; + + /** + * TID of the tunnel + */ + uint32_t tid GNUNET_PACKED; + + /** + * OID of the tunnel + */ + struct GNUNET_PeerIdentity oid; + + /** + * Sender of the message. + */ + struct GNUNET_PeerIdentity sender; + + /** + * Payload follows + */ +}; + /** * Message for ack'ing a path */