diff options
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/Makefile.am | 2 | ||||
-rw-r--r-- | src/mesh/Makefile.in | 4 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 53 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 69 | ||||
-rw-r--r-- | src/mesh/mesh_tunnel_tree.c | 12 | ||||
-rw-r--r-- | src/mesh/test_mesh.conf | 5 | ||||
-rw-r--r-- | src/mesh/test_mesh_2dtorus.c | 4 | ||||
-rw-r--r-- | src/mesh/test_mesh_api.c | 2 | ||||
-rw-r--r-- | src/mesh/test_mesh_local_1.c | 2 | ||||
-rw-r--r-- | src/mesh/test_mesh_local_2.c | 2 | ||||
-rw-r--r-- | src/mesh/test_mesh_path.conf | 2 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.c | 2 |
12 files changed, 76 insertions, 83 deletions
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index e9c0109..ac38b0d 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am @@ -41,7 +41,7 @@ libgnunetmesh_la_LIBADD = \ $(XLIB) libgnunetmesh_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 0:0:0 + -version-info 1:0:0 check_PROGRAMS = \ test_mesh_api \ diff --git a/src/mesh/Makefile.in b/src/mesh/Makefile.in index 337d6ab..1504c4b 100644 --- a/src/mesh/Makefile.in +++ b/src/mesh/Makefile.in @@ -242,6 +242,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INTLLIBS = @INTLLIBS@ INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ +JAVAPORT = @JAVAPORT@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ @@ -275,6 +276,7 @@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ +MONKEYPREFIX = @MONKEYPREFIX@ MSGFMT = @MSGFMT@ MSGFMT_015 = @MSGFMT_015@ MSGMERGE = @MSGMERGE@ @@ -426,7 +428,7 @@ libgnunetmesh_la_LIBADD = \ libgnunetmesh_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ - -version-info 0:0:0 + -version-info 1:0:0 test_mesh_api_SOURCES = \ test_mesh_api.c diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index 80848f2..36c6115 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c @@ -474,21 +474,25 @@ struct MeshClient /** * GNUNET_SCHEDULER_Task for printing a message after some operation is done * @param cls string to print - * @param tc task context + * @param success GNUNET_OK if the PUT was transmitted, + * GNUNET_NO on timeout, + * GNUNET_SYSERR on disconnect from service + * after the PUT message was transmitted + * (so we don't know if it was received or not) */ + +#if 0 static void -mesh_debug (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) +mesh_debug (void *cls, int success) { char *s = cls; - if (NULL != tc && GNUNET_SCHEDULER_REASON_SHUTDOWN == tc->reason) - { - return; - } - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s\n", s); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s (%d)\n", s, success); } #endif +#endif + /******************************************************************************/ /*********************** GLOBAL VARIABLES ****************************/ /******************************************************************************/ @@ -622,19 +626,15 @@ static int announce_application (void *cls, const GNUNET_HashCode * key, void *value) { /* FIXME are hashes in multihash map equal on all aquitectures? */ - GNUNET_DHT_put (dht_handle, key, 10U, + /* FIXME: keep return value of 'put' to possibly cancel!? */ + GNUNET_DHT_put (dht_handle, key, 10, GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_BLOCK_TYPE_TEST, sizeof (struct GNUNET_PeerIdentity), (const char *) &my_full_id, -#if MESH_DEBUG - GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, - &mesh_debug, "DHT_put for app completed"); -#else GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), APP_ANNOUNCE_TIME), APP_ANNOUNCE_TIME, NULL, NULL); -#endif return GNUNET_OK; } @@ -689,19 +689,15 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_DHT_put (dht_handle, /* DHT handle */ &my_full_id.hashPubKey, /* Key to use */ - 10U, /* Replication level */ + 10, /* Replication level */ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, /* DHT options */ GNUNET_BLOCK_TYPE_TEST, /* Block type */ sizeof (my_full_id), /* Size of the data */ (char *) &my_full_id, /* Data itself */ - GNUNET_TIME_absolute_get_forever (), /* Data expiration */ + GNUNET_TIME_UNIT_FOREVER_ABS, /* Data expiration */ GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */ -#if MESH_DEBUG_DHT - &mesh_debug, "DHT_put for id completed"); -#else NULL, /* Continuation */ NULL); /* Continuation closure */ -#endif announce_id_task = GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, &announce_id, cls); } @@ -1608,10 +1604,9 @@ peer_info_connect (struct MeshPeerInfo *peer, struct MeshTunnel *t) " Starting DHT GET for peer %s\n", GNUNET_i2s (&id)); peer->dhtgetcls = path_info; peer->dhtget = GNUNET_DHT_get_start (dht_handle, /* handle */ - GNUNET_TIME_UNIT_FOREVER_REL, /* timeout */ GNUNET_BLOCK_TYPE_TEST, /* type */ &id.hashPubKey, /* key to search */ - 10U, /* replication level */ + 10, /* replication level */ GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, /* xquery */ 0, /* xquery bits */ &dht_get_id_handler, path_info); @@ -2987,7 +2982,7 @@ handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, info->peer->types[j] = GNUNET_MESSAGE_TYPE_MESH_PATH_ACK; info->peer->infos[j] = info; info->peer->core_transmit[j] = - GNUNET_CORE_notify_transmit_ready (core_handle, 0, 100, + GNUNET_CORE_notify_transmit_ready (core_handle, 0, 10, GNUNET_TIME_UNIT_FOREVER_REL, peer, sizeof (struct GNUNET_MESH_PathACK), &send_core_path_ack, info); @@ -4025,8 +4020,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } - send_client_tunnel_disconnect(t, c); - if (c != t->owner) + if (c != t->owner || tid >= GNUNET_MESH_LOCAL_TUNNEL_ID_SERV) { client_ignore_tunnel (c, t); #if 0 @@ -4045,6 +4039,7 @@ handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_SERVER_receive_done (client, GNUNET_OK); return; } + send_client_tunnel_disconnect(t, c); client_delete_tunnel(c, t); /* Don't try to ACK the client about the tunnel_destroy multicast packet */ @@ -4288,8 +4283,8 @@ handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " looking in DHT for %s\n", GNUNET_h2s (&hash)); t->dht_get_type = - GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, - GNUNET_BLOCK_TYPE_TEST, &hash, 10U, + GNUNET_DHT_get_start (dht_handle, + GNUNET_BLOCK_TYPE_TEST, &hash, 10, GNUNET_DHT_RO_RECORD_ROUTE | GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, 0, &dht_get_type_handler, t); @@ -4370,7 +4365,7 @@ handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client, * (pretend we got it from a mesh peer) */ { - char buf[ntohs (message->size)]; + char buf[ntohs (message->size)] GNUNET_ALIGN; struct GNUNET_MESH_Unicast *copy; /* Work around const limitation */ @@ -4454,7 +4449,7 @@ handle_local_to_origin (void *cls, struct GNUNET_SERVER_Client *client, * (pretend we got it from a mesh peer) */ { - char buf[ntohs (message->size)]; + char buf[ntohs (message->size)] GNUNET_ALIGN; struct GNUNET_MESH_ToOrigin *copy; /* Work around const limitation */ @@ -4527,7 +4522,7 @@ handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client, } { - char buf[ntohs (message->size)]; + char buf[ntohs (message->size)] GNUNET_ALIGN; struct GNUNET_MESH_Multicast *copy; copy = (struct GNUNET_MESH_Multicast *) buf; diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 7b9aa06..de931db 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c @@ -28,14 +28,6 @@ * - SEND FUNCTIONS * - API CALL DEFINITIONS */ -#ifdef __cplusplus -extern "C" -{ -#if 0 /* keep Emacsens' auto-indent happy */ -} -#endif -#endif - #include "platform.h" #include "gnunet_common.h" #include "gnunet_client_lib.h" @@ -45,13 +37,8 @@ extern "C" #include "mesh.h" #include "mesh_protocol.h" -#define MESH_API_DEBUG GNUNET_YES - -#if MESH_API_DEBUG #define LOG(kind,...) GNUNET_log_from (kind, "mesh-api",__VA_ARGS__) -#else -#define LOG(kind,...) -#endif + /******************************************************************************/ /************************ DATA STRUCTURES ****************************/ @@ -618,7 +605,7 @@ send_connect (struct GNUNET_MESH_Handle *h) size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType); size += h->n_handlers * sizeof (uint16_t); { - char buf[size]; + char buf[size] GNUNET_ALIGN; struct GNUNET_MESH_ClientConnect *msg; GNUNET_MESH_ApplicationType *apps; uint16_t napps; @@ -675,7 +662,7 @@ do_reconnect (struct GNUNET_MESH_Handle *h) } if (NULL != h->client) { - GNUNET_CLIENT_disconnect (h->client, GNUNET_NO); + GNUNET_CLIENT_disconnect (h->client); } /* connect again */ @@ -805,26 +792,38 @@ process_tunnel_created (struct GNUNET_MESH_Handle *h, GNUNET_break (0); return; } - t = create_tunnel (h, tid); - t->owner = GNUNET_PEER_intern (&msg->peer); - t->npeers = 1; - t->peers = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer *)); - t->peers[0] = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer)); - t->peers[0]->t = t; - t->peers[0]->connected = 1; - t->peers[0]->id = t->owner; - GNUNET_PEER_change_rc (t->owner, 1); - t->mesh = h; - t->tid = tid; if (NULL != h->new_tunnel) { struct GNUNET_ATS_Information atsi; + t = create_tunnel (h, tid); + t->owner = GNUNET_PEER_intern (&msg->peer); + t->npeers = 1; + t->peers = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer *)); + t->peers[0] = GNUNET_malloc (sizeof (struct GNUNET_MESH_Peer)); + t->peers[0]->t = t; + t->peers[0]->connected = 1; + t->peers[0]->id = t->owner; + GNUNET_PEER_change_rc (t->owner, 1); + t->mesh = h; + t->tid = tid; atsi.type = 0; atsi.value = 0; t->ctx = h->new_tunnel (h->cls, t, &msg->peer, &atsi); + LOG (GNUNET_ERROR_TYPE_DEBUG, "new incoming tunnel %X\n", t->tid); + } + else + { + struct GNUNET_MESH_TunnelMessage d_msg; + + LOG (GNUNET_ERROR_TYPE_DEBUG, "No handler for incoming tunnels\n"); + + d_msg.header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); + d_msg.header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); + d_msg.tunnel_id = msg->tunnel_id; + + send_packet (h, &d_msg.header, NULL); } - LOG (GNUNET_ERROR_TYPE_DEBUG, "new incoming tunnel %X\n", t->tid); return; } @@ -853,7 +852,7 @@ process_tunnel_destroy (struct GNUNET_MESH_Handle *h, { GNUNET_break (0); } - LOG (GNUNET_ERROR_TYPE_DEBUG, "tunnel %u destroyed\n", t->tid); + LOG (GNUNET_ERROR_TYPE_DEBUG, "tunnel %X destroyed\n", t->tid); destroy_tunnel (t, GNUNET_YES); return; } @@ -974,7 +973,7 @@ process_incoming_data (struct GNUNET_MESH_Handle *h, } if (NULL == t) { - GNUNET_break (0); + /* Tunnel was ignored, probably service didn't get it yet */ return GNUNET_YES; } type = ntohs (payload->type); @@ -1363,7 +1362,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) } if (NULL != handle->client) { - GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); + GNUNET_CLIENT_disconnect (handle->client); handle->client = NULL; } if (GNUNET_SCHEDULER_NO_TASK != handle->reconnect_task) @@ -1446,7 +1445,7 @@ GNUNET_MESH_tunnel_destroy (struct GNUNET_MESH_Tunnel *tunnel) } destroy_tunnel (tunnel, GNUNET_NO); - send_packet (h, &msg.header, tunnel); + send_packet (h, &msg.header, NULL); } @@ -1705,9 +1704,3 @@ GNUNET_MESH_tunnel_get_data (struct GNUNET_MESH_Tunnel *tunnel) } -#if 0 /* keep Emacsens' auto-indent happy */ -{ -#endif -#ifdef __cplusplus -} -#endif diff --git a/src/mesh/mesh_tunnel_tree.c b/src/mesh/mesh_tunnel_tree.c index 445b710..287eefc 100644 --- a/src/mesh/mesh_tunnel_tree.c +++ b/src/mesh/mesh_tunnel_tree.c @@ -837,7 +837,7 @@ tree_add_path (struct MeshTunnelTree *t, const struct MeshPeerPath *p, GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tree: Adding peer %s.\n", GNUNET_i2s (&id)); GNUNET_PEER_resolve (parent->peer, &id); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tree: to %s.\n", + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "tree: to %s.\n", GNUNET_i2s (&id)); #endif @@ -860,11 +860,11 @@ tree_add_path (struct MeshTunnelTree *t, const struct MeshPeerPath *p, #endif n = tree_node_new (parent, p->peers[i]); n->status = MESH_PEER_RELAY; - if (n->peer == 1) - { - t->me = n; - me = i; - } + } + if (n->peer == 1) + { + t->me = n; + me = i; } i++; parent = n; diff --git a/src/mesh/test_mesh.conf b/src/mesh/test_mesh.conf index 3d955f0..f2e51e4 100644 --- a/src/mesh/test_mesh.conf +++ b/src/mesh/test_mesh.conf @@ -19,7 +19,7 @@ AUTOSTART = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; HOSTNAME = localhost -PORT = 2100 +PORT = 12100 [block] plugins = dht test @@ -67,3 +67,6 @@ AUTOSTART = NO [nse] AUTOSTART = NO + +[namestore] +AUTOSTART = NO diff --git a/src/mesh/test_mesh_2dtorus.c b/src/mesh/test_mesh_2dtorus.c index 9946fe2..c708e8f 100644 --- a/src/mesh/test_mesh_2dtorus.c +++ b/src/mesh/test_mesh_2dtorus.c @@ -171,7 +171,7 @@ topo_cb (void *cls, const struct GNUNET_PeerIdentity *first, if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (disconnect_task); - GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); + disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_peers, NULL); } return; } @@ -316,7 +316,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c index fbc1fba..1e12e9b 100644 --- a/src/mesh/test_mesh_api.c +++ b/src/mesh/test_mesh_api.c @@ -85,7 +85,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); } GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); - GNUNET_OS_process_close (arm_pid); + GNUNET_OS_process_destroy (arm_pid); } static void diff --git a/src/mesh/test_mesh_local_1.c b/src/mesh/test_mesh_local_1.c index 73e2bdc..d80bee8 100644 --- a/src/mesh/test_mesh_local_1.c +++ b/src/mesh/test_mesh_local_1.c @@ -77,7 +77,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Wait\n"); GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); - GNUNET_OS_process_close (arm_pid); + GNUNET_OS_process_destroy (arm_pid); } diff --git a/src/mesh/test_mesh_local_2.c b/src/mesh/test_mesh_local_2.c index b185f1b..d495b71 100644 --- a/src/mesh/test_mesh_local_2.c +++ b/src/mesh/test_mesh_local_2.c @@ -76,7 +76,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Wait\n"); GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); - GNUNET_OS_process_close (arm_pid); + GNUNET_OS_process_destroy (arm_pid); } diff --git a/src/mesh/test_mesh_path.conf b/src/mesh/test_mesh_path.conf index 3d955f0..c3d8a2c 100644 --- a/src/mesh/test_mesh_path.conf +++ b/src/mesh/test_mesh_path.conf @@ -19,7 +19,7 @@ AUTOSTART = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; HOSTNAME = localhost -PORT = 2100 +PORT = 12100 [block] plugins = dht test diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index b06e324..974b635 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c @@ -901,7 +901,7 @@ run (void *cls, char *const *args, const char *cfgfile, hosts); GNUNET_assert (pg != NULL); shutdown_handle = - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } |