diff options
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/Makefile.am | 1 | ||||
-rw-r--r-- | src/mesh/gnunet-service-mesh-enc.c | 2 | ||||
-rw-r--r-- | src/mesh/mesh_test_lib.c | 14 | ||||
-rw-r--r-- | src/mesh/mesh_test_lib.h | 6 | ||||
-rw-r--r-- | src/mesh/test_mesh.conf | 4 | ||||
-rw-r--r-- | src/mesh/test_mesh_local.c | 10 | ||||
-rw-r--r-- | src/mesh/test_mesh_single.c | 65 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.c | 109 |
8 files changed, 106 insertions, 105 deletions
diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index c76b1e640..72ce932a5 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am | |||
@@ -159,7 +159,6 @@ ld_mesh_test_lib = \ | |||
159 | $(top_builddir)/src/testing/libgnunettesting.la \ | 159 | $(top_builddir)/src/testing/libgnunettesting.la \ |
160 | $(top_builddir)/src/mesh/libgnunetmeshtest.a \ | 160 | $(top_builddir)/src/mesh/libgnunetmeshtest.a \ |
161 | $(top_builddir)/src/mesh/libgnunetmeshenc.la \ | 161 | $(top_builddir)/src/mesh/libgnunetmeshenc.la \ |
162 | $(top_builddir)/src/mesh/libgnunetmesh.la \ | ||
163 | $(top_builddir)/src/testbed/libgnunettestbed.la | 162 | $(top_builddir)/src/testbed/libgnunettestbed.la |
164 | 163 | ||
165 | dep_mesh_test_lib = \ | 164 | dep_mesh_test_lib = \ |
diff --git a/src/mesh/gnunet-service-mesh-enc.c b/src/mesh/gnunet-service-mesh-enc.c index 566988253..0ef1f9cdd 100644 --- a/src/mesh/gnunet-service-mesh-enc.c +++ b/src/mesh/gnunet-service-mesh-enc.c | |||
@@ -1675,7 +1675,7 @@ send_prebuilt_message_connection (const struct GNUNET_MessageHeader *message, | |||
1675 | type = ntohs (message->type); | 1675 | type = ntohs (message->type); |
1676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send %s[%u] on connection %s\n", | 1676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Send %s[%u] on connection %s\n", |
1677 | GNUNET_MESH_DEBUG_M2S (type), size, GNUNET_h2s (&c->id)); | 1677 | GNUNET_MESH_DEBUG_M2S (type), size, GNUNET_h2s (&c->id)); |
1678 | 1678 | ||
1679 | switch (type) | 1679 | switch (type) |
1680 | { | 1680 | { |
1681 | struct GNUNET_MESH_Encrypted *emsg; | 1681 | struct GNUNET_MESH_Encrypted *emsg; |
diff --git a/src/mesh/mesh_test_lib.c b/src/mesh/mesh_test_lib.c index e9ccb631f..a6a7c2114 100644 --- a/src/mesh/mesh_test_lib.c +++ b/src/mesh/mesh_test_lib.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include "platform.h" | 25 | #include "platform.h" |
26 | #include "gnunet_util_lib.h" | 26 | #include "gnunet_util_lib.h" |
27 | #include "mesh_test_lib.h" | 27 | #include "mesh_test_lib.h" |
28 | #include "gnunet_mesh_service.h" | 28 | #include "gnunet_mesh_service_enc.h" |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * Test context for a MESH Test. | 31 | * Test context for a MESH Test. |
@@ -65,12 +65,12 @@ struct GNUNET_MESH_TEST_Context | |||
65 | /** | 65 | /** |
66 | * Handler for incoming tunnels. | 66 | * Handler for incoming tunnels. |
67 | */ | 67 | */ |
68 | GNUNET_MESH_InboundTunnelNotificationHandler *new_tunnel; | 68 | GNUNET_MESH_InboundChannelNotificationHandler *new_channel; |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Cleaner for destroyed incoming tunnels. | 71 | * Cleaner for destroyed incoming tunnels. |
72 | */ | 72 | */ |
73 | GNUNET_MESH_TunnelEndHandler *cleaner; | 73 | GNUNET_MESH_ChannelEndHandler *cleaner; |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Message handlers. | 76 | * Message handlers. |
@@ -122,7 +122,7 @@ mesh_connect_adapter (void *cls, | |||
122 | 122 | ||
123 | h = GNUNET_MESH_connect (cfg, | 123 | h = GNUNET_MESH_connect (cfg, |
124 | (void *) (long) actx->peer, | 124 | (void *) (long) actx->peer, |
125 | ctx->new_tunnel, | 125 | ctx->new_channel, |
126 | ctx->cleaner, | 126 | ctx->cleaner, |
127 | ctx->handlers, | 127 | ctx->handlers, |
128 | ctx->ports); | 128 | ctx->ports); |
@@ -256,8 +256,8 @@ GNUNET_MESH_TEST_run (const char *testname, | |||
256 | unsigned int num_peers, | 256 | unsigned int num_peers, |
257 | GNUNET_MESH_TEST_AppMain tmain, | 257 | GNUNET_MESH_TEST_AppMain tmain, |
258 | void *tmain_cls, | 258 | void *tmain_cls, |
259 | GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel, | 259 | GNUNET_MESH_InboundChannelNotificationHandler new_channel, |
260 | GNUNET_MESH_TunnelEndHandler cleaner, | 260 | GNUNET_MESH_ChannelEndHandler cleaner, |
261 | struct GNUNET_MESH_MessageHandler* handlers, | 261 | struct GNUNET_MESH_MessageHandler* handlers, |
262 | const uint32_t *ports) | 262 | const uint32_t *ports) |
263 | { | 263 | { |
@@ -269,7 +269,7 @@ GNUNET_MESH_TEST_run (const char *testname, | |||
269 | ctx->meshes = GNUNET_malloc (num_peers * sizeof (struct GNUNET_MESH_Handle *)); | 269 | ctx->meshes = GNUNET_malloc (num_peers * sizeof (struct GNUNET_MESH_Handle *)); |
270 | ctx->app_main = tmain; | 270 | ctx->app_main = tmain; |
271 | ctx->app_main_cls = tmain_cls; | 271 | ctx->app_main_cls = tmain_cls; |
272 | ctx->new_tunnel = new_tunnel; | 272 | ctx->new_channel = new_channel; |
273 | ctx->cleaner = cleaner; | 273 | ctx->cleaner = cleaner; |
274 | ctx->handlers = handlers; | 274 | ctx->handlers = handlers; |
275 | ctx->ports = ports; | 275 | ctx->ports = ports; |
diff --git a/src/mesh/mesh_test_lib.h b/src/mesh/mesh_test_lib.h index 4dd2151b8..c560d50c0 100644 --- a/src/mesh/mesh_test_lib.h +++ b/src/mesh/mesh_test_lib.h | |||
@@ -34,7 +34,7 @@ extern "C" | |||
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #include "gnunet_testbed_service.h" | 36 | #include "gnunet_testbed_service.h" |
37 | #include "gnunet_mesh_service.h" | 37 | #include "gnunet_mesh_service_enc.h" |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * Test context for a MESH Test. | 40 | * Test context for a MESH Test. |
@@ -79,8 +79,8 @@ GNUNET_MESH_TEST_run (const char *testname, | |||
79 | unsigned int num_peers, | 79 | unsigned int num_peers, |
80 | GNUNET_MESH_TEST_AppMain tmain, | 80 | GNUNET_MESH_TEST_AppMain tmain, |
81 | void *tmain_cls, | 81 | void *tmain_cls, |
82 | GNUNET_MESH_InboundTunnelNotificationHandler new_tunnel, | 82 | GNUNET_MESH_InboundChannelNotificationHandler new_channel, |
83 | GNUNET_MESH_TunnelEndHandler cleaner, | 83 | GNUNET_MESH_ChannelEndHandler cleaner, |
84 | struct GNUNET_MESH_MessageHandler* handlers, | 84 | struct GNUNET_MESH_MessageHandler* handlers, |
85 | const uint32_t* ports); | 85 | const uint32_t* ports); |
86 | 86 | ||
diff --git a/src/mesh/test_mesh.conf b/src/mesh/test_mesh.conf index 2c577ab84..2ae07e30f 100644 --- a/src/mesh/test_mesh.conf +++ b/src/mesh/test_mesh.conf | |||
@@ -2,12 +2,12 @@ | |||
2 | SERVICEHOME = /tmp/test-mesh/ | 2 | SERVICEHOME = /tmp/test-mesh/ |
3 | 3 | ||
4 | [mesh] | 4 | [mesh] |
5 | # BINARY = gnunet-service-mesh-enc | 5 | BINARY = gnunet-service-mesh-enc |
6 | AUTOSTART = NO | 6 | AUTOSTART = NO |
7 | ACCEPT_FROM = 127.0.0.1; | 7 | ACCEPT_FROM = 127.0.0.1; |
8 | HOSTNAME = localhost | 8 | HOSTNAME = localhost |
9 | PORT = 10511 | 9 | PORT = 10511 |
10 | # PREFIX = valgrind --leak-check=full | 10 | PREFIX = valgrind --leak-check=full |
11 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args | 11 | #PREFIX = xterm -geometry 100x85 -T peer1 -e gdb --args |
12 | REFRESH_PATH_TIME = 2 s | 12 | REFRESH_PATH_TIME = 2 s |
13 | ID_ANNOUNCE_TIME = 5 s | 13 | ID_ANNOUNCE_TIME = 5 s |
diff --git a/src/mesh/test_mesh_local.c b/src/mesh/test_mesh_local.c index 25ccf7b2e..5bf3e0ce4 100644 --- a/src/mesh/test_mesh_local.c +++ b/src/mesh/test_mesh_local.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file mesh/test_mesh_local.c | 22 | * @file mesh/test_mesh_local.c |
23 | * @brief test mesh local: test of mesh tunnels with just one peer | 23 | * @brief test mesh local: test of mesh channels with just one peer |
24 | * @author Bartlomiej Polot | 24 | * @author Bartlomiej Polot |
25 | */ | 25 | */ |
26 | 26 | ||
@@ -130,14 +130,14 @@ data_callback (void *cls, struct GNUNET_MESH_Channel *channel, | |||
130 | * (can be NULL -- that's not an error) | 130 | * (can be NULL -- that's not an error) |
131 | */ | 131 | */ |
132 | static void * | 132 | static void * |
133 | inbound_tunnel (void *cls, struct GNUNET_MESH_Channel *channel, | 133 | inbound_channel (void *cls, struct GNUNET_MESH_Channel *channel, |
134 | const struct GNUNET_PeerIdentity *initiator, | 134 | const struct GNUNET_PeerIdentity *initiator, |
135 | uint32_t port) | 135 | uint32_t port) |
136 | { | 136 | { |
137 | long id = (long) cls; | 137 | long id = (long) cls; |
138 | 138 | ||
139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
140 | "received incoming tunnel on peer %d, port %u\n", | 140 | "received incoming channel on peer %d, port %u\n", |
141 | id, port); | 141 | id, port); |
142 | if (id != 2L) | 142 | if (id != 2L) |
143 | { | 143 | { |
@@ -257,14 +257,14 @@ run (void *cls, | |||
257 | NULL); | 257 | NULL); |
258 | mesh_peer_1 = GNUNET_MESH_connect (cfg, /* configuration */ | 258 | mesh_peer_1 = GNUNET_MESH_connect (cfg, /* configuration */ |
259 | (void *) 1L, /* cls */ | 259 | (void *) 1L, /* cls */ |
260 | &inbound_tunnel, /* inbound new hndlr */ | 260 | &inbound_channel, /* inbound new hndlr */ |
261 | &inbound_end, /* inbound end hndlr */ | 261 | &inbound_end, /* inbound end hndlr */ |
262 | handlers1, /* traffic handlers */ | 262 | handlers1, /* traffic handlers */ |
263 | NULL); /* ports offered */ | 263 | NULL); /* ports offered */ |
264 | 264 | ||
265 | mesh_peer_2 = GNUNET_MESH_connect (cfg, /* configuration */ | 265 | mesh_peer_2 = GNUNET_MESH_connect (cfg, /* configuration */ |
266 | (void *) 2L, /* cls */ | 266 | (void *) 2L, /* cls */ |
267 | &inbound_tunnel, /* inbound new hndlr */ | 267 | &inbound_channel, /* inbound new hndlr */ |
268 | &inbound_end, /* inbound end hndlr */ | 268 | &inbound_end, /* inbound end hndlr */ |
269 | handlers2, /* traffic handlers */ | 269 | handlers2, /* traffic handlers */ |
270 | ports); /* ports offered */ | 270 | ports); /* ports offered */ |
diff --git a/src/mesh/test_mesh_single.c b/src/mesh/test_mesh_single.c index 4c5d0a659..2179b1f1d 100644 --- a/src/mesh/test_mesh_single.c +++ b/src/mesh/test_mesh_single.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file mesh/test_mesh_local.c | 22 | * @file mesh/test_mesh_local.c |
23 | * @brief test mesh local: test of mesh tunnels with just one peer | 23 | * @brief test mesh local: test of mesh channels with just one peer |
24 | * @author Bartlomiej Polot | 24 | * @author Bartlomiej Polot |
25 | */ | 25 | */ |
26 | 26 | ||
@@ -28,7 +28,7 @@ | |||
28 | #include "gnunet_util_lib.h" | 28 | #include "gnunet_util_lib.h" |
29 | #include "gnunet_dht_service.h" | 29 | #include "gnunet_dht_service.h" |
30 | #include "gnunet_testing_lib.h" | 30 | #include "gnunet_testing_lib.h" |
31 | #include "gnunet_mesh_service.h" | 31 | #include "gnunet_mesh_service_enc.h" |
32 | 32 | ||
33 | #define REPETITIONS 5 | 33 | #define REPETITIONS 5 |
34 | #define DATA_SIZE 35000 | 34 | #define DATA_SIZE 35000 |
@@ -37,9 +37,9 @@ struct GNUNET_TESTING_Peer *me; | |||
37 | 37 | ||
38 | static struct GNUNET_MESH_Handle *mesh; | 38 | static struct GNUNET_MESH_Handle *mesh; |
39 | 39 | ||
40 | static struct GNUNET_MESH_Tunnel *t1; | 40 | static struct GNUNET_MESH_Channel *ch1; |
41 | 41 | ||
42 | static struct GNUNET_MESH_Tunnel *t2; | 42 | static struct GNUNET_MESH_Channel *ch2; |
43 | 43 | ||
44 | static int result = GNUNET_OK; | 44 | static int result = GNUNET_OK; |
45 | 45 | ||
@@ -66,9 +66,9 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
66 | { | 66 | { |
67 | GNUNET_SCHEDULER_cancel (abort_task); | 67 | GNUNET_SCHEDULER_cancel (abort_task); |
68 | } | 68 | } |
69 | if (NULL != t1) | 69 | if (NULL != ch1) |
70 | { | 70 | { |
71 | GNUNET_MESH_tunnel_destroy (t1); | 71 | GNUNET_MESH_channel_destroy (ch1); |
72 | } | 72 | } |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); | 73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 1\n"); |
74 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); | 74 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnect client 2\n"); |
@@ -101,15 +101,16 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
101 | * Function is called whenever a message is received. | 101 | * Function is called whenever a message is received. |
102 | * | 102 | * |
103 | * @param cls closure (set from GNUNET_MESH_connect) | 103 | * @param cls closure (set from GNUNET_MESH_connect) |
104 | * @param tunnel connection to the other end | 104 | * @param channel connection to the other end |
105 | * @param tunnel_ctx place to store local state associated with the tunnel | 105 | * @param channel_ctx place to store local state associated with the channel |
106 | * @param message the actual message | 106 | * @param message the actual message |
107 | * | 107 | * |
108 | * @return GNUNET_OK to keep the connection open, | 108 | * @return GNUNET_OK to keep the connection open, |
109 | * GNUNET_SYSERR to close it (signal serious error) | 109 | * GNUNET_SYSERR to close it (signal serious error) |
110 | */ | 110 | */ |
111 | static int | 111 | static int |
112 | data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | 112 | data_callback (void *cls, struct GNUNET_MESH_Channel *channel, |
113 | void **channel_ctx, | ||
113 | const struct GNUNET_MessageHeader *message) | 114 | const struct GNUNET_MessageHeader *message) |
114 | { | 115 | { |
115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data callback! Repetition %u\n", repetition); | 116 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data callback! Repetition %u\n", repetition); |
@@ -117,16 +118,16 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
117 | repetition = repetition + 1; | 118 | repetition = repetition + 1; |
118 | if (repetition < REPETITIONS) | 119 | if (repetition < REPETITIONS) |
119 | { | 120 | { |
120 | struct GNUNET_MESH_Tunnel *my_tunnel; | 121 | struct GNUNET_MESH_Channel *my_channel; |
121 | if (repetition % 2 == 0) | 122 | if (repetition % 2 == 0) |
122 | my_tunnel = t1; | 123 | my_channel = ch1; |
123 | else | 124 | else |
124 | my_tunnel = t2; | 125 | my_channel = ch2; |
125 | GNUNET_MESH_notify_transmit_ready (my_tunnel, GNUNET_NO, | 126 | GNUNET_MESH_notify_transmit_ready (my_channel, GNUNET_NO, |
126 | GNUNET_TIME_UNIT_FOREVER_REL, | 127 | GNUNET_TIME_UNIT_FOREVER_REL, |
127 | sizeof (struct GNUNET_MessageHeader) + DATA_SIZE, | 128 | sizeof (struct GNUNET_MessageHeader) + DATA_SIZE, |
128 | &do_send, NULL); | 129 | &do_send, NULL); |
129 | GNUNET_MESH_receive_done (tunnel); | 130 | GNUNET_MESH_receive_done (channel); |
130 | return GNUNET_OK; | 131 | return GNUNET_OK; |
131 | } | 132 | } |
132 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) | 133 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_task) |
@@ -134,51 +135,51 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
134 | shutdown_task = | 135 | shutdown_task = |
135 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown, | 136 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &do_shutdown, |
136 | NULL); | 137 | NULL); |
137 | GNUNET_MESH_receive_done (tunnel); | 138 | GNUNET_MESH_receive_done (channel); |
138 | return GNUNET_OK; | 139 | return GNUNET_OK; |
139 | } | 140 | } |
140 | 141 | ||
141 | 142 | ||
142 | /** | 143 | /** |
143 | * Method called whenever another peer has added us to a tunnel | 144 | * Method called whenever another peer has added us to a channel |
144 | * the other peer initiated. | 145 | * the other peer initiated. |
145 | * | 146 | * |
146 | * @param cls closure | 147 | * @param cls closure |
147 | * @param tunnel new handle to the tunnel | 148 | * @param channel new handle to the channel |
148 | * @param initiator peer that started the tunnel | 149 | * @param initiator peer that started the channel |
149 | * @param port port number | 150 | * @param port port number |
150 | * @return initial tunnel context for the tunnel (can be NULL -- that's not an error) | 151 | * @return initial channel context for the channel (can be NULL -- that's not an error) |
151 | */ | 152 | */ |
152 | static void * | 153 | static void * |
153 | inbound_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, | 154 | inbound_channel (void *cls, struct GNUNET_MESH_Channel *channel, |
154 | const struct GNUNET_PeerIdentity *initiator, | 155 | const struct GNUNET_PeerIdentity *initiator, |
155 | uint32_t port) | 156 | uint32_t port) |
156 | { | 157 | { |
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "received incoming tunnel on port %u\n", | 159 | "received incoming channel on port %u\n", |
159 | port); | 160 | port); |
160 | t2 = tunnel; | 161 | ch2 = channel; |
161 | return NULL; | 162 | return NULL; |
162 | } | 163 | } |
163 | 164 | ||
164 | 165 | ||
165 | /** | 166 | /** |
166 | * Function called whenever an inbound tunnel is destroyed. Should clean up | 167 | * Function called whenever an inbound channel is destroyed. Should clean up |
167 | * any associated state. | 168 | * any associated state. |
168 | * | 169 | * |
169 | * @param cls closure (set from GNUNET_MESH_connect) | 170 | * @param cls closure (set from GNUNET_MESH_connect) |
170 | * @param tunnel connection to the other end (henceforth invalid) | 171 | * @param channel connection to the other end (henceforth invalid) |
171 | * @param tunnel_ctx place where local state associated | 172 | * @param channel_ctx place where local state associated |
172 | * with the tunnel is stored | 173 | * with the channel is stored |
173 | */ | 174 | */ |
174 | static void | 175 | static void |
175 | inbound_end (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, | 176 | inbound_end (void *cls, const struct GNUNET_MESH_Channel *channel, |
176 | void *tunnel_ctx) | 177 | void *channel_ctx) |
177 | { | 178 | { |
178 | long id = (long) cls; | 179 | long id = (long) cls; |
179 | 180 | ||
180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
181 | "incoming tunnel closed at peer %ld\n", | 182 | "incoming channel closed at peer %ld\n", |
182 | id); | 183 | id); |
183 | } | 184 | } |
184 | 185 | ||
@@ -232,8 +233,8 @@ do_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
232 | 233 | ||
233 | GNUNET_TESTING_peer_get_identity (me, &id); | 234 | GNUNET_TESTING_peer_get_identity (me, &id); |
234 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); | 235 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONNECT BY PORT\n"); |
235 | t1 = GNUNET_MESH_tunnel_create (mesh, NULL, &id, 1, GNUNET_YES, GNUNET_NO); | 236 | ch1 = GNUNET_MESH_channel_create (mesh, NULL, &id, 1, GNUNET_YES, GNUNET_NO); |
236 | GNUNET_MESH_notify_transmit_ready (t1, GNUNET_NO, | 237 | GNUNET_MESH_notify_transmit_ready (ch1, GNUNET_NO, |
237 | GNUNET_TIME_UNIT_FOREVER_REL, | 238 | GNUNET_TIME_UNIT_FOREVER_REL, |
238 | sizeof (struct GNUNET_MessageHeader) + DATA_SIZE, | 239 | sizeof (struct GNUNET_MessageHeader) + DATA_SIZE, |
239 | &do_send, NULL); | 240 | &do_send, NULL); |
@@ -261,7 +262,7 @@ run (void *cls, | |||
261 | NULL); | 262 | NULL); |
262 | mesh = GNUNET_MESH_connect (cfg, /* configuration */ | 263 | mesh = GNUNET_MESH_connect (cfg, /* configuration */ |
263 | (void *) 1L, /* cls */ | 264 | (void *) 1L, /* cls */ |
264 | &inbound_tunnel, /* inbound new hndlr */ | 265 | &inbound_channel, /* inbound new hndlr */ |
265 | &inbound_end, /* inbound end hndlr */ | 266 | &inbound_end, /* inbound end hndlr */ |
266 | handlers1, /* traffic handlers */ | 267 | handlers1, /* traffic handlers */ |
267 | ports); /* ports offered */ | 268 | ports); /* ports offered */ |
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index dc9f9461c..edd55a593 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c | |||
@@ -25,7 +25,7 @@ | |||
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "mesh_test_lib.h" | 27 | #include "mesh_test_lib.h" |
28 | #include "gnunet_mesh_service.h" | 28 | #include "gnunet_mesh_service_enc.h" |
29 | #include <gauger.h> | 29 | #include <gauger.h> |
30 | 30 | ||
31 | 31 | ||
@@ -77,11 +77,11 @@ static int ok; | |||
77 | 77 | ||
78 | /** | 78 | /** |
79 | * Each peer is supposed to generate the following callbacks: | 79 | * Each peer is supposed to generate the following callbacks: |
80 | * 1 incoming tunnel (@dest) | 80 | * 1 incoming channel (@dest) |
81 | * 1 connected peer (@orig) | 81 | * 1 connected peer (@orig) |
82 | * 1 received data packet (@dest) | 82 | * 1 received data packet (@dest) |
83 | * 1 received data packet (@orig) | 83 | * 1 received data packet (@orig) |
84 | * 1 received tunnel destroy (@dest) | 84 | * 1 received channel destroy (@dest) |
85 | * _________________________________ | 85 | * _________________________________ |
86 | * 5 x ok expected per peer | 86 | * 5 x ok expected per peer |
87 | */ | 87 | */ |
@@ -164,17 +164,17 @@ static struct GNUNET_MESH_Handle *h1; | |||
164 | static struct GNUNET_MESH_Handle *h2; | 164 | static struct GNUNET_MESH_Handle *h2; |
165 | 165 | ||
166 | /** | 166 | /** |
167 | * Tunnel handle for the root peer | 167 | * Channel handle for the root peer |
168 | */ | 168 | */ |
169 | static struct GNUNET_MESH_Tunnel *t; | 169 | static struct GNUNET_MESH_Channel *ch; |
170 | 170 | ||
171 | /** | 171 | /** |
172 | * Tunnel handle for the first leaf peer | 172 | * Channel handle for the dest peer |
173 | */ | 173 | */ |
174 | static struct GNUNET_MESH_Tunnel *incoming_t; | 174 | static struct GNUNET_MESH_Channel *incoming_ch; |
175 | 175 | ||
176 | /** | 176 | /** |
177 | * Time we started the data transmission (after tunnel has been established | 177 | * Time we started the data transmission (after channel has been established |
178 | * and initilized). | 178 | * and initilized). |
179 | */ | 179 | */ |
180 | static struct GNUNET_TIME_Absolute start_time; | 180 | static struct GNUNET_TIME_Absolute start_time; |
@@ -239,15 +239,15 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
239 | { | 239 | { |
240 | GNUNET_TESTBED_operation_done (t_op[i]); | 240 | GNUNET_TESTBED_operation_done (t_op[i]); |
241 | } | 241 | } |
242 | if (NULL != t) | 242 | if (NULL != ch) |
243 | { | 243 | { |
244 | GNUNET_MESH_tunnel_destroy (t); | 244 | GNUNET_MESH_channel_destroy (ch); |
245 | t = NULL; | 245 | ch = NULL; |
246 | } | 246 | } |
247 | if (NULL != incoming_t) | 247 | if (NULL != incoming_ch) |
248 | { | 248 | { |
249 | GNUNET_MESH_tunnel_destroy (incoming_t); | 249 | GNUNET_MESH_channel_destroy (incoming_ch); |
250 | incoming_t = NULL; | 250 | incoming_ch = NULL; |
251 | } | 251 | } |
252 | GNUNET_MESH_TEST_cleanup (test_ctx); | 252 | GNUNET_MESH_TEST_cleanup (test_ctx); |
253 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) | 253 | if (GNUNET_SCHEDULER_NO_TASK != shutdown_handle) |
@@ -297,7 +297,7 @@ static void | |||
297 | data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 297 | data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
298 | { | 298 | { |
299 | struct GNUNET_MESH_TransmitHandle *th; | 299 | struct GNUNET_MESH_TransmitHandle *th; |
300 | struct GNUNET_MESH_Tunnel *tunnel; | 300 | struct GNUNET_MESH_Channel *channel; |
301 | 301 | ||
302 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) | 302 | if ((GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason) != 0) |
303 | return; | 303 | return; |
@@ -305,13 +305,13 @@ data_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n"); | 305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Data task\n"); |
306 | if (GNUNET_YES == test_backwards) | 306 | if (GNUNET_YES == test_backwards) |
307 | { | 307 | { |
308 | tunnel = incoming_t; | 308 | channel = incoming_ch; |
309 | } | 309 | } |
310 | else | 310 | else |
311 | { | 311 | { |
312 | tunnel = t; | 312 | channel = ch; |
313 | } | 313 | } |
314 | th = GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, | 314 | th = GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO, |
315 | GNUNET_TIME_UNIT_FOREVER_REL, | 315 | GNUNET_TIME_UNIT_FOREVER_REL, |
316 | size_payload, &tmt_rdy, (void *) 1L); | 316 | size_payload, &tmt_rdy, (void *) 1L); |
317 | if (NULL == th) | 317 | if (NULL == th) |
@@ -388,14 +388,15 @@ tmt_rdy (void *cls, size_t size, void *buf) | |||
388 | * Function is called whenever a message is received. | 388 | * Function is called whenever a message is received. |
389 | * | 389 | * |
390 | * @param cls closure (set from GNUNET_MESH_connect) | 390 | * @param cls closure (set from GNUNET_MESH_connect) |
391 | * @param tunnel connection to the other end | 391 | * @param channel connection to the other end |
392 | * @param tunnel_ctx place to store local state associated with the tunnel | 392 | * @param channel_ctx place to store local state associated with the channel |
393 | * @param message the actual message | 393 | * @param message the actual message |
394 | * @return GNUNET_OK to keep the connection open, | 394 | * @return GNUNET_OK to keep the connection open, |
395 | * GNUNET_SYSERR to close it (signal serious error) | 395 | * GNUNET_SYSERR to close it (signal serious error) |
396 | */ | 396 | */ |
397 | int | 397 | int |
398 | data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | 398 | data_callback (void *cls, struct GNUNET_MESH_Channel *channel, |
399 | void **channel_ctx, | ||
399 | const struct GNUNET_MessageHeader *message) | 400 | const struct GNUNET_MessageHeader *message) |
400 | { | 401 | { |
401 | long client = (long) cls; | 402 | long client = (long) cls; |
@@ -404,7 +405,7 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
404 | 405 | ||
405 | ok++; | 406 | ok++; |
406 | 407 | ||
407 | GNUNET_MESH_receive_done (tunnel); | 408 | GNUNET_MESH_receive_done (channel); |
408 | 409 | ||
409 | if ((ok % 20) == 0) | 410 | if ((ok % 20) == 0) |
410 | { | 411 | { |
@@ -462,7 +463,7 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
462 | " received data %u\n", data_received); | 463 | " received data %u\n", data_received); |
463 | if (SPEED != test || (ok_goal - 2) == ok) | 464 | if (SPEED != test || (ok_goal - 2) == ok) |
464 | { | 465 | { |
465 | GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, | 466 | GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO, |
466 | GNUNET_TIME_UNIT_FOREVER_REL, | 467 | GNUNET_TIME_UNIT_FOREVER_REL, |
467 | size_payload, &tmt_rdy, (void *) 1L); | 468 | size_payload, &tmt_rdy, (void *) 1L); |
468 | return GNUNET_OK; | 469 | return GNUNET_OK; |
@@ -480,7 +481,7 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
480 | data_ack++; | 481 | data_ack++; |
481 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 482 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
482 | " received ack %u\n", data_ack); | 483 | " received ack %u\n", data_ack); |
483 | GNUNET_MESH_notify_transmit_ready (tunnel, GNUNET_NO, | 484 | GNUNET_MESH_notify_transmit_ready (channel, GNUNET_NO, |
484 | GNUNET_TIME_UNIT_FOREVER_REL, | 485 | GNUNET_TIME_UNIT_FOREVER_REL, |
485 | size_payload, &tmt_rdy, (void *) 1L); | 486 | size_payload, &tmt_rdy, (void *) 1L); |
486 | if (data_ack < TOTAL_PACKETS && SPEED != test) | 487 | if (data_ack < TOTAL_PACKETS && SPEED != test) |
@@ -491,13 +492,13 @@ data_callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, | |||
491 | } | 492 | } |
492 | if (test == P2P_SIGNAL) | 493 | if (test == P2P_SIGNAL) |
493 | { | 494 | { |
494 | GNUNET_MESH_tunnel_destroy (incoming_t); | 495 | GNUNET_MESH_channel_destroy (incoming_ch); |
495 | incoming_t = NULL; | 496 | incoming_ch = NULL; |
496 | } | 497 | } |
497 | else | 498 | else |
498 | { | 499 | { |
499 | GNUNET_MESH_tunnel_destroy (t); | 500 | GNUNET_MESH_channel_destroy (ch); |
500 | t = NULL; | 501 | ch = NULL; |
501 | } | 502 | } |
502 | } | 503 | } |
503 | 504 | ||
@@ -523,32 +524,32 @@ static struct GNUNET_MESH_MessageHandler handlers[] = { | |||
523 | 524 | ||
524 | 525 | ||
525 | /** | 526 | /** |
526 | * Method called whenever another peer has added us to a tunnel | 527 | * Method called whenever another peer has added us to a channel |
527 | * the other peer initiated. | 528 | * the other peer initiated. |
528 | * | 529 | * |
529 | * @param cls Closure. | 530 | * @param cls Closure. |
530 | * @param tunnel New handle to the tunnel. | 531 | * @param channel New handle to the channel. |
531 | * @param initiator Peer that started the tunnel. | 532 | * @param initiator Peer that started the channel. |
532 | * @param port Port this tunnels is connected to. | 533 | * @param port Port this channel is connected to. |
533 | * @return Initial tunnel context for the tunnel | 534 | * @return Initial channel context for the channel |
534 | * (can be NULL -- that's not an error). | 535 | * (can be NULL -- that's not an error). |
535 | */ | 536 | */ |
536 | static void * | 537 | static void * |
537 | incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, | 538 | incoming_channel (void *cls, struct GNUNET_MESH_Channel *channel, |
538 | const struct GNUNET_PeerIdentity *initiator, | 539 | const struct GNUNET_PeerIdentity *initiator, |
539 | uint32_t port) | 540 | uint32_t port) |
540 | { | 541 | { |
541 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 542 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
542 | "Incoming tunnel from %s to peer %d\n", | 543 | "Incoming channel from %s to peer %d\n", |
543 | GNUNET_i2s (initiator), (long) cls); | 544 | GNUNET_i2s (initiator), (long) cls); |
544 | ok++; | 545 | ok++; |
545 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); | 546 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, " ok: %d\n", ok); |
546 | if ((long) cls == 4L) | 547 | if ((long) cls == 4L) |
547 | incoming_t = tunnel; | 548 | incoming_ch = channel; |
548 | else | 549 | else |
549 | { | 550 | { |
550 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 551 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
551 | "Incoming tunnel for unknown client %lu\n", (long) cls); | 552 | "Incoming channel for unknown client %lu\n", (long) cls); |
552 | GNUNET_break(0); | 553 | GNUNET_break(0); |
553 | } | 554 | } |
554 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) | 555 | if (GNUNET_SCHEDULER_NO_TASK != disconnect_task) |
@@ -563,32 +564,32 @@ incoming_tunnel (void *cls, struct GNUNET_MESH_Tunnel *tunnel, | |||
563 | } | 564 | } |
564 | 565 | ||
565 | /** | 566 | /** |
566 | * Function called whenever an inbound tunnel is destroyed. Should clean up | 567 | * Function called whenever an inbound channel is destroyed. Should clean up |
567 | * any associated state. | 568 | * any associated state. |
568 | * | 569 | * |
569 | * @param cls closure (set from GNUNET_MESH_connect) | 570 | * @param cls closure (set from GNUNET_MESH_connect) |
570 | * @param tunnel connection to the other end (henceforth invalid) | 571 | * @param channel connection to the other end (henceforth invalid) |
571 | * @param tunnel_ctx place where local state associated | 572 | * @param channel_ctx place where local state associated |
572 | * with the tunnel is stored | 573 | * with the channel is stored |
573 | */ | 574 | */ |
574 | static void | 575 | static void |
575 | tunnel_cleaner (void *cls, const struct GNUNET_MESH_Tunnel *tunnel, | 576 | channel_cleaner (void *cls, const struct GNUNET_MESH_Channel *channel, |
576 | void *tunnel_ctx) | 577 | void *channel_ctx) |
577 | { | 578 | { |
578 | long i = (long) cls; | 579 | long i = (long) cls; |
579 | 580 | ||
580 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 581 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
581 | "Incoming tunnel disconnected at peer %d\n", | 582 | "Incoming channel disconnected at peer %d\n", |
582 | i); | 583 | i); |
583 | if (4L == i) | 584 | if (4L == i) |
584 | { | 585 | { |
585 | ok++; | 586 | ok++; |
586 | incoming_t = NULL; | 587 | incoming_ch = NULL; |
587 | } | 588 | } |
588 | else if (0L == i && P2P_SIGNAL == test) | 589 | else if (0L == i && P2P_SIGNAL == test) |
589 | { | 590 | { |
590 | ok ++; | 591 | ok ++; |
591 | t = NULL; | 592 | ch = NULL; |
592 | } | 593 | } |
593 | else | 594 | else |
594 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 595 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -645,7 +646,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
645 | } | 646 | } |
646 | else | 647 | else |
647 | rel = GNUNET_NO; | 648 | rel = GNUNET_NO; |
648 | t = GNUNET_MESH_tunnel_create (h1, NULL, p_id[1], 1, nobuf, rel); | 649 | ch = GNUNET_MESH_channel_create (h1, NULL, p_id[1], 1, nobuf, rel); |
649 | 650 | ||
650 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, | 651 | disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME, |
651 | &disconnect_mesh_peers, | 652 | &disconnect_mesh_peers, |
@@ -655,7 +656,7 @@ do_test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
655 | data_ack = 0; | 656 | data_ack = 0; |
656 | data_received = 0; | 657 | data_received = 0; |
657 | data_sent = 0; | 658 | data_sent = 0; |
658 | GNUNET_MESH_notify_transmit_ready (t, GNUNET_NO, | 659 | GNUNET_MESH_notify_transmit_ready (ch, GNUNET_NO, |
659 | GNUNET_TIME_UNIT_FOREVER_REL, | 660 | GNUNET_TIME_UNIT_FOREVER_REL, |
660 | size_payload, &tmt_rdy, (void *) 1L); | 661 | size_payload, &tmt_rdy, (void *) 1L); |
661 | } | 662 | } |
@@ -763,10 +764,10 @@ main (int argc, char *argv[]) | |||
763 | else if (strstr (argv[0], "_small_speed_ack") != NULL) | 764 | else if (strstr (argv[0], "_small_speed_ack") != NULL) |
764 | { | 765 | { |
765 | /* Each peer is supposed to generate the following callbacks: | 766 | /* Each peer is supposed to generate the following callbacks: |
766 | * 1 incoming tunnel (@dest) | 767 | * 1 incoming channel (@dest) |
767 | * TOTAL_PACKETS received data packet (@dest) | 768 | * TOTAL_PACKETS received data packet (@dest) |
768 | * TOTAL_PACKETS received data packet (@orig) | 769 | * TOTAL_PACKETS received data packet (@orig) |
769 | * 1 received tunnel destroy (@dest) | 770 | * 1 received channel destroy (@dest) |
770 | * _________________________________ | 771 | * _________________________________ |
771 | * 5 x ok expected per peer | 772 | * 5 x ok expected per peer |
772 | */ | 773 | */ |
@@ -778,11 +779,11 @@ main (int argc, char *argv[]) | |||
778 | else if (strstr (argv[0], "_small_speed") != NULL) | 779 | else if (strstr (argv[0], "_small_speed") != NULL) |
779 | { | 780 | { |
780 | /* Each peer is supposed to generate the following callbacks: | 781 | /* Each peer is supposed to generate the following callbacks: |
781 | * 1 incoming tunnel (@dest) | 782 | * 1 incoming channel (@dest) |
782 | * 1 initial packet (@dest) | 783 | * 1 initial packet (@dest) |
783 | * TOTAL_PACKETS received data packet (@dest) | 784 | * TOTAL_PACKETS received data packet (@dest) |
784 | * 1 received data packet (@orig) | 785 | * 1 received data packet (@orig) |
785 | * 1 received tunnel destroy (@dest) | 786 | * 1 received channel destroy (@dest) |
786 | * _________________________________ | 787 | * _________________________________ |
787 | */ | 788 | */ |
788 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n"); | 789 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "SPEED\n"); |
@@ -830,8 +831,8 @@ main (int argc, char *argv[]) | |||
830 | 5, | 831 | 5, |
831 | &tmain, | 832 | &tmain, |
832 | NULL, /* tmain cls */ | 833 | NULL, /* tmain cls */ |
833 | &incoming_tunnel, | 834 | &incoming_channel, |
834 | &tunnel_cleaner, | 835 | &channel_cleaner, |
835 | handlers, | 836 | handlers, |
836 | ports); | 837 | ports); |
837 | 838 | ||