-/* Internal routine to actually create the channel packet and send it
- to network. This is common function in channel message sending. If
- `channel_message' is TRUE this encrypts the message as it is strictly
- a channel message. If FALSE normal encryption process is used. */
-
-static void
-silc_server_packet_send_to_channel_real(SilcServer server,
- SilcSocketConnection sock,
- SilcPacketContext *packet,
- SilcCipher cipher,
- SilcHmac hmac,
- SilcUInt32 sequence,
- unsigned char *data,
- SilcUInt32 data_len,
- bool channel_message,
- bool force_send)
-{
- int block_len;
- const SilcBufferStruct p;
-
- if (!sock)
- return;
-
- data_len = SILC_PACKET_DATALEN(data_len, (SILC_PACKET_HEADER_LEN +
- packet->src_id_len +
- packet->dst_id_len));
- packet->truelen = data_len + SILC_PACKET_HEADER_LEN +
- packet->src_id_len + packet->dst_id_len;
-
- block_len = cipher ? silc_cipher_get_block_len(cipher) : 0;
- if (channel_message)
- packet->padlen = SILC_PACKET_PADLEN((SILC_PACKET_HEADER_LEN +
- packet->src_id_len +
- packet->dst_id_len), block_len);
- else
- packet->padlen = SILC_PACKET_PADLEN(packet->truelen, block_len);
-
- /* Put the data to buffer, assemble and encrypt the packet. The packet
- is encrypted with normal session key shared with the client, unless
- the `channel_message' is TRUE. */
- if (!silc_packet_assemble(packet, NULL, cipher, hmac, sock, data,
- data_len, (const SilcBuffer)&p)) {
- SILC_LOG_ERROR(("Cannot assemble packet"));
- return;
- }
-
- if (channel_message)
- silc_packet_encrypt(cipher, hmac, sequence, (SilcBuffer)&p,
- SILC_PACKET_HEADER_LEN + packet->src_id_len +
- packet->dst_id_len + packet->padlen);
- else
- silc_packet_encrypt(cipher, hmac, sequence, (SilcBuffer)&p, p.len);
-
- SILC_LOG_HEXDUMP(("Channel packet (%d), len %d", sequence, p.len),
- p.data, p.len);
-
- /* Now actually send the packet */
- silc_server_packet_send_real(server, sock, force_send);
-}
-
-/* This routine is used by the server to send packets to channel. The