diff options
-rw-r--r-- | src/chat/chat.c | 398 | ||||
-rw-r--r-- | src/chat/gnunet-chat.c | 222 | ||||
-rw-r--r-- | src/chat/gnunet-service-chat.c | 820 | ||||
-rw-r--r-- | src/chat/test_chat.c | 172 | ||||
-rw-r--r-- | src/chat/test_chat_private.c | 208 | ||||
-rw-r--r-- | src/include/gnunet_chat_service.h | 60 |
6 files changed, 940 insertions, 940 deletions
diff --git a/src/chat/chat.c b/src/chat/chat.c index 5f4e121dc..3c8f9a862 100644 --- a/src/chat/chat.c +++ b/src/chat/chat.c | |||
@@ -162,8 +162,8 @@ rejoin_room (struct GNUNET_CHAT_Room *chat_room); | |||
162 | */ | 162 | */ |
163 | static size_t | 163 | static size_t |
164 | transmit_acknowledge_request (void *cls, | 164 | transmit_acknowledge_request (void *cls, |
165 | size_t size, | 165 | size_t size, |
166 | void *buf) | 166 | void *buf) |
167 | { | 167 | { |
168 | struct GNUNET_CHAT_SendReceiptContext *src = cls; | 168 | struct GNUNET_CHAT_SendReceiptContext *src = cls; |
169 | struct ConfirmationReceiptMessage *receipt; | 169 | struct ConfirmationReceiptMessage *receipt; |
@@ -174,12 +174,12 @@ transmit_acknowledge_request (void *cls, | |||
174 | if (NULL == buf) | 174 | if (NULL == buf) |
175 | { | 175 | { |
176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 176 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
177 | _("Could not transmit confirmation receipt\n")); | 177 | _("Could not transmit confirmation receipt\n")); |
178 | return 0; | 178 | return 0; |
179 | } | 179 | } |
180 | #if DEBUG_CHAT | 180 | #if DEBUG_CHAT |
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
182 | "Transmitting confirmation receipt to the service\n"); | 182 | "Transmitting confirmation receipt to the service\n"); |
183 | #endif | 183 | #endif |
184 | msg_size = sizeof (struct ConfirmationReceiptMessage); | 184 | msg_size = sizeof (struct ConfirmationReceiptMessage); |
185 | GNUNET_assert (size >= msg_size); | 185 | GNUNET_assert (size >= msg_size); |
@@ -192,23 +192,23 @@ transmit_acknowledge_request (void *cls, | |||
192 | receipt->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); | 192 | receipt->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ()); |
193 | GNUNET_CRYPTO_rsa_key_get_public (src->chat_room->my_private_key, &pub_key); | 193 | GNUNET_CRYPTO_rsa_key_get_public (src->chat_room->my_private_key, &pub_key); |
194 | GNUNET_CRYPTO_hash (&pub_key, | 194 | GNUNET_CRYPTO_hash (&pub_key, |
195 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 195 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
196 | &receipt->target); | 196 | &receipt->target); |
197 | receipt->author = src->received_msg->sender; | 197 | receipt->author = src->received_msg->sender; |
198 | receipt->purpose.purpose = | 198 | receipt->purpose.purpose = |
199 | htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT); | 199 | htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT); |
200 | receipt->purpose.size = | 200 | receipt->purpose.size = |
201 | htonl (msg_size - | 201 | htonl (msg_size - |
202 | sizeof (struct GNUNET_MessageHeader) - | 202 | sizeof (struct GNUNET_MessageHeader) - |
203 | sizeof (uint32_t) - | 203 | sizeof (uint32_t) - |
204 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 204 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
205 | msg_len = ntohs (src->received_msg->header.size) - | 205 | msg_len = ntohs (src->received_msg->header.size) - |
206 | sizeof (struct ReceiveNotificationMessage); | 206 | sizeof (struct ReceiveNotificationMessage); |
207 | GNUNET_CRYPTO_hash (&src->received_msg[1], msg_len, &receipt->content); | 207 | GNUNET_CRYPTO_hash (&src->received_msg[1], msg_len, &receipt->content); |
208 | GNUNET_assert (GNUNET_OK == | 208 | GNUNET_assert (GNUNET_OK == |
209 | GNUNET_CRYPTO_rsa_sign (src->chat_room->my_private_key, | 209 | GNUNET_CRYPTO_rsa_sign (src->chat_room->my_private_key, |
210 | &receipt->purpose, | 210 | &receipt->purpose, |
211 | &receipt->signature)); | 211 | &receipt->signature)); |
212 | GNUNET_free (src->received_msg); | 212 | GNUNET_free (src->received_msg); |
213 | GNUNET_free (src); | 213 | GNUNET_free (src); |
214 | return msg_size; | 214 | return msg_size; |
@@ -221,7 +221,7 @@ transmit_acknowledge_request (void *cls, | |||
221 | */ | 221 | */ |
222 | static void | 222 | static void |
223 | process_result (struct GNUNET_CHAT_Room *room, | 223 | process_result (struct GNUNET_CHAT_Room *room, |
224 | const struct GNUNET_MessageHeader *reply) | 224 | const struct GNUNET_MessageHeader *reply) |
225 | { | 225 | { |
226 | struct LeaveNotificationMessage *leave_msg; | 226 | struct LeaveNotificationMessage *leave_msg; |
227 | struct JoinNotificationMessage *join_msg; | 227 | struct JoinNotificationMessage *join_msg; |
@@ -249,80 +249,80 @@ process_result (struct GNUNET_CHAT_Room *room, | |||
249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a join notification\n"); | 249 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a join notification\n"); |
250 | #endif | 250 | #endif |
251 | if (size < sizeof (struct JoinNotificationMessage)) | 251 | if (size < sizeof (struct JoinNotificationMessage)) |
252 | { | 252 | { |
253 | GNUNET_break (0); | 253 | GNUNET_break (0); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | join_msg = (struct JoinNotificationMessage *) reply; | 256 | join_msg = (struct JoinNotificationMessage *) reply; |
257 | meta_len = size - sizeof (struct JoinNotificationMessage); | 257 | meta_len = size - sizeof (struct JoinNotificationMessage); |
258 | meta = | 258 | meta = |
259 | GNUNET_CONTAINER_meta_data_deserialize ((const char *) &join_msg[1], | 259 | GNUNET_CONTAINER_meta_data_deserialize ((const char *) &join_msg[1], |
260 | meta_len); | 260 | meta_len); |
261 | if (NULL == meta) | 261 | if (NULL == meta) |
262 | { | 262 | { |
263 | GNUNET_break (0); | 263 | GNUNET_break (0); |
264 | return; | 264 | return; |
265 | } | 265 | } |
266 | pos = GNUNET_malloc (sizeof (struct MemberList)); | 266 | pos = GNUNET_malloc (sizeof (struct MemberList)); |
267 | pos->meta = meta; | 267 | pos->meta = meta; |
268 | GNUNET_CRYPTO_hash (&join_msg->public_key, | 268 | GNUNET_CRYPTO_hash (&join_msg->public_key, |
269 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 269 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
270 | &pos->id); | 270 | &pos->id); |
271 | GNUNET_PSEUDONYM_add (room->cfg, &pos->id, meta); | 271 | GNUNET_PSEUDONYM_add (room->cfg, &pos->id, meta); |
272 | pos->next = room->members; | 272 | pos->next = room->members; |
273 | room->members = pos; | 273 | room->members = pos; |
274 | if (GNUNET_NO == room->is_joined) | 274 | if (GNUNET_NO == room->is_joined) |
275 | { | 275 | { |
276 | GNUNET_CRYPTO_rsa_key_get_public (room->my_private_key, &pkey); | 276 | GNUNET_CRYPTO_rsa_key_get_public (room->my_private_key, &pkey); |
277 | if (0 == memcmp (&join_msg->public_key, | 277 | if (0 == memcmp (&join_msg->public_key, |
278 | &pkey, | 278 | &pkey, |
279 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) | 279 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded))) |
280 | { | 280 | { |
281 | room->join_callback (room->join_callback_cls); | 281 | room->join_callback (room->join_callback_cls); |
282 | room->is_joined = GNUNET_YES; | 282 | room->is_joined = GNUNET_YES; |
283 | } | 283 | } |
284 | else | 284 | else |
285 | { | 285 | { |
286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 286 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
287 | _("The current user must be the the first one joined\n")); | 287 | _("The current user must be the the first one joined\n")); |
288 | GNUNET_break (0); | 288 | GNUNET_break (0); |
289 | return; | 289 | return; |
290 | } | 290 | } |
291 | } | 291 | } |
292 | else | 292 | else |
293 | room->member_list_callback (room->member_list_callback_cls, | 293 | room->member_list_callback (room->member_list_callback_cls, |
294 | meta, &join_msg->public_key, | 294 | meta, &join_msg->public_key, |
295 | ntohl (join_msg->msg_options)); | 295 | ntohl (join_msg->msg_options)); |
296 | break; | 296 | break; |
297 | case GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION: | 297 | case GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION: |
298 | #if DEBUG_CHAT | 298 | #if DEBUG_CHAT |
299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a leave notification\n"); | 299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a leave notification\n"); |
300 | #endif | 300 | #endif |
301 | if (size < sizeof (struct LeaveNotificationMessage)) | 301 | if (size < sizeof (struct LeaveNotificationMessage)) |
302 | { | 302 | { |
303 | GNUNET_break (0); | 303 | GNUNET_break (0); |
304 | return; | 304 | return; |
305 | } | 305 | } |
306 | leave_msg = (struct LeaveNotificationMessage *) reply; | 306 | leave_msg = (struct LeaveNotificationMessage *) reply; |
307 | room->member_list_callback (room->member_list_callback_cls, | 307 | room->member_list_callback (room->member_list_callback_cls, |
308 | NULL, &leave_msg->user, | 308 | NULL, &leave_msg->user, |
309 | GNUNET_CHAT_MSG_OPTION_NONE); | 309 | GNUNET_CHAT_MSG_OPTION_NONE); |
310 | GNUNET_CRYPTO_hash (&leave_msg->user, | 310 | GNUNET_CRYPTO_hash (&leave_msg->user, |
311 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 311 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
312 | &id); | 312 | &id); |
313 | prev = NULL; | 313 | prev = NULL; |
314 | pos = room->members; | 314 | pos = room->members; |
315 | while ((NULL != pos) && | 315 | while ((NULL != pos) && |
316 | (0 != memcmp (&pos->id, &id, sizeof (GNUNET_HashCode)))) | 316 | (0 != memcmp (&pos->id, &id, sizeof (GNUNET_HashCode)))) |
317 | { | 317 | { |
318 | prev = pos; | 318 | prev = pos; |
319 | pos = pos->next; | 319 | pos = pos->next; |
320 | } | 320 | } |
321 | GNUNET_assert (NULL != pos); | 321 | GNUNET_assert (NULL != pos); |
322 | if (NULL == prev) | 322 | if (NULL == prev) |
323 | room->members = pos->next; | 323 | room->members = pos->next; |
324 | else | 324 | else |
325 | prev->next = pos->next; | 325 | prev->next = pos->next; |
326 | GNUNET_CONTAINER_meta_data_destroy (pos->meta); | 326 | GNUNET_CONTAINER_meta_data_destroy (pos->meta); |
327 | GNUNET_free (pos); | 327 | GNUNET_free (pos); |
328 | break; | 328 | break; |
@@ -331,96 +331,96 @@ process_result (struct GNUNET_CHAT_Room *room, | |||
331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a message notification\n"); | 331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a message notification\n"); |
332 | #endif | 332 | #endif |
333 | if (size <= sizeof (struct ReceiveNotificationMessage)) | 333 | if (size <= sizeof (struct ReceiveNotificationMessage)) |
334 | { | 334 | { |
335 | GNUNET_break (0); | 335 | GNUNET_break (0); |
336 | return; | 336 | return; |
337 | } | 337 | } |
338 | received_msg = (struct ReceiveNotificationMessage *) reply; | 338 | received_msg = (struct ReceiveNotificationMessage *) reply; |
339 | if (0 != | 339 | if (0 != |
340 | (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ACKNOWLEDGED)) | 340 | (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ACKNOWLEDGED)) |
341 | { | 341 | { |
342 | src = GNUNET_malloc (sizeof (struct GNUNET_CHAT_SendReceiptContext)); | 342 | src = GNUNET_malloc (sizeof (struct GNUNET_CHAT_SendReceiptContext)); |
343 | src->chat_room = room; | 343 | src->chat_room = room; |
344 | src->received_msg = GNUNET_memdup (received_msg, size); | 344 | src->received_msg = GNUNET_memdup (received_msg, size); |
345 | GNUNET_CLIENT_notify_transmit_ready (room->client, | 345 | GNUNET_CLIENT_notify_transmit_ready (room->client, |
346 | sizeof (struct ConfirmationReceiptMessage), | 346 | sizeof (struct ConfirmationReceiptMessage), |
347 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 347 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
348 | GNUNET_YES, | 348 | GNUNET_YES, |
349 | &transmit_acknowledge_request, | 349 | &transmit_acknowledge_request, |
350 | src); | 350 | src); |
351 | } | 351 | } |
352 | msg_len = size - sizeof (struct ReceiveNotificationMessage); | 352 | msg_len = size - sizeof (struct ReceiveNotificationMessage); |
353 | if (0 != | 353 | if (0 != |
354 | (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_PRIVATE)) | 354 | (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_PRIVATE)) |
355 | { | 355 | { |
356 | if (-1 == GNUNET_CRYPTO_rsa_decrypt (room->my_private_key, | 356 | if (-1 == GNUNET_CRYPTO_rsa_decrypt (room->my_private_key, |
357 | &received_msg->encrypted_key, | 357 | &received_msg->encrypted_key, |
358 | &key, | 358 | &key, |
359 | sizeof (struct GNUNET_CRYPTO_AesSessionKey))) | 359 | sizeof (struct GNUNET_CRYPTO_AesSessionKey))) |
360 | { | 360 | { |
361 | GNUNET_break (0); | 361 | GNUNET_break (0); |
362 | return; | 362 | return; |
363 | } | 363 | } |
364 | msg_len = GNUNET_CRYPTO_aes_decrypt (&received_msg[1], | 364 | msg_len = GNUNET_CRYPTO_aes_decrypt (&received_msg[1], |
365 | msg_len, | 365 | msg_len, |
366 | &key, | 366 | &key, |
367 | (const struct GNUNET_CRYPTO_AesInitializationVector *) INITVALUE, | 367 | (const struct GNUNET_CRYPTO_AesInitializationVector *) INITVALUE, |
368 | decrypted_msg); | 368 | decrypted_msg); |
369 | message_content = decrypted_msg; | 369 | message_content = decrypted_msg; |
370 | } | 370 | } |
371 | else | 371 | else |
372 | { | 372 | { |
373 | message_content = GNUNET_malloc (msg_len + 1); | 373 | message_content = GNUNET_malloc (msg_len + 1); |
374 | memcpy (message_content, &received_msg[1], msg_len); | 374 | memcpy (message_content, &received_msg[1], msg_len); |
375 | } | 375 | } |
376 | message_content[msg_len] = '\0'; | 376 | message_content[msg_len] = '\0'; |
377 | if (0 != (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ANONYMOUS)) | 377 | if (0 != (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ANONYMOUS)) |
378 | { | 378 | { |
379 | sender = NULL; | 379 | sender = NULL; |
380 | meta = NULL; | 380 | meta = NULL; |
381 | } | 381 | } |
382 | else | 382 | else |
383 | { | 383 | { |
384 | pos = room->members; | 384 | pos = room->members; |
385 | while ((NULL != pos) && | 385 | while ((NULL != pos) && |
386 | (0 != memcmp (&pos->id, | 386 | (0 != memcmp (&pos->id, |
387 | &received_msg->sender, | 387 | &received_msg->sender, |
388 | sizeof (GNUNET_HashCode)))) | 388 | sizeof (GNUNET_HashCode)))) |
389 | pos = pos->next; | 389 | pos = pos->next; |
390 | GNUNET_assert (NULL != pos); | 390 | GNUNET_assert (NULL != pos); |
391 | sender = &received_msg->sender; | 391 | sender = &received_msg->sender; |
392 | meta = pos->meta; | 392 | meta = pos->meta; |
393 | } | 393 | } |
394 | room->message_callback (room->message_callback_cls, | 394 | room->message_callback (room->message_callback_cls, |
395 | room, | 395 | room, |
396 | sender, | 396 | sender, |
397 | meta, | 397 | meta, |
398 | message_content, | 398 | message_content, |
399 | GNUNET_TIME_absolute_ntoh (received_msg->timestamp), | 399 | GNUNET_TIME_absolute_ntoh (received_msg->timestamp), |
400 | ntohl (received_msg->msg_options)); | 400 | ntohl (received_msg->msg_options)); |
401 | if (message_content != decrypted_msg) | 401 | if (message_content != decrypted_msg) |
402 | GNUNET_free (message_content); | 402 | GNUNET_free (message_content); |
403 | break; | 403 | break; |
404 | case GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION: | 404 | case GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION: |
405 | #if DEBUG_CHAT | 405 | #if DEBUG_CHAT |
406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a confirmation receipt\n"); | 406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a confirmation receipt\n"); |
407 | #endif | 407 | #endif |
408 | if (size < sizeof (struct ConfirmationReceiptMessage)) | 408 | if (size < sizeof (struct ConfirmationReceiptMessage)) |
409 | { | 409 | { |
410 | GNUNET_break (0); | 410 | GNUNET_break (0); |
411 | return; | 411 | return; |
412 | } | 412 | } |
413 | receipt = (struct ConfirmationReceiptMessage *) reply; | 413 | receipt = (struct ConfirmationReceiptMessage *) reply; |
414 | if (NULL != room->confirmation_callback) | 414 | if (NULL != room->confirmation_callback) |
415 | room->confirmation_callback (room->confirmation_cls, | 415 | room->confirmation_callback (room->confirmation_cls, |
416 | room, | 416 | room, |
417 | ntohl (receipt->sequence_number), | 417 | ntohl (receipt->sequence_number), |
418 | GNUNET_TIME_absolute_ntoh (receipt->timestamp), | 418 | GNUNET_TIME_absolute_ntoh (receipt->timestamp), |
419 | &receipt->target); | 419 | &receipt->target); |
420 | break; | 420 | break; |
421 | default: | 421 | default: |
422 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 422 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
423 | _("Unknown message type: '%u'\n"), ntohs (reply->type)); | 423 | _("Unknown message type: '%u'\n"), ntohs (reply->type)); |
424 | GNUNET_break_op (0); | 424 | GNUNET_break_op (0); |
425 | break; | 425 | break; |
426 | } | 426 | } |
@@ -436,7 +436,7 @@ process_result (struct GNUNET_CHAT_Room *room, | |||
436 | */ | 436 | */ |
437 | static void | 437 | static void |
438 | receive_results (void *cls, | 438 | receive_results (void *cls, |
439 | const struct GNUNET_MessageHeader *msg) | 439 | const struct GNUNET_MessageHeader *msg) |
440 | { | 440 | { |
441 | struct GNUNET_CHAT_Room *chat_room = cls; | 441 | struct GNUNET_CHAT_Room *chat_room = cls; |
442 | 442 | ||
@@ -456,9 +456,9 @@ receive_results (void *cls, | |||
456 | return; /* fatal error */ | 456 | return; /* fatal error */ |
457 | /* continue receiving */ | 457 | /* continue receiving */ |
458 | GNUNET_CLIENT_receive (chat_room->client, | 458 | GNUNET_CLIENT_receive (chat_room->client, |
459 | &receive_results, | 459 | &receive_results, |
460 | chat_room, | 460 | chat_room, |
461 | GNUNET_TIME_UNIT_FOREVER_REL); | 461 | GNUNET_TIME_UNIT_FOREVER_REL); |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
@@ -469,7 +469,7 @@ receive_results (void *cls, | |||
469 | */ | 469 | */ |
470 | static struct GNUNET_CRYPTO_RsaPrivateKey * | 470 | static struct GNUNET_CRYPTO_RsaPrivateKey * |
471 | init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg, | 471 | init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg, |
472 | const char *nick_name) | 472 | const char *nick_name) |
473 | { | 473 | { |
474 | char *home; | 474 | char *home; |
475 | char *keyfile; | 475 | char *keyfile; |
@@ -480,29 +480,29 @@ init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
480 | #endif | 480 | #endif |
481 | if (GNUNET_OK != | 481 | if (GNUNET_OK != |
482 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 482 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
483 | "chat", | 483 | "chat", |
484 | "HOME", | 484 | "HOME", |
485 | &home)) | 485 | &home)) |
486 | { | 486 | { |
487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 487 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
488 | _("Configuration option `%s' in section `%s' missing\n"), | 488 | _("Configuration option `%s' in section `%s' missing\n"), |
489 | "HOME", | 489 | "HOME", |
490 | "chat"); | 490 | "chat"); |
491 | return NULL; | 491 | return NULL; |
492 | } | 492 | } |
493 | GNUNET_DISK_directory_create (home); | 493 | GNUNET_DISK_directory_create (home); |
494 | if (GNUNET_OK != GNUNET_DISK_directory_test (home)) | 494 | if (GNUNET_OK != GNUNET_DISK_directory_test (home)) |
495 | { | 495 | { |
496 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 496 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
497 | _("Failed to access chat home directory `%s'\n"), | 497 | _("Failed to access chat home directory `%s'\n"), |
498 | home); | 498 | home); |
499 | GNUNET_free (home); | 499 | GNUNET_free (home); |
500 | return NULL; | 500 | return NULL; |
501 | } | 501 | } |
502 | /* read or create private key */ | 502 | /* read or create private key */ |
503 | keyfile = | 503 | keyfile = |
504 | GNUNET_malloc (strlen (home) + strlen (NICK_IDENTITY_PREFIX) + | 504 | GNUNET_malloc (strlen (home) + strlen (NICK_IDENTITY_PREFIX) + |
505 | strlen (nick_name) + 2); | 505 | strlen (nick_name) + 2); |
506 | strcpy (keyfile, home); | 506 | strcpy (keyfile, home); |
507 | GNUNET_free (home); | 507 | GNUNET_free (home); |
508 | if (keyfile[strlen (keyfile) - 1] != DIR_SEPARATOR) | 508 | if (keyfile[strlen (keyfile) - 1] != DIR_SEPARATOR) |
@@ -513,8 +513,8 @@ init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
513 | if (NULL == privKey) | 513 | if (NULL == privKey) |
514 | { | 514 | { |
515 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 515 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
516 | _("Failed to create/open key in file `%s'\n"), | 516 | _("Failed to create/open key in file `%s'\n"), |
517 | keyfile); | 517 | keyfile); |
518 | } | 518 | } |
519 | GNUNET_free (keyfile); | 519 | GNUNET_free (keyfile); |
520 | return privKey; | 520 | return privKey; |
@@ -531,8 +531,8 @@ init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
531 | */ | 531 | */ |
532 | static size_t | 532 | static size_t |
533 | transmit_join_request (void *cls, | 533 | transmit_join_request (void *cls, |
534 | size_t size, | 534 | size_t size, |
535 | void *buf) | 535 | void *buf) |
536 | { | 536 | { |
537 | struct GNUNET_CHAT_Room *chat_room = cls; | 537 | struct GNUNET_CHAT_Room *chat_room = cls; |
538 | struct JoinRequestMessage *join_msg; | 538 | struct JoinRequestMessage *join_msg; |
@@ -546,14 +546,14 @@ transmit_join_request (void *cls, | |||
546 | { | 546 | { |
547 | #if DEBUG_CHAT | 547 | #if DEBUG_CHAT |
548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 548 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
549 | "Could not transmit join request, retrying...\n"); | 549 | "Could not transmit join request, retrying...\n"); |
550 | #endif | 550 | #endif |
551 | rejoin_room (chat_room); | 551 | rejoin_room (chat_room); |
552 | return 0; | 552 | return 0; |
553 | } | 553 | } |
554 | #if DEBUG_CHAT | 554 | #if DEBUG_CHAT |
555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 555 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
556 | "Transmitting join request to the service\n"); | 556 | "Transmitting join request to the service\n"); |
557 | #endif | 557 | #endif |
558 | room_len = strlen (chat_room->room_name); | 558 | room_len = strlen (chat_room->room_name); |
559 | meta_len = GNUNET_CONTAINER_meta_data_get_serialized_size (chat_room->member_info); | 559 | meta_len = GNUNET_CONTAINER_meta_data_get_serialized_size (chat_room->member_info); |
@@ -571,18 +571,18 @@ transmit_join_request (void *cls, | |||
571 | meta = &room[room_len]; | 571 | meta = &room[room_len]; |
572 | if (GNUNET_SYSERR == | 572 | if (GNUNET_SYSERR == |
573 | GNUNET_CONTAINER_meta_data_serialize (chat_room->member_info, | 573 | GNUNET_CONTAINER_meta_data_serialize (chat_room->member_info, |
574 | &meta, | 574 | &meta, |
575 | meta_len, | 575 | meta_len, |
576 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) | 576 | GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL)) |
577 | { | 577 | { |
578 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 578 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
579 | _("Could not serialize metadata\n")); | 579 | _("Could not serialize metadata\n")); |
580 | return 0; | 580 | return 0; |
581 | } | 581 | } |
582 | GNUNET_CLIENT_receive (chat_room->client, | 582 | GNUNET_CLIENT_receive (chat_room->client, |
583 | &receive_results, | 583 | &receive_results, |
584 | chat_room, | 584 | chat_room, |
585 | GNUNET_TIME_UNIT_FOREVER_REL); | 585 | GNUNET_TIME_UNIT_FOREVER_REL); |
586 | return size_of_join; | 586 | return size_of_join; |
587 | } | 587 | } |
588 | 588 | ||
@@ -600,11 +600,11 @@ rejoin_room (struct GNUNET_CHAT_Room *chat_room) | |||
600 | strlen (chat_room->room_name); | 600 | strlen (chat_room->room_name); |
601 | if (NULL == | 601 | if (NULL == |
602 | GNUNET_CLIENT_notify_transmit_ready (chat_room->client, | 602 | GNUNET_CLIENT_notify_transmit_ready (chat_room->client, |
603 | size_of_join, | 603 | size_of_join, |
604 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 604 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
605 | GNUNET_YES, | 605 | GNUNET_YES, |
606 | &transmit_join_request, | 606 | &transmit_join_request, |
607 | chat_room)) | 607 | chat_room)) |
608 | return GNUNET_SYSERR; | 608 | return GNUNET_SYSERR; |
609 | return GNUNET_OK; | 609 | return GNUNET_OK; |
610 | } | 610 | } |
@@ -620,7 +620,7 @@ GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room) | |||
620 | 620 | ||
621 | #if DEBUG_CHAT | 621 | #if DEBUG_CHAT |
622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
623 | "Leaving the room '%s'\n", chat_room->room_name); | 623 | "Leaving the room '%s'\n", chat_room->room_name); |
624 | #endif | 624 | #endif |
625 | GNUNET_CLIENT_disconnect (chat_room->client, GNUNET_NO); | 625 | GNUNET_CLIENT_disconnect (chat_room->client, GNUNET_NO); |
626 | GNUNET_free (chat_room->room_name); | 626 | GNUNET_free (chat_room->room_name); |
@@ -660,19 +660,19 @@ GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room) | |||
660 | */ | 660 | */ |
661 | struct GNUNET_CHAT_Room * | 661 | struct GNUNET_CHAT_Room * |
662 | GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, | 662 | GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, |
663 | const char *nick_name, | 663 | const char *nick_name, |
664 | struct GNUNET_CONTAINER_MetaData *member_info, | 664 | struct GNUNET_CONTAINER_MetaData *member_info, |
665 | const char *room_name, | 665 | const char *room_name, |
666 | enum GNUNET_CHAT_MsgOptions msg_options, | 666 | enum GNUNET_CHAT_MsgOptions msg_options, |
667 | GNUNET_CHAT_JoinCallback joinCallback, | 667 | GNUNET_CHAT_JoinCallback joinCallback, |
668 | void *join_cls, | 668 | void *join_cls, |
669 | GNUNET_CHAT_MessageCallback messageCallback, | 669 | GNUNET_CHAT_MessageCallback messageCallback, |
670 | void *message_cls, | 670 | void *message_cls, |
671 | GNUNET_CHAT_MemberListCallback memberCallback, | 671 | GNUNET_CHAT_MemberListCallback memberCallback, |
672 | void *member_cls, | 672 | void *member_cls, |
673 | GNUNET_CHAT_MessageConfirmation confirmationCallback, | 673 | GNUNET_CHAT_MessageConfirmation confirmationCallback, |
674 | void *confirmation_cls, | 674 | void *confirmation_cls, |
675 | GNUNET_HashCode *me) | 675 | GNUNET_HashCode *me) |
676 | { | 676 | { |
677 | struct GNUNET_CHAT_Room *chat_room; | 677 | struct GNUNET_CHAT_Room *chat_room; |
678 | struct GNUNET_CRYPTO_RsaPrivateKey *priv_key; | 678 | struct GNUNET_CRYPTO_RsaPrivateKey *priv_key; |
@@ -687,32 +687,32 @@ GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
687 | return NULL; | 687 | return NULL; |
688 | GNUNET_CRYPTO_rsa_key_get_public (priv_key, &pub_key); | 688 | GNUNET_CRYPTO_rsa_key_get_public (priv_key, &pub_key); |
689 | GNUNET_CRYPTO_hash (&pub_key, | 689 | GNUNET_CRYPTO_hash (&pub_key, |
690 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 690 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
691 | me); | 691 | me); |
692 | GNUNET_PSEUDONYM_add (cfg, me, member_info); | 692 | GNUNET_PSEUDONYM_add (cfg, me, member_info); |
693 | client = GNUNET_CLIENT_connect ("chat", cfg); | 693 | client = GNUNET_CLIENT_connect ("chat", cfg); |
694 | if (NULL == client) | 694 | if (NULL == client) |
695 | { | 695 | { |
696 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 696 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
697 | _("Failed to connect to the chat service\n")); | 697 | _("Failed to connect to the chat service\n")); |
698 | return NULL; | 698 | return NULL; |
699 | } | 699 | } |
700 | if (NULL == joinCallback) | 700 | if (NULL == joinCallback) |
701 | { | 701 | { |
702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 702 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
703 | _("Undefined mandatory parameter: joinCallback\n")); | 703 | _("Undefined mandatory parameter: joinCallback\n")); |
704 | return NULL; | 704 | return NULL; |
705 | } | 705 | } |
706 | if (NULL == messageCallback) | 706 | if (NULL == messageCallback) |
707 | { | 707 | { |
708 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 708 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
709 | _("Undefined mandatory parameter: messageCallback\n")); | 709 | _("Undefined mandatory parameter: messageCallback\n")); |
710 | return NULL; | 710 | return NULL; |
711 | } | 711 | } |
712 | if (NULL == memberCallback) | 712 | if (NULL == memberCallback) |
713 | { | 713 | { |
714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 714 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
715 | _("Undefined mandatory parameter: memberCallback\n")); | 715 | _("Undefined mandatory parameter: memberCallback\n")); |
716 | return NULL; | 716 | return NULL; |
717 | } | 717 | } |
718 | chat_room = GNUNET_malloc (sizeof (struct GNUNET_CHAT_Room)); | 718 | chat_room = GNUNET_malloc (sizeof (struct GNUNET_CHAT_Room)); |
@@ -751,8 +751,8 @@ GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
751 | */ | 751 | */ |
752 | static size_t | 752 | static size_t |
753 | transmit_send_request (void *cls, | 753 | transmit_send_request (void *cls, |
754 | size_t size, | 754 | size_t size, |
755 | void *buf) | 755 | void *buf) |
756 | { | 756 | { |
757 | struct GNUNET_CHAT_SendMessageContext *smc = cls; | 757 | struct GNUNET_CHAT_SendMessageContext *smc = cls; |
758 | struct TransmitRequestMessage *msg_to_send; | 758 | struct TransmitRequestMessage *msg_to_send; |
@@ -762,13 +762,13 @@ transmit_send_request (void *cls, | |||
762 | { | 762 | { |
763 | #if DEBUG_CHAT | 763 | #if DEBUG_CHAT |
764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
765 | "Could not transmit a chat message\n"); | 765 | "Could not transmit a chat message\n"); |
766 | #endif | 766 | #endif |
767 | return 0; | 767 | return 0; |
768 | } | 768 | } |
769 | #if DEBUG_CHAT | 769 | #if DEBUG_CHAT |
770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
771 | "Transmitting a chat message to the service\n"); | 771 | "Transmitting a chat message to the service\n"); |
772 | #endif | 772 | #endif |
773 | msg_size = strlen (smc->message) + sizeof (struct TransmitRequestMessage); | 773 | msg_size = strlen (smc->message) + sizeof (struct TransmitRequestMessage); |
774 | GNUNET_assert (size >= msg_size); | 774 | GNUNET_assert (size >= msg_size); |
@@ -784,8 +784,8 @@ transmit_send_request (void *cls, | |||
784 | memset (&msg_to_send->target, 0, sizeof (GNUNET_HashCode)); | 784 | memset (&msg_to_send->target, 0, sizeof (GNUNET_HashCode)); |
785 | else | 785 | else |
786 | GNUNET_CRYPTO_hash (smc->receiver, | 786 | GNUNET_CRYPTO_hash (smc->receiver, |
787 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 787 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
788 | &msg_to_send->target); | 788 | &msg_to_send->target); |
789 | memcpy (&msg_to_send[1], smc->message, strlen (smc->message)); | 789 | memcpy (&msg_to_send[1], smc->message, strlen (smc->message)); |
790 | /** | 790 | /** |
791 | * Client don't encode private messages since public keys of other members are | 791 | * Client don't encode private messages since public keys of other members are |
@@ -794,15 +794,15 @@ transmit_send_request (void *cls, | |||
794 | if (smc->options & GNUNET_CHAT_MSG_AUTHENTICATED) | 794 | if (smc->options & GNUNET_CHAT_MSG_AUTHENTICATED) |
795 | { | 795 | { |
796 | msg_to_send->purpose.purpose = | 796 | msg_to_send->purpose.purpose = |
797 | htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); | 797 | htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE); |
798 | msg_to_send->purpose.size = | 798 | msg_to_send->purpose.size = |
799 | htonl (msg_size - | 799 | htonl (msg_size - |
800 | sizeof (struct GNUNET_MessageHeader) - | 800 | sizeof (struct GNUNET_MessageHeader) - |
801 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); | 801 | sizeof (struct GNUNET_CRYPTO_RsaSignature)); |
802 | GNUNET_assert (GNUNET_OK == | 802 | GNUNET_assert (GNUNET_OK == |
803 | GNUNET_CRYPTO_rsa_sign (smc->chat_room->my_private_key, | 803 | GNUNET_CRYPTO_rsa_sign (smc->chat_room->my_private_key, |
804 | &msg_to_send->purpose, | 804 | &msg_to_send->purpose, |
805 | &msg_to_send->signature)); | 805 | &msg_to_send->signature)); |
806 | } | 806 | } |
807 | GNUNET_free (smc->message); | 807 | GNUNET_free (smc->message); |
808 | GNUNET_free (smc); | 808 | GNUNET_free (smc); |
@@ -821,10 +821,10 @@ transmit_send_request (void *cls, | |||
821 | */ | 821 | */ |
822 | void | 822 | void |
823 | GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, | 823 | GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, |
824 | const char *message, | 824 | const char *message, |
825 | enum GNUNET_CHAT_MsgOptions options, | 825 | enum GNUNET_CHAT_MsgOptions options, |
826 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver, | 826 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver, |
827 | uint32_t *sequence_number) | 827 | uint32_t *sequence_number) |
828 | { | 828 | { |
829 | size_t msg_size; | 829 | size_t msg_size; |
830 | struct GNUNET_CHAT_SendMessageContext *smc; | 830 | struct GNUNET_CHAT_SendMessageContext *smc; |
@@ -843,11 +843,11 @@ GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, | |||
843 | smc->sequence_number = room->sequence_number; | 843 | smc->sequence_number = room->sequence_number; |
844 | msg_size = strlen (message) + sizeof (struct TransmitRequestMessage); | 844 | msg_size = strlen (message) + sizeof (struct TransmitRequestMessage); |
845 | GNUNET_CLIENT_notify_transmit_ready (room->client, | 845 | GNUNET_CLIENT_notify_transmit_ready (room->client, |
846 | msg_size, | 846 | msg_size, |
847 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | 847 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, |
848 | GNUNET_YES, | 848 | GNUNET_YES, |
849 | &transmit_send_request, | 849 | &transmit_send_request, |
850 | smc); | 850 | smc); |
851 | } | 851 | } |
852 | 852 | ||
853 | /* end of chat.c */ | 853 | /* end of chat.c */ |
diff --git a/src/chat/gnunet-chat.c b/src/chat/gnunet-chat.c index 22bdcc237..12366695a 100644 --- a/src/chat/gnunet-chat.c +++ b/src/chat/gnunet-chat.c | |||
@@ -105,12 +105,12 @@ join_cb (void *cls) | |||
105 | */ | 105 | */ |
106 | static int | 106 | static int |
107 | receive_cb (void *cls, | 107 | receive_cb (void *cls, |
108 | struct GNUNET_CHAT_Room *room, | 108 | struct GNUNET_CHAT_Room *room, |
109 | const GNUNET_HashCode *sender, | 109 | const GNUNET_HashCode *sender, |
110 | const struct GNUNET_CONTAINER_MetaData *member_info, | 110 | const struct GNUNET_CONTAINER_MetaData *member_info, |
111 | const char *message, | 111 | const char *message, |
112 | struct GNUNET_TIME_Absolute timestamp, | 112 | struct GNUNET_TIME_Absolute timestamp, |
113 | enum GNUNET_CHAT_MsgOptions options) | 113 | enum GNUNET_CHAT_MsgOptions options) |
114 | { | 114 | { |
115 | char *nick; | 115 | char *nick; |
116 | char *time; | 116 | char *time; |
@@ -181,10 +181,10 @@ receive_cb (void *cls, | |||
181 | */ | 181 | */ |
182 | static int | 182 | static int |
183 | confirmation_cb (void *cls, | 183 | confirmation_cb (void *cls, |
184 | struct GNUNET_CHAT_Room *room, | 184 | struct GNUNET_CHAT_Room *room, |
185 | uint32_t orig_seq_number, | 185 | uint32_t orig_seq_number, |
186 | struct GNUNET_TIME_Absolute timestamp, | 186 | struct GNUNET_TIME_Absolute timestamp, |
187 | const GNUNET_HashCode *receiver) | 187 | const GNUNET_HashCode *receiver) |
188 | { | 188 | { |
189 | char *nick; | 189 | char *nick; |
190 | 190 | ||
@@ -206,9 +206,9 @@ confirmation_cb (void *cls, | |||
206 | */ | 206 | */ |
207 | static int | 207 | static int |
208 | member_list_cb (void *cls, | 208 | member_list_cb (void *cls, |
209 | const struct GNUNET_CONTAINER_MetaData *member_info, | 209 | const struct GNUNET_CONTAINER_MetaData *member_info, |
210 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, | 210 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, |
211 | enum GNUNET_CHAT_MsgOptions options) | 211 | enum GNUNET_CHAT_MsgOptions options) |
212 | { | 212 | { |
213 | char *nick; | 213 | char *nick; |
214 | GNUNET_HashCode id; | 214 | GNUNET_HashCode id; |
@@ -216,11 +216,11 @@ member_list_cb (void *cls, | |||
216 | struct UserList *prev; | 216 | struct UserList *prev; |
217 | 217 | ||
218 | GNUNET_CRYPTO_hash (member_id, | 218 | GNUNET_CRYPTO_hash (member_id, |
219 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 219 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
220 | &id); | 220 | &id); |
221 | nick = GNUNET_PSEUDONYM_id_to_name (cfg, &id); | 221 | nick = GNUNET_PSEUDONYM_id_to_name (cfg, &id); |
222 | fprintf (stdout, member_info != NULL | 222 | fprintf (stdout, member_info != NULL |
223 | ? _("`%s' entered the room\n") : _("`%s' left the room\n"), nick); | 223 | ? _("`%s' entered the room\n") : _("`%s' left the room\n"), nick); |
224 | GNUNET_free (nick); | 224 | GNUNET_free (nick); |
225 | if (NULL != member_info) | 225 | if (NULL != member_info) |
226 | { | 226 | { |
@@ -237,25 +237,25 @@ member_list_cb (void *cls, | |||
237 | prev = NULL; | 237 | prev = NULL; |
238 | pos = users; | 238 | pos = users; |
239 | while ((NULL != pos) && | 239 | while ((NULL != pos) && |
240 | (0 != memcmp (&pos->pkey, | 240 | (0 != memcmp (&pos->pkey, |
241 | member_id, | 241 | member_id, |
242 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))) | 242 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))) |
243 | { | 243 | { |
244 | prev = pos; | 244 | prev = pos; |
245 | pos = pos->next; | 245 | pos = pos->next; |
246 | } | 246 | } |
247 | if (NULL == pos) | 247 | if (NULL == pos) |
248 | { | 248 | { |
249 | GNUNET_break (0); | 249 | GNUNET_break (0); |
250 | } | 250 | } |
251 | else | 251 | else |
252 | { | 252 | { |
253 | if (NULL == prev) | 253 | if (NULL == prev) |
254 | users = pos->next; | 254 | users = pos->next; |
255 | else | 255 | else |
256 | prev->next = pos->next; | 256 | prev->next = pos->next; |
257 | GNUNET_free (pos); | 257 | GNUNET_free (pos); |
258 | } | 258 | } |
259 | } | 259 | } |
260 | return GNUNET_OK; | 260 | return GNUNET_OK; |
261 | } | 261 | } |
@@ -274,14 +274,14 @@ do_join (const char *arg, const void *xtra) | |||
274 | GNUNET_free (room_name); | 274 | GNUNET_free (room_name); |
275 | room_name = GNUNET_strdup (arg); | 275 | room_name = GNUNET_strdup (arg); |
276 | room = GNUNET_CHAT_join_room (cfg, | 276 | room = GNUNET_CHAT_join_room (cfg, |
277 | nickname, | 277 | nickname, |
278 | meta, | 278 | meta, |
279 | room_name, | 279 | room_name, |
280 | -1, | 280 | -1, |
281 | &join_cb, NULL, | 281 | &join_cb, NULL, |
282 | &receive_cb, NULL, | 282 | &receive_cb, NULL, |
283 | &member_list_cb, NULL, | 283 | &member_list_cb, NULL, |
284 | &confirmation_cb, NULL, &me); | 284 | &confirmation_cb, NULL, &me); |
285 | if (NULL == room) | 285 | if (NULL == room) |
286 | { | 286 | { |
287 | fprintf (stdout, _("Could not change username\n")); | 287 | fprintf (stdout, _("Could not change username\n")); |
@@ -307,21 +307,21 @@ do_nick (const char *msg, const void *xtra) | |||
307 | nickname = GNUNET_strdup (msg); | 307 | nickname = GNUNET_strdup (msg); |
308 | meta = GNUNET_CONTAINER_meta_data_create (); | 308 | meta = GNUNET_CONTAINER_meta_data_create (); |
309 | GNUNET_CONTAINER_meta_data_insert (meta, | 309 | GNUNET_CONTAINER_meta_data_insert (meta, |
310 | "<gnunet>", | 310 | "<gnunet>", |
311 | EXTRACTOR_METATYPE_TITLE, | 311 | EXTRACTOR_METATYPE_TITLE, |
312 | EXTRACTOR_METAFORMAT_UTF8, | 312 | EXTRACTOR_METAFORMAT_UTF8, |
313 | "text/plain", | 313 | "text/plain", |
314 | nickname, | 314 | nickname, |
315 | strlen(nickname)+1); | 315 | strlen(nickname)+1); |
316 | room = GNUNET_CHAT_join_room (cfg, | 316 | room = GNUNET_CHAT_join_room (cfg, |
317 | nickname, | 317 | nickname, |
318 | meta, | 318 | meta, |
319 | room_name, | 319 | room_name, |
320 | -1, | 320 | -1, |
321 | &join_cb, NULL, | 321 | &join_cb, NULL, |
322 | &receive_cb, NULL, | 322 | &receive_cb, NULL, |
323 | &member_list_cb, NULL, | 323 | &member_list_cb, NULL, |
324 | &confirmation_cb, NULL, &me); | 324 | &confirmation_cb, NULL, &me); |
325 | if (NULL == room) | 325 | if (NULL == room) |
326 | { | 326 | { |
327 | fprintf (stdout, _("Could not change username\n")); | 327 | fprintf (stdout, _("Could not change username\n")); |
@@ -346,8 +346,8 @@ do_names (const char *msg, const void *xtra) | |||
346 | while (NULL != pos) | 346 | while (NULL != pos) |
347 | { | 347 | { |
348 | GNUNET_CRYPTO_hash (&pos->pkey, | 348 | GNUNET_CRYPTO_hash (&pos->pkey, |
349 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 349 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
350 | &pid); | 350 | &pid); |
351 | name = GNUNET_PSEUDONYM_id_to_name (cfg, &pid); | 351 | name = GNUNET_PSEUDONYM_id_to_name (cfg, &pid); |
352 | fprintf (stdout, "`%s' ", name); | 352 | fprintf (stdout, "`%s' ", name); |
353 | GNUNET_free (name); | 353 | GNUNET_free (name); |
@@ -363,9 +363,9 @@ do_send (const char *msg, const void *xtra) | |||
363 | { | 363 | { |
364 | uint32_t seq; | 364 | uint32_t seq; |
365 | GNUNET_CHAT_send_message (room, | 365 | GNUNET_CHAT_send_message (room, |
366 | msg, | 366 | msg, |
367 | GNUNET_CHAT_MSG_OPTION_NONE, | 367 | GNUNET_CHAT_MSG_OPTION_NONE, |
368 | NULL, &seq); | 368 | NULL, &seq); |
369 | return GNUNET_OK; | 369 | return GNUNET_OK; |
370 | } | 370 | } |
371 | 371 | ||
@@ -397,10 +397,10 @@ do_send_pm (const char *msg, const void *xtra) | |||
397 | while (NULL != pos) | 397 | while (NULL != pos) |
398 | { | 398 | { |
399 | GNUNET_CRYPTO_hash (&pos->pkey, | 399 | GNUNET_CRYPTO_hash (&pos->pkey, |
400 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 400 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
401 | &pid); | 401 | &pid); |
402 | if (0 == memcmp (&pid, &uid, sizeof (GNUNET_HashCode))) | 402 | if (0 == memcmp (&pid, &uid, sizeof (GNUNET_HashCode))) |
403 | break; | 403 | break; |
404 | pos = pos->next; | 404 | pos = pos->next; |
405 | } | 405 | } |
406 | if (NULL == pos) | 406 | if (NULL == pos) |
@@ -410,10 +410,10 @@ do_send_pm (const char *msg, const void *xtra) | |||
410 | return GNUNET_OK; | 410 | return GNUNET_OK; |
411 | } | 411 | } |
412 | GNUNET_CHAT_send_message (room, | 412 | GNUNET_CHAT_send_message (room, |
413 | msg, | 413 | msg, |
414 | GNUNET_CHAT_MSG_PRIVATE, | 414 | GNUNET_CHAT_MSG_PRIVATE, |
415 | &pos->pkey, | 415 | &pos->pkey, |
416 | &seq); | 416 | &seq); |
417 | GNUNET_free (user); | 417 | GNUNET_free (user); |
418 | return GNUNET_OK; | 418 | return GNUNET_OK; |
419 | } | 419 | } |
@@ -424,9 +424,9 @@ do_send_sig (const char *msg, const void *xtra) | |||
424 | { | 424 | { |
425 | uint32_t seq; | 425 | uint32_t seq; |
426 | GNUNET_CHAT_send_message (room, | 426 | GNUNET_CHAT_send_message (room, |
427 | msg, | 427 | msg, |
428 | GNUNET_CHAT_MSG_AUTHENTICATED, | 428 | GNUNET_CHAT_MSG_AUTHENTICATED, |
429 | NULL, &seq); | 429 | NULL, &seq); |
430 | return GNUNET_OK; | 430 | return GNUNET_OK; |
431 | } | 431 | } |
432 | 432 | ||
@@ -436,9 +436,9 @@ do_send_ack (const char *msg, const void *xtra) | |||
436 | { | 436 | { |
437 | uint32_t seq; | 437 | uint32_t seq; |
438 | GNUNET_CHAT_send_message (room, | 438 | GNUNET_CHAT_send_message (room, |
439 | msg, | 439 | msg, |
440 | GNUNET_CHAT_MSG_ACKNOWLEDGED, | 440 | GNUNET_CHAT_MSG_ACKNOWLEDGED, |
441 | NULL, &seq); | 441 | NULL, &seq); |
442 | return GNUNET_OK; | 442 | return GNUNET_OK; |
443 | } | 443 | } |
444 | 444 | ||
@@ -448,9 +448,9 @@ do_send_anonymous (const char *msg, const void *xtra) | |||
448 | { | 448 | { |
449 | uint32_t seq; | 449 | uint32_t seq; |
450 | GNUNET_CHAT_send_message (room, | 450 | GNUNET_CHAT_send_message (room, |
451 | msg, | 451 | msg, |
452 | GNUNET_CHAT_MSG_ANONYMOUS, | 452 | GNUNET_CHAT_MSG_ANONYMOUS, |
453 | NULL, &seq); | 453 | NULL, &seq); |
454 | return GNUNET_OK; | 454 | return GNUNET_OK; |
455 | } | 455 | } |
456 | 456 | ||
@@ -525,14 +525,14 @@ do_help (const char *args, const void *xtra) | |||
525 | int i; | 525 | int i; |
526 | i = 0; | 526 | i = 0; |
527 | while ((NULL != args) && | 527 | while ((NULL != args) && |
528 | (0 != strlen (args)) && (commands[i].Action != &do_help)) | 528 | (0 != strlen (args)) && (commands[i].Action != &do_help)) |
529 | { | 529 | { |
530 | if (0 == | 530 | if (0 == |
531 | strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) | 531 | strncasecmp (&args[1], &commands[i].command[1], strlen (args) - 1)) |
532 | { | 532 | { |
533 | fprintf (stdout, "%s\n", gettext (commands[i].helptext)); | 533 | fprintf (stdout, "%s\n", gettext (commands[i].helptext)); |
534 | return GNUNET_OK; | 534 | return GNUNET_OK; |
535 | } | 535 | } |
536 | i++; | 536 | i++; |
537 | } | 537 | } |
538 | i = 0; | 538 | i = 0; |
@@ -550,7 +550,7 @@ do_help (const char *args, const void *xtra) | |||
550 | 550 | ||
551 | static void | 551 | static void |
552 | do_stop_task (void *cls, | 552 | do_stop_task (void *cls, |
553 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 553 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
554 | { | 554 | { |
555 | GNUNET_CHAT_leave_room (room); | 555 | GNUNET_CHAT_leave_room (room); |
556 | if (handle_cmd_task != GNUNET_SCHEDULER_NO_TASK) | 556 | if (handle_cmd_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -583,8 +583,8 @@ handle_command (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
583 | goto next; | 583 | goto next; |
584 | i = 0; | 584 | i = 0; |
585 | while ((NULL != commands[i].command) && | 585 | while ((NULL != commands[i].command) && |
586 | (0 != strncasecmp (commands[i].command, | 586 | (0 != strncasecmp (commands[i].command, |
587 | message, strlen (commands[i].command)))) | 587 | message, strlen (commands[i].command)))) |
588 | i++; | 588 | i++; |
589 | if (GNUNET_OK != | 589 | if (GNUNET_OK != |
590 | commands[i].Action (&message[strlen (commands[i].command)], NULL)) | 590 | commands[i].Action (&message[strlen (commands[i].command)], NULL)) |
@@ -593,9 +593,9 @@ handle_command (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
593 | next: | 593 | next: |
594 | handle_cmd_task = | 594 | handle_cmd_task = |
595 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 595 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
596 | 100), | 596 | 100), |
597 | &handle_command, | 597 | &handle_command, |
598 | NULL); | 598 | NULL); |
599 | return; | 599 | return; |
600 | 600 | ||
601 | out: | 601 | out: |
@@ -633,21 +633,21 @@ run (void *cls, | |||
633 | room_name = GNUNET_strdup ("gnunet"); | 633 | room_name = GNUNET_strdup ("gnunet"); |
634 | meta = GNUNET_CONTAINER_meta_data_create (); | 634 | meta = GNUNET_CONTAINER_meta_data_create (); |
635 | GNUNET_CONTAINER_meta_data_insert (meta, | 635 | GNUNET_CONTAINER_meta_data_insert (meta, |
636 | "<gnunet>", | 636 | "<gnunet>", |
637 | EXTRACTOR_METATYPE_TITLE, | 637 | EXTRACTOR_METATYPE_TITLE, |
638 | EXTRACTOR_METAFORMAT_UTF8, | 638 | EXTRACTOR_METAFORMAT_UTF8, |
639 | "text/plain", | 639 | "text/plain", |
640 | nickname, | 640 | nickname, |
641 | strlen(nickname)+1); | 641 | strlen(nickname)+1); |
642 | room = GNUNET_CHAT_join_room (cfg, | 642 | room = GNUNET_CHAT_join_room (cfg, |
643 | nickname, | 643 | nickname, |
644 | meta, | 644 | meta, |
645 | room_name, | 645 | room_name, |
646 | -1, | 646 | -1, |
647 | &join_cb, NULL, | 647 | &join_cb, NULL, |
648 | &receive_cb, NULL, | 648 | &receive_cb, NULL, |
649 | &member_list_cb, NULL, | 649 | &member_list_cb, NULL, |
650 | &confirmation_cb, NULL, &me); | 650 | &confirmation_cb, NULL, &me); |
651 | if (NULL == room) | 651 | if (NULL == room) |
652 | { | 652 | { |
653 | fprintf (stderr, _("Failed to join room `%s'\n"), room_name); | 653 | fprintf (stderr, _("Failed to join room `%s'\n"), room_name); |
@@ -662,11 +662,11 @@ run (void *cls, | |||
662 | GNUNET_free (my_name); | 662 | GNUNET_free (my_name); |
663 | handle_cmd_task = | 663 | handle_cmd_task = |
664 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, | 664 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_UI, |
665 | &handle_command, | 665 | &handle_command, |
666 | NULL); | 666 | NULL); |
667 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 667 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
668 | &do_stop_task, | 668 | &do_stop_task, |
669 | NULL); | 669 | NULL); |
670 | } | 670 | } |
671 | 671 | ||
672 | 672 | ||
@@ -697,11 +697,11 @@ main (int argc, char *const *argv) | |||
697 | fcntl (0, F_SETFL, flags); | 697 | fcntl (0, F_SETFL, flags); |
698 | #endif | 698 | #endif |
699 | return (GNUNET_OK == | 699 | return (GNUNET_OK == |
700 | GNUNET_PROGRAM_run (argc, | 700 | GNUNET_PROGRAM_run (argc, |
701 | argv, | 701 | argv, |
702 | "gnunet-chat", | 702 | "gnunet-chat", |
703 | gettext_noop ("Join a chat on GNUnet."), | 703 | gettext_noop ("Join a chat on GNUnet."), |
704 | options, &run, NULL)) ? ret : 1; | 704 | options, &run, NULL)) ? ret : 1; |
705 | } | 705 | } |
706 | 706 | ||
707 | /* end of gnunet-chat.c */ | 707 | /* end of gnunet-chat.c */ |
diff --git a/src/chat/gnunet-service-chat.c b/src/chat/gnunet-service-chat.c index 6a5c5790a..bbf4dd8f1 100644 --- a/src/chat/gnunet-service-chat.c +++ b/src/chat/gnunet-service-chat.c | |||
@@ -184,7 +184,7 @@ remember_anonymous_message (const struct P2PReceiveNotificationMessage *p2p_rnms | |||
184 | { | 184 | { |
185 | GNUNET_free (anon_msg); | 185 | GNUNET_free (anon_msg); |
186 | if (NULL != prev) | 186 | if (NULL != prev) |
187 | prev->next = NULL; | 187 | prev->next = NULL; |
188 | } | 188 | } |
189 | } | 189 | } |
190 | 190 | ||
@@ -198,7 +198,7 @@ lookup_anonymous_message (const struct P2PReceiveNotificationMessage *p2p_rnmsg) | |||
198 | GNUNET_CRYPTO_hash (p2p_rnmsg, ntohs (p2p_rnmsg->header.size), &hash); | 198 | GNUNET_CRYPTO_hash (p2p_rnmsg, ntohs (p2p_rnmsg->header.size), &hash); |
199 | anon_msg = anonymous_list_head; | 199 | anon_msg = anonymous_list_head; |
200 | while ((NULL != anon_msg) && | 200 | while ((NULL != anon_msg) && |
201 | (0 != memcmp (&anon_msg->hash, &hash, sizeof (GNUNET_HashCode)))) | 201 | (0 != memcmp (&anon_msg->hash, &hash, sizeof (GNUNET_HashCode)))) |
202 | anon_msg = anon_msg->next; | 202 | anon_msg = anon_msg->next; |
203 | return (NULL != anon_msg); | 203 | return (NULL != anon_msg); |
204 | } | 204 | } |
@@ -214,8 +214,8 @@ lookup_anonymous_message (const struct P2PReceiveNotificationMessage *p2p_rnmsg) | |||
214 | */ | 214 | */ |
215 | static size_t | 215 | static size_t |
216 | transmit_message_notification_to_peer (void *cls, | 216 | transmit_message_notification_to_peer (void *cls, |
217 | size_t size, | 217 | size_t size, |
218 | void *buf) | 218 | void *buf) |
219 | { | 219 | { |
220 | struct P2PReceiveNotificationMessage *my_msg = cls; | 220 | struct P2PReceiveNotificationMessage *my_msg = cls; |
221 | struct P2PReceiveNotificationMessage *m = buf; | 221 | struct P2PReceiveNotificationMessage *m = buf; |
@@ -223,14 +223,14 @@ transmit_message_notification_to_peer (void *cls, | |||
223 | 223 | ||
224 | #if DEBUG_CHAT_SERVICE | 224 | #if DEBUG_CHAT_SERVICE |
225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 225 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
226 | "Transmitting P2P message notification\n"); | 226 | "Transmitting P2P message notification\n"); |
227 | #endif | 227 | #endif |
228 | if (buf == NULL) | 228 | if (buf == NULL) |
229 | { | 229 | { |
230 | /* client disconnected */ | 230 | /* client disconnected */ |
231 | #if DEBUG_CHAT_SERVICE | 231 | #if DEBUG_CHAT_SERVICE |
232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
233 | "Buffer is NULL, dropping the message\n"); | 233 | "Buffer is NULL, dropping the message\n"); |
234 | #endif | 234 | #endif |
235 | return 0; | 235 | return 0; |
236 | } | 236 | } |
@@ -247,8 +247,8 @@ transmit_message_notification_to_peer (void *cls, | |||
247 | */ | 247 | */ |
248 | static int | 248 | static int |
249 | send_message_noficiation (void *cls, | 249 | send_message_noficiation (void *cls, |
250 | const GNUNET_HashCode *key, | 250 | const GNUNET_HashCode *key, |
251 | void *value) | 251 | void *value) |
252 | { | 252 | { |
253 | struct P2PReceiveNotificationMessage *msg = cls; | 253 | struct P2PReceiveNotificationMessage *msg = cls; |
254 | struct ConnectedPeer *cp = value; | 254 | struct ConnectedPeer *cp = value; |
@@ -258,18 +258,18 @@ send_message_noficiation (void *cls, | |||
258 | GNUNET_PEER_resolve (cp->pid, &pid); | 258 | GNUNET_PEER_resolve (cp->pid, &pid); |
259 | #if DEBUG_CHAT_SERVICE | 259 | #if DEBUG_CHAT_SERVICE |
260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 260 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
261 | "Sending message notification to `%s'\n", GNUNET_i2s (&pid)); | 261 | "Sending message notification to `%s'\n", GNUNET_i2s (&pid)); |
262 | #endif | 262 | #endif |
263 | my_msg = GNUNET_memdup (msg, ntohs (msg->header.size)); | 263 | my_msg = GNUNET_memdup (msg, ntohs (msg->header.size)); |
264 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, | 264 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, |
265 | 1, | 265 | 1, |
266 | MAX_TRANSMIT_DELAY, | 266 | MAX_TRANSMIT_DELAY, |
267 | &pid, | 267 | &pid, |
268 | ntohs (msg->header.size), | 268 | ntohs (msg->header.size), |
269 | &transmit_message_notification_to_peer, | 269 | &transmit_message_notification_to_peer, |
270 | my_msg)) | 270 | my_msg)) |
271 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 271 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
272 | _("Failed to queue a message notification\n")); | 272 | _("Failed to queue a message notification\n")); |
273 | return GNUNET_YES; | 273 | return GNUNET_YES; |
274 | } | 274 | } |
275 | 275 | ||
@@ -284,8 +284,8 @@ send_message_noficiation (void *cls, | |||
284 | */ | 284 | */ |
285 | static void | 285 | static void |
286 | handle_transmit_request (void *cls, | 286 | handle_transmit_request (void *cls, |
287 | struct GNUNET_SERVER_Client *client, | 287 | struct GNUNET_SERVER_Client *client, |
288 | const struct GNUNET_MessageHeader *message) | 288 | const struct GNUNET_MessageHeader *message) |
289 | { | 289 | { |
290 | static GNUNET_HashCode all_zeros; | 290 | static GNUNET_HashCode all_zeros; |
291 | const struct TransmitRequestMessage *trmsg; | 291 | const struct TransmitRequestMessage *trmsg; |
@@ -319,22 +319,22 @@ handle_transmit_request (void *cls, | |||
319 | #endif | 319 | #endif |
320 | GNUNET_CRYPTO_aes_create_session_key (&key); | 320 | GNUNET_CRYPTO_aes_create_session_key (&key); |
321 | msg_len = GNUNET_CRYPTO_aes_encrypt (&trmsg[1], | 321 | msg_len = GNUNET_CRYPTO_aes_encrypt (&trmsg[1], |
322 | msg_len, | 322 | msg_len, |
323 | &key, | 323 | &key, |
324 | (const struct GNUNET_CRYPTO_AesInitializationVector *) INITVALUE, | 324 | (const struct GNUNET_CRYPTO_AesInitializationVector *) INITVALUE, |
325 | encrypted_msg); | 325 | encrypted_msg); |
326 | if (-1 == msg_len) | 326 | if (-1 == msg_len) |
327 | { | 327 | { |
328 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 328 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
329 | "Could not encrypt the message text\n"); | 329 | "Could not encrypt the message text\n"); |
330 | GNUNET_break (0); | 330 | GNUNET_break (0); |
331 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 331 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
332 | return; | 332 | return; |
333 | } | 333 | } |
334 | } | 334 | } |
335 | rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); | 335 | rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); |
336 | rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + | 336 | rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + |
337 | msg_len); | 337 | msg_len); |
338 | rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); | 338 | rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); |
339 | rnmsg->msg_options = trmsg->msg_options; | 339 | rnmsg->msg_options = trmsg->msg_options; |
340 | rnmsg->timestamp = trmsg->timestamp; | 340 | rnmsg->timestamp = trmsg->timestamp; |
@@ -344,8 +344,8 @@ handle_transmit_request (void *cls, | |||
344 | if (NULL == pos) | 344 | if (NULL == pos) |
345 | { | 345 | { |
346 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 346 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
347 | "The client is not a member of a chat room. Client has to " | 347 | "The client is not a member of a chat room. Client has to " |
348 | "join a chat room first\n"); | 348 | "join a chat room first\n"); |
349 | GNUNET_break (0); | 349 | GNUNET_break (0); |
350 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 350 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
351 | GNUNET_free (rnmsg); | 351 | GNUNET_free (rnmsg); |
@@ -368,46 +368,46 @@ handle_transmit_request (void *cls, | |||
368 | { | 368 | { |
369 | #if DEBUG_CHAT_SERVICE | 369 | #if DEBUG_CHAT_SERVICE |
370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 370 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
371 | "Encrypting the session key using the public key of '%s'\n", | 371 | "Encrypting the session key using the public key of '%s'\n", |
372 | GNUNET_h2s (&trmsg->target)); | 372 | GNUNET_h2s (&trmsg->target)); |
373 | #endif | 373 | #endif |
374 | if (0 == memcmp (&all_zeros, &trmsg->target, sizeof (GNUNET_HashCode))) | 374 | if (0 == memcmp (&all_zeros, &trmsg->target, sizeof (GNUNET_HashCode))) |
375 | { | 375 | { |
376 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 376 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
377 | "Malformed message: private, but no target\n"); | 377 | "Malformed message: private, but no target\n"); |
378 | GNUNET_break (0); | 378 | GNUNET_break (0); |
379 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 379 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
380 | GNUNET_free (rnmsg); | 380 | GNUNET_free (rnmsg); |
381 | return; | 381 | return; |
382 | } | 382 | } |
383 | memcpy (&rnmsg[1], encrypted_msg, msg_len); | 383 | memcpy (&rnmsg[1], encrypted_msg, msg_len); |
384 | target = client_list_head; | 384 | target = client_list_head; |
385 | while ((NULL != target) && | 385 | while ((NULL != target) && |
386 | (0 != memcmp (&target->id, | 386 | (0 != memcmp (&target->id, |
387 | &trmsg->target, | 387 | &trmsg->target, |
388 | sizeof (GNUNET_HashCode)))) | 388 | sizeof (GNUNET_HashCode)))) |
389 | target = target->next; | 389 | target = target->next; |
390 | if (NULL == target) | 390 | if (NULL == target) |
391 | { | 391 | { |
392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 392 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
393 | "Unknown target of the private message\n"); | 393 | "Unknown target of the private message\n"); |
394 | GNUNET_break (0); | 394 | GNUNET_break (0); |
395 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 395 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
396 | GNUNET_free (rnmsg); | 396 | GNUNET_free (rnmsg); |
397 | return; | 397 | return; |
398 | } | 398 | } |
399 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (&key, | 399 | if (GNUNET_SYSERR == GNUNET_CRYPTO_rsa_encrypt (&key, |
400 | sizeof (struct GNUNET_CRYPTO_AesSessionKey), | 400 | sizeof (struct GNUNET_CRYPTO_AesSessionKey), |
401 | &target->public_key, | 401 | &target->public_key, |
402 | &rnmsg->encrypted_key)) | 402 | &rnmsg->encrypted_key)) |
403 | { | 403 | { |
404 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 404 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
405 | "Could not encrypt the session key\n"); | 405 | "Could not encrypt the session key\n"); |
406 | GNUNET_break (0); | 406 | GNUNET_break (0); |
407 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 407 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
408 | GNUNET_free (rnmsg); | 408 | GNUNET_free (rnmsg); |
409 | return; | 409 | return; |
410 | } | 410 | } |
411 | } | 411 | } |
412 | else | 412 | else |
413 | { | 413 | { |
@@ -420,35 +420,35 @@ handle_transmit_request (void *cls, | |||
420 | while (NULL != pos) | 420 | while (NULL != pos) |
421 | { | 421 | { |
422 | if ((0 == strcmp (room, pos->room)) && | 422 | if ((0 == strcmp (room, pos->room)) && |
423 | (NULL != pos->client) && | 423 | (NULL != pos->client) && |
424 | (pos->client != client)) | 424 | (pos->client != client)) |
425 | { | 425 | { |
426 | if (((!is_priv) || | 426 | if (((!is_priv) || |
427 | (0 == memcmp (&trmsg->target, | 427 | (0 == memcmp (&trmsg->target, |
428 | &pos->id, | 428 | &pos->id, |
429 | sizeof (GNUNET_HashCode)))) && | 429 | sizeof (GNUNET_HashCode)))) && |
430 | (0 == (ntohl (trmsg->msg_options) & (~pos->msg_options)))) | 430 | (0 == (ntohl (trmsg->msg_options) & (~pos->msg_options)))) |
431 | { | 431 | { |
432 | GNUNET_SERVER_notification_context_unicast (nc, | 432 | GNUNET_SERVER_notification_context_unicast (nc, |
433 | pos->client, | 433 | pos->client, |
434 | &rnmsg->header, | 434 | &rnmsg->header, |
435 | GNUNET_NO); | 435 | GNUNET_NO); |
436 | } | 436 | } |
437 | } | 437 | } |
438 | pos = pos->next; | 438 | pos = pos->next; |
439 | } | 439 | } |
440 | #if DEBUG_CHAT_SERVICE | 440 | #if DEBUG_CHAT_SERVICE |
441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 441 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
442 | "Broadcasting message to neighbour peers\n"); | 442 | "Broadcasting message to neighbour peers\n"); |
443 | #endif | 443 | #endif |
444 | if (is_anon) | 444 | if (is_anon) |
445 | { | 445 | { |
446 | room_len = strlen (room); | 446 | room_len = strlen (room); |
447 | p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + | 447 | p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + |
448 | msg_len + room_len); | 448 | msg_len + room_len); |
449 | p2p_rnmsg->header.size = | 449 | p2p_rnmsg->header.size = |
450 | htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len + | 450 | htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len + |
451 | room_len); | 451 | room_len); |
452 | p2p_rnmsg->room_name_len = htons (room_len); | 452 | p2p_rnmsg->room_name_len = htons (room_len); |
453 | memcpy ((char *) &p2p_rnmsg[1], room, room_len); | 453 | memcpy ((char *) &p2p_rnmsg[1], room, room_len); |
454 | memcpy ((char *) &p2p_rnmsg[1] + room_len, &trmsg[1], msg_len); | 454 | memcpy ((char *) &p2p_rnmsg[1] + room_len, &trmsg[1], msg_len); |
@@ -456,15 +456,15 @@ handle_transmit_request (void *cls, | |||
456 | else | 456 | else |
457 | { | 457 | { |
458 | p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + | 458 | p2p_rnmsg = GNUNET_malloc (sizeof (struct P2PReceiveNotificationMessage) + |
459 | msg_len); | 459 | msg_len); |
460 | p2p_rnmsg->header.size = | 460 | p2p_rnmsg->header.size = |
461 | htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len); | 461 | htons (sizeof (struct P2PReceiveNotificationMessage) + msg_len); |
462 | if (is_priv) | 462 | if (is_priv) |
463 | { | 463 | { |
464 | memcpy (&p2p_rnmsg[1], encrypted_msg, msg_len); | 464 | memcpy (&p2p_rnmsg[1], encrypted_msg, msg_len); |
465 | memcpy (&p2p_rnmsg->encrypted_key, | 465 | memcpy (&p2p_rnmsg->encrypted_key, |
466 | &rnmsg->encrypted_key, | 466 | &rnmsg->encrypted_key, |
467 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); | 467 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); |
468 | } | 468 | } |
469 | else | 469 | else |
470 | memcpy (&p2p_rnmsg[1], &trmsg[1], msg_len); | 470 | memcpy (&p2p_rnmsg[1], &trmsg[1], msg_len); |
@@ -479,8 +479,8 @@ handle_transmit_request (void *cls, | |||
479 | if (is_anon) | 479 | if (is_anon) |
480 | remember_anonymous_message (p2p_rnmsg); | 480 | remember_anonymous_message (p2p_rnmsg); |
481 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 481 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
482 | &send_message_noficiation, | 482 | &send_message_noficiation, |
483 | p2p_rnmsg); | 483 | p2p_rnmsg); |
484 | GNUNET_free (p2p_rnmsg); | 484 | GNUNET_free (p2p_rnmsg); |
485 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 485 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
486 | GNUNET_free (rnmsg); | 486 | GNUNET_free (rnmsg); |
@@ -497,8 +497,8 @@ handle_transmit_request (void *cls, | |||
497 | */ | 497 | */ |
498 | static size_t | 498 | static size_t |
499 | transmit_join_notification_to_peer (void *cls, | 499 | transmit_join_notification_to_peer (void *cls, |
500 | size_t size, | 500 | size_t size, |
501 | void *buf) | 501 | void *buf) |
502 | { | 502 | { |
503 | struct ChatClient *entry = cls; | 503 | struct ChatClient *entry = cls; |
504 | struct P2PJoinNotificationMessage *m = buf; | 504 | struct P2PJoinNotificationMessage *m = buf; |
@@ -509,7 +509,7 @@ transmit_join_notification_to_peer (void *cls, | |||
509 | 509 | ||
510 | #if DEBUG_CHAT_SERVICE | 510 | #if DEBUG_CHAT_SERVICE |
511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
512 | "Transmitting P2P join notification\n"); | 512 | "Transmitting P2P join notification\n"); |
513 | #endif | 513 | #endif |
514 | room_len = strlen (entry->room); | 514 | room_len = strlen (entry->room); |
515 | meta_len = entry->meta_len; | 515 | meta_len = entry->meta_len; |
@@ -536,8 +536,8 @@ transmit_join_notification_to_peer (void *cls, | |||
536 | */ | 536 | */ |
537 | static int | 537 | static int |
538 | send_join_noficiation (void *cls, | 538 | send_join_noficiation (void *cls, |
539 | const GNUNET_HashCode *key, | 539 | const GNUNET_HashCode *key, |
540 | void *value) | 540 | void *value) |
541 | { | 541 | { |
542 | struct ChatClient *entry = cls; | 542 | struct ChatClient *entry = cls; |
543 | struct ConnectedPeer *cp = value; | 543 | struct ConnectedPeer *cp = value; |
@@ -547,20 +547,20 @@ send_join_noficiation (void *cls, | |||
547 | GNUNET_PEER_resolve (cp->pid, &pid); | 547 | GNUNET_PEER_resolve (cp->pid, &pid); |
548 | #if DEBUG_CHAT_SERVICE | 548 | #if DEBUG_CHAT_SERVICE |
549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
550 | "Sending join notification to `%s'\n", GNUNET_i2s (&pid)); | 550 | "Sending join notification to `%s'\n", GNUNET_i2s (&pid)); |
551 | #endif | 551 | #endif |
552 | msg_size = sizeof (struct P2PJoinNotificationMessage) + | 552 | msg_size = sizeof (struct P2PJoinNotificationMessage) + |
553 | strlen (entry->room) + | 553 | strlen (entry->room) + |
554 | entry->meta_len; | 554 | entry->meta_len; |
555 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, | 555 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, |
556 | 1, | 556 | 1, |
557 | MAX_TRANSMIT_DELAY, | 557 | MAX_TRANSMIT_DELAY, |
558 | &pid, | 558 | &pid, |
559 | msg_size, | 559 | msg_size, |
560 | &transmit_join_notification_to_peer, | 560 | &transmit_join_notification_to_peer, |
561 | entry)) | 561 | entry)) |
562 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 562 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
563 | _("Failed to queue a join notification\n")); | 563 | _("Failed to queue a join notification\n")); |
564 | return GNUNET_YES; | 564 | return GNUNET_YES; |
565 | } | 565 | } |
566 | 566 | ||
@@ -575,8 +575,8 @@ send_join_noficiation (void *cls, | |||
575 | */ | 575 | */ |
576 | static void | 576 | static void |
577 | handle_join_request (void *cls, | 577 | handle_join_request (void *cls, |
578 | struct GNUNET_SERVER_Client *client, | 578 | struct GNUNET_SERVER_Client *client, |
579 | const struct GNUNET_MessageHeader *message) | 579 | const struct GNUNET_MessageHeader *message) |
580 | { | 580 | { |
581 | const struct JoinRequestMessage *jrmsg; | 581 | const struct JoinRequestMessage *jrmsg; |
582 | char *room_name; | 582 | char *room_name; |
@@ -604,7 +604,7 @@ handle_join_request (void *cls, | |||
604 | room_name_len) | 604 | room_name_len) |
605 | { | 605 | { |
606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 606 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
607 | "Malformed message: wrong length of the room name\n"); | 607 | "Malformed message: wrong length of the room name\n"); |
608 | GNUNET_break (0); | 608 | GNUNET_break (0); |
609 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 609 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
610 | return; | 610 | return; |
@@ -629,14 +629,14 @@ handle_join_request (void *cls, | |||
629 | else | 629 | else |
630 | new_entry->member_info = NULL; | 630 | new_entry->member_info = NULL; |
631 | GNUNET_CRYPTO_hash (&new_entry->public_key, | 631 | GNUNET_CRYPTO_hash (&new_entry->public_key, |
632 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 632 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
633 | &new_entry->id); | 633 | &new_entry->id); |
634 | new_entry->msg_options = ntohl (jrmsg->msg_options); | 634 | new_entry->msg_options = ntohl (jrmsg->msg_options); |
635 | new_entry->next = client_list_head; | 635 | new_entry->next = client_list_head; |
636 | client_list_head = new_entry; | 636 | client_list_head = new_entry; |
637 | #if DEBUG_CHAT_SERVICE | 637 | #if DEBUG_CHAT_SERVICE |
638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 638 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
639 | "Synchronizing room members between local clients\n"); | 639 | "Synchronizing room members between local clients\n"); |
640 | #endif | 640 | #endif |
641 | jnmsg = GNUNET_malloc (sizeof (struct JoinNotificationMessage) + meta_len); | 641 | jnmsg = GNUNET_malloc (sizeof (struct JoinNotificationMessage) + meta_len); |
642 | jnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); | 642 | jnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); |
@@ -650,41 +650,41 @@ handle_join_request (void *cls, | |||
650 | while (NULL != entry) | 650 | while (NULL != entry) |
651 | { | 651 | { |
652 | if (0 == strcmp (room_name, entry->room)) | 652 | if (0 == strcmp (room_name, entry->room)) |
653 | { | 653 | { |
654 | if (NULL != entry->client) | 654 | if (NULL != entry->client) |
655 | GNUNET_SERVER_notification_context_unicast (nc, | 655 | GNUNET_SERVER_notification_context_unicast (nc, |
656 | entry->client, | 656 | entry->client, |
657 | &jnmsg->header, | 657 | &jnmsg->header, |
658 | GNUNET_NO); | 658 | GNUNET_NO); |
659 | if (entry->client != client) | 659 | if (entry->client != client) |
660 | { | 660 | { |
661 | entry_jnmsg = | 661 | entry_jnmsg = |
662 | GNUNET_malloc (sizeof (struct JoinNotificationMessage) + | 662 | GNUNET_malloc (sizeof (struct JoinNotificationMessage) + |
663 | entry->meta_len); | 663 | entry->meta_len); |
664 | entry_jnmsg->header.type = | 664 | entry_jnmsg->header.type = |
665 | htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); | 665 | htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); |
666 | entry_jnmsg->header.size = | 666 | entry_jnmsg->header.size = |
667 | htons (sizeof (struct JoinNotificationMessage) + | 667 | htons (sizeof (struct JoinNotificationMessage) + |
668 | entry->meta_len); | 668 | entry->meta_len); |
669 | entry_jnmsg->msg_options = entry->msg_options; | 669 | entry_jnmsg->msg_options = entry->msg_options; |
670 | entry_jnmsg->public_key = entry->public_key; | 670 | entry_jnmsg->public_key = entry->public_key; |
671 | memcpy (&entry_jnmsg[1], entry->member_info, entry->meta_len); | 671 | memcpy (&entry_jnmsg[1], entry->member_info, entry->meta_len); |
672 | GNUNET_SERVER_notification_context_unicast (nc, | 672 | GNUNET_SERVER_notification_context_unicast (nc, |
673 | client, | 673 | client, |
674 | &entry_jnmsg->header, | 674 | &entry_jnmsg->header, |
675 | GNUNET_NO); | 675 | GNUNET_NO); |
676 | GNUNET_free (entry_jnmsg); | 676 | GNUNET_free (entry_jnmsg); |
677 | } | 677 | } |
678 | } | 678 | } |
679 | entry = entry->next; | 679 | entry = entry->next; |
680 | } | 680 | } |
681 | #if DEBUG_CHAT_SERVICE | 681 | #if DEBUG_CHAT_SERVICE |
682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 682 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
683 | "Broadcasting join notification to neighbour peers\n"); | 683 | "Broadcasting join notification to neighbour peers\n"); |
684 | #endif | 684 | #endif |
685 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 685 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
686 | &send_join_noficiation, | 686 | &send_join_noficiation, |
687 | new_entry); | 687 | new_entry); |
688 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 688 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
689 | GNUNET_free (jnmsg); | 689 | GNUNET_free (jnmsg); |
690 | } | 690 | } |
@@ -699,23 +699,23 @@ handle_join_request (void *cls, | |||
699 | */ | 699 | */ |
700 | static size_t | 700 | static size_t |
701 | transmit_confirmation_receipt_to_peer (void *cls, | 701 | transmit_confirmation_receipt_to_peer (void *cls, |
702 | size_t size, | 702 | size_t size, |
703 | void *buf) | 703 | void *buf) |
704 | { | 704 | { |
705 | struct P2PConfirmationReceiptMessage *receipt = cls; | 705 | struct P2PConfirmationReceiptMessage *receipt = cls; |
706 | size_t msg_size; | 706 | size_t msg_size; |
707 | 707 | ||
708 | #if DEBUG_CHAT_SERVICE | 708 | #if DEBUG_CHAT_SERVICE |
709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
710 | "Transmitting P2P confirmation receipt to '%s'\n", | 710 | "Transmitting P2P confirmation receipt to '%s'\n", |
711 | GNUNET_h2s (&receipt->target)); | 711 | GNUNET_h2s (&receipt->target)); |
712 | #endif | 712 | #endif |
713 | if (buf == NULL) | 713 | if (buf == NULL) |
714 | { | 714 | { |
715 | /* client disconnected */ | 715 | /* client disconnected */ |
716 | #if DEBUG_CHAT_SERVICE | 716 | #if DEBUG_CHAT_SERVICE |
717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
718 | "Buffer is NULL, dropping the message\n"); | 718 | "Buffer is NULL, dropping the message\n"); |
719 | #endif | 719 | #endif |
720 | return 0; | 720 | return 0; |
721 | } | 721 | } |
@@ -732,8 +732,8 @@ transmit_confirmation_receipt_to_peer (void *cls, | |||
732 | */ | 732 | */ |
733 | static int | 733 | static int |
734 | send_confirmation_receipt (void *cls, | 734 | send_confirmation_receipt (void *cls, |
735 | const GNUNET_HashCode *key, | 735 | const GNUNET_HashCode *key, |
736 | void *value) | 736 | void *value) |
737 | { | 737 | { |
738 | struct P2PConfirmationReceiptMessage *receipt = cls; | 738 | struct P2PConfirmationReceiptMessage *receipt = cls; |
739 | struct ConnectedPeer *cp = value; | 739 | struct ConnectedPeer *cp = value; |
@@ -744,20 +744,20 @@ send_confirmation_receipt (void *cls, | |||
744 | GNUNET_PEER_resolve (cp->pid, &pid); | 744 | GNUNET_PEER_resolve (cp->pid, &pid); |
745 | #if DEBUG_CHAT_SERVICE | 745 | #if DEBUG_CHAT_SERVICE |
746 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 746 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
747 | "Sending confirmation receipt to `%s'\n", GNUNET_i2s (&pid)); | 747 | "Sending confirmation receipt to `%s'\n", GNUNET_i2s (&pid)); |
748 | #endif | 748 | #endif |
749 | msg_size = sizeof (struct P2PConfirmationReceiptMessage); | 749 | msg_size = sizeof (struct P2PConfirmationReceiptMessage); |
750 | my_receipt = GNUNET_memdup (receipt, | 750 | my_receipt = GNUNET_memdup (receipt, |
751 | sizeof (struct P2PConfirmationReceiptMessage)); | 751 | sizeof (struct P2PConfirmationReceiptMessage)); |
752 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, | 752 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, |
753 | 1, | 753 | 1, |
754 | MAX_TRANSMIT_DELAY, | 754 | MAX_TRANSMIT_DELAY, |
755 | &pid, | 755 | &pid, |
756 | msg_size, | 756 | msg_size, |
757 | &transmit_confirmation_receipt_to_peer, | 757 | &transmit_confirmation_receipt_to_peer, |
758 | my_receipt)) | 758 | my_receipt)) |
759 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 759 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
760 | _("Failed to queue a confirmation receipt\n")); | 760 | _("Failed to queue a confirmation receipt\n")); |
761 | return GNUNET_YES; | 761 | return GNUNET_YES; |
762 | } | 762 | } |
763 | 763 | ||
@@ -773,8 +773,8 @@ send_confirmation_receipt (void *cls, | |||
773 | */ | 773 | */ |
774 | static void | 774 | static void |
775 | handle_acknowledge_request (void *cls, | 775 | handle_acknowledge_request (void *cls, |
776 | struct GNUNET_SERVER_Client *client, | 776 | struct GNUNET_SERVER_Client *client, |
777 | const struct GNUNET_MessageHeader *message) | 777 | const struct GNUNET_MessageHeader *message) |
778 | { | 778 | { |
779 | const struct ConfirmationReceiptMessage *receipt; | 779 | const struct ConfirmationReceiptMessage *receipt; |
780 | struct ConfirmationReceiptMessage *crmsg; | 780 | struct ConfirmationReceiptMessage *crmsg; |
@@ -786,28 +786,28 @@ handle_acknowledge_request (void *cls, | |||
786 | receipt = (const struct ConfirmationReceiptMessage *) message; | 786 | receipt = (const struct ConfirmationReceiptMessage *) message; |
787 | author = client_list_head; | 787 | author = client_list_head; |
788 | while ((NULL != author) && | 788 | while ((NULL != author) && |
789 | (0 != memcmp (&receipt->author, | 789 | (0 != memcmp (&receipt->author, |
790 | &author->id, | 790 | &author->id, |
791 | sizeof (GNUNET_HashCode)))) | 791 | sizeof (GNUNET_HashCode)))) |
792 | author = author->next; | 792 | author = author->next; |
793 | if (NULL == author) | 793 | if (NULL == author) |
794 | { | 794 | { |
795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 795 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
796 | "Unknown author of the original message\n"); | 796 | "Unknown author of the original message\n"); |
797 | GNUNET_break (0); | 797 | GNUNET_break (0); |
798 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 798 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
799 | return; | 799 | return; |
800 | } | 800 | } |
801 | target = client_list_head; | 801 | target = client_list_head; |
802 | while ((NULL != target) && | 802 | while ((NULL != target) && |
803 | (0 != memcmp (&receipt->target, | 803 | (0 != memcmp (&receipt->target, |
804 | &target->id, | 804 | &target->id, |
805 | sizeof (GNUNET_HashCode)))) | 805 | sizeof (GNUNET_HashCode)))) |
806 | target = target->next; | 806 | target = target->next; |
807 | if (NULL == target) | 807 | if (NULL == target) |
808 | { | 808 | { |
809 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 809 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
810 | "Unknown target of the confirmation receipt\n"); | 810 | "Unknown target of the confirmation receipt\n"); |
811 | GNUNET_break (0); | 811 | GNUNET_break (0); |
812 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 812 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
813 | return; | 813 | return; |
@@ -817,8 +817,8 @@ handle_acknowledge_request (void *cls, | |||
817 | target->rcpt_sequence_number++; | 817 | target->rcpt_sequence_number++; |
818 | #if DEBUG_CHAT_SERVICE | 818 | #if DEBUG_CHAT_SERVICE |
819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 819 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
820 | "Broadcasting %s's receipt #%u to neighbour peers\n", | 820 | "Broadcasting %s's receipt #%u to neighbour peers\n", |
821 | GNUNET_h2s (&target->id), target->rcpt_sequence_number); | 821 | GNUNET_h2s (&target->id), target->rcpt_sequence_number); |
822 | #endif | 822 | #endif |
823 | p2p_crmsg = GNUNET_malloc (sizeof (struct P2PConfirmationReceiptMessage)); | 823 | p2p_crmsg = GNUNET_malloc (sizeof (struct P2PConfirmationReceiptMessage)); |
824 | p2p_crmsg->header.size = htons (sizeof (struct P2PConfirmationReceiptMessage)); | 824 | p2p_crmsg->header.size = htons (sizeof (struct P2PConfirmationReceiptMessage)); |
@@ -832,38 +832,38 @@ handle_acknowledge_request (void *cls, | |||
832 | p2p_crmsg->content = receipt->content; | 832 | p2p_crmsg->content = receipt->content; |
833 | p2p_crmsg->sequence_number = htonl (target->rcpt_sequence_number); | 833 | p2p_crmsg->sequence_number = htonl (target->rcpt_sequence_number); |
834 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 834 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
835 | &send_confirmation_receipt, | 835 | &send_confirmation_receipt, |
836 | p2p_crmsg); | 836 | p2p_crmsg); |
837 | GNUNET_free (p2p_crmsg); | 837 | GNUNET_free (p2p_crmsg); |
838 | } | 838 | } |
839 | else | 839 | else |
840 | { | 840 | { |
841 | #if DEBUG_CHAT_SERVICE | 841 | #if DEBUG_CHAT_SERVICE |
842 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 842 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
843 | "Verifying signature of the receipt\n"); | 843 | "Verifying signature of the receipt\n"); |
844 | #endif | 844 | #endif |
845 | if (GNUNET_OK != | 845 | if (GNUNET_OK != |
846 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, | 846 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, |
847 | &receipt->purpose, | 847 | &receipt->purpose, |
848 | &receipt->signature, | 848 | &receipt->signature, |
849 | &target->public_key)) | 849 | &target->public_key)) |
850 | { | 850 | { |
851 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 851 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
852 | "Invalid signature of the receipt\n"); | 852 | "Invalid signature of the receipt\n"); |
853 | GNUNET_break (0); | 853 | GNUNET_break (0); |
854 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 854 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
855 | return; | 855 | return; |
856 | } | 856 | } |
857 | #if DEBUG_CHAT_SERVICE | 857 | #if DEBUG_CHAT_SERVICE |
858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 858 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
859 | "Sending receipt to the client which sent the original message\n"); | 859 | "Sending receipt to the client which sent the original message\n"); |
860 | #endif | 860 | #endif |
861 | crmsg = GNUNET_memdup (receipt, sizeof (struct ConfirmationReceiptMessage)); | 861 | crmsg = GNUNET_memdup (receipt, sizeof (struct ConfirmationReceiptMessage)); |
862 | crmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION); | 862 | crmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION); |
863 | GNUNET_SERVER_notification_context_unicast (nc, | 863 | GNUNET_SERVER_notification_context_unicast (nc, |
864 | author->client, | 864 | author->client, |
865 | &crmsg->header, | 865 | &crmsg->header, |
866 | GNUNET_NO); | 866 | GNUNET_NO); |
867 | GNUNET_free (crmsg); | 867 | GNUNET_free (crmsg); |
868 | } | 868 | } |
869 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 869 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -881,8 +881,8 @@ handle_acknowledge_request (void *cls, | |||
881 | */ | 881 | */ |
882 | static size_t | 882 | static size_t |
883 | transmit_leave_notification_to_peer (void *cls, | 883 | transmit_leave_notification_to_peer (void *cls, |
884 | size_t size, | 884 | size_t size, |
885 | void *buf) | 885 | void *buf) |
886 | { | 886 | { |
887 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key = cls; | 887 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *public_key = cls; |
888 | struct P2PLeaveNotificationMessage *m = buf; | 888 | struct P2PLeaveNotificationMessage *m = buf; |
@@ -890,14 +890,14 @@ transmit_leave_notification_to_peer (void *cls, | |||
890 | 890 | ||
891 | #if DEBUG_CHAT_SERVICE | 891 | #if DEBUG_CHAT_SERVICE |
892 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 892 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
893 | "Transmitting P2P leave notification\n"); | 893 | "Transmitting P2P leave notification\n"); |
894 | #endif | 894 | #endif |
895 | if (buf == NULL) | 895 | if (buf == NULL) |
896 | { | 896 | { |
897 | /* client disconnected */ | 897 | /* client disconnected */ |
898 | #if DEBUG_CHAT_SERVICE | 898 | #if DEBUG_CHAT_SERVICE |
899 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 899 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
900 | "Buffer is NULL, dropping the message\n"); | 900 | "Buffer is NULL, dropping the message\n"); |
901 | #endif | 901 | #endif |
902 | return 0; | 902 | return 0; |
903 | } | 903 | } |
@@ -918,8 +918,8 @@ transmit_leave_notification_to_peer (void *cls, | |||
918 | */ | 918 | */ |
919 | static int | 919 | static int |
920 | send_leave_noficiation (void *cls, | 920 | send_leave_noficiation (void *cls, |
921 | const GNUNET_HashCode *key, | 921 | const GNUNET_HashCode *key, |
922 | void *value) | 922 | void *value) |
923 | { | 923 | { |
924 | struct ChatClient *entry = cls; | 924 | struct ChatClient *entry = cls; |
925 | struct ConnectedPeer *cp = value; | 925 | struct ConnectedPeer *cp = value; |
@@ -930,20 +930,20 @@ send_leave_noficiation (void *cls, | |||
930 | GNUNET_PEER_resolve (cp->pid, &pid); | 930 | GNUNET_PEER_resolve (cp->pid, &pid); |
931 | #if DEBUG_CHAT_SERVICE | 931 | #if DEBUG_CHAT_SERVICE |
932 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 932 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
933 | "Sending leave notification to `%s'\n", GNUNET_i2s (&pid)); | 933 | "Sending leave notification to `%s'\n", GNUNET_i2s (&pid)); |
934 | #endif | 934 | #endif |
935 | msg_size = sizeof (struct P2PLeaveNotificationMessage); | 935 | msg_size = sizeof (struct P2PLeaveNotificationMessage); |
936 | public_key = GNUNET_memdup (&entry->public_key, | 936 | public_key = GNUNET_memdup (&entry->public_key, |
937 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 937 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
938 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, | 938 | if (NULL == GNUNET_CORE_notify_transmit_ready (core, |
939 | 1, | 939 | 1, |
940 | MAX_TRANSMIT_DELAY, | 940 | MAX_TRANSMIT_DELAY, |
941 | &pid, | 941 | &pid, |
942 | msg_size, | 942 | msg_size, |
943 | &transmit_leave_notification_to_peer, | 943 | &transmit_leave_notification_to_peer, |
944 | public_key)) | 944 | public_key)) |
945 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 945 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
946 | _("Failed to queue a leave notification\n")); | 946 | _("Failed to queue a leave notification\n")); |
947 | return GNUNET_YES; | 947 | return GNUNET_YES; |
948 | } | 948 | } |
949 | 949 | ||
@@ -957,7 +957,7 @@ send_leave_noficiation (void *cls, | |||
957 | */ | 957 | */ |
958 | static void | 958 | static void |
959 | handle_client_disconnect (void *cls, | 959 | handle_client_disconnect (void *cls, |
960 | struct GNUNET_SERVER_Client *client) | 960 | struct GNUNET_SERVER_Client *client) |
961 | { | 961 | { |
962 | struct ChatClient *entry; | 962 | struct ChatClient *entry; |
963 | struct ChatClient *pos; | 963 | struct ChatClient *pos; |
@@ -976,7 +976,7 @@ handle_client_disconnect (void *cls, | |||
976 | { | 976 | { |
977 | #if DEBUG_CHAT_SERVICE | 977 | #if DEBUG_CHAT_SERVICE |
978 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 978 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
979 | "No such client. There is nothing to do\n"); | 979 | "No such client. There is nothing to do\n"); |
980 | #endif | 980 | #endif |
981 | return; | 981 | return; |
982 | } | 982 | } |
@@ -987,7 +987,7 @@ handle_client_disconnect (void *cls, | |||
987 | entry = client_list_head; | 987 | entry = client_list_head; |
988 | #if DEBUG_CHAT_SERVICE | 988 | #if DEBUG_CHAT_SERVICE |
989 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 989 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
990 | "Notifying local room members that the client has disconnected\n"); | 990 | "Notifying local room members that the client has disconnected\n"); |
991 | #endif | 991 | #endif |
992 | lnmsg.header.size = htons (sizeof (struct LeaveNotificationMessage)); | 992 | lnmsg.header.size = htons (sizeof (struct LeaveNotificationMessage)); |
993 | lnmsg.header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION); | 993 | lnmsg.header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION); |
@@ -996,22 +996,22 @@ handle_client_disconnect (void *cls, | |||
996 | while (NULL != entry) | 996 | while (NULL != entry) |
997 | { | 997 | { |
998 | if ((0 == strcmp (pos->room, entry->room)) && | 998 | if ((0 == strcmp (pos->room, entry->room)) && |
999 | (NULL != entry->client)) | 999 | (NULL != entry->client)) |
1000 | { | 1000 | { |
1001 | GNUNET_SERVER_notification_context_unicast (nc, | 1001 | GNUNET_SERVER_notification_context_unicast (nc, |
1002 | entry->client, | 1002 | entry->client, |
1003 | &lnmsg.header, | 1003 | &lnmsg.header, |
1004 | GNUNET_NO); | 1004 | GNUNET_NO); |
1005 | } | 1005 | } |
1006 | entry = entry->next; | 1006 | entry = entry->next; |
1007 | } | 1007 | } |
1008 | #if DEBUG_CHAT_SERVICE | 1008 | #if DEBUG_CHAT_SERVICE |
1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1009 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1010 | "Broadcasting leave notification to neighbour peers\n"); | 1010 | "Broadcasting leave notification to neighbour peers\n"); |
1011 | #endif | 1011 | #endif |
1012 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1012 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1013 | &send_leave_noficiation, | 1013 | &send_leave_noficiation, |
1014 | pos); | 1014 | pos); |
1015 | GNUNET_free (pos->room); | 1015 | GNUNET_free (pos->room); |
1016 | GNUNET_free_non_null (pos->member_info); | 1016 | GNUNET_free_non_null (pos->member_info); |
1017 | GNUNET_free (pos); | 1017 | GNUNET_free (pos); |
@@ -1030,9 +1030,9 @@ handle_client_disconnect (void *cls, | |||
1030 | */ | 1030 | */ |
1031 | static int | 1031 | static int |
1032 | handle_p2p_join_notification (void *cls, | 1032 | handle_p2p_join_notification (void *cls, |
1033 | const struct GNUNET_PeerIdentity *other, | 1033 | const struct GNUNET_PeerIdentity *other, |
1034 | const struct GNUNET_MessageHeader *message, | 1034 | const struct GNUNET_MessageHeader *message, |
1035 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1035 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1036 | { | 1036 | { |
1037 | const struct P2PJoinNotificationMessage *p2p_jnmsg; | 1037 | const struct P2PJoinNotificationMessage *p2p_jnmsg; |
1038 | char *room_name; | 1038 | char *room_name; |
@@ -1059,24 +1059,24 @@ handle_p2p_join_notification (void *cls, | |||
1059 | room_name_len) | 1059 | room_name_len) |
1060 | { | 1060 | { |
1061 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1061 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1062 | "Malformed message: wrong length of the room name\n"); | 1062 | "Malformed message: wrong length of the room name\n"); |
1063 | GNUNET_break_op (0); | 1063 | GNUNET_break_op (0); |
1064 | return GNUNET_SYSERR; | 1064 | return GNUNET_SYSERR; |
1065 | } | 1065 | } |
1066 | GNUNET_CRYPTO_hash (&p2p_jnmsg->public_key, | 1066 | GNUNET_CRYPTO_hash (&p2p_jnmsg->public_key, |
1067 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1067 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1068 | &id); | 1068 | &id); |
1069 | entry = client_list_head; | 1069 | entry = client_list_head; |
1070 | while (NULL != entry) | 1070 | while (NULL != entry) |
1071 | { | 1071 | { |
1072 | if (0 == memcmp (&entry->id, &id, sizeof (GNUNET_HashCode))) | 1072 | if (0 == memcmp (&entry->id, &id, sizeof (GNUNET_HashCode))) |
1073 | { | 1073 | { |
1074 | #if DEBUG_CHAT_SERVICE | 1074 | #if DEBUG_CHAT_SERVICE |
1075 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1075 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1076 | "The client has already joined. There is nothing to do\n"); | 1076 | "The client has already joined. There is nothing to do\n"); |
1077 | #endif | 1077 | #endif |
1078 | return GNUNET_OK; | 1078 | return GNUNET_OK; |
1079 | } | 1079 | } |
1080 | entry = entry->next; | 1080 | entry = entry->next; |
1081 | } | 1081 | } |
1082 | meta_len = | 1082 | meta_len = |
@@ -1104,7 +1104,7 @@ handle_p2p_join_notification (void *cls, | |||
1104 | client_list_head = new_entry; | 1104 | client_list_head = new_entry; |
1105 | #if DEBUG_CHAT_SERVICE | 1105 | #if DEBUG_CHAT_SERVICE |
1106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1106 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1107 | "Notifying local room members that we have a new client\n"); | 1107 | "Notifying local room members that we have a new client\n"); |
1108 | #endif | 1108 | #endif |
1109 | jnmsg = GNUNET_malloc (sizeof (struct JoinNotificationMessage) + meta_len); | 1109 | jnmsg = GNUNET_malloc (sizeof (struct JoinNotificationMessage) + meta_len); |
1110 | jnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); | 1110 | jnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION); |
@@ -1117,22 +1117,22 @@ handle_p2p_join_notification (void *cls, | |||
1117 | while (NULL != entry) | 1117 | while (NULL != entry) |
1118 | { | 1118 | { |
1119 | if ((0 == strcmp (room_name, entry->room)) && | 1119 | if ((0 == strcmp (room_name, entry->room)) && |
1120 | (NULL != entry->client)) | 1120 | (NULL != entry->client)) |
1121 | { | 1121 | { |
1122 | GNUNET_SERVER_notification_context_unicast (nc, | 1122 | GNUNET_SERVER_notification_context_unicast (nc, |
1123 | entry->client, | 1123 | entry->client, |
1124 | &jnmsg->header, | 1124 | &jnmsg->header, |
1125 | GNUNET_NO); | 1125 | GNUNET_NO); |
1126 | } | 1126 | } |
1127 | entry = entry->next; | 1127 | entry = entry->next; |
1128 | } | 1128 | } |
1129 | #if DEBUG_CHAT_SERVICE | 1129 | #if DEBUG_CHAT_SERVICE |
1130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1130 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1131 | "Broadcasting join notification to neighbour peers\n"); | 1131 | "Broadcasting join notification to neighbour peers\n"); |
1132 | #endif | 1132 | #endif |
1133 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1133 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1134 | &send_join_noficiation, | 1134 | &send_join_noficiation, |
1135 | new_entry); | 1135 | new_entry); |
1136 | GNUNET_free (jnmsg); | 1136 | GNUNET_free (jnmsg); |
1137 | return GNUNET_OK; | 1137 | return GNUNET_OK; |
1138 | } | 1138 | } |
@@ -1150,9 +1150,9 @@ handle_p2p_join_notification (void *cls, | |||
1150 | */ | 1150 | */ |
1151 | static int | 1151 | static int |
1152 | handle_p2p_leave_notification (void *cls, | 1152 | handle_p2p_leave_notification (void *cls, |
1153 | const struct GNUNET_PeerIdentity *other, | 1153 | const struct GNUNET_PeerIdentity *other, |
1154 | const struct GNUNET_MessageHeader *message, | 1154 | const struct GNUNET_MessageHeader *message, |
1155 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1155 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1156 | { | 1156 | { |
1157 | const struct P2PLeaveNotificationMessage *p2p_lnmsg; | 1157 | const struct P2PLeaveNotificationMessage *p2p_lnmsg; |
1158 | GNUNET_HashCode id; | 1158 | GNUNET_HashCode id; |
@@ -1164,14 +1164,14 @@ handle_p2p_leave_notification (void *cls, | |||
1164 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got P2P leave notification\n"); | 1164 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got P2P leave notification\n"); |
1165 | p2p_lnmsg = (const struct P2PLeaveNotificationMessage *) message; | 1165 | p2p_lnmsg = (const struct P2PLeaveNotificationMessage *) message; |
1166 | GNUNET_CRYPTO_hash (&p2p_lnmsg->user, | 1166 | GNUNET_CRYPTO_hash (&p2p_lnmsg->user, |
1167 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1167 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1168 | &id); | 1168 | &id); |
1169 | pos = client_list_head; | 1169 | pos = client_list_head; |
1170 | prev = NULL; | 1170 | prev = NULL; |
1171 | while (NULL != pos) | 1171 | while (NULL != pos) |
1172 | { | 1172 | { |
1173 | if (0 == memcmp (&pos->id, &id, sizeof (GNUNET_HashCode))) | 1173 | if (0 == memcmp (&pos->id, &id, sizeof (GNUNET_HashCode))) |
1174 | break; | 1174 | break; |
1175 | prev = pos; | 1175 | prev = pos; |
1176 | pos = pos->next; | 1176 | pos = pos->next; |
1177 | } | 1177 | } |
@@ -1179,7 +1179,7 @@ handle_p2p_leave_notification (void *cls, | |||
1179 | { | 1179 | { |
1180 | #if DEBUG_CHAT_SERVICE | 1180 | #if DEBUG_CHAT_SERVICE |
1181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1182 | "No such client. There is nothing to do\n"); | 1182 | "No such client. There is nothing to do\n"); |
1183 | #endif | 1183 | #endif |
1184 | return GNUNET_OK; | 1184 | return GNUNET_OK; |
1185 | } | 1185 | } |
@@ -1189,7 +1189,7 @@ handle_p2p_leave_notification (void *cls, | |||
1189 | prev->next = pos->next; | 1189 | prev->next = pos->next; |
1190 | #if DEBUG_CHAT_SERVICE | 1190 | #if DEBUG_CHAT_SERVICE |
1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1192 | "Notifying local room members that the client has gone away\n"); | 1192 | "Notifying local room members that the client has gone away\n"); |
1193 | #endif | 1193 | #endif |
1194 | lnmsg.header.size = htons (sizeof (struct LeaveNotificationMessage)); | 1194 | lnmsg.header.size = htons (sizeof (struct LeaveNotificationMessage)); |
1195 | lnmsg.header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION); | 1195 | lnmsg.header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION); |
@@ -1199,22 +1199,22 @@ handle_p2p_leave_notification (void *cls, | |||
1199 | while (NULL != entry) | 1199 | while (NULL != entry) |
1200 | { | 1200 | { |
1201 | if (0 == strcmp (pos->room, entry->room) && | 1201 | if (0 == strcmp (pos->room, entry->room) && |
1202 | (NULL != entry->client)) | 1202 | (NULL != entry->client)) |
1203 | { | 1203 | { |
1204 | GNUNET_SERVER_notification_context_unicast (nc, | 1204 | GNUNET_SERVER_notification_context_unicast (nc, |
1205 | entry->client, | 1205 | entry->client, |
1206 | &lnmsg.header, | 1206 | &lnmsg.header, |
1207 | GNUNET_NO); | 1207 | GNUNET_NO); |
1208 | } | 1208 | } |
1209 | entry = entry->next; | 1209 | entry = entry->next; |
1210 | } | 1210 | } |
1211 | #if DEBUG_CHAT_SERVICE | 1211 | #if DEBUG_CHAT_SERVICE |
1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1213 | "Broadcasting leave notification to neighbour peers\n"); | 1213 | "Broadcasting leave notification to neighbour peers\n"); |
1214 | #endif | 1214 | #endif |
1215 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1215 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1216 | &send_leave_noficiation, | 1216 | &send_leave_noficiation, |
1217 | pos); | 1217 | pos); |
1218 | GNUNET_free (pos->room); | 1218 | GNUNET_free (pos->room); |
1219 | GNUNET_free_non_null (pos->member_info); | 1219 | GNUNET_free_non_null (pos->member_info); |
1220 | GNUNET_free (pos); | 1220 | GNUNET_free (pos); |
@@ -1234,9 +1234,9 @@ handle_p2p_leave_notification (void *cls, | |||
1234 | */ | 1234 | */ |
1235 | static int | 1235 | static int |
1236 | handle_p2p_message_notification (void *cls, | 1236 | handle_p2p_message_notification (void *cls, |
1237 | const struct GNUNET_PeerIdentity *other, | 1237 | const struct GNUNET_PeerIdentity *other, |
1238 | const struct GNUNET_MessageHeader *message, | 1238 | const struct GNUNET_MessageHeader *message, |
1239 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1239 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1240 | { | 1240 | { |
1241 | const struct P2PReceiveNotificationMessage *p2p_rnmsg; | 1241 | const struct P2PReceiveNotificationMessage *p2p_rnmsg; |
1242 | struct P2PReceiveNotificationMessage *my_p2p_rnmsg; | 1242 | struct P2PReceiveNotificationMessage *my_p2p_rnmsg; |
@@ -1267,21 +1267,21 @@ handle_p2p_message_notification (void *cls, | |||
1267 | { | 1267 | { |
1268 | room_name_len = ntohs (p2p_rnmsg->room_name_len); | 1268 | room_name_len = ntohs (p2p_rnmsg->room_name_len); |
1269 | if (msg_len <= room_name_len) | 1269 | if (msg_len <= room_name_len) |
1270 | { | 1270 | { |
1271 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1271 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1272 | "Malformed message: wrong length of the room name\n"); | 1272 | "Malformed message: wrong length of the room name\n"); |
1273 | GNUNET_break_op (0); | 1273 | GNUNET_break_op (0); |
1274 | return GNUNET_SYSERR; | 1274 | return GNUNET_SYSERR; |
1275 | } | 1275 | } |
1276 | msg_len -= room_name_len; | 1276 | msg_len -= room_name_len; |
1277 | if (lookup_anonymous_message (p2p_rnmsg)) | 1277 | if (lookup_anonymous_message (p2p_rnmsg)) |
1278 | { | 1278 | { |
1279 | #if DEBUG_CHAT_SERVICE | 1279 | #if DEBUG_CHAT_SERVICE |
1280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1280 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1281 | "This anonymous message has already been handled."); | 1281 | "This anonymous message has already been handled."); |
1282 | #endif | 1282 | #endif |
1283 | return GNUNET_OK; | 1283 | return GNUNET_OK; |
1284 | } | 1284 | } |
1285 | remember_anonymous_message (p2p_rnmsg); | 1285 | remember_anonymous_message (p2p_rnmsg); |
1286 | room_name = GNUNET_malloc (room_name_len + 1); | 1286 | room_name = GNUNET_malloc (room_name_len + 1); |
1287 | memcpy (room_name, (char *) &p2p_rnmsg[1], room_name_len); | 1287 | memcpy (room_name, (char *) &p2p_rnmsg[1], room_name_len); |
@@ -1292,28 +1292,28 @@ handle_p2p_message_notification (void *cls, | |||
1292 | { | 1292 | { |
1293 | sender = client_list_head; | 1293 | sender = client_list_head; |
1294 | while ((NULL != sender) && | 1294 | while ((NULL != sender) && |
1295 | (0 != memcmp (&sender->id, | 1295 | (0 != memcmp (&sender->id, |
1296 | &p2p_rnmsg->sender, | 1296 | &p2p_rnmsg->sender, |
1297 | sizeof (GNUNET_HashCode)))) | 1297 | sizeof (GNUNET_HashCode)))) |
1298 | sender = sender->next; | 1298 | sender = sender->next; |
1299 | if (NULL == sender) | 1299 | if (NULL == sender) |
1300 | { | 1300 | { |
1301 | /* not an error since the sender may have left before we got the | 1301 | /* not an error since the sender may have left before we got the |
1302 | message */ | 1302 | message */ |
1303 | #if DEBUG_CHAT_SERVICE | 1303 | #if DEBUG_CHAT_SERVICE |
1304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1304 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1305 | "Unknown source. Rejecting the message\n"); | 1305 | "Unknown source. Rejecting the message\n"); |
1306 | #endif | 1306 | #endif |
1307 | return GNUNET_OK; | 1307 | return GNUNET_OK; |
1308 | } | 1308 | } |
1309 | if (sender->msg_sequence_number >= ntohl (p2p_rnmsg->sequence_number)) | 1309 | if (sender->msg_sequence_number >= ntohl (p2p_rnmsg->sequence_number)) |
1310 | { | 1310 | { |
1311 | #if DEBUG_CHAT_SERVICE | 1311 | #if DEBUG_CHAT_SERVICE |
1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1313 | "This message has already been handled." | 1313 | "This message has already been handled." |
1314 | " Sequence numbers (msg/sender): %u/%u\n", | 1314 | " Sequence numbers (msg/sender): %u/%u\n", |
1315 | ntohl (p2p_rnmsg->sequence_number), | 1315 | ntohl (p2p_rnmsg->sequence_number), |
1316 | sender->msg_sequence_number); | 1316 | sender->msg_sequence_number); |
1317 | #endif | 1317 | #endif |
1318 | return GNUNET_OK; | 1318 | return GNUNET_OK; |
1319 | } | 1319 | } |
@@ -1324,53 +1324,53 @@ handle_p2p_message_notification (void *cls, | |||
1324 | 1324 | ||
1325 | #if DEBUG_CHAT_SERVICE | 1325 | #if DEBUG_CHAT_SERVICE |
1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1327 | "Sending message to local room members\n"); | 1327 | "Sending message to local room members\n"); |
1328 | #endif | 1328 | #endif |
1329 | rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); | 1329 | rnmsg = GNUNET_malloc (sizeof (struct ReceiveNotificationMessage) + msg_len); |
1330 | rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + | 1330 | rnmsg->header.size = htons (sizeof (struct ReceiveNotificationMessage) + |
1331 | msg_len); | 1331 | msg_len); |
1332 | rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); | 1332 | rnmsg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION); |
1333 | rnmsg->msg_options = p2p_rnmsg->msg_options; | 1333 | rnmsg->msg_options = p2p_rnmsg->msg_options; |
1334 | rnmsg->sequence_number = p2p_rnmsg->sequence_number; | 1334 | rnmsg->sequence_number = p2p_rnmsg->sequence_number; |
1335 | rnmsg->timestamp = p2p_rnmsg->timestamp; | 1335 | rnmsg->timestamp = p2p_rnmsg->timestamp; |
1336 | is_priv = (0 != memcmp (&all_zeros, | 1336 | is_priv = (0 != memcmp (&all_zeros, |
1337 | &p2p_rnmsg->target, sizeof (GNUNET_HashCode))); | 1337 | &p2p_rnmsg->target, sizeof (GNUNET_HashCode))); |
1338 | if (is_priv) | 1338 | if (is_priv) |
1339 | memcpy (&rnmsg->encrypted_key, | 1339 | memcpy (&rnmsg->encrypted_key, |
1340 | &p2p_rnmsg->encrypted_key, | 1340 | &p2p_rnmsg->encrypted_key, |
1341 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); | 1341 | sizeof (struct GNUNET_CRYPTO_RsaEncryptedData)); |
1342 | rnmsg->sender = p2p_rnmsg->sender; | 1342 | rnmsg->sender = p2p_rnmsg->sender; |
1343 | memcpy (&rnmsg[1], text, msg_len); | 1343 | memcpy (&rnmsg[1], text, msg_len); |
1344 | pos = client_list_head; | 1344 | pos = client_list_head; |
1345 | while (NULL != pos) | 1345 | while (NULL != pos) |
1346 | { | 1346 | { |
1347 | if ((0 == strcmp (room_name, pos->room)) && | 1347 | if ((0 == strcmp (room_name, pos->room)) && |
1348 | (NULL != pos->client)) | 1348 | (NULL != pos->client)) |
1349 | { | 1349 | { |
1350 | if (((!is_priv) || | 1350 | if (((!is_priv) || |
1351 | (0 == memcmp (&p2p_rnmsg->target, | 1351 | (0 == memcmp (&p2p_rnmsg->target, |
1352 | &pos->id, | 1352 | &pos->id, |
1353 | sizeof (GNUNET_HashCode)))) && | 1353 | sizeof (GNUNET_HashCode)))) && |
1354 | (0 == (ntohl (p2p_rnmsg->msg_options) & (~pos->msg_options)))) | 1354 | (0 == (ntohl (p2p_rnmsg->msg_options) & (~pos->msg_options)))) |
1355 | { | 1355 | { |
1356 | GNUNET_SERVER_notification_context_unicast (nc, | 1356 | GNUNET_SERVER_notification_context_unicast (nc, |
1357 | pos->client, | 1357 | pos->client, |
1358 | &rnmsg->header, | 1358 | &rnmsg->header, |
1359 | GNUNET_NO); | 1359 | GNUNET_NO); |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | pos = pos->next; | 1362 | pos = pos->next; |
1363 | } | 1363 | } |
1364 | if (is_anon) | 1364 | if (is_anon) |
1365 | GNUNET_free (room_name); | 1365 | GNUNET_free (room_name); |
1366 | #if DEBUG_CHAT_SERVICE | 1366 | #if DEBUG_CHAT_SERVICE |
1367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1368 | "Broadcasting message notification to neighbour peers\n"); | 1368 | "Broadcasting message notification to neighbour peers\n"); |
1369 | #endif | 1369 | #endif |
1370 | my_p2p_rnmsg = GNUNET_memdup (p2p_rnmsg, ntohs (p2p_rnmsg->header.size)); | 1370 | my_p2p_rnmsg = GNUNET_memdup (p2p_rnmsg, ntohs (p2p_rnmsg->header.size)); |
1371 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1371 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1372 | &send_message_noficiation, | 1372 | &send_message_noficiation, |
1373 | my_p2p_rnmsg); | 1373 | my_p2p_rnmsg); |
1374 | GNUNET_free (rnmsg); | 1374 | GNUNET_free (rnmsg); |
1375 | return GNUNET_OK; | 1375 | return GNUNET_OK; |
1376 | } | 1376 | } |
@@ -1388,9 +1388,9 @@ handle_p2p_message_notification (void *cls, | |||
1388 | */ | 1388 | */ |
1389 | static int | 1389 | static int |
1390 | handle_p2p_sync_request (void *cls, | 1390 | handle_p2p_sync_request (void *cls, |
1391 | const struct GNUNET_PeerIdentity *other, | 1391 | const struct GNUNET_PeerIdentity *other, |
1392 | const struct GNUNET_MessageHeader *message, | 1392 | const struct GNUNET_MessageHeader *message, |
1393 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1393 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1394 | { | 1394 | { |
1395 | struct ChatClient *entry; | 1395 | struct ChatClient *entry; |
1396 | struct GNUNET_CORE_TransmitHandle *th; | 1396 | struct GNUNET_CORE_TransmitHandle *th; |
@@ -1399,21 +1399,21 @@ handle_p2p_sync_request (void *cls, | |||
1399 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got P2P sync request\n"); | 1399 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Got P2P sync request\n"); |
1400 | #if DEBUG_CHAT_SERVICE | 1400 | #if DEBUG_CHAT_SERVICE |
1401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1401 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1402 | "Notifying the requester of all known clients\n"); | 1402 | "Notifying the requester of all known clients\n"); |
1403 | #endif | 1403 | #endif |
1404 | entry = client_list_head; | 1404 | entry = client_list_head; |
1405 | while (NULL != entry) | 1405 | while (NULL != entry) |
1406 | { | 1406 | { |
1407 | msg_size = sizeof (struct P2PJoinNotificationMessage) + | 1407 | msg_size = sizeof (struct P2PJoinNotificationMessage) + |
1408 | strlen (entry->room) + | 1408 | strlen (entry->room) + |
1409 | entry->meta_len; | 1409 | entry->meta_len; |
1410 | th = GNUNET_CORE_notify_transmit_ready (core, | 1410 | th = GNUNET_CORE_notify_transmit_ready (core, |
1411 | 1, | 1411 | 1, |
1412 | MAX_TRANSMIT_DELAY, | 1412 | MAX_TRANSMIT_DELAY, |
1413 | other, | 1413 | other, |
1414 | msg_size, | 1414 | msg_size, |
1415 | &transmit_join_notification_to_peer, | 1415 | &transmit_join_notification_to_peer, |
1416 | entry); | 1416 | entry); |
1417 | GNUNET_assert (NULL != th); | 1417 | GNUNET_assert (NULL != th); |
1418 | entry = entry->next; | 1418 | entry = entry->next; |
1419 | } | 1419 | } |
@@ -1433,9 +1433,9 @@ handle_p2p_sync_request (void *cls, | |||
1433 | */ | 1433 | */ |
1434 | static int | 1434 | static int |
1435 | handle_p2p_confirmation_receipt (void *cls, | 1435 | handle_p2p_confirmation_receipt (void *cls, |
1436 | const struct GNUNET_PeerIdentity *other, | 1436 | const struct GNUNET_PeerIdentity *other, |
1437 | const struct GNUNET_MessageHeader *message, | 1437 | const struct GNUNET_MessageHeader *message, |
1438 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1438 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1439 | { | 1439 | { |
1440 | const struct P2PConfirmationReceiptMessage *p2p_crmsg; | 1440 | const struct P2PConfirmationReceiptMessage *p2p_crmsg; |
1441 | struct P2PConfirmationReceiptMessage *my_p2p_crmsg; | 1441 | struct P2PConfirmationReceiptMessage *my_p2p_crmsg; |
@@ -1447,14 +1447,14 @@ handle_p2p_confirmation_receipt (void *cls, | |||
1447 | p2p_crmsg = (const struct P2PConfirmationReceiptMessage *) message; | 1447 | p2p_crmsg = (const struct P2PConfirmationReceiptMessage *) message; |
1448 | target = client_list_head; | 1448 | target = client_list_head; |
1449 | while ((NULL != target) && | 1449 | while ((NULL != target) && |
1450 | (0 != memcmp (&target->id, | 1450 | (0 != memcmp (&target->id, |
1451 | &p2p_crmsg->target, | 1451 | &p2p_crmsg->target, |
1452 | sizeof (GNUNET_HashCode)))) | 1452 | sizeof (GNUNET_HashCode)))) |
1453 | target = target->next; | 1453 | target = target->next; |
1454 | if (NULL == target) | 1454 | if (NULL == target) |
1455 | { | 1455 | { |
1456 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1456 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1457 | "Unknown source of the receipt. Rejecting the message\n"); | 1457 | "Unknown source of the receipt. Rejecting the message\n"); |
1458 | GNUNET_break_op (0); | 1458 | GNUNET_break_op (0); |
1459 | return GNUNET_SYSERR; | 1459 | return GNUNET_SYSERR; |
1460 | } | 1460 | } |
@@ -1462,23 +1462,23 @@ handle_p2p_confirmation_receipt (void *cls, | |||
1462 | { | 1462 | { |
1463 | #if DEBUG_CHAT_SERVICE | 1463 | #if DEBUG_CHAT_SERVICE |
1464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1464 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1465 | "This receipt has already been handled." | 1465 | "This receipt has already been handled." |
1466 | " Sequence numbers (msg/sender): %u/%u\n", | 1466 | " Sequence numbers (msg/sender): %u/%u\n", |
1467 | ntohl (p2p_crmsg->sequence_number), target->rcpt_sequence_number); | 1467 | ntohl (p2p_crmsg->sequence_number), target->rcpt_sequence_number); |
1468 | #endif | 1468 | #endif |
1469 | return GNUNET_OK; | 1469 | return GNUNET_OK; |
1470 | } | 1470 | } |
1471 | target->rcpt_sequence_number = ntohl (p2p_crmsg->sequence_number); | 1471 | target->rcpt_sequence_number = ntohl (p2p_crmsg->sequence_number); |
1472 | author = client_list_head; | 1472 | author = client_list_head; |
1473 | while ((NULL != author) && | 1473 | while ((NULL != author) && |
1474 | (0 != memcmp (&author->id, | 1474 | (0 != memcmp (&author->id, |
1475 | &p2p_crmsg->author, | 1475 | &p2p_crmsg->author, |
1476 | sizeof (GNUNET_HashCode)))) | 1476 | sizeof (GNUNET_HashCode)))) |
1477 | author = author->next; | 1477 | author = author->next; |
1478 | if (NULL == author) | 1478 | if (NULL == author) |
1479 | { | 1479 | { |
1480 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1480 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1481 | "Unknown addressee. Rejecting the receipt\n"); | 1481 | "Unknown addressee. Rejecting the receipt\n"); |
1482 | GNUNET_break_op (0); | 1482 | GNUNET_break_op (0); |
1483 | return GNUNET_SYSERR; | 1483 | return GNUNET_SYSERR; |
1484 | } | 1484 | } |
@@ -1487,21 +1487,21 @@ handle_p2p_confirmation_receipt (void *cls, | |||
1487 | { | 1487 | { |
1488 | #if DEBUG_CHAT_SERVICE | 1488 | #if DEBUG_CHAT_SERVICE |
1489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1489 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1490 | "The author of the original message is not a local client." | 1490 | "The author of the original message is not a local client." |
1491 | " Broadcasting receipt to neighbour peers\n"); | 1491 | " Broadcasting receipt to neighbour peers\n"); |
1492 | #endif | 1492 | #endif |
1493 | my_p2p_crmsg = GNUNET_memdup (p2p_crmsg, sizeof (struct P2PConfirmationReceiptMessage)); | 1493 | my_p2p_crmsg = GNUNET_memdup (p2p_crmsg, sizeof (struct P2PConfirmationReceiptMessage)); |
1494 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1494 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1495 | &send_confirmation_receipt, | 1495 | &send_confirmation_receipt, |
1496 | my_p2p_crmsg); | 1496 | my_p2p_crmsg); |
1497 | GNUNET_free (my_p2p_crmsg); | 1497 | GNUNET_free (my_p2p_crmsg); |
1498 | } | 1498 | } |
1499 | else | 1499 | else |
1500 | { | 1500 | { |
1501 | #if DEBUG_CHAT_SERVICE | 1501 | #if DEBUG_CHAT_SERVICE |
1502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1502 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1503 | "The author of the original message is a local client." | 1503 | "The author of the original message is a local client." |
1504 | " Verifying signature of the receipt\n"); | 1504 | " Verifying signature of the receipt\n"); |
1505 | #endif | 1505 | #endif |
1506 | crmsg = GNUNET_malloc (sizeof (struct ConfirmationReceiptMessage)); | 1506 | crmsg = GNUNET_malloc (sizeof (struct ConfirmationReceiptMessage)); |
1507 | crmsg->header.size = htons (sizeof (struct ConfirmationReceiptMessage)); | 1507 | crmsg->header.size = htons (sizeof (struct ConfirmationReceiptMessage)); |
@@ -1515,25 +1515,25 @@ handle_p2p_confirmation_receipt (void *cls, | |||
1515 | crmsg->author = p2p_crmsg->author; | 1515 | crmsg->author = p2p_crmsg->author; |
1516 | crmsg->content = p2p_crmsg->content; | 1516 | crmsg->content = p2p_crmsg->content; |
1517 | if (GNUNET_OK != | 1517 | if (GNUNET_OK != |
1518 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, | 1518 | GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT, |
1519 | &crmsg->purpose, | 1519 | &crmsg->purpose, |
1520 | &crmsg->signature, | 1520 | &crmsg->signature, |
1521 | &target->public_key)) | 1521 | &target->public_key)) |
1522 | { | 1522 | { |
1523 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1523 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1524 | "Invalid signature of the receipt\n"); | 1524 | "Invalid signature of the receipt\n"); |
1525 | GNUNET_break_op (0); | 1525 | GNUNET_break_op (0); |
1526 | return GNUNET_SYSERR; | 1526 | return GNUNET_SYSERR; |
1527 | } | 1527 | } |
1528 | #if DEBUG_CHAT_SERVICE | 1528 | #if DEBUG_CHAT_SERVICE |
1529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1530 | "The author of the original message is a local client." | 1530 | "The author of the original message is a local client." |
1531 | " Sending receipt to the client\n"); | 1531 | " Sending receipt to the client\n"); |
1532 | #endif | 1532 | #endif |
1533 | GNUNET_SERVER_notification_context_unicast (nc, | 1533 | GNUNET_SERVER_notification_context_unicast (nc, |
1534 | author->client, | 1534 | author->client, |
1535 | &crmsg->header, | 1535 | &crmsg->header, |
1536 | GNUNET_NO); | 1536 | GNUNET_NO); |
1537 | GNUNET_free (crmsg); | 1537 | GNUNET_free (crmsg); |
1538 | } | 1538 | } |
1539 | return GNUNET_OK; | 1539 | return GNUNET_OK; |
@@ -1550,8 +1550,8 @@ handle_p2p_confirmation_receipt (void *cls, | |||
1550 | */ | 1550 | */ |
1551 | static size_t | 1551 | static size_t |
1552 | transmit_sync_request_to_peer (void *cls, | 1552 | transmit_sync_request_to_peer (void *cls, |
1553 | size_t size, | 1553 | size_t size, |
1554 | void *buf) | 1554 | void *buf) |
1555 | { | 1555 | { |
1556 | struct GNUNET_MessageHeader *m = buf; | 1556 | struct GNUNET_MessageHeader *m = buf; |
1557 | size_t msg_size; | 1557 | size_t msg_size; |
@@ -1578,8 +1578,8 @@ transmit_sync_request_to_peer (void *cls, | |||
1578 | */ | 1578 | */ |
1579 | static void | 1579 | static void |
1580 | peer_connect_handler (void *cls, | 1580 | peer_connect_handler (void *cls, |
1581 | const struct GNUNET_PeerIdentity *peer, | 1581 | const struct GNUNET_PeerIdentity *peer, |
1582 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1582 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1583 | { | 1583 | { |
1584 | struct ConnectedPeer *cp; | 1584 | struct ConnectedPeer *cp; |
1585 | struct GNUNET_CORE_TransmitHandle *th; | 1585 | struct GNUNET_CORE_TransmitHandle *th; |
@@ -1587,17 +1587,17 @@ peer_connect_handler (void *cls, | |||
1587 | if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) | 1587 | if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) |
1588 | return; | 1588 | return; |
1589 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1589 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1590 | "Peer connected: %s\n", GNUNET_i2s (peer)); | 1590 | "Peer connected: %s\n", GNUNET_i2s (peer)); |
1591 | th = GNUNET_CORE_notify_transmit_ready (core, | 1591 | th = GNUNET_CORE_notify_transmit_ready (core, |
1592 | 1, | 1592 | 1, |
1593 | MAX_TRANSMIT_DELAY, | 1593 | MAX_TRANSMIT_DELAY, |
1594 | peer, | 1594 | peer, |
1595 | sizeof (struct GNUNET_MessageHeader), | 1595 | sizeof (struct GNUNET_MessageHeader), |
1596 | &transmit_sync_request_to_peer, | 1596 | &transmit_sync_request_to_peer, |
1597 | NULL); | 1597 | NULL); |
1598 | GNUNET_assert (NULL != th); | 1598 | GNUNET_assert (NULL != th); |
1599 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, | 1599 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, |
1600 | &peer->hashPubKey); | 1600 | &peer->hashPubKey); |
1601 | if (NULL != cp) | 1601 | if (NULL != cp) |
1602 | { | 1602 | { |
1603 | GNUNET_break (0); | 1603 | GNUNET_break (0); |
@@ -1606,10 +1606,10 @@ peer_connect_handler (void *cls, | |||
1606 | cp = GNUNET_malloc (sizeof (struct ConnectedPeer)); | 1606 | cp = GNUNET_malloc (sizeof (struct ConnectedPeer)); |
1607 | cp->pid = GNUNET_PEER_intern (peer); | 1607 | cp->pid = GNUNET_PEER_intern (peer); |
1608 | GNUNET_break (GNUNET_OK == | 1608 | GNUNET_break (GNUNET_OK == |
1609 | GNUNET_CONTAINER_multihashmap_put (connected_peers, | 1609 | GNUNET_CONTAINER_multihashmap_put (connected_peers, |
1610 | &peer->hashPubKey, | 1610 | &peer->hashPubKey, |
1611 | cp, | 1611 | cp, |
1612 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 1612 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1613 | } | 1613 | } |
1614 | 1614 | ||
1615 | 1615 | ||
@@ -1623,20 +1623,20 @@ peer_connect_handler (void *cls, | |||
1623 | */ | 1623 | */ |
1624 | static int | 1624 | static int |
1625 | clean_peer (void *cls, | 1625 | clean_peer (void *cls, |
1626 | const GNUNET_HashCode * key, | 1626 | const GNUNET_HashCode * key, |
1627 | void *value) | 1627 | void *value) |
1628 | { | 1628 | { |
1629 | struct ConnectedPeer *cp; | 1629 | struct ConnectedPeer *cp; |
1630 | const struct GNUNET_PeerIdentity *peer = (const struct GNUNET_PeerIdentity *) key; | 1630 | const struct GNUNET_PeerIdentity *peer = (const struct GNUNET_PeerIdentity *) key; |
1631 | 1631 | ||
1632 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, | 1632 | cp = GNUNET_CONTAINER_multihashmap_get (connected_peers, |
1633 | &peer->hashPubKey); | 1633 | &peer->hashPubKey); |
1634 | if (cp == NULL) | 1634 | if (cp == NULL) |
1635 | return GNUNET_YES; | 1635 | return GNUNET_YES; |
1636 | GNUNET_break (GNUNET_YES == | 1636 | GNUNET_break (GNUNET_YES == |
1637 | GNUNET_CONTAINER_multihashmap_remove (connected_peers, | 1637 | GNUNET_CONTAINER_multihashmap_remove (connected_peers, |
1638 | &peer->hashPubKey, | 1638 | &peer->hashPubKey, |
1639 | cp)); | 1639 | cp)); |
1640 | GNUNET_PEER_change_rc (cp->pid, -1); | 1640 | GNUNET_PEER_change_rc (cp->pid, -1); |
1641 | GNUNET_free (cp); | 1641 | GNUNET_free (cp); |
1642 | return GNUNET_YES; | 1642 | return GNUNET_YES; |
@@ -1651,13 +1651,13 @@ clean_peer (void *cls, | |||
1651 | */ | 1651 | */ |
1652 | static void | 1652 | static void |
1653 | peer_disconnect_handler (void *cls, | 1653 | peer_disconnect_handler (void *cls, |
1654 | const struct GNUNET_PeerIdentity *peer) | 1654 | const struct GNUNET_PeerIdentity *peer) |
1655 | { | 1655 | { |
1656 | 1656 | ||
1657 | if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) | 1657 | if (0 == memcmp (peer, me, sizeof (struct GNUNET_PeerIdentity))) |
1658 | return; | 1658 | return; |
1659 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1659 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1660 | "Peer disconnected: %s\n", GNUNET_i2s (peer)); | 1660 | "Peer disconnected: %s\n", GNUNET_i2s (peer)); |
1661 | clean_peer (NULL, (const GNUNET_HashCode *) peer, NULL); | 1661 | clean_peer (NULL, (const GNUNET_HashCode *) peer, NULL); |
1662 | } | 1662 | } |
1663 | 1663 | ||
@@ -1670,7 +1670,7 @@ peer_disconnect_handler (void *cls, | |||
1670 | */ | 1670 | */ |
1671 | static void | 1671 | static void |
1672 | cleanup_task (void *cls, | 1672 | cleanup_task (void *cls, |
1673 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1673 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1674 | { | 1674 | { |
1675 | struct AnonymousMessage *next_msg; | 1675 | struct AnonymousMessage *next_msg; |
1676 | struct ChatClient *next_client; | 1676 | struct ChatClient *next_client; |
@@ -1701,8 +1701,8 @@ cleanup_task (void *cls, | |||
1701 | anonymous_list_head = next_msg; | 1701 | anonymous_list_head = next_msg; |
1702 | } | 1702 | } |
1703 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, | 1703 | GNUNET_CONTAINER_multihashmap_iterate (connected_peers, |
1704 | &clean_peer, | 1704 | &clean_peer, |
1705 | NULL); | 1705 | NULL); |
1706 | GNUNET_CONTAINER_multihashmap_destroy (connected_peers); | 1706 | GNUNET_CONTAINER_multihashmap_destroy (connected_peers); |
1707 | connected_peers = NULL; | 1707 | connected_peers = NULL; |
1708 | } | 1708 | } |
@@ -1718,9 +1718,9 @@ cleanup_task (void *cls, | |||
1718 | */ | 1718 | */ |
1719 | static void | 1719 | static void |
1720 | core_init (void *cls, | 1720 | core_init (void *cls, |
1721 | struct GNUNET_CORE_Handle *server, | 1721 | struct GNUNET_CORE_Handle *server, |
1722 | const struct GNUNET_PeerIdentity *my_identity, | 1722 | const struct GNUNET_PeerIdentity *my_identity, |
1723 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 1723 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
1724 | { | 1724 | { |
1725 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Core initialized\n"); | 1725 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Core initialized\n"); |
1726 | me = my_identity; | 1726 | me = my_identity; |
@@ -1742,59 +1742,59 @@ run (void *cls, | |||
1742 | static const struct GNUNET_SERVER_MessageHandler handlers[] = | 1742 | static const struct GNUNET_SERVER_MessageHandler handlers[] = |
1743 | { | 1743 | { |
1744 | { &handle_join_request, NULL, | 1744 | { &handle_join_request, NULL, |
1745 | GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST, 0 }, | 1745 | GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST, 0 }, |
1746 | { &handle_transmit_request, NULL, | 1746 | { &handle_transmit_request, NULL, |
1747 | GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST, 0 }, | 1747 | GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST, 0 }, |
1748 | { &handle_acknowledge_request, NULL, | 1748 | { &handle_acknowledge_request, NULL, |
1749 | GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT, | 1749 | GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT, |
1750 | sizeof (struct ConfirmationReceiptMessage) }, | 1750 | sizeof (struct ConfirmationReceiptMessage) }, |
1751 | { NULL, NULL, 0, 0 } | 1751 | { NULL, NULL, 0, 0 } |
1752 | }; | 1752 | }; |
1753 | static const struct GNUNET_CORE_MessageHandler p2p_handlers[] = | 1753 | static const struct GNUNET_CORE_MessageHandler p2p_handlers[] = |
1754 | { | 1754 | { |
1755 | { &handle_p2p_join_notification, | 1755 | { &handle_p2p_join_notification, |
1756 | GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION, 0 }, | 1756 | GNUNET_MESSAGE_TYPE_CHAT_P2P_JOIN_NOTIFICATION, 0 }, |
1757 | { &handle_p2p_leave_notification, | 1757 | { &handle_p2p_leave_notification, |
1758 | GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION, | 1758 | GNUNET_MESSAGE_TYPE_CHAT_P2P_LEAVE_NOTIFICATION, |
1759 | sizeof (struct P2PLeaveNotificationMessage) }, | 1759 | sizeof (struct P2PLeaveNotificationMessage) }, |
1760 | { &handle_p2p_message_notification, | 1760 | { &handle_p2p_message_notification, |
1761 | GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION, 0 }, | 1761 | GNUNET_MESSAGE_TYPE_CHAT_P2P_MESSAGE_NOTIFICATION, 0 }, |
1762 | { &handle_p2p_sync_request, | 1762 | { &handle_p2p_sync_request, |
1763 | GNUNET_MESSAGE_TYPE_CHAT_P2P_SYNC_REQUEST, | 1763 | GNUNET_MESSAGE_TYPE_CHAT_P2P_SYNC_REQUEST, |
1764 | sizeof (struct GNUNET_MessageHeader) }, | 1764 | sizeof (struct GNUNET_MessageHeader) }, |
1765 | { &handle_p2p_confirmation_receipt, | 1765 | { &handle_p2p_confirmation_receipt, |
1766 | GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT, | 1766 | GNUNET_MESSAGE_TYPE_CHAT_P2P_CONFIRMATION_RECEIPT, |
1767 | sizeof (struct P2PConfirmationReceiptMessage) }, | 1767 | sizeof (struct P2PConfirmationReceiptMessage) }, |
1768 | { NULL, 0, 0 } | 1768 | { NULL, 0, 0 } |
1769 | }; | 1769 | }; |
1770 | 1770 | ||
1771 | GNUNET_log_setup ("gnunet-service-chat", | 1771 | GNUNET_log_setup ("gnunet-service-chat", |
1772 | #if DEBUG_CHAT_SERVICE | 1772 | #if DEBUG_CHAT_SERVICE |
1773 | "DEBUG", | 1773 | "DEBUG", |
1774 | #else | 1774 | #else |
1775 | "WARNING", | 1775 | "WARNING", |
1776 | #endif | 1776 | #endif |
1777 | NULL); | 1777 | NULL); |
1778 | cfg = c; | 1778 | cfg = c; |
1779 | nc = GNUNET_SERVER_notification_context_create (server, 16); | 1779 | nc = GNUNET_SERVER_notification_context_create (server, 16); |
1780 | connected_peers = GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT); | 1780 | connected_peers = GNUNET_CONTAINER_multihashmap_create (EXPECTED_NEIGHBOUR_COUNT); |
1781 | GNUNET_SERVER_add_handlers (server, handlers); | 1781 | GNUNET_SERVER_add_handlers (server, handlers); |
1782 | core = GNUNET_CORE_connect (cfg, | 1782 | core = GNUNET_CORE_connect (cfg, |
1783 | QUEUE_SIZE, | 1783 | QUEUE_SIZE, |
1784 | NULL, | 1784 | NULL, |
1785 | &core_init, | 1785 | &core_init, |
1786 | &peer_connect_handler, | 1786 | &peer_connect_handler, |
1787 | &peer_disconnect_handler, | 1787 | &peer_disconnect_handler, |
1788 | NULL, | 1788 | NULL, |
1789 | NULL, GNUNET_NO, | 1789 | NULL, GNUNET_NO, |
1790 | NULL, GNUNET_NO, | 1790 | NULL, GNUNET_NO, |
1791 | p2p_handlers); | 1791 | p2p_handlers); |
1792 | GNUNET_SERVER_disconnect_notify (server, | 1792 | GNUNET_SERVER_disconnect_notify (server, |
1793 | &handle_client_disconnect, | 1793 | &handle_client_disconnect, |
1794 | NULL); | 1794 | NULL); |
1795 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1795 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
1796 | &cleanup_task, | 1796 | &cleanup_task, |
1797 | NULL); | 1797 | NULL); |
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | 1800 | ||
@@ -1809,11 +1809,11 @@ int | |||
1809 | main (int argc, char *const *argv) | 1809 | main (int argc, char *const *argv) |
1810 | { | 1810 | { |
1811 | return (GNUNET_OK == | 1811 | return (GNUNET_OK == |
1812 | GNUNET_SERVICE_run (argc, | 1812 | GNUNET_SERVICE_run (argc, |
1813 | argv, | 1813 | argv, |
1814 | "chat", | 1814 | "chat", |
1815 | GNUNET_SERVICE_OPTION_NONE, | 1815 | GNUNET_SERVICE_OPTION_NONE, |
1816 | &run, NULL)) ? 0 : 1; | 1816 | &run, NULL)) ? 0 : 1; |
1817 | } | 1817 | } |
1818 | 1818 | ||
1819 | /* end of gnunet-service-chat.c */ | 1819 | /* end of gnunet-service-chat.c */ |
diff --git a/src/chat/test_chat.c b/src/chat/test_chat.c index 8b96e6a58..7a20c0331 100644 --- a/src/chat/test_chat.c +++ b/src/chat/test_chat.c | |||
@@ -148,7 +148,7 @@ stop_arm (struct PeerContext *p) | |||
148 | 148 | ||
149 | static void | 149 | static void |
150 | abort_test (void *cls, | 150 | abort_test (void *cls, |
151 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 151 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
152 | { | 152 | { |
153 | if (alice_room != NULL) | 153 | if (alice_room != NULL) |
154 | { | 154 | { |
@@ -166,7 +166,7 @@ abort_test (void *cls, | |||
166 | 166 | ||
167 | static void | 167 | static void |
168 | timeout_kill (void *cls, | 168 | timeout_kill (void *cls, |
169 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 169 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
170 | { | 170 | { |
171 | #if VERBOSE | 171 | #if VERBOSE |
172 | printf ("Timed out, stopping the test.\n"); | 172 | printf ("Timed out, stopping the test.\n"); |
@@ -178,7 +178,7 @@ timeout_kill (void *cls, | |||
178 | wait_task = GNUNET_SCHEDULER_NO_TASK; | 178 | wait_task = GNUNET_SCHEDULER_NO_TASK; |
179 | } | 179 | } |
180 | GNUNET_SCHEDULER_add_continuation (&abort_test, NULL, | 180 | GNUNET_SCHEDULER_add_continuation (&abort_test, NULL, |
181 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 181 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
182 | } | 182 | } |
183 | 183 | ||
184 | 184 | ||
@@ -198,9 +198,9 @@ join_cb (void *cls) | |||
198 | 198 | ||
199 | static int | 199 | static int |
200 | member_list_cb (void *cls, | 200 | member_list_cb (void *cls, |
201 | const struct GNUNET_CONTAINER_MetaData *member_info, | 201 | const struct GNUNET_CONTAINER_MetaData *member_info, |
202 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, | 202 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, |
203 | enum GNUNET_CHAT_MsgOptions options) | 203 | enum GNUNET_CHAT_MsgOptions options) |
204 | { | 204 | { |
205 | struct Wanted *want = cls; | 205 | struct Wanted *want = cls; |
206 | GNUNET_HashCode sender; | 206 | GNUNET_HashCode sender; |
@@ -210,24 +210,24 @@ member_list_cb (void *cls, | |||
210 | want->me, | 210 | want->me, |
211 | member_info == NULL ? NULL | 211 | member_info == NULL ? NULL |
212 | : GNUNET_CONTAINER_meta_data_get_by_type (member_info, | 212 | : GNUNET_CONTAINER_meta_data_get_by_type (member_info, |
213 | EXTRACTOR_METATYPE_TITLE), | 213 | EXTRACTOR_METATYPE_TITLE), |
214 | member_info == NULL ? "left" : "joined"); | 214 | member_info == NULL ? "left" : "joined"); |
215 | #endif | 215 | #endif |
216 | GNUNET_CRYPTO_hash (member_id, | 216 | GNUNET_CRYPTO_hash (member_id, |
217 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 217 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
218 | &sender); | 218 | &sender); |
219 | if ((0 == memcmp (&sender, want->sender, | 219 | if ((0 == memcmp (&sender, want->sender, |
220 | sizeof (GNUNET_HashCode))) && | 220 | sizeof (GNUNET_HashCode))) && |
221 | (((member_info == NULL) && | 221 | (((member_info == NULL) && |
222 | (want->meta == NULL)) || | 222 | (want->meta == NULL)) || |
223 | ((member_info != NULL) && | 223 | ((member_info != NULL) && |
224 | (want->meta != NULL) && | 224 | (want->meta != NULL) && |
225 | (GNUNET_CONTAINER_meta_data_test_equal (member_info, | 225 | (GNUNET_CONTAINER_meta_data_test_equal (member_info, |
226 | want->meta)))) && | 226 | want->meta)))) && |
227 | (options == want->opt)) | 227 | (options == want->opt)) |
228 | { | 228 | { |
229 | if (NULL != want->next_task) | 229 | if (NULL != want->next_task) |
230 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); | 230 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); |
231 | } | 231 | } |
232 | else | 232 | else |
233 | { | 233 | { |
@@ -241,28 +241,28 @@ member_list_cb (void *cls, | |||
241 | 241 | ||
242 | static int | 242 | static int |
243 | receive_cb (void *cls, | 243 | receive_cb (void *cls, |
244 | struct GNUNET_CHAT_Room *room, | 244 | struct GNUNET_CHAT_Room *room, |
245 | const GNUNET_HashCode *sender, | 245 | const GNUNET_HashCode *sender, |
246 | const struct GNUNET_CONTAINER_MetaData *meta, | 246 | const struct GNUNET_CONTAINER_MetaData *meta, |
247 | const char *message, | 247 | const char *message, |
248 | struct GNUNET_TIME_Absolute timestamp, | 248 | struct GNUNET_TIME_Absolute timestamp, |
249 | enum GNUNET_CHAT_MsgOptions options) | 249 | enum GNUNET_CHAT_MsgOptions options) |
250 | { | 250 | { |
251 | struct Wanted *want = cls; | 251 | struct Wanted *want = cls; |
252 | 252 | ||
253 | #if VERBOSE | 253 | #if VERBOSE |
254 | printf ("%s - told that %s said %s\n", | 254 | printf ("%s - told that %s said %s\n", |
255 | want->me, | 255 | want->me, |
256 | meta == NULL ? NULL | 256 | meta == NULL ? NULL |
257 | : GNUNET_CONTAINER_meta_data_get_by_type (meta, | 257 | : GNUNET_CONTAINER_meta_data_get_by_type (meta, |
258 | EXTRACTOR_METATYPE_TITLE), | 258 | EXTRACTOR_METATYPE_TITLE), |
259 | message); | 259 | message); |
260 | #endif | 260 | #endif |
261 | if ((0 == strcmp (message, want->msg)) && | 261 | if ((0 == strcmp (message, want->msg)) && |
262 | (((sender == NULL) && (want->sender == NULL)) || | 262 | (((sender == NULL) && (want->sender == NULL)) || |
263 | ((sender != NULL) && (want->sender != NULL) && | 263 | ((sender != NULL) && (want->sender != NULL) && |
264 | (0 == memcmp (sender, want->sender, | 264 | (0 == memcmp (sender, want->sender, |
265 | sizeof (GNUNET_HashCode))))) && | 265 | sizeof (GNUNET_HashCode))))) && |
266 | (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && | 266 | (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && |
267 | (options == want->opt) && | 267 | (options == want->opt) && |
268 | /* Not == since the library sets the actual timestamp, so it may be | 268 | /* Not == since the library sets the actual timestamp, so it may be |
@@ -271,7 +271,7 @@ receive_cb (void *cls, | |||
271 | (timestamp.abs_value >= want->timestamp.abs_value)) | 271 | (timestamp.abs_value >= want->timestamp.abs_value)) |
272 | { | 272 | { |
273 | if (NULL != want->next_task) | 273 | if (NULL != want->next_task) |
274 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); | 274 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); |
275 | } | 275 | } |
276 | else | 276 | else |
277 | { | 277 | { |
@@ -285,27 +285,27 @@ receive_cb (void *cls, | |||
285 | 285 | ||
286 | static int | 286 | static int |
287 | confirmation_cb (void *cls, | 287 | confirmation_cb (void *cls, |
288 | struct GNUNET_CHAT_Room *room, | 288 | struct GNUNET_CHAT_Room *room, |
289 | uint32_t orig_seq_number, | 289 | uint32_t orig_seq_number, |
290 | struct GNUNET_TIME_Absolute timestamp, | 290 | struct GNUNET_TIME_Absolute timestamp, |
291 | const GNUNET_HashCode *receiver) | 291 | const GNUNET_HashCode *receiver) |
292 | { | 292 | { |
293 | struct Wanted *want = cls; | 293 | struct Wanted *want = cls; |
294 | 294 | ||
295 | #if VERBOSE | 295 | #if VERBOSE |
296 | printf ("%s - told that %s acknowledged message #%d\n", | 296 | printf ("%s - told that %s acknowledged message #%d\n", |
297 | want->me, | 297 | want->me, |
298 | GNUNET_CONTAINER_meta_data_get_by_type (want->meta, | 298 | GNUNET_CONTAINER_meta_data_get_by_type (want->meta, |
299 | EXTRACTOR_METATYPE_TITLE), | 299 | EXTRACTOR_METATYPE_TITLE), |
300 | orig_seq_number); | 300 | orig_seq_number); |
301 | #endif | 301 | #endif |
302 | if ((0 == memcmp (receiver, want->sender, | 302 | if ((0 == memcmp (receiver, want->sender, |
303 | sizeof (GNUNET_HashCode))) && | 303 | sizeof (GNUNET_HashCode))) && |
304 | (orig_seq_number == want->sequence_number) && | 304 | (orig_seq_number == want->sequence_number) && |
305 | (timestamp.abs_value >= want->timestamp.abs_value)) | 305 | (timestamp.abs_value >= want->timestamp.abs_value)) |
306 | { | 306 | { |
307 | if (NULL != want->next_task) | 307 | if (NULL != want->next_task) |
308 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); | 308 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); |
309 | } | 309 | } |
310 | else | 310 | else |
311 | { | 311 | { |
@@ -319,7 +319,7 @@ confirmation_cb (void *cls, | |||
319 | 319 | ||
320 | static void | 320 | static void |
321 | wait_until_ready (void *cls, | 321 | wait_until_ready (void *cls, |
322 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 322 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
323 | { | 323 | { |
324 | GNUNET_SCHEDULER_Task task = cls; | 324 | GNUNET_SCHEDULER_Task task = cls; |
325 | 325 | ||
@@ -334,15 +334,15 @@ wait_until_ready (void *cls, | |||
334 | else | 334 | else |
335 | wait_task = | 335 | wait_task = |
336 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 336 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
337 | 50), | 337 | 50), |
338 | &wait_until_ready, | 338 | &wait_until_ready, |
339 | task); | 339 | task); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | static void | 343 | static void |
344 | disconnect_alice (void *cls, | 344 | disconnect_alice (void *cls, |
345 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 345 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
346 | { | 346 | { |
347 | #if VERBOSE | 347 | #if VERBOSE |
348 | printf ("Alice is leaving.\n"); | 348 | printf ("Alice is leaving.\n"); |
@@ -358,7 +358,7 @@ disconnect_alice (void *cls, | |||
358 | 358 | ||
359 | static void | 359 | static void |
360 | disconnect_bob (void *cls, | 360 | disconnect_bob (void *cls, |
361 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 361 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
362 | { | 362 | { |
363 | #if VERBOSE | 363 | #if VERBOSE |
364 | printf ("Bod is leaving.\n"); | 364 | printf ("Bod is leaving.\n"); |
@@ -376,7 +376,7 @@ disconnect_bob (void *cls, | |||
376 | 376 | ||
377 | static void | 377 | static void |
378 | set_ready (void *cls, | 378 | set_ready (void *cls, |
379 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 379 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
380 | { | 380 | { |
381 | is_ready = GNUNET_YES; | 381 | is_ready = GNUNET_YES; |
382 | } | 382 | } |
@@ -384,7 +384,7 @@ set_ready (void *cls, | |||
384 | 384 | ||
385 | static void | 385 | static void |
386 | send_to_alice (void *cls, | 386 | send_to_alice (void *cls, |
387 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 387 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
388 | { | 388 | { |
389 | #if VERBOSE | 389 | #if VERBOSE |
390 | printf ("Bob says 'Hi!'\n"); | 390 | printf ("Bob says 'Hi!'\n"); |
@@ -398,16 +398,16 @@ send_to_alice (void *cls, | |||
398 | alice_wanted.next_task = &disconnect_bob; | 398 | alice_wanted.next_task = &disconnect_bob; |
399 | alice_wanted.next_task_cls = NULL; | 399 | alice_wanted.next_task_cls = NULL; |
400 | GNUNET_CHAT_send_message (bob_room, | 400 | GNUNET_CHAT_send_message (bob_room, |
401 | "Hi Alice!", | 401 | "Hi Alice!", |
402 | GNUNET_CHAT_MSG_OPTION_NONE, | 402 | GNUNET_CHAT_MSG_OPTION_NONE, |
403 | NULL, | 403 | NULL, |
404 | NULL); | 404 | NULL); |
405 | } | 405 | } |
406 | 406 | ||
407 | 407 | ||
408 | static void | 408 | static void |
409 | send_to_bob (void *cls, | 409 | send_to_bob (void *cls, |
410 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 410 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
411 | { | 411 | { |
412 | enum GNUNET_CHAT_MsgOptions options; | 412 | enum GNUNET_CHAT_MsgOptions options; |
413 | uint32_t *seq = NULL; | 413 | uint32_t *seq = NULL; |
@@ -459,7 +459,7 @@ send_to_bob (void *cls, | |||
459 | 459 | ||
460 | static void | 460 | static void |
461 | prepare_for_alice_task (void *cls, | 461 | prepare_for_alice_task (void *cls, |
462 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 462 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
463 | { | 463 | { |
464 | bob_wanted.meta = alice_meta; | 464 | bob_wanted.meta = alice_meta; |
465 | bob_wanted.sender = &alice; | 465 | bob_wanted.sender = &alice; |
@@ -472,7 +472,7 @@ prepare_for_alice_task (void *cls, | |||
472 | 472 | ||
473 | static void | 473 | static void |
474 | join_bob_task (void *cls, | 474 | join_bob_task (void *cls, |
475 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 475 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
476 | { | 476 | { |
477 | #if VERBOSE | 477 | #if VERBOSE |
478 | printf ("Bob joining\n"); | 478 | printf ("Bob joining\n"); |
@@ -488,12 +488,12 @@ join_bob_task (void *cls, | |||
488 | is_ready = GNUNET_NO; | 488 | is_ready = GNUNET_NO; |
489 | bob_room = | 489 | bob_room = |
490 | GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, | 490 | GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, |
491 | "test", -1, | 491 | "test", -1, |
492 | &join_cb, &bob_wanted, | 492 | &join_cb, &bob_wanted, |
493 | &receive_cb, &bob_wanted, | 493 | &receive_cb, &bob_wanted, |
494 | &member_list_cb, &bob_wanted, | 494 | &member_list_cb, &bob_wanted, |
495 | &confirmation_cb, &bob_wanted, | 495 | &confirmation_cb, &bob_wanted, |
496 | &bob); | 496 | &bob); |
497 | if (NULL == bob_room) | 497 | if (NULL == bob_room) |
498 | { | 498 | { |
499 | GNUNET_SCHEDULER_cancel (kill_task); | 499 | GNUNET_SCHEDULER_cancel (kill_task); |
@@ -507,7 +507,7 @@ join_bob_task (void *cls, | |||
507 | 507 | ||
508 | static void | 508 | static void |
509 | join_alice_task (void *cls, | 509 | join_alice_task (void *cls, |
510 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 510 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
511 | { | 511 | { |
512 | #if VERBOSE | 512 | #if VERBOSE |
513 | printf ("Alice joining\n"); | 513 | printf ("Alice joining\n"); |
@@ -516,12 +516,12 @@ join_alice_task (void *cls, | |||
516 | alice_wanted.next_task_cls = NULL; | 516 | alice_wanted.next_task_cls = NULL; |
517 | alice_room = | 517 | alice_room = |
518 | GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, | 518 | GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, |
519 | "test", -1, | 519 | "test", -1, |
520 | &join_cb, &alice_wanted, | 520 | &join_cb, &alice_wanted, |
521 | &receive_cb, &alice_wanted, | 521 | &receive_cb, &alice_wanted, |
522 | &member_list_cb, &alice_wanted, | 522 | &member_list_cb, &alice_wanted, |
523 | &confirmation_cb, &alice_wanted, | 523 | &confirmation_cb, &alice_wanted, |
524 | &alice); | 524 | &alice); |
525 | if (NULL == alice_room) | 525 | if (NULL == alice_room) |
526 | { | 526 | { |
527 | GNUNET_SCHEDULER_cancel (kill_task); | 527 | GNUNET_SCHEDULER_cancel (kill_task); |
@@ -551,23 +551,23 @@ run (void *cls, | |||
551 | bob_wanted.me = "Bob"; | 551 | bob_wanted.me = "Bob"; |
552 | alice_meta = GNUNET_CONTAINER_meta_data_create (); | 552 | alice_meta = GNUNET_CONTAINER_meta_data_create (); |
553 | GNUNET_CONTAINER_meta_data_insert (alice_meta, | 553 | GNUNET_CONTAINER_meta_data_insert (alice_meta, |
554 | "<gnunet>", | 554 | "<gnunet>", |
555 | EXTRACTOR_METATYPE_TITLE, | 555 | EXTRACTOR_METATYPE_TITLE, |
556 | EXTRACTOR_METAFORMAT_UTF8, | 556 | EXTRACTOR_METAFORMAT_UTF8, |
557 | "text/plain", | 557 | "text/plain", |
558 | "Alice", | 558 | "Alice", |
559 | strlen("Alice")+1); | 559 | strlen("Alice")+1); |
560 | bob_meta = GNUNET_CONTAINER_meta_data_create (); | 560 | bob_meta = GNUNET_CONTAINER_meta_data_create (); |
561 | GNUNET_CONTAINER_meta_data_insert (bob_meta, | 561 | GNUNET_CONTAINER_meta_data_insert (bob_meta, |
562 | "<gnunet>", | 562 | "<gnunet>", |
563 | EXTRACTOR_METATYPE_TITLE, | 563 | EXTRACTOR_METATYPE_TITLE, |
564 | EXTRACTOR_METAFORMAT_UTF8, | 564 | EXTRACTOR_METAFORMAT_UTF8, |
565 | "text/plain", | 565 | "text/plain", |
566 | "Bob", | 566 | "Bob", |
567 | strlen("Bob")+1); | 567 | strlen("Bob")+1); |
568 | kill_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 568 | kill_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, |
569 | &timeout_kill, | 569 | &timeout_kill, |
570 | NULL); | 570 | NULL); |
571 | GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); | 571 | GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); |
572 | } | 572 | } |
573 | 573 | ||
@@ -590,11 +590,11 @@ main (int argc, char *argv[]) | |||
590 | 590 | ||
591 | GNUNET_log_setup ("test_chat", | 591 | GNUNET_log_setup ("test_chat", |
592 | #if VERBOSE | 592 | #if VERBOSE |
593 | "DEBUG", | 593 | "DEBUG", |
594 | #else | 594 | #else |
595 | "WARNING", | 595 | "WARNING", |
596 | #endif | 596 | #endif |
597 | NULL); | 597 | NULL); |
598 | if (strstr(argv[0], "p2p") != NULL) | 598 | if (strstr(argv[0], "p2p") != NULL) |
599 | { | 599 | { |
600 | is_p2p = GNUNET_YES; | 600 | is_p2p = GNUNET_YES; |
@@ -613,7 +613,7 @@ main (int argc, char *argv[]) | |||
613 | } | 613 | } |
614 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 614 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, |
615 | argvx, "test-chat", | 615 | argvx, "test-chat", |
616 | "nohelp", options, &run, NULL); | 616 | "nohelp", options, &run, NULL); |
617 | stop_arm (&p1); | 617 | stop_arm (&p1); |
618 | GNUNET_CONTAINER_meta_data_destroy (alice_meta); | 618 | GNUNET_CONTAINER_meta_data_destroy (alice_meta); |
619 | GNUNET_CONTAINER_meta_data_destroy (bob_meta); | 619 | GNUNET_CONTAINER_meta_data_destroy (bob_meta); |
diff --git a/src/chat/test_chat_private.c b/src/chat/test_chat_private.c index 7649bffe4..c14de0a88 100644 --- a/src/chat/test_chat_private.c +++ b/src/chat/test_chat_private.c | |||
@@ -162,7 +162,7 @@ stop_arm (struct PeerContext *p) | |||
162 | 162 | ||
163 | static void | 163 | static void |
164 | abort_test (void *cls, | 164 | abort_test (void *cls, |
165 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 165 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
166 | { | 166 | { |
167 | if (alice_room != NULL) | 167 | if (alice_room != NULL) |
168 | { | 168 | { |
@@ -185,7 +185,7 @@ abort_test (void *cls, | |||
185 | 185 | ||
186 | static void | 186 | static void |
187 | timeout_kill (void *cls, | 187 | timeout_kill (void *cls, |
188 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 188 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
189 | { | 189 | { |
190 | #if VERBOSE | 190 | #if VERBOSE |
191 | printf ("Timed out, stopping the test.\n"); | 191 | printf ("Timed out, stopping the test.\n"); |
@@ -197,7 +197,7 @@ timeout_kill (void *cls, | |||
197 | wait_task = GNUNET_SCHEDULER_NO_TASK; | 197 | wait_task = GNUNET_SCHEDULER_NO_TASK; |
198 | } | 198 | } |
199 | GNUNET_SCHEDULER_add_continuation (&abort_test, NULL, | 199 | GNUNET_SCHEDULER_add_continuation (&abort_test, NULL, |
200 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 200 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
@@ -217,9 +217,9 @@ join_cb (void *cls) | |||
217 | 217 | ||
218 | static int | 218 | static int |
219 | member_list_cb (void *cls, | 219 | member_list_cb (void *cls, |
220 | const struct GNUNET_CONTAINER_MetaData *member_info, | 220 | const struct GNUNET_CONTAINER_MetaData *member_info, |
221 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, | 221 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, |
222 | enum GNUNET_CHAT_MsgOptions options) | 222 | enum GNUNET_CHAT_MsgOptions options) |
223 | { | 223 | { |
224 | struct Wanted *want = cls; | 224 | struct Wanted *want = cls; |
225 | GNUNET_HashCode sender; | 225 | GNUNET_HashCode sender; |
@@ -229,46 +229,46 @@ member_list_cb (void *cls, | |||
229 | want->me, | 229 | want->me, |
230 | member_info == NULL ? NULL | 230 | member_info == NULL ? NULL |
231 | : GNUNET_CONTAINER_meta_data_get_by_type (member_info, | 231 | : GNUNET_CONTAINER_meta_data_get_by_type (member_info, |
232 | EXTRACTOR_METATYPE_TITLE), | 232 | EXTRACTOR_METATYPE_TITLE), |
233 | member_info == NULL ? "left" : "joined"); | 233 | member_info == NULL ? "left" : "joined"); |
234 | #endif | 234 | #endif |
235 | GNUNET_CRYPTO_hash (member_id, | 235 | GNUNET_CRYPTO_hash (member_id, |
236 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 236 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
237 | &sender); | 237 | &sender); |
238 | /* entertain both primary and an alternative sender/meta */ | 238 | /* entertain both primary and an alternative sender/meta */ |
239 | if (((0 == memcmp (&sender, want->sender, sizeof (GNUNET_HashCode))) || | 239 | if (((0 == memcmp (&sender, want->sender, sizeof (GNUNET_HashCode))) || |
240 | ((want->sender2 != NULL) && | 240 | ((want->sender2 != NULL) && |
241 | (0 == memcmp (&sender, want->sender2, sizeof (GNUNET_HashCode))))) && | 241 | (0 == memcmp (&sender, want->sender2, sizeof (GNUNET_HashCode))))) && |
242 | (((member_info == NULL) && (want->meta == NULL)) || | 242 | (((member_info == NULL) && (want->meta == NULL)) || |
243 | ((member_info != NULL) && | 243 | ((member_info != NULL) && |
244 | (((want->meta != NULL) && | 244 | (((want->meta != NULL) && |
245 | GNUNET_CONTAINER_meta_data_test_equal (member_info, | 245 | GNUNET_CONTAINER_meta_data_test_equal (member_info, |
246 | want->meta)) || | 246 | want->meta)) || |
247 | ((want->meta2 != NULL) && | 247 | ((want->meta2 != NULL) && |
248 | GNUNET_CONTAINER_meta_data_test_equal (member_info, | 248 | GNUNET_CONTAINER_meta_data_test_equal (member_info, |
249 | want->meta2))))) && | 249 | want->meta2))))) && |
250 | (options == want->opt)) | 250 | (options == want->opt)) |
251 | { | 251 | { |
252 | /* remember Bob's public key, we need it to send private message */ | 252 | /* remember Bob's public key, we need it to send private message */ |
253 | if (NULL == bob_public_key && | 253 | if (NULL == bob_public_key && |
254 | (0 == memcmp (&bob, want->sender, sizeof (GNUNET_HashCode)))) | 254 | (0 == memcmp (&bob, want->sender, sizeof (GNUNET_HashCode)))) |
255 | bob_public_key = | 255 | bob_public_key = |
256 | GNUNET_memdup (member_id, | 256 | GNUNET_memdup (member_id, |
257 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); | 257 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)); |
258 | if (want->sender2 != NULL) | 258 | if (want->sender2 != NULL) |
259 | { | 259 | { |
260 | /* flush alternative sender */ | 260 | /* flush alternative sender */ |
261 | if (0 == memcmp (&sender, want->sender, sizeof (GNUNET_HashCode))) | 261 | if (0 == memcmp (&sender, want->sender, sizeof (GNUNET_HashCode))) |
262 | { | 262 | { |
263 | want->sender = want->sender2; | 263 | want->sender = want->sender2; |
264 | want->meta = want->meta2; | 264 | want->meta = want->meta2; |
265 | } | 265 | } |
266 | want->sender2 = NULL; | 266 | want->sender2 = NULL; |
267 | want->meta2 = NULL; | 267 | want->meta2 = NULL; |
268 | } | 268 | } |
269 | else | 269 | else |
270 | if (NULL != want->next_task) | 270 | if (NULL != want->next_task) |
271 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); | 271 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); |
272 | } | 272 | } |
273 | else | 273 | else |
274 | { | 274 | { |
@@ -282,29 +282,29 @@ member_list_cb (void *cls, | |||
282 | 282 | ||
283 | static int | 283 | static int |
284 | receive_cb (void *cls, | 284 | receive_cb (void *cls, |
285 | struct GNUNET_CHAT_Room *room, | 285 | struct GNUNET_CHAT_Room *room, |
286 | const GNUNET_HashCode *sender, | 286 | const GNUNET_HashCode *sender, |
287 | const struct GNUNET_CONTAINER_MetaData *meta, | 287 | const struct GNUNET_CONTAINER_MetaData *meta, |
288 | const char *message, | 288 | const char *message, |
289 | struct GNUNET_TIME_Absolute timestamp, | 289 | struct GNUNET_TIME_Absolute timestamp, |
290 | enum GNUNET_CHAT_MsgOptions options) | 290 | enum GNUNET_CHAT_MsgOptions options) |
291 | { | 291 | { |
292 | struct Wanted *want = cls; | 292 | struct Wanted *want = cls; |
293 | 293 | ||
294 | #if VERBOSE | 294 | #if VERBOSE |
295 | printf ("%s - told that %s said '%s'\n", | 295 | printf ("%s - told that %s said '%s'\n", |
296 | want->me, | 296 | want->me, |
297 | meta == NULL ? NULL | 297 | meta == NULL ? NULL |
298 | : GNUNET_CONTAINER_meta_data_get_by_type (meta, | 298 | : GNUNET_CONTAINER_meta_data_get_by_type (meta, |
299 | EXTRACTOR_METATYPE_TITLE), | 299 | EXTRACTOR_METATYPE_TITLE), |
300 | message); | 300 | message); |
301 | #endif | 301 | #endif |
302 | 302 | ||
303 | if ((want->msg != NULL) && (0 == strcmp (message, want->msg)) && | 303 | if ((want->msg != NULL) && (0 == strcmp (message, want->msg)) && |
304 | (((sender == NULL) && (want->sender == NULL)) || | 304 | (((sender == NULL) && (want->sender == NULL)) || |
305 | ((sender != NULL) && (want->sender != NULL) && | 305 | ((sender != NULL) && (want->sender != NULL) && |
306 | (0 == memcmp (sender, want->sender, | 306 | (0 == memcmp (sender, want->sender, |
307 | sizeof (GNUNET_HashCode))))) && | 307 | sizeof (GNUNET_HashCode))))) && |
308 | (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && | 308 | (GNUNET_CONTAINER_meta_data_test_equal (meta, want->meta)) && |
309 | (options == want->opt) && | 309 | (options == want->opt) && |
310 | /* Not == since the library sets the actual timestamp, so it may be | 310 | /* Not == since the library sets the actual timestamp, so it may be |
@@ -313,7 +313,7 @@ receive_cb (void *cls, | |||
313 | (timestamp.abs_value >= want->timestamp.abs_value)) | 313 | (timestamp.abs_value >= want->timestamp.abs_value)) |
314 | { | 314 | { |
315 | if (NULL != want->next_task) | 315 | if (NULL != want->next_task) |
316 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); | 316 | GNUNET_SCHEDULER_add_now (want->next_task, want->next_task_cls); |
317 | } | 317 | } |
318 | else | 318 | else |
319 | { | 319 | { |
@@ -329,7 +329,7 @@ receive_cb (void *cls, | |||
329 | 329 | ||
330 | static void | 330 | static void |
331 | wait_until_all_ready (void *cls, | 331 | wait_until_all_ready (void *cls, |
332 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 332 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
333 | { | 333 | { |
334 | GNUNET_SCHEDULER_Task task = cls; | 334 | GNUNET_SCHEDULER_Task task = cls; |
335 | 335 | ||
@@ -344,15 +344,15 @@ wait_until_all_ready (void *cls, | |||
344 | else | 344 | else |
345 | wait_task = | 345 | wait_task = |
346 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 346 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, |
347 | 5000), | 347 | 5000), |
348 | &wait_until_all_ready, | 348 | &wait_until_all_ready, |
349 | task); | 349 | task); |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | static void | 353 | static void |
354 | set_alice_ready (void *cls, | 354 | set_alice_ready (void *cls, |
355 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 355 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
356 | { | 356 | { |
357 | alice_ready = GNUNET_YES; | 357 | alice_ready = GNUNET_YES; |
358 | } | 358 | } |
@@ -360,7 +360,7 @@ set_alice_ready (void *cls, | |||
360 | 360 | ||
361 | static void | 361 | static void |
362 | set_bob_ready (void *cls, | 362 | set_bob_ready (void *cls, |
363 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 363 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
364 | { | 364 | { |
365 | bob_ready = GNUNET_YES; | 365 | bob_ready = GNUNET_YES; |
366 | } | 366 | } |
@@ -368,7 +368,7 @@ set_bob_ready (void *cls, | |||
368 | 368 | ||
369 | static void | 369 | static void |
370 | disconnect_alice (void *cls, | 370 | disconnect_alice (void *cls, |
371 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 371 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
372 | { | 372 | { |
373 | #if VERBOSE | 373 | #if VERBOSE |
374 | printf ("Alice is leaving.\n"); | 374 | printf ("Alice is leaving.\n"); |
@@ -384,7 +384,7 @@ disconnect_alice (void *cls, | |||
384 | 384 | ||
385 | static void | 385 | static void |
386 | disconnect_bob (void *cls, | 386 | disconnect_bob (void *cls, |
387 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 387 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
388 | { | 388 | { |
389 | #if VERBOSE | 389 | #if VERBOSE |
390 | printf ("Bod is leaving.\n"); | 390 | printf ("Bod is leaving.\n"); |
@@ -404,7 +404,7 @@ disconnect_bob (void *cls, | |||
404 | 404 | ||
405 | static void | 405 | static void |
406 | disconnect_carol (void *cls, | 406 | disconnect_carol (void *cls, |
407 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 407 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
408 | { | 408 | { |
409 | #if VERBOSE | 409 | #if VERBOSE |
410 | printf ("Carol is leaving.\n"); | 410 | printf ("Carol is leaving.\n"); |
@@ -430,7 +430,7 @@ disconnect_carol (void *cls, | |||
430 | 430 | ||
431 | static void | 431 | static void |
432 | send_from_alice_to_bob (void *cls, | 432 | send_from_alice_to_bob (void *cls, |
433 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 433 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
434 | { | 434 | { |
435 | uint32_t seq; | 435 | uint32_t seq; |
436 | 436 | ||
@@ -453,18 +453,18 @@ send_from_alice_to_bob (void *cls, | |||
453 | carol_wanted.next_task = NULL; | 453 | carol_wanted.next_task = NULL; |
454 | carol_wanted.next_task_cls = NULL; | 454 | carol_wanted.next_task_cls = NULL; |
455 | GNUNET_CHAT_send_message (alice_room, | 455 | GNUNET_CHAT_send_message (alice_room, |
456 | "Hi Bob!", | 456 | "Hi Bob!", |
457 | GNUNET_CHAT_MSG_PRIVATE, | 457 | GNUNET_CHAT_MSG_PRIVATE, |
458 | bob_public_key, &seq); | 458 | bob_public_key, &seq); |
459 | finish_task = GNUNET_SCHEDULER_add_delayed (PM_TIMEOUT, | 459 | finish_task = GNUNET_SCHEDULER_add_delayed (PM_TIMEOUT, |
460 | &wait_until_all_ready, | 460 | &wait_until_all_ready, |
461 | &disconnect_carol); | 461 | &disconnect_carol); |
462 | } | 462 | } |
463 | 463 | ||
464 | 464 | ||
465 | static void | 465 | static void |
466 | prepare_bob_for_alice_task (void *cls, | 466 | prepare_bob_for_alice_task (void *cls, |
467 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 467 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
468 | { | 468 | { |
469 | bob_wanted.meta = alice_meta; | 469 | bob_wanted.meta = alice_meta; |
470 | bob_wanted.sender = &alice; | 470 | bob_wanted.sender = &alice; |
@@ -477,7 +477,7 @@ prepare_bob_for_alice_task (void *cls, | |||
477 | 477 | ||
478 | static void | 478 | static void |
479 | prepare_carol_for_alice_and_bob_task (void *cls, | 479 | prepare_carol_for_alice_and_bob_task (void *cls, |
480 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 480 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
481 | { | 481 | { |
482 | carol_wanted.meta = alice_meta; | 482 | carol_wanted.meta = alice_meta; |
483 | carol_wanted.sender = &alice; | 483 | carol_wanted.sender = &alice; |
@@ -494,7 +494,7 @@ prepare_carol_for_alice_and_bob_task (void *cls, | |||
494 | 494 | ||
495 | static void | 495 | static void |
496 | join_carol_task (void *cls, | 496 | join_carol_task (void *cls, |
497 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 497 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
498 | { | 498 | { |
499 | #if VERBOSE | 499 | #if VERBOSE |
500 | printf ("Carol joining\n"); | 500 | printf ("Carol joining\n"); |
@@ -517,11 +517,11 @@ join_carol_task (void *cls, | |||
517 | carol_wanted.next_task_cls = NULL; | 517 | carol_wanted.next_task_cls = NULL; |
518 | carol_room = | 518 | carol_room = |
519 | GNUNET_CHAT_join_room (is_p2p ? p3.cfg : p1.cfg, "carol", carol_meta, | 519 | GNUNET_CHAT_join_room (is_p2p ? p3.cfg : p1.cfg, "carol", carol_meta, |
520 | "test", -1, | 520 | "test", -1, |
521 | &join_cb, &carol_wanted, | 521 | &join_cb, &carol_wanted, |
522 | &receive_cb, &carol_wanted, | 522 | &receive_cb, &carol_wanted, |
523 | &member_list_cb, &carol_wanted, | 523 | &member_list_cb, &carol_wanted, |
524 | NULL, NULL, &carol); | 524 | NULL, NULL, &carol); |
525 | if (NULL == carol_room) | 525 | if (NULL == carol_room) |
526 | { | 526 | { |
527 | GNUNET_SCHEDULER_cancel (kill_task); | 527 | GNUNET_SCHEDULER_cancel (kill_task); |
@@ -537,7 +537,7 @@ join_carol_task (void *cls, | |||
537 | 537 | ||
538 | static void | 538 | static void |
539 | join_bob_task (void *cls, | 539 | join_bob_task (void *cls, |
540 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 540 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
541 | { | 541 | { |
542 | #if VERBOSE | 542 | #if VERBOSE |
543 | printf ("Bob joining\n"); | 543 | printf ("Bob joining\n"); |
@@ -554,11 +554,11 @@ join_bob_task (void *cls, | |||
554 | bob_ready = GNUNET_NO; | 554 | bob_ready = GNUNET_NO; |
555 | bob_room = | 555 | bob_room = |
556 | GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, | 556 | GNUNET_CHAT_join_room (is_p2p ? p2.cfg : p1.cfg, "bob", bob_meta, |
557 | "test", -1, | 557 | "test", -1, |
558 | &join_cb, &bob_wanted, | 558 | &join_cb, &bob_wanted, |
559 | &receive_cb, &bob_wanted, | 559 | &receive_cb, &bob_wanted, |
560 | &member_list_cb, &bob_wanted, | 560 | &member_list_cb, &bob_wanted, |
561 | NULL, NULL, &bob); | 561 | NULL, NULL, &bob); |
562 | if (NULL == bob_room) | 562 | if (NULL == bob_room) |
563 | { | 563 | { |
564 | GNUNET_SCHEDULER_cancel (kill_task); | 564 | GNUNET_SCHEDULER_cancel (kill_task); |
@@ -572,7 +572,7 @@ join_bob_task (void *cls, | |||
572 | 572 | ||
573 | static void | 573 | static void |
574 | join_alice_task (void *cls, | 574 | join_alice_task (void *cls, |
575 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 575 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
576 | { | 576 | { |
577 | #if VERBOSE | 577 | #if VERBOSE |
578 | printf ("Alice joining\n"); | 578 | printf ("Alice joining\n"); |
@@ -581,11 +581,11 @@ join_alice_task (void *cls, | |||
581 | alice_wanted.next_task_cls = NULL; | 581 | alice_wanted.next_task_cls = NULL; |
582 | alice_room = | 582 | alice_room = |
583 | GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, | 583 | GNUNET_CHAT_join_room (p1.cfg, "alice", alice_meta, |
584 | "test", -1, | 584 | "test", -1, |
585 | &join_cb, &alice_wanted, | 585 | &join_cb, &alice_wanted, |
586 | &receive_cb, &alice_wanted, | 586 | &receive_cb, &alice_wanted, |
587 | &member_list_cb, &alice_wanted, | 587 | &member_list_cb, &alice_wanted, |
588 | NULL, NULL, &alice); | 588 | NULL, NULL, &alice); |
589 | if (NULL == alice_room) | 589 | if (NULL == alice_room) |
590 | { | 590 | { |
591 | GNUNET_SCHEDULER_cancel (kill_task); | 591 | GNUNET_SCHEDULER_cancel (kill_task); |
@@ -618,28 +618,28 @@ run (void *cls, | |||
618 | carol_wanted.me = "Carol"; | 618 | carol_wanted.me = "Carol"; |
619 | alice_meta = GNUNET_CONTAINER_meta_data_create (); | 619 | alice_meta = GNUNET_CONTAINER_meta_data_create (); |
620 | GNUNET_CONTAINER_meta_data_insert (alice_meta, | 620 | GNUNET_CONTAINER_meta_data_insert (alice_meta, |
621 | "<gnunet>", | 621 | "<gnunet>", |
622 | EXTRACTOR_METATYPE_TITLE, | 622 | EXTRACTOR_METATYPE_TITLE, |
623 | EXTRACTOR_METAFORMAT_UTF8, | 623 | EXTRACTOR_METAFORMAT_UTF8, |
624 | "text/plain", | 624 | "text/plain", |
625 | "Alice", | 625 | "Alice", |
626 | strlen("Alice")+1); | 626 | strlen("Alice")+1); |
627 | bob_meta = GNUNET_CONTAINER_meta_data_create (); | 627 | bob_meta = GNUNET_CONTAINER_meta_data_create (); |
628 | GNUNET_CONTAINER_meta_data_insert (bob_meta, | 628 | GNUNET_CONTAINER_meta_data_insert (bob_meta, |
629 | "<gnunet>", | 629 | "<gnunet>", |
630 | EXTRACTOR_METATYPE_TITLE, | 630 | EXTRACTOR_METATYPE_TITLE, |
631 | EXTRACTOR_METAFORMAT_UTF8, | 631 | EXTRACTOR_METAFORMAT_UTF8, |
632 | "text/plain", | 632 | "text/plain", |
633 | "Bob", | 633 | "Bob", |
634 | strlen("Bob")+1); | 634 | strlen("Bob")+1); |
635 | carol_meta = GNUNET_CONTAINER_meta_data_create (); | 635 | carol_meta = GNUNET_CONTAINER_meta_data_create (); |
636 | GNUNET_CONTAINER_meta_data_insert (carol_meta, | 636 | GNUNET_CONTAINER_meta_data_insert (carol_meta, |
637 | "<gnunet>", | 637 | "<gnunet>", |
638 | EXTRACTOR_METATYPE_TITLE, | 638 | EXTRACTOR_METATYPE_TITLE, |
639 | EXTRACTOR_METAFORMAT_UTF8, | 639 | EXTRACTOR_METAFORMAT_UTF8, |
640 | "text/plain", | 640 | "text/plain", |
641 | "Carol", | 641 | "Carol", |
642 | strlen("Carol")+1); | 642 | strlen("Carol")+1); |
643 | kill_task = GNUNET_SCHEDULER_add_delayed (KILL_TIMEOUT, &timeout_kill, NULL); | 643 | kill_task = GNUNET_SCHEDULER_add_delayed (KILL_TIMEOUT, &timeout_kill, NULL); |
644 | GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); | 644 | GNUNET_SCHEDULER_add_now (&join_alice_task, NULL); |
645 | } | 645 | } |
@@ -663,18 +663,18 @@ main (int argc, char *argv[]) | |||
663 | 663 | ||
664 | GNUNET_log_setup ("test_chat", | 664 | GNUNET_log_setup ("test_chat", |
665 | #if VERBOSE | 665 | #if VERBOSE |
666 | "DEBUG", | 666 | "DEBUG", |
667 | #else | 667 | #else |
668 | "WARNING", | 668 | "WARNING", |
669 | #endif | 669 | #endif |
670 | NULL); | 670 | NULL); |
671 | if (strstr(argv[0], "p2p") != NULL) | 671 | if (strstr(argv[0], "p2p") != NULL) |
672 | { | 672 | { |
673 | is_p2p = GNUNET_YES; | 673 | is_p2p = GNUNET_YES; |
674 | } | 674 | } |
675 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 675 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, |
676 | argvx, "test-chat", | 676 | argvx, "test-chat", |
677 | "nohelp", options, &run, NULL); | 677 | "nohelp", options, &run, NULL); |
678 | stop_arm (&p1); | 678 | stop_arm (&p1); |
679 | GNUNET_CONTAINER_meta_data_destroy (alice_meta); | 679 | GNUNET_CONTAINER_meta_data_destroy (alice_meta); |
680 | GNUNET_CONTAINER_meta_data_destroy (bob_meta); | 680 | GNUNET_CONTAINER_meta_data_destroy (bob_meta); |
diff --git a/src/include/gnunet_chat_service.h b/src/include/gnunet_chat_service.h index 732d625f2..0a45cf533 100644 --- a/src/include/gnunet_chat_service.h +++ b/src/include/gnunet_chat_service.h | |||
@@ -110,12 +110,12 @@ typedef int (*GNUNET_CHAT_JoinCallback) (void *cls); | |||
110 | * accept (but user is away), GNUNET_SYSERR to signal denied delivery | 110 | * accept (but user is away), GNUNET_SYSERR to signal denied delivery |
111 | */ | 111 | */ |
112 | typedef int (*GNUNET_CHAT_MessageCallback) (void *cls, | 112 | typedef int (*GNUNET_CHAT_MessageCallback) (void *cls, |
113 | struct GNUNET_CHAT_Room *room, | 113 | struct GNUNET_CHAT_Room *room, |
114 | const GNUNET_HashCode *sender, | 114 | const GNUNET_HashCode *sender, |
115 | const struct GNUNET_CONTAINER_MetaData *member_info, | 115 | const struct GNUNET_CONTAINER_MetaData *member_info, |
116 | const char *message, | 116 | const char *message, |
117 | struct GNUNET_TIME_Absolute timestamp, | 117 | struct GNUNET_TIME_Absolute timestamp, |
118 | enum GNUNET_CHAT_MsgOptions options); | 118 | enum GNUNET_CHAT_MsgOptions options); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | * Callback used for notification that another room member has joined or left. | 121 | * Callback used for notification that another room member has joined or left. |
@@ -128,9 +128,9 @@ typedef int (*GNUNET_CHAT_MessageCallback) (void *cls, | |||
128 | * @return GNUNET_OK | 128 | * @return GNUNET_OK |
129 | */ | 129 | */ |
130 | typedef int (*GNUNET_CHAT_MemberListCallback) (void *cls, | 130 | typedef int (*GNUNET_CHAT_MemberListCallback) (void *cls, |
131 | const struct GNUNET_CONTAINER_MetaData *member_info, | 131 | const struct GNUNET_CONTAINER_MetaData *member_info, |
132 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, | 132 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *member_id, |
133 | enum GNUNET_CHAT_MsgOptions options); | 133 | enum GNUNET_CHAT_MsgOptions options); |
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Callback used for message delivery confirmations. | 136 | * Callback used for message delivery confirmations. |
@@ -144,10 +144,10 @@ typedef int (*GNUNET_CHAT_MemberListCallback) (void *cls, | |||
144 | * confirmations from anyone for this message | 144 | * confirmations from anyone for this message |
145 | */ | 145 | */ |
146 | typedef int (*GNUNET_CHAT_MessageConfirmation) (void *cls, | 146 | typedef int (*GNUNET_CHAT_MessageConfirmation) (void *cls, |
147 | struct GNUNET_CHAT_Room *room, | 147 | struct GNUNET_CHAT_Room *room, |
148 | uint32_t orig_seq_number, | 148 | uint32_t orig_seq_number, |
149 | struct GNUNET_TIME_Absolute timestamp, | 149 | struct GNUNET_TIME_Absolute timestamp, |
150 | const GNUNET_HashCode *receiver); | 150 | const GNUNET_HashCode *receiver); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * Join a chat room. | 153 | * Join a chat room. |
@@ -175,19 +175,19 @@ typedef int (*GNUNET_CHAT_MessageConfirmation) (void *cls, | |||
175 | */ | 175 | */ |
176 | struct GNUNET_CHAT_Room * | 176 | struct GNUNET_CHAT_Room * |
177 | GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, | 177 | GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, |
178 | const char *nick_name, | 178 | const char *nick_name, |
179 | struct GNUNET_CONTAINER_MetaData *member_info, | 179 | struct GNUNET_CONTAINER_MetaData *member_info, |
180 | const char *room_name, | 180 | const char *room_name, |
181 | enum GNUNET_CHAT_MsgOptions msg_options, | 181 | enum GNUNET_CHAT_MsgOptions msg_options, |
182 | GNUNET_CHAT_JoinCallback joinCallback, | 182 | GNUNET_CHAT_JoinCallback joinCallback, |
183 | void *join_cls, | 183 | void *join_cls, |
184 | GNUNET_CHAT_MessageCallback messageCallback, | 184 | GNUNET_CHAT_MessageCallback messageCallback, |
185 | void *message_cls, | 185 | void *message_cls, |
186 | GNUNET_CHAT_MemberListCallback memberCallback, | 186 | GNUNET_CHAT_MemberListCallback memberCallback, |
187 | void *member_cls, | 187 | void *member_cls, |
188 | GNUNET_CHAT_MessageConfirmation confirmationCallback, | 188 | GNUNET_CHAT_MessageConfirmation confirmationCallback, |
189 | void *confirmation_cls, | 189 | void *confirmation_cls, |
190 | GNUNET_HashCode *me); | 190 | GNUNET_HashCode *me); |
191 | 191 | ||
192 | /** | 192 | /** |
193 | * Send a message. | 193 | * Send a message. |
@@ -200,10 +200,10 @@ GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
200 | */ | 200 | */ |
201 | void | 201 | void |
202 | GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, | 202 | GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room, |
203 | const char *message, | 203 | const char *message, |
204 | enum GNUNET_CHAT_MsgOptions options, | 204 | enum GNUNET_CHAT_MsgOptions options, |
205 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver, | 205 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver, |
206 | uint32_t *sequence_number); | 206 | uint32_t *sequence_number); |
207 | 207 | ||
208 | 208 | ||
209 | /** | 209 | /** |