diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-08-23 15:24:41 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-08-23 15:24:41 +0000 |
commit | c60f24fa1d3db9f446d8cc6cc5606e4fd387529a (patch) | |
tree | abfa4fe65d7c2e0e8428fa0588a7b648986e38db /src/mesh/test_mesh_single.c | |
parent | 892a5dd08ee9993a21e122c0bcc894eaadfd316e (diff) | |
download | gnunet-c60f24fa1d3db9f446d8cc6cc5606e4fd387529a.tar.gz gnunet-c60f24fa1d3db9f446d8cc6cc5606e4fd387529a.zip |
- use -enc for test by default
Diffstat (limited to 'src/mesh/test_mesh_single.c')
-rw-r--r-- | src/mesh/test_mesh_single.c | 65 |
1 files changed, 33 insertions, 32 deletions
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 */ |