From 76e897b90794cd1cde6b0a2f79c70104ca6c98f5 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 17 Oct 2013 13:05:52 +0000 Subject: - multiple fixes --- src/mesh/Makefile.am | 8 ++-- src/mesh/gnunet-service-mesh_connection.c | 64 +++++++++++++------------------ src/mesh/gnunet-service-mesh_connection.h | 21 ++-------- src/mesh/gnunet-service-mesh_peer.c | 9 ++--- src/mesh/gnunet-service-mesh_tunnel.c | 4 +- src/mesh/mesh_common.c | 11 ++---- src/mesh/test_mesh.conf | 8 ++++ 7 files changed, 50 insertions(+), 75 deletions(-) (limited to 'src/mesh') diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index df1c74c87..3c71f4792 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am @@ -102,15 +102,15 @@ if LINUX endif gnunet_service_mesh_enc_SOURCES = \ - gnunet-service-mesh-enc.c \ gnunet-service-mesh_tunnel.c \ - gnunet-service-mesh_channel.c \ gnunet-service-mesh_connection.c \ + gnunet-service-mesh_channel.c \ + gnunet-service-mesh_local.c \ gnunet-service-mesh_peer.c \ gnunet-service-mesh_dht.c \ - gnunet-service-mesh_local.c \ mesh_path.c \ - mesh_common.c + mesh_common.c \ + gnunet-service-mesh-enc.c gnunet_service_mesh_enc_CFLAGS = $(AM_CFLAGS) gnunet_service_mesh_enc_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ diff --git a/src/mesh/gnunet-service-mesh_connection.c b/src/mesh/gnunet-service-mesh_connection.c index 5ca287cb1..3197255ef 100644 --- a/src/mesh/gnunet-service-mesh_connection.c +++ b/src/mesh/gnunet-service-mesh_connection.c @@ -409,8 +409,7 @@ message_sent (void *cls, /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ switch (type) { - case GNUNET_MESSAGE_TYPE_MESH_FWD: - case GNUNET_MESSAGE_TYPE_MESH_BCK: + case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: fc->last_pid_sent++; LOG (GNUNET_ERROR_TYPE_DEBUG, "! accounting pid %u\n", fc->last_pid_sent); // send_ack (c, ch, fwd); @@ -1309,23 +1308,23 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, * * @param peer Peer identity this notification is about. * @param message Encrypted message. - * @param fwd Is this FWD traffic? GNUNET_YES : GNUNET_NO; * * @return GNUNET_OK to keep the connection open, * GNUNET_SYSERR to close it (signal serious error) */ static int handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MESH_Encrypted *msg, - int fwd) + const struct GNUNET_MESH_Encrypted *msg) { struct MeshConnection *c; struct MeshPeer *neighbor; struct MeshFlowControl *fc; + GNUNET_PEER_Id peer_id; uint32_t pid; uint32_t ttl; uint16_t type; size_t size; + int fwd; /* Check size */ size = ntohs (msg->header.size); @@ -1350,15 +1349,27 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, return GNUNET_OK; } - fc = fwd ? &c->bck_fc : &c->fwd_fc; - /* Check if origin is as expected */ - neighbor = get_hop (c, !fwd); - if (GNUNET_PEER_search (peer) != GMP_get_short_id (neighbor)) + neighbor = get_prev_hop (c); + peer_id = GNUNET_PEER_search (peer); + if (peer_id == GMP_get_short_id (neighbor)) { - GNUNET_break_op (0); - return GNUNET_OK; + fwd = GNUNET_YES; + } + else + { + neighbor = get_next_hop (c); + if (peer_id == GMP_get_short_id (neighbor)) + { + fwd = GNUNET_NO; + } + else + { + GNUNET_break_op (0); + return GNUNET_OK; + } } + fc = fwd ? &c->bck_fc : &c->fwd_fc; /* Check PID */ pid = ntohl (msg->pid); @@ -1421,7 +1432,7 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, /** - * Core handler for mesh network traffic going orig->dest. + * Core handler for encrypted mesh network traffic (channel mgmt, data). * * @param cls Closure (unused). * @param message Message received. @@ -1431,31 +1442,11 @@ handle_mesh_encrypted (const struct GNUNET_PeerIdentity *peer, * GNUNET_SYSERR to close it (signal serious error) */ int -GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) -{ - return handle_mesh_encrypted (peer, - (struct GNUNET_MESH_Encrypted *)message, - GNUNET_YES); -} - -/** - * Core handler for mesh network traffic going dest->orig. - * - * @param cls Closure (unused). - * @param message Message received. - * @param peer Peer who sent the message. - * - * @return GNUNET_OK to keep the connection open, - * GNUNET_SYSERR to close it (signal serious error) - */ -int -GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message) +GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message) { return handle_mesh_encrypted (peer, - (struct GNUNET_MESH_Encrypted *)message, - GNUNET_NO); + (struct GNUNET_MESH_Encrypted *)message); } @@ -2118,8 +2109,7 @@ GMC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, struct GNUNET_MESH_ConnectionBroken *bmsg; uint32_t ttl; - case GNUNET_MESSAGE_TYPE_MESH_FWD: - case GNUNET_MESSAGE_TYPE_MESH_BCK: + case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: emsg = (struct GNUNET_MESH_Encrypted *) data; ttl = ntohl (emsg->ttl); if (0 == ttl) diff --git a/src/mesh/gnunet-service-mesh_connection.h b/src/mesh/gnunet-service-mesh_connection.h index bdfaaf988..3fecf3b63 100644 --- a/src/mesh/gnunet-service-mesh_connection.h +++ b/src/mesh/gnunet-service-mesh_connection.h @@ -136,7 +136,7 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_MessageHeader *message); /** - * Core handler for mesh network traffic going orig->dest. + * Core handler for encrypted mesh network traffic (channel mgmt, data). * * @param cls Closure (unused). * @param message Message received. @@ -146,23 +146,8 @@ GMC_handle_destroy (void *cls, const struct GNUNET_PeerIdentity *peer, * GNUNET_SYSERR to close it (signal serious error) */ int -GMC_handle_fwd (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message); - - -/** - * Core handler for mesh network traffic going dest->orig. - * - * @param cls Closure (unused). - * @param message Message received. - * @param peer Peer who sent the message. - * - * @return GNUNET_OK to keep the connection open, - * GNUNET_SYSERR to close it (signal serious error) - */ -int -GMC_handle_bck (void *cls, const struct GNUNET_PeerIdentity *peer, - const struct GNUNET_MessageHeader *message); +GMC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, + const struct GNUNET_MessageHeader *message); /** * Core handler for mesh network traffic point-to-point acks. diff --git a/src/mesh/gnunet-service-mesh_peer.c b/src/mesh/gnunet-service-mesh_peer.c index ff0d43813..515c4b4f0 100644 --- a/src/mesh/gnunet-service-mesh_peer.c +++ b/src/mesh/gnunet-service-mesh_peer.c @@ -332,8 +332,7 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { sizeof (struct GNUNET_MESH_ACK)}, {&GMC_handle_poll, GNUNET_MESSAGE_TYPE_MESH_POLL, sizeof (struct GNUNET_MESH_Poll)}, - {&GMC_handle_fwd, GNUNET_MESSAGE_TYPE_MESH_FWD, 0}, - {&GMC_handle_bck, GNUNET_MESSAGE_TYPE_MESH_BCK, 0}, + {&GMC_handle_encrypted, GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED, 0}, {NULL, 0, 0} }; @@ -774,8 +773,7 @@ queue_destroy (struct MeshPeerQueue *queue, int clear_cls) case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: LOG (GNUNET_ERROR_TYPE_INFO, "destroying a DESTROY message\n"); /* fall through */ - case GNUNET_MESSAGE_TYPE_MESH_FWD: - case GNUNET_MESSAGE_TYPE_MESH_BCK: + case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: case GNUNET_MESSAGE_TYPE_MESH_ACK: case GNUNET_MESSAGE_TYPE_MESH_POLL: case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_ACK: @@ -872,8 +870,7 @@ queue_send (void *cls, size_t size, void *buf) case GNUNET_MESSAGE_TYPE_MESH_TUNNEL_DESTROY: case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_DESTROY: case GNUNET_MESSAGE_TYPE_MESH_CONNECTION_BROKEN: - case GNUNET_MESSAGE_TYPE_MESH_FWD: - case GNUNET_MESSAGE_TYPE_MESH_BCK: + case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: case GNUNET_MESSAGE_TYPE_MESH_ACK: case GNUNET_MESSAGE_TYPE_MESH_POLL: LOG (GNUNET_ERROR_TYPE_DEBUG, diff --git a/src/mesh/gnunet-service-mesh_tunnel.c b/src/mesh/gnunet-service-mesh_tunnel.c index a5220a04f..e2cf7db17 100644 --- a/src/mesh/gnunet-service-mesh_tunnel.c +++ b/src/mesh/gnunet-service-mesh_tunnel.c @@ -1199,10 +1199,10 @@ GMT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, type = ntohs (message->type); switch (type) { - case GNUNET_MESSAGE_TYPE_MESH_FWD: - case GNUNET_MESSAGE_TYPE_MESH_BCK: + case GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED: case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_CREATE: case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY: + case GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK: msg->cid = *GMC_get_id (c); msg->ttl = htonl (default_ttl); break; diff --git a/src/mesh/mesh_common.c b/src/mesh/mesh_common.c index 1089e8edc..90f2e5299 100644 --- a/src/mesh/mesh_common.c +++ b/src/mesh/mesh_common.c @@ -146,19 +146,14 @@ GNUNET_MESH_DEBUG_M2S (uint16_t m) case 274: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_DESTROY"; /** - * Confirm the creation of a channel + * Confirm the creation of a channel. */ case 275: return "GNUNET_MESSAGE_TYPE_MESH_CHANNEL_ACK"; /** - * Ask the mesh service to create a new tunnel - */ - case 280: return "GNUNET_MESSAGE_TYPE_MESH_FWD"; - - /** - * Ask the mesh service to destroy a tunnel + * Encrypted payload. */ - case 281: return "GNUNET_MESSAGE_TYPE_MESH_BCK"; + case 280: return "GNUNET_MESSAGE_TYPE_MESH_ENCRYPTED"; /** * Local payload traffic diff --git a/src/mesh/test_mesh.conf b/src/mesh/test_mesh.conf index 7d04cd97d..e7d265bea 100644 --- a/src/mesh/test_mesh.conf +++ b/src/mesh/test_mesh.conf @@ -79,3 +79,11 @@ AUTOSTART = NO [consensus] AUTOSTART = NO + +[nat] +# Allow running on systems with only loopback? +RETURN_LOCAL_ADDRESSES = YES +# Disable redundant addresses... +DISABLEV6 = YES +USE_LOCALADDR = YES + -- cgit v1.2.3