return value.
with the next receiver's key. The `data' is the channel message. If
the `force_send' is TRUE then the packet is sent immediately. */
-void silc_client_send_channel_message(SilcClient client,
+bool silc_client_send_channel_message(SilcClient client,
SilcClientConnection conn,
SilcChannelEntry channel,
SilcChannelPrivateKey key,
unsigned char *id_string;
int block_len;
SilcChannelUser chu;
+ bool ret = FALSE;
assert(client && conn && channel);
sock = conn->sock;
chu = silc_client_on_channel(channel, conn->local_entry);
if (!chu) {
SILC_LOG_ERROR(("Cannot send message to channel we are not joined"));
- return;
+ return FALSE;
}
/* Check if it is allowed to send messages to this channel by us. */
if (channel->mode & SILC_CHANNEL_MODE_SILENCE_USERS && !chu->mode)
- return;
+ return FALSE;
if (channel->mode & SILC_CHANNEL_MODE_SILENCE_OPERS &&
chu->mode & SILC_CHANNEL_UMODE_CHANOP &&
!(chu->mode & SILC_CHANNEL_UMODE_CHANFO))
- return;
+ return FALSE;
if (chu->mode & SILC_CHANNEL_UMODE_QUIET)
- return;
+ return FALSE;
/* Take the key to be used */
if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
hmac = channel->hmac;
}
- if (!cipher || !hmac)
- return;
+ if (!cipher || !hmac) {
+ SILC_LOG_ERROR(("No cipher and HMAC for channel"));
+ return FALSE;
+ }
block_len = silc_cipher_get_block_len(cipher);
payload = silc_message_payload_encode(flags, data, data_len, TRUE, FALSE,
cipher, hmac, client->rng, NULL,
client->private_key, client->sha1hash);
- if (!payload)
- return;
+ if (!payload) {
+ SILC_LOG_ERROR(("Error encoding channel message"));
+ return FALSE;
+ }
/* Get data used in packet header encryption, keys and stuff. */
cipher = conn->internal->send_key;
silc_client_rekey_callback, sock, 0, 1,
SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+ ret = TRUE;
+
out:
silc_buffer_free(payload);
silc_free(id_string);
+
+ return ret;
}
typedef struct {
message. The `data' is the private message. If the `force_send' is
TRUE the packet is sent immediately. */
-void silc_client_send_private_message(SilcClient client,
+bool silc_client_send_private_message(SilcClient client,
SilcClientConnection conn,
SilcClientEntry client_entry,
SilcMessageFlags flags,
SilcCipher cipher;
SilcHmac hmac;
int block_len;
+ bool ret = FALSE;
assert(client && conn && client_entry);
sock = conn->sock;
client_entry->hmac_send,
client->rng, NULL, client->private_key,
client->sha1hash);
- if (!buffer)
- return;
+ if (!buffer) {
+ SILC_LOG_ERROR(("Error encoding private message"));
+ return FALSE;
+ }
/* If we don't have private message specific key then private messages
are just as any normal packet thus call normal packet sending. If
silc_free(packetdata.dst_id);
+ ret = TRUE;
+
out:
silc_buffer_free(buffer);
+
+ return ret;
}
static void silc_client_private_message_cb(SilcClient client,
*
* SYNOPSIS
*
- * void silc_client_send_channel_message(SilcClient client,
+ * bool silc_client_send_channel_message(SilcClient client,
* SilcClientConnection conn,
* SilcChannelEntry channel,
* SilcChannelPrivateKey key,
* If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
* digitally signed with the SILC key pair.
*
+ * Returns TRUE if the message was sent, and FALSE if error occurred or
+ * the sending is not allowed due to channel modes (like sending is
+ * blocked).
+ *
***/
-void silc_client_send_channel_message(SilcClient client,
+bool silc_client_send_channel_message(SilcClient client,
SilcClientConnection conn,
SilcChannelEntry channel,
SilcChannelPrivateKey key,
*
* SYNOPSIS
*
- * void silc_client_send_private_message(SilcClient client,
+ * bool silc_client_send_private_message(SilcClient client,
* SilcClientConnection conn,
* SilcClientEntry client_entry,
* SilcMessageFlags flags,
* If the `flags' includes SILC_MESSAGE_FLAG_SIGNED the message will be
* digitally signed with the SILC key pair.
*
+ * Returns TRUE if the message was sent, and FALSE if error occurred.
+ *
***/
-void silc_client_send_private_message(SilcClient client,
+bool silc_client_send_private_message(SilcClient client,
SilcClientConnection conn,
SilcClientEntry client_entry,
SilcMessageFlags flags,