/* Parser callback called by silc_packet_receive_process. This merely
registers timeout that will handle the actual parsing when appropriate. */
-void silc_server_packet_parse(SilcPacketParserContext *parser_context,
+bool silc_server_packet_parse(SilcPacketParserContext *parser_context,
void *context)
{
SilcServer server = (SilcServer)context;
if (idata)
idata->psn_receive = parser_context->packet->sequence + 1;
+ /* If protocol for this connection is key exchange or rekey then we'll
+ process all packets synchronously, since there might be packets in
+ queue that we are not able to decrypt without first processing the
+ packets before them. */
+ if (sock->protocol && sock->protocol->protocol &&
+ (sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_KEY_EXCHANGE ||
+ sock->protocol->protocol->type == SILC_PROTOCOL_SERVER_REKEY)) {
+ silc_server_packet_parse_real(server->schedule, 0, sock->sock,
+ parser_context);
+
+ /* Reprocess data since we'll return FALSE here. This is because
+ the idata->receive_key might have become valid in the last packet
+ and we want to call this processor with valid cipher. */
+ if (idata)
+ silc_packet_receive_process(sock, server->server_type == SILC_ROUTER ?
+ TRUE : FALSE, idata->receive_key,
+ idata->hmac_receive, idata->psn_receive,
+ silc_server_packet_parse, server);
+ else
+ silc_packet_receive_process(sock, server->server_type == SILC_ROUTER ?
+ TRUE : FALSE, NULL, NULL, 0,
+ silc_server_packet_parse, server);
+ return FALSE;
+ }
+
switch (sock->type) {
case SILC_SOCKET_TYPE_UNKNOWN:
case SILC_SOCKET_TYPE_CLIENT:
SILC_TASK_PRI_NORMAL);
break;
default:
- return;
+ return TRUE;
}
+
+ return TRUE;
}
/* Parses the packet type and calls what ever routines the packet type
break;
case SILC_PACKET_FTP:
- /* Ignored */
+ /* FTP packet */
+ SILC_LOG_DEBUG(("FTP packet"));
+ if (packet->flags & SILC_PACKET_FLAG_LIST)
+ break;
+ silc_server_ftp(server, sock, packet);
break;
case SILC_PACKET_RESUME_ROUTER:
to the network before removing the client entry. */
silc_server_packet_queue_purge(server, sock);
+ if (!client->id)
+ return;
+
/* Send SIGNOFF notify to routers. */
if (notify && !server->standalone && server->router)
silc_server_send_notify_signoff(server, server->router->connection,
server->server_type == SILC_SERVER ?
FALSE : TRUE, client->id, signoff);
-
+
/* Remove client from all channels */
if (notify)
silc_server_remove_from_channels(server, NULL, client,
else
silc_server_remove_from_channels(server, NULL, client,
FALSE, NULL, FALSE);
-
+
/* We will not delete the client entry right away. We will take it
into history (for WHOWAS command) for 5 minutes */
i->server = server;
silc_schedule_task_del_by_context(server->schedule, channel->rekey);
if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
continue;
}
/* Remove the channel entry */
if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
continue;
}
silc_schedule_task_del_by_context(server->schedule, channel->rekey);
if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
silc_buffer_free(clidp);
return FALSE;
}
/* Remove the channel entry */
if (silc_idlist_del_channel(server->local_list, channel))
server->stat.my_channels--;
- else if (silc_idlist_del_channel(server->global_list, channel))
- server->stat.my_channels--;
+ else
+ silc_idlist_del_channel(server->global_list, channel);
return FALSE;
}