SilcArgumentPayload args;
SilcChannelID *channel_id, *channel_id2;
SilcClientID *client_id, *client_id2;
+ SilcServerID *server_id;
SilcChannelEntry channel;
SilcClientEntry client;
+ SilcServerEntry server_entry;
SilcChannelClientEntry chl;
SilcIDCacheEntry cache;
- unsigned int mode;
+ uint32 mode;
unsigned char *tmp;
- unsigned int tmp_len;
+ uint32 tmp_len;
SILC_LOG_DEBUG(("Start"));
break;
case SILC_NOTIFY_TYPE_SERVER_SIGNOFF:
- SILC_LOG_DEBUG(("SERVER SIGNOFF notify (not-impl XXX)"));
+ /*
+ * Remove the server entry and all clients that this server owns.
+ */
+
+ SILC_LOG_DEBUG(("SERVER SIGNOFF notify"));
+
+ /* Get Server ID */
+ tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
+ if (!tmp)
+ goto out;
+ server_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (!server_id)
+ goto out;
+
+ /* Get server entry */
+ server_entry = silc_idlist_find_server_by_id(server->global_list,
+ server_id, NULL);
+ if (!server_entry) {
+ server_entry = silc_idlist_find_server_by_id(server->local_list,
+ server_id, NULL);
+ if (!server_entry) {
+ silc_free(server_id);
+ goto out;
+ }
+ }
+ silc_free(server_id);
+
+ /* Free all client entries that this server owns as they will
+ become invalid now as well. */
+ silc_server_remove_clients_by_server(server, server_entry, TRUE);
+
+ /* Remove the server entry */
+ if (!silc_idlist_del_server(server->global_list, server_entry))
+ silc_idlist_del_server(server->local_list, server_entry);
+
+ /* XXX update statistics */
+
break;
case SILC_NOTIFY_TYPE_KICKED:
* Distribute the notify to local clients on channels
*/
unsigned char *id;
- unsigned int id_len;
+ uint32 id_len;
SILC_LOG_DEBUG(("KILLED notify"));
{
SilcPacketContext *new;
SilcBuffer buffer;
- unsigned short len;
+ uint16 len;
SILC_LOG_DEBUG(("Processing New Notify List"));
sock->type == SILC_SOCKET_TYPE_ROUTER &&
!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
SilcBuffer chp;
- unsigned int iv_len, i;
- unsigned short data_len, flags;
+ uint32 iv_len, i;
+ uint16 data_len, flags;
iv_len = silc_cipher_get_block_len(channel->channel_key);
if (channel->iv[0] == '\0')
cache->id = (void *)client_id;
cache->type = SILC_ID_CLIENT;
cache->data = username;
+ cache->data_len = strlen(username);
silc_idcache_sort_by_data(server->local_list->clients);
/* Notify our router about new client on the SILC network */
SilcServerID *server_id;
SilcIDListData idata;
unsigned char *server_name, *id_string;
- unsigned short id_len, name_len;
+ uint16 id_len, name_len;
int ret;
SILC_LOG_DEBUG(("Creating new server"));
{
SilcPacketContext *new_id;
SilcBuffer idp;
- unsigned short id_len;
+ uint16 id_len;
SILC_LOG_DEBUG(("Processing New ID List"));
SilcChannelPayload payload;
SilcChannelID *channel_id;
char *channel_name;
- unsigned int name_len;
+ uint32 name_len;
unsigned char *id;
- unsigned int id_len;
- unsigned int mode;
+ uint32 id_len;
+ uint32 mode;
SILC_LOG_DEBUG(("Processing New Channel"));
We also create a new key for the channel. */
SilcBuffer users = NULL;
+ if (!channel->id)
+ channel_id = silc_id_dup(channel_id, SILC_ID_CHANNEL);
+
if (SILC_ID_CHANNEL_COMPARE(channel_id, channel->id)) {
/* They don't match, send CHANNEL_CHANGE notify to the server to
force the ID change. */
{
SilcPacketContext *new;
SilcBuffer buffer;
- unsigned short len1, len2;
+ uint16 len1, len2;
SILC_LOG_DEBUG(("Processing New Channel List"));
SilcPacketContext *packet)
{
SilcServerConfigSectionClientConnection *client = NULL;
- unsigned short conn_type;
+ uint16 conn_type;
int ret;
SilcAuthMethod auth_meth;
conn_type,
auth_meth);
}
+
+/* Received REKEY packet. The sender of the packet wants to regenerate
+ its session keys. This starts the REKEY protocol. */
+
+void silc_server_rekey(SilcServer server,
+ SilcSocketConnection sock,
+ SilcPacketContext *packet)
+{
+ SilcProtocol protocol;
+ SilcServerRekeyInternalContext *proto_ctx;
+ SilcIDListData idata = (SilcIDListData)sock->user_data;
+
+ SILC_LOG_DEBUG(("Start"));
+
+ /* Allocate internal protocol context. This is sent as context
+ to the protocol. */
+ proto_ctx = silc_calloc(1, sizeof(*proto_ctx));
+ proto_ctx->server = (void *)server;
+ proto_ctx->sock = sock;
+ proto_ctx->responder = TRUE;
+ proto_ctx->pfs = idata->rekey->pfs;
+
+ /* Perform rekey protocol. Will call the final callback after the
+ protocol is over. */
+ silc_protocol_alloc(SILC_PROTOCOL_SERVER_REKEY,
+ &protocol, proto_ctx, silc_server_rekey_final);
+ sock->protocol = protocol;
+
+ if (proto_ctx->pfs == FALSE)
+ /* Run the protocol */
+ protocol->execute(server->timeout_queue, 0, protocol, sock->sock, 0, 0);
+}