-/* 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;
-
- if (!sock)
- return;
-
- 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);
-
- /* Prepare outgoing data buffer for packet sending */
- silc_packet_send_prepare(sock,
- SILC_PACKET_HEADER_LEN +
- packet->src_id_len +
- packet->dst_id_len,
- packet->padlen,
- data_len);
-
- packet->buffer = sock->outbuf;
-
- /* 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. */
- silc_buffer_put(sock->outbuf, data, data_len);
- silc_packet_assemble(packet, cipher);
- if (channel_message)
- silc_packet_encrypt(cipher, hmac, sequence, sock->outbuf,
- SILC_PACKET_HEADER_LEN + packet->src_id_len +
- packet->dst_id_len + packet->padlen);
- else
- silc_packet_encrypt(cipher, hmac, sequence, sock->outbuf,
- sock->outbuf->len);
-
- SILC_LOG_HEXDUMP(("Channel packet (%d), len %d", sequence,
- sock->outbuf->len),
- sock->outbuf->data, sock->outbuf->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