/* Send the packet */
ret = silc_packet_send(sock, force_send);
- if (ret != -2)
+ if (ret != -2) {
+ server->stat.packets_sent++;
return ret;
+ }
/* Mark that there is some outgoing data available for this connection.
This call sets the connection both for input and output (the input
channel->channel_key) {
SilcUInt32 mac_len = silc_hmac_len(channel->hmac);
SilcUInt32 iv_len = silc_cipher_get_block_len(channel->channel_key);
+ unsigned char iv[SILC_CIPHER_MAX_IV_SIZE];
if (data_len <= mac_len + iv_len) {
SILC_LOG_WARNING(("Corrupted channel message, cannot relay it"));
return FALSE;
}
- memcpy(channel->iv, data + (data_len - iv_len), iv_len);
+ memcpy(iv, data + (data_len - iv_len), iv_len);
silc_channel_message_payload_encrypt(data, data_len - iv_len - mac_len,
- data_len, channel->iv, iv_len,
+ data_len, iv, iv_len,
channel->channel_key, channel->hmac);
}
SilcChannelEntry channel,
SilcUInt32 mode_mask,
void *id, SilcIdType id_type,
- char *cipher, char *hmac,
- char *passphrase)
+ const char *cipher, const char *hmac,
+ const char *passphrase,
+ SilcPublicKey founder_key)
{
SilcBuffer idp;
- unsigned char mode[4];
+ unsigned char mode[4], *key = NULL;
+ SilcUInt32 key_len = 0;
idp = silc_id_payload_encode((void *)id, id_type);
SILC_PUT32_MSB(mode_mask, mode);
+ if (founder_key)
+ key = silc_pkcs_public_key_encode(founder_key, &key_len);
silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_CMODE_CHANGE,
- 5, idp->data, idp->len,
+ 6, idp->data, idp->len,
mode, 4,
cipher, cipher ? strlen(cipher) : 0,
hmac, hmac ? strlen(hmac) : 0,
passphrase, passphrase ?
- strlen(passphrase) : 0);
+ strlen(passphrase) : 0,
+ key, key_len);
+ silc_free(key);
silc_buffer_free(idp);
}
-/* Sends CUMODE_CHANGE notify type. This tells that `client_id' changed the
+/* Sends CUMODE_CHANGE notify type. This tells that `id' changed the
`target' client's mode on `channel'. The notify packet is always
destined to the channel. */
SilcChannelEntry channel,
SilcUInt32 mode_mask,
void *id, SilcIdType id_type,
- SilcClientID *target)
+ SilcClientID *target,
+ SilcPublicKey founder_key)
{
SilcBuffer idp1, idp2;
- unsigned char mode[4];
+ unsigned char mode[4], *key = NULL;
+ SilcUInt32 key_len = 0;
idp1 = silc_id_payload_encode((void *)id, id_type);
idp2 = silc_id_payload_encode((void *)target, SILC_ID_CLIENT);
SILC_PUT32_MSB(mode_mask, mode);
+ if (founder_key)
+ key = silc_pkcs_public_key_encode(founder_key, &key_len);
silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
SILC_ID_CHANNEL,
- SILC_NOTIFY_TYPE_CUMODE_CHANGE, 3,
+ SILC_NOTIFY_TYPE_CUMODE_CHANGE, 4,
idp1->data, idp1->len,
mode, 4,
- idp2->data, idp2->len);
+ idp2->data, idp2->len,
+ key, key_len);
+ silc_free(key);
silc_buffer_free(idp1);
silc_buffer_free(idp2);
}
silc_server_send_notify_dest(server, sock, FALSE, watcher->id,
SILC_ID_CLIENT, SILC_NOTIFY_TYPE_WATCH,
4, idp->data, idp->len,
- nickname, strlen(nickname),
+ nickname, nickname ? strlen(nickname) : 0,
mode, sizeof(mode),
type != SILC_NOTIFY_TYPE_NONE ?
n : NULL, sizeof(n));
silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID,
broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
idp->data, idp->len, FALSE);
-
- /* Send to backup routers if this is being broadcasted to primary
- router. */
- if (server->router && server->router->connection &&
- sock == server->router->connection && broadcast)
- silc_server_backup_send(server, NULL, SILC_PACKET_NEW_ID, 0,
- idp->data, idp->len, FALSE, TRUE);
-
silc_buffer_free(idp);
}
broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
packet->data, packet->len, FALSE);
- /* Send to backup routers if this is being broadcasted to primary
- router. */
- if (server->server_type == SILC_ROUTER &&
- server->router && server->router->connection &&
- sock == server->router->connection && broadcast)
- silc_server_backup_send(server, NULL, SILC_PACKET_NEW_CHANNEL, 0,
- packet->data, packet->len, FALSE, TRUE);
-
silc_free(cid);
silc_buffer_free(packet);
}