- int ret;
-
- /* If disconnecting, ignore the data */
- if (SILC_IS_DISCONNECTING(sock) || SILC_IS_DISCONNECTED(sock))
- return -1;
-
- /* Send the packet */
- ret = silc_packet_send(sock, FALSE);
- if (ret != -2) {
- if (ret == -1) {
- SILC_SET_CONNECTION_FOR_INPUT(server->schedule, sock->sock);
- SILC_UNSET_OUTBUF_PENDING(sock);
- silc_buffer_clear(sock->outbuf);
-
- SILC_LOG_ERROR(("Error sending packet to connection "
- "%s:%d [%s]", sock->hostname, sock->port,
- (sock->type == SILC_SOCKET_TYPE_UNKNOWN ? "Unknown" :
- sock->type == SILC_SOCKET_TYPE_CLIENT ? "Client" :
- sock->type == SILC_SOCKET_TYPE_SERVER ? "Server" :
- "Router")));
-
- if (sock->user_data) {
- /* If backup then mark that resuming will not be allowed */
- if (server->server_type == SILC_ROUTER && !server->backup_router &&
- sock->type == SILC_SOCKET_TYPE_SERVER) {
- SilcServerEntry server_entry = sock->user_data;
- if (server_entry->server_type == SILC_BACKUP_ROUTER)
- server->backup_closed = TRUE;
- }
-
- silc_server_free_sock_user_data(server, sock, NULL);
- }
- SILC_SET_DISCONNECTING(sock);
- silc_server_close_connection(server, sock);
- return ret;
- }
-
- 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
- is set always and this call keeps the input setting, actually).
- Actual data sending is performed by silc_server_packet_process. */
- SILC_SET_CONNECTION_FOR_OUTPUT(server->schedule, sock->sock);
-
- /* Mark to socket that data is pending in outgoing buffer. This flag
- is needed if new data is added to the buffer before the earlier
- put data is sent to the network. */
- SILC_SET_OUTBUF_PENDING(sock);
-
- return 0;
-}
-
-/* Assembles a new packet to be sent out to network. This doesn't actually
- send the packet but creates the packet and fills the outgoing data
- buffer and marks the packet ready to be sent to network. However, If
- argument force_send is TRUE the packet is sent immediately and not put
- to queue. Normal case is that the packet is not sent immediately. */
-
-void silc_server_packet_send(SilcServer server,
- SilcSocketConnection sock,
- SilcPacketType type,
- SilcPacketFlags flags,
- unsigned char *data,
- SilcUInt32 data_len,
- bool force_send)
-{
- void *dst_id = NULL;
- SilcIdType dst_id_type = SILC_ID_NONE;