diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-03-04 08:10:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-03-04 08:10:00 +0000 |
commit | fb199b4553100aa977d4d2f4a108bb0a27a705d2 (patch) | |
tree | 03f6fbb293c879d3015a599ce6da2419d55da92b /src/chat/gnunet-service-chat.c | |
parent | e3445ef22cc8478bb6cdca2b35f20f7f3325c697 (diff) | |
download | gnunet-fb199b4553100aa977d4d2f4a108bb0a27a705d2.tar.gz gnunet-fb199b4553100aa977d4d2f4a108bb0a27a705d2.zip |
chat indent -- Mantis 1665
Diffstat (limited to 'src/chat/gnunet-service-chat.c')
-rw-r--r-- | src/chat/gnunet-service-chat.c | 820 |
1 files changed, 410 insertions, 410 deletions
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 */ |