2 This file is part of GNUnet.
3 (C) 2008, 2011 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
23 * @brief convenience API for sending and receiving chat messages
24 * @author Christian Grothoff
25 * @author Nathan Evans
26 * @author Vitaly Minko
30 #include "gnunet_constants.h"
31 #include "gnunet_protocols.h"
32 #include "gnunet_signatures.h"
35 #define DEBUG_CHAT GNUNET_NO
36 #define NICK_IDENTITY_PREFIX ".chat_identity_"
40 * Handle for a chat room.
42 struct GNUNET_CHAT_Room
44 struct GNUNET_CLIENT_Connection *client;
46 const struct GNUNET_CONFIGURATION_Handle *cfg;
48 struct GNUNET_CONTAINER_MetaData *member_info;
52 struct GNUNET_CRYPTO_RsaPrivateKey *my_private_key;
54 struct MemberList *members;
58 GNUNET_CHAT_JoinCallback join_callback;
60 void *join_callback_cls;
62 GNUNET_CHAT_MessageCallback message_callback;
64 void *message_callback_cls;
66 GNUNET_CHAT_MemberListCallback member_list_callback;
68 void *member_list_callback_cls;
70 GNUNET_CHAT_MessageConfirmation confirmation_callback;
72 void *confirmation_cls;
74 uint32_t sequence_number;
81 * Linked list of members in the chat room.
85 struct MemberList *next;
88 * Description of the member.
90 struct GNUNET_CONTAINER_MetaData *meta;
93 * Member ID (pseudonym).
100 * Context for transmitting a send-message request.
102 struct GNUNET_CHAT_SendMessageContext
105 * Handle for the chat room.
107 struct GNUNET_CHAT_Room *chat_room;
110 * Message that we're sending.
115 * Options for the message.
117 enum GNUNET_CHAT_MsgOptions options;
120 * Receiver of the message. NULL to send to everyone in the room.
122 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver;
125 * Sequence id of the message.
127 uint32_t sequence_number;
132 * Context for transmitting a confirmation receipt.
134 struct GNUNET_CHAT_SendReceiptContext
137 * Handle for the chat room.
139 struct GNUNET_CHAT_Room *chat_room;
142 * The original message that we're going to acknowledge.
144 struct ReceiveNotificationMessage *received_msg;
149 * Ask client to send a join request.
152 rejoin_room (struct GNUNET_CHAT_Room *chat_room);
156 * Transmit a confirmation receipt to the chat service.
158 * @param cls closure, pointer to the 'struct GNUNET_CHAT_SendReceiptContext'
159 * @param size number of bytes available in buf
160 * @param buf where the callee should write the message
161 * @return number of bytes written to buf
164 transmit_acknowledge_request (void *cls,
168 struct GNUNET_CHAT_SendReceiptContext *src = cls;
169 struct ConfirmationReceiptMessage *receipt;
170 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub_key;
176 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
177 _("Could not transmit confirmation receipt\n"));
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
182 "Transmitting confirmation receipt to the service\n");
184 msg_size = sizeof (struct ConfirmationReceiptMessage);
185 GNUNET_assert (size >= msg_size);
187 receipt->header.size = htons (msg_size);
188 receipt->header.type =
189 htons (GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_RECEIPT);
190 receipt->sequence_number = src->received_msg->sequence_number;
191 receipt->reserved2 = 0;
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);
194 GNUNET_CRYPTO_hash (&pub_key,
195 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
197 receipt->author = src->received_msg->sender;
198 receipt->purpose.purpose =
199 htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_RECEIPT);
200 receipt->purpose.size =
202 sizeof (struct GNUNET_MessageHeader) -
204 sizeof (struct GNUNET_CRYPTO_RsaSignature));
205 msg_len = ntohs (src->received_msg->header.size) -
206 sizeof (struct ReceiveNotificationMessage);
207 GNUNET_CRYPTO_hash (&src->received_msg[1], msg_len, &receipt->content);
208 GNUNET_assert (GNUNET_OK ==
209 GNUNET_CRYPTO_rsa_sign (src->chat_room->my_private_key,
211 &receipt->signature));
212 GNUNET_free (src->received_msg);
219 * Handles messages received from the service. Calls the proper client
223 process_result (struct GNUNET_CHAT_Room *room,
224 const struct GNUNET_MessageHeader *reply)
226 struct LeaveNotificationMessage *leave_msg;
227 struct JoinNotificationMessage *join_msg;
228 struct ReceiveNotificationMessage *received_msg;
229 struct ConfirmationReceiptMessage *receipt;
230 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pkey;
232 const GNUNET_HashCode *sender;
233 struct GNUNET_CONTAINER_MetaData *meta;
234 struct GNUNET_CHAT_SendReceiptContext *src;
235 struct MemberList *pos;
236 struct MemberList *prev;
237 struct GNUNET_CRYPTO_AesSessionKey key;
238 char decrypted_msg[MAX_MESSAGE_LENGTH];
242 char *message_content;
244 size = ntohs (reply->size);
245 switch (ntohs (reply->type))
247 case GNUNET_MESSAGE_TYPE_CHAT_JOIN_NOTIFICATION:
249 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a join notification\n");
251 if (size < sizeof (struct JoinNotificationMessage))
256 join_msg = (struct JoinNotificationMessage *) reply;
257 meta_len = size - sizeof (struct JoinNotificationMessage);
259 GNUNET_CONTAINER_meta_data_deserialize ((const char *) &join_msg[1],
266 pos = GNUNET_malloc (sizeof (struct MemberList));
268 GNUNET_CRYPTO_hash (&join_msg->public_key,
269 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
271 GNUNET_PSEUDONYM_add (room->cfg, &pos->id, meta);
272 pos->next = room->members;
274 if (GNUNET_NO == room->is_joined)
276 GNUNET_CRYPTO_rsa_key_get_public (room->my_private_key, &pkey);
277 if (0 == memcmp (&join_msg->public_key,
279 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded)))
281 room->join_callback (room->join_callback_cls);
282 room->is_joined = GNUNET_YES;
286 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
287 _("The current user must be the the first one joined\n"));
293 room->member_list_callback (room->member_list_callback_cls,
294 meta, &join_msg->public_key,
295 ntohl (join_msg->msg_options));
297 case GNUNET_MESSAGE_TYPE_CHAT_LEAVE_NOTIFICATION:
299 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a leave notification\n");
301 if (size < sizeof (struct LeaveNotificationMessage))
306 leave_msg = (struct LeaveNotificationMessage *) reply;
307 room->member_list_callback (room->member_list_callback_cls,
308 NULL, &leave_msg->user,
309 GNUNET_CHAT_MSG_OPTION_NONE);
310 GNUNET_CRYPTO_hash (&leave_msg->user,
311 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
315 while ((NULL != pos) &&
316 (0 != memcmp (&pos->id, &id, sizeof (GNUNET_HashCode))))
321 GNUNET_assert (NULL != pos);
323 room->members = pos->next;
325 prev->next = pos->next;
326 GNUNET_CONTAINER_meta_data_destroy (pos->meta);
329 case GNUNET_MESSAGE_TYPE_CHAT_MESSAGE_NOTIFICATION:
331 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a message notification\n");
333 if (size <= sizeof (struct ReceiveNotificationMessage))
338 received_msg = (struct ReceiveNotificationMessage *) reply;
340 (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ACKNOWLEDGED))
342 src = GNUNET_malloc (sizeof (struct GNUNET_CHAT_SendReceiptContext));
343 src->chat_room = room;
344 src->received_msg = GNUNET_memdup (received_msg, size);
345 GNUNET_CLIENT_notify_transmit_ready (room->client,
346 sizeof (struct ConfirmationReceiptMessage),
347 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
349 &transmit_acknowledge_request,
352 msg_len = size - sizeof (struct ReceiveNotificationMessage);
354 (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_PRIVATE))
356 if (-1 == GNUNET_CRYPTO_rsa_decrypt (room->my_private_key,
357 &received_msg->encrypted_key,
359 sizeof (struct GNUNET_CRYPTO_AesSessionKey)))
364 msg_len = GNUNET_CRYPTO_aes_decrypt (&received_msg[1],
367 (const struct GNUNET_CRYPTO_AesInitializationVector *) INITVALUE,
369 message_content = decrypted_msg;
373 message_content = GNUNET_malloc (msg_len + 1);
374 memcpy (message_content, &received_msg[1], msg_len);
376 message_content[msg_len] = '\0';
377 if (0 != (ntohl (received_msg->msg_options) & GNUNET_CHAT_MSG_ANONYMOUS))
385 while ((NULL != pos) &&
386 (0 != memcmp (&pos->id,
387 &received_msg->sender,
388 sizeof (GNUNET_HashCode))))
390 GNUNET_assert (NULL != pos);
391 sender = &received_msg->sender;
394 room->message_callback (room->message_callback_cls,
399 GNUNET_TIME_absolute_ntoh (received_msg->timestamp),
400 ntohl (received_msg->msg_options));
401 if (message_content != decrypted_msg)
402 GNUNET_free (message_content);
404 case GNUNET_MESSAGE_TYPE_CHAT_CONFIRMATION_NOTIFICATION:
406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a confirmation receipt\n");
408 if (size < sizeof (struct ConfirmationReceiptMessage))
413 receipt = (struct ConfirmationReceiptMessage *) reply;
414 if (NULL != room->confirmation_callback)
415 room->confirmation_callback (room->confirmation_cls,
417 ntohl (receipt->sequence_number),
418 GNUNET_TIME_absolute_ntoh (receipt->timestamp),
422 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
423 _("Unknown message type: '%u'\n"), ntohs (reply->type));
431 * Listen for incoming messages on this chat room. Also, support servers going
432 * away/coming back (i.e. rejoin chat room to keep server state up to date).
434 * @param cls closure, pointer to the 'struct GNUNET_CHAT_Room'
435 * @param msg message received, NULL on timeout or fatal error
438 receive_results (void *cls,
439 const struct GNUNET_MessageHeader *msg)
441 struct GNUNET_CHAT_Room *chat_room = cls;
444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got a message from the service\n");
446 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason ()))
451 rejoin_room (chat_room);
454 process_result (chat_room, msg);
455 if (NULL == chat_room->client)
456 return; /* fatal error */
457 /* continue receiving */
458 GNUNET_CLIENT_receive (chat_room->client,
461 GNUNET_TIME_UNIT_FOREVER_REL);
466 * Read existing private key from file or create a new one if it does not exist
468 * Returns the private key on success, NULL on error.
470 static struct GNUNET_CRYPTO_RsaPrivateKey *
471 init_private_key (const struct GNUNET_CONFIGURATION_Handle *cfg,
472 const char *nick_name)
476 struct GNUNET_CRYPTO_RsaPrivateKey *privKey;
479 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing private key\n");
482 GNUNET_CONFIGURATION_get_value_filename (cfg,
487 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
488 _("Configuration option `%s' in section `%s' missing\n"),
493 GNUNET_DISK_directory_create (home);
494 if (GNUNET_OK != GNUNET_DISK_directory_test (home))
496 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
497 _("Failed to access chat home directory `%s'\n"),
502 /* read or create private key */
504 GNUNET_malloc (strlen (home) + strlen (NICK_IDENTITY_PREFIX) +
505 strlen (nick_name) + 2);
506 strcpy (keyfile, home);
508 if (keyfile[strlen (keyfile) - 1] != DIR_SEPARATOR)
509 strcat (keyfile, DIR_SEPARATOR_STR);
510 strcat (keyfile, NICK_IDENTITY_PREFIX);
511 strcat (keyfile, nick_name);
512 privKey = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
515 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
516 _("Failed to create/open key in file `%s'\n"),
519 GNUNET_free (keyfile);
525 * Transmit a join request to the chat service.
527 * @param cls closure, pointer to the 'struct GNUNET_CHAT_Room'
528 * @param size number of bytes available in buf
529 * @param buf where the callee should write the message
530 * @return number of bytes written to buf
533 transmit_join_request (void *cls,
537 struct GNUNET_CHAT_Room *chat_room = cls;
538 struct JoinRequestMessage *join_msg;
548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
549 "Could not transmit join request, retrying...\n");
551 rejoin_room (chat_room);
555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
556 "Transmitting join request to the service\n");
558 room_len = strlen (chat_room->room_name);
559 meta_len = GNUNET_CONTAINER_meta_data_get_serialized_size (chat_room->member_info);
560 size_of_join = sizeof (struct JoinRequestMessage) + meta_len + room_len;
561 GNUNET_assert (size >= size_of_join);
563 join_msg->header.size = htons (size);
564 join_msg->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_JOIN_REQUEST);
565 join_msg->msg_options = htonl (chat_room->msg_options);
566 join_msg->room_name_len = htons (room_len);
567 join_msg->reserved = htons (0);
568 GNUNET_CRYPTO_rsa_key_get_public (chat_room->my_private_key, &join_msg->public_key);
569 room = (char *) &join_msg[1];
570 memcpy (room, chat_room->room_name, room_len);
571 meta = &room[room_len];
573 GNUNET_CONTAINER_meta_data_serialize (chat_room->member_info,
576 GNUNET_CONTAINER_META_DATA_SERIALIZE_FULL))
578 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
579 _("Could not serialize metadata\n"));
582 GNUNET_CLIENT_receive (chat_room->client,
585 GNUNET_TIME_UNIT_FOREVER_REL);
591 * Ask to send a join request.
594 rejoin_room (struct GNUNET_CHAT_Room *chat_room)
598 size_of_join = sizeof (struct JoinRequestMessage) +
599 GNUNET_CONTAINER_meta_data_get_serialized_size (chat_room->member_info) +
600 strlen (chat_room->room_name);
602 GNUNET_CLIENT_notify_transmit_ready (chat_room->client,
604 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
606 &transmit_join_request,
608 return GNUNET_SYSERR;
617 GNUNET_CHAT_leave_room (struct GNUNET_CHAT_Room *chat_room)
619 struct MemberList *pos;
622 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
623 "Leaving the room '%s'\n", chat_room->room_name);
625 GNUNET_CLIENT_disconnect (chat_room->client, GNUNET_NO);
626 GNUNET_free (chat_room->room_name);
627 GNUNET_CONTAINER_meta_data_destroy (chat_room->member_info);
628 GNUNET_CRYPTO_rsa_key_free (chat_room->my_private_key);
629 while (NULL != chat_room->members)
631 pos = chat_room->members;
632 chat_room->members = pos->next;
633 GNUNET_CONTAINER_meta_data_destroy (pos->meta);
636 GNUNET_free (chat_room);
643 * @param cfg configuration
644 * @param nick_name nickname of the user joining (used to
645 * determine which public key to use);
646 * the nickname should probably also
647 * be used in the member_info (as "EXTRACTOR_TITLE")
648 * @param member_info information about the joining member
649 * @param room_name name of the room
650 * @param msg_options message options of the joining user
651 * @param joinCallback function to call on successful join
652 * @param join_cls closure for joinCallback
653 * @param messageCallback which function to call if a message has
655 * @param message_cls argument to callback
656 * @param memberCallback which function to call for join/leave notifications
657 * @param member_cls argument to callback
658 * @param confirmationCallback which function to call for confirmations (maybe NULL)
659 * @param confirmation_cls argument to callback
660 * @param me member ID (pseudonym)
661 * @return NULL on error
663 struct GNUNET_CHAT_Room *
664 GNUNET_CHAT_join_room (const struct GNUNET_CONFIGURATION_Handle *cfg,
665 const char *nick_name,
666 struct GNUNET_CONTAINER_MetaData *member_info,
667 const char *room_name,
668 enum GNUNET_CHAT_MsgOptions msg_options,
669 GNUNET_CHAT_JoinCallback joinCallback,
671 GNUNET_CHAT_MessageCallback messageCallback,
673 GNUNET_CHAT_MemberListCallback memberCallback,
675 GNUNET_CHAT_MessageConfirmation confirmationCallback,
676 void *confirmation_cls,
679 struct GNUNET_CHAT_Room *chat_room;
680 struct GNUNET_CRYPTO_RsaPrivateKey *priv_key;
681 struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded pub_key;
682 struct GNUNET_CLIENT_Connection *client;
685 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Joining the room '%s'\n", room_name);
687 priv_key = init_private_key (cfg, nick_name);
688 if (NULL == priv_key)
690 GNUNET_CRYPTO_rsa_key_get_public (priv_key, &pub_key);
691 GNUNET_CRYPTO_hash (&pub_key,
692 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
694 GNUNET_PSEUDONYM_add (cfg, me, member_info);
695 client = GNUNET_CLIENT_connect ("chat", cfg);
698 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
699 _("Failed to connect to the chat service\n"));
702 if (NULL == joinCallback)
704 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
705 _("Undefined mandatory parameter: joinCallback\n"));
708 if (NULL == messageCallback)
710 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
711 _("Undefined mandatory parameter: messageCallback\n"));
714 if (NULL == memberCallback)
716 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
717 _("Undefined mandatory parameter: memberCallback\n"));
720 chat_room = GNUNET_malloc (sizeof (struct GNUNET_CHAT_Room));
721 chat_room->msg_options = msg_options;
722 chat_room->room_name = GNUNET_strdup (room_name);
723 chat_room->member_info = GNUNET_CONTAINER_meta_data_duplicate (member_info);
724 chat_room->my_private_key = priv_key;
725 chat_room->is_joined = GNUNET_NO;
726 chat_room->join_callback = joinCallback;
727 chat_room->join_callback_cls = join_cls;
728 chat_room->message_callback = messageCallback;
729 chat_room->message_callback_cls = message_cls;
730 chat_room->member_list_callback = memberCallback;
731 chat_room->member_list_callback_cls = member_cls;
732 chat_room->confirmation_callback = confirmationCallback;
733 chat_room->confirmation_cls = confirmation_cls;
734 chat_room->cfg = cfg;
735 chat_room->client = client;
736 chat_room->members = NULL;
737 if (GNUNET_SYSERR == rejoin_room (chat_room))
739 GNUNET_CHAT_leave_room (chat_room);
747 * Transmit a send-message request to the chat service.
749 * @param cls closure, pointer to the 'struct GNUNET_CHAT_SendMessageContext'
750 * @param size number of bytes available in buf
751 * @param buf where the callee should write the message
752 * @return number of bytes written to buf
755 transmit_send_request (void *cls,
759 struct GNUNET_CHAT_SendMessageContext *smc = cls;
760 struct TransmitRequestMessage *msg_to_send;
766 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
767 "Could not transmit a chat message\n");
772 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
773 "Transmitting a chat message to the service\n");
775 msg_size = strlen (smc->message) + sizeof (struct TransmitRequestMessage);
776 GNUNET_assert (size >= msg_size);
778 msg_to_send->header.size = htons (msg_size);
779 msg_to_send->header.type = htons (GNUNET_MESSAGE_TYPE_CHAT_TRANSMIT_REQUEST);
780 msg_to_send->msg_options = htonl (smc->options);
781 msg_to_send->sequence_number = htonl (smc->sequence_number);
782 msg_to_send->timestamp =
783 GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
784 msg_to_send->reserved = htonl (0);
785 if (NULL == smc->receiver)
786 memset (&msg_to_send->target, 0, sizeof (GNUNET_HashCode));
788 GNUNET_CRYPTO_hash (smc->receiver,
789 sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
790 &msg_to_send->target);
791 memcpy (&msg_to_send[1], smc->message, strlen (smc->message));
793 * Client don't encode private messages since public keys of other members are
794 * stored on the service side.
796 if (smc->options & GNUNET_CHAT_MSG_AUTHENTICATED)
798 msg_to_send->purpose.purpose =
799 htonl (GNUNET_SIGNATURE_PURPOSE_CHAT_MESSAGE);
800 msg_to_send->purpose.size =
802 sizeof (struct GNUNET_MessageHeader) -
803 sizeof (struct GNUNET_CRYPTO_RsaSignature));
804 GNUNET_assert (GNUNET_OK ==
805 GNUNET_CRYPTO_rsa_sign (smc->chat_room->my_private_key,
806 &msg_to_send->purpose,
807 &msg_to_send->signature));
809 GNUNET_free (smc->message);
818 * @param room handle for the chat room
819 * @param message message to be sent
820 * @param options options for the message
821 * @param receiver use NULL to send to everyone in the room
822 * @param sequence_number where to write the sequence id of the message
825 GNUNET_CHAT_send_message (struct GNUNET_CHAT_Room *room,
827 enum GNUNET_CHAT_MsgOptions options,
828 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *receiver,
829 uint32_t *sequence_number)
832 struct GNUNET_CHAT_SendMessageContext *smc;
835 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending a message\n");
837 room->sequence_number++;
838 if (NULL != sequence_number)
839 *sequence_number = room->sequence_number;
840 smc = GNUNET_malloc (sizeof (struct GNUNET_CHAT_SendMessageContext));
841 smc->chat_room = room;
842 smc->message = GNUNET_strdup (message);
843 smc->options = options;
844 smc->receiver = receiver;
845 smc->sequence_number = room->sequence_number;
846 msg_size = strlen (message) + sizeof (struct TransmitRequestMessage);
847 GNUNET_CLIENT_notify_transmit_ready (room->client,
849 GNUNET_CONSTANTS_SERVICE_TIMEOUT,
851 &transmit_send_request,