diff options
Diffstat (limited to 'src/multicast/test_multicast_multipeer.c')
-rw-r--r-- | src/multicast/test_multicast_multipeer.c | 106 |
1 files changed, 79 insertions, 27 deletions
diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c index 1b76737f4..58e43d4ba 100644 --- a/src/multicast/test_multicast_multipeer.c +++ b/src/multicast/test_multicast_multipeer.c | |||
@@ -107,7 +107,6 @@ shutdown_task (void *cls) | |||
107 | static void | 107 | static void |
108 | timeout_task (void *cls) | 108 | timeout_task (void *cls) |
109 | { | 109 | { |
110 | timeout_tid = NULL; | ||
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 110 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
112 | "Timeout!\n"); | 111 | "Timeout!\n"); |
113 | result = GNUNET_SYSERR; | 112 | result = GNUNET_SYSERR; |
@@ -126,6 +125,21 @@ member_join_request (void *cls, | |||
126 | 125 | ||
127 | } | 126 | } |
128 | 127 | ||
128 | int notify (void *cls, | ||
129 | size_t *data_size, | ||
130 | void *data) | ||
131 | { | ||
132 | |||
133 | char text[] = "ping"; | ||
134 | *data_size = strlen(text)+1; | ||
135 | GNUNET_memcpy(data, text, *data_size); | ||
136 | |||
137 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
138 | "Member sents message to origin: %s\n", text); | ||
139 | |||
140 | return GNUNET_YES; | ||
141 | } | ||
142 | |||
129 | 143 | ||
130 | static void | 144 | static void |
131 | member_join_decision (void *cls, | 145 | member_join_decision (void *cls, |
@@ -135,11 +149,19 @@ member_join_decision (void *cls, | |||
135 | const struct GNUNET_PeerIdentity *relays, | 149 | const struct GNUNET_PeerIdentity *relays, |
136 | const struct GNUNET_MessageHeader *join_msg) | 150 | const struct GNUNET_MessageHeader *join_msg) |
137 | { | 151 | { |
138 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 152 | struct GNUNET_MULTICAST_MemberTransmitHandle *req; |
153 | |||
154 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
139 | "Member received a decision from origin: %s\n", (GNUNET_YES == is_admitted)?"accepted":"rejected"); | 155 | "Member received a decision from origin: %s\n", (GNUNET_YES == is_admitted)?"accepted":"rejected"); |
140 | 156 | ||
141 | result = GNUNET_OK; | 157 | if (GNUNET_YES == is_admitted) |
142 | GNUNET_SCHEDULER_shutdown (); | 158 | { |
159 | req = GNUNET_MULTICAST_member_to_origin (member, | ||
160 | 0, | ||
161 | notify, | ||
162 | NULL); | ||
163 | |||
164 | } | ||
143 | } | 165 | } |
144 | 166 | ||
145 | static void | 167 | static void |
@@ -161,6 +183,10 @@ member_message () | |||
161 | { | 183 | { |
162 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 184 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
163 | "member message...\n"); | 185 | "member message...\n"); |
186 | |||
187 | // FIXME: not finished here | ||
188 | result = GNUNET_YES; | ||
189 | GNUNET_SCHEDULER_shutdown (); | ||
164 | } | 190 | } |
165 | 191 | ||
166 | static void | 192 | static void |
@@ -173,20 +199,21 @@ origin_join_request (void *cls, | |||
173 | 199 | ||
174 | uint8_t data_size = ntohs (join_msg->size); | 200 | uint8_t data_size = ntohs (join_msg->size); |
175 | 201 | ||
176 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 202 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
177 | "Dizzy: Mh, got a join request...\n"); | 203 | "origin got a join request...\n"); |
178 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 204 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
179 | "'%s'\n", (char *)&join_msg[1]); | 205 | "origin receives: '%s'\n", (char *)&join_msg[1]); |
180 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
181 | "Dizzy: Oh, it's Bird! Let's get him in.\n"); | ||
182 | 206 | ||
183 | char data[] = "Hi, Bird. Come in!"; | 207 | char data[] = "Come in!"; |
184 | data_size = strlen (data) + 1; | 208 | data_size = strlen (data) + 1; |
185 | join_resp = GNUNET_malloc (sizeof (join_resp) + data_size); | 209 | join_resp = GNUNET_malloc (sizeof (join_resp) + data_size); |
186 | join_resp->size = htons (sizeof (join_resp) + data_size); | 210 | join_resp->size = htons (sizeof (join_resp) + data_size); |
187 | join_resp->type = htons (123); | 211 | join_resp->type = htons (123); |
188 | GNUNET_memcpy (&join_resp[1], data, data_size); | 212 | GNUNET_memcpy (&join_resp[1], data, data_size); |
189 | 213 | ||
214 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
215 | "origin sends: '%s'\n", data); | ||
216 | |||
190 | GNUNET_MULTICAST_join_decision (jh, | 217 | GNUNET_MULTICAST_join_decision (jh, |
191 | GNUNET_YES, | 218 | GNUNET_YES, |
192 | 0, | 219 | 0, |
@@ -198,37 +225,62 @@ origin_join_request (void *cls, | |||
198 | 225 | ||
199 | static void | 226 | static void |
200 | origin_replay_frag (void *cls, | 227 | origin_replay_frag (void *cls, |
201 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_pub_key, | 228 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_pub_key, |
202 | uint64_t fragment_id, | 229 | uint64_t fragment_id, |
203 | uint64_t flags, | 230 | uint64_t flags, |
204 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 231 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
205 | { | 232 | { |
206 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay fraq msg\n"); | 233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay fraq msg\n"); |
207 | } | 234 | } |
208 | 235 | ||
209 | static void | 236 | static void |
210 | origin_replay_msg (void *cls, | 237 | origin_replay_msg (void *cls, |
211 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_pub_key, | 238 | const struct GNUNET_CRYPTO_EcdsaPublicKey *member_pub_key, |
212 | uint64_t message_id, | 239 | uint64_t message_id, |
213 | uint64_t fragment_offset, | 240 | uint64_t fragment_offset, |
214 | uint64_t flags, | 241 | uint64_t flags, |
215 | struct GNUNET_MULTICAST_ReplayHandle *rh) | 242 | struct GNUNET_MULTICAST_ReplayHandle *rh) |
216 | { | 243 | { |
217 | 244 | ||
218 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay msg\n"); | 245 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin replay msg\n"); |
219 | } | 246 | } |
220 | 247 | ||
248 | |||
249 | int | ||
250 | origin_notify (void *cls, | ||
251 | size_t *data_size, | ||
252 | void *data) | ||
253 | { | ||
254 | char text[] = "pong"; | ||
255 | *data_size = strlen(text)+1; | ||
256 | memcpy(data, text, *data_size); | ||
257 | |||
258 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends (to all): %s\n", text); | ||
259 | |||
260 | return GNUNET_YES; | ||
261 | } | ||
262 | |||
263 | |||
221 | static void | 264 | static void |
222 | origin_request (void *cls, | 265 | origin_request (void *cls, |
223 | const struct GNUNET_MULTICAST_RequestHeader *req) | 266 | const struct GNUNET_MULTICAST_RequestHeader *req) |
224 | { | 267 | { |
225 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin request msg\n"); | 268 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin receives: %s\n", (char *)&req[1]); |
269 | |||
270 | if (0 != strncmp ("ping", (char *)&req[1], 4)) { | ||
271 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "origin didn't reveice a correct request"); | ||
272 | } | ||
226 | 273 | ||
274 | GNUNET_MULTICAST_origin_to_all (origin, | ||
275 | 0, | ||
276 | 0, | ||
277 | origin_notify, | ||
278 | NULL); | ||
227 | } | 279 | } |
228 | 280 | ||
229 | static void | 281 | static void |
230 | origin_message (void *cls, | 282 | origin_message (void *cls, |
231 | const struct GNUNET_MULTICAST_MessageHeader *msg) | 283 | const struct GNUNET_MULTICAST_MessageHeader *msg) |
232 | { | 284 | { |
233 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin message msg\n"); | 285 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin message msg\n"); |
234 | } | 286 | } |
@@ -268,8 +320,8 @@ multicast_ca1 (void *cls, | |||
268 | // Get members keys | 320 | // Get members keys |
269 | member_key = GNUNET_CRYPTO_ecdsa_key_create (); | 321 | member_key = GNUNET_CRYPTO_ecdsa_key_create (); |
270 | GNUNET_CRYPTO_ecdsa_key_get_public (member_key, &member_pub_key); | 322 | GNUNET_CRYPTO_ecdsa_key_get_public (member_key, &member_pub_key); |
271 | 323 | ||
272 | char data[] = "Whut's up, Dizzy!"; | 324 | char data[] = "Hi, can I enter?"; |
273 | uint8_t data_size = strlen (data) + 1; | 325 | uint8_t data_size = strlen (data) + 1; |
274 | join_msg = GNUNET_malloc (sizeof (join_msg) + data_size); | 326 | join_msg = GNUNET_malloc (sizeof (join_msg) + data_size); |
275 | join_msg->size = htons (sizeof (join_msg) + data_size); | 327 | join_msg->size = htons (sizeof (join_msg) + data_size); |
@@ -453,7 +505,7 @@ testbed_master (void *cls, | |||
453 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); /* Schedule a new task on shutdown */ | 505 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); /* Schedule a new task on shutdown */ |
454 | 506 | ||
455 | /* Schedule the shutdown task with a delay of a few Seconds */ | 507 | /* Schedule the shutdown task with a delay of a few Seconds */ |
456 | timeout_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 40), | 508 | timeout_tid = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 48), |
457 | &timeout_task, NULL); | 509 | &timeout_task, NULL); |
458 | } | 510 | } |
459 | 511 | ||