packet_receive.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
if (dst_sock)
/* Relay the packet */
silc_server_relay_packet(server, dst_sock, idata->send_key,
- idata->hmac_receive, idata->psn_send++,
+ idata->hmac_send, idata->psn_send++,
packet, TRUE);
}
}
silc_free(client_id);
+ /* Get the topic */
+ tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+ if (!tmp) {
+ silc_free(channel_id);
+ goto out;
+ }
+
if (!channel_id) {
channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
packet->dst_id_type);
}
}
- /* Get the topic */
- tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
- if (!tmp) {
- silc_free(channel_id);
+ if (channel->topic && !strcmp(channel->topic, tmp))
goto out;
- }
/* Get user's channel entry and check that topic set is allowed. */
if (!silc_server_client_on_channel(client, channel, &chl))
goto out;
if (chl->mode == SILC_CHANNEL_UMODE_NONE &&
- channel->mode & SILC_CHANNEL_MODE_TOPIC)
+ channel->mode & SILC_CHANNEL_MODE_TOPIC) {
+ SILC_LOG_DEBUG(("Topic change is not allowed"));
goto out;
+ }
- /* Set the topic for channel */
+ /* Change the topic */
silc_free(channel->topic);
channel->topic = strdup(tmp);
if (client) {
if (!silc_server_client_on_channel(client, channel, &chl))
goto out;
- if (!silc_server_check_cmode_rights(server, channel, chl, mode))
+ if (!silc_server_check_cmode_rights(server, channel, chl, mode)) {
+ SILC_LOG_DEBUG(("CMODE change is not allowed"));
goto out;
+ }
}
/* Send the same notify to the channel */
if (client != client2) {
/* Sender must be operator */
- if (chl->mode == SILC_CHANNEL_UMODE_NONE)
+ if (chl->mode == SILC_CHANNEL_UMODE_NONE) {
+ SILC_LOG_DEBUG(("CUMODE change is not allowed"));
goto out;
+ }
/* Check that target is on channel */
if (!silc_server_client_on_channel(client2, channel, &chl))
goto out;
/* If target is founder mode change is not allowed. */
- if (chl->mode & SILC_CHANNEL_UMODE_CHANFO)
+ if (chl->mode & SILC_CHANNEL_UMODE_CHANFO) {
+ SILC_LOG_DEBUG(("CUMODE change is not allowed"));
goto out;
+ }
}
}
if (!silc_server_client_on_channel(client, channel, &chl))
goto out;
if (chl->mode == SILC_CHANNEL_UMODE_NONE &&
- channel->mode & SILC_CHANNEL_MODE_INVITE)
+ channel->mode & SILC_CHANNEL_MODE_INVITE) {
+ SILC_LOG_DEBUG(("Inviting is not allowed"));
goto out;
+ }
/* Get the added invite */
tmp = silc_argument_get_arg_type(args, 4, &tmp_len);
client2 = silc_idlist_find_client_by_id(server->global_list,
client_id, TRUE, NULL);
if (!client2) {
- client = silc_idlist_find_client_by_id(server->local_list,
- client_id, TRUE, NULL);
+ client2 = silc_idlist_find_client_by_id(server->local_list,
+ client_id, TRUE, NULL);
if (!client2) {
silc_free(client_id);
goto out;
/* Kicker must be operator on channel */
if (!silc_server_client_on_channel(client2, channel, &chl))
goto out;
- if (chl->mode == SILC_CHANNEL_UMODE_NONE)
+ if (chl->mode == SILC_CHANNEL_UMODE_NONE) {
+ SILC_LOG_DEBUG(("Kicking is not allowed"));
goto out;
+ }
}
/* Send to channel */
SILC_GET32_MSB(mode, tmp);
/* Check that mode changing is allowed. */
- if (!silc_server_check_umode_rights(server, client, mode))
+ if (!silc_server_check_umode_rights(server, client, mode)) {
+ SILC_LOG_DEBUG(("UMODE change is not allowed"));
goto out;
+ }
/* Change the mode */
client->mode = mode;
username));
SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
("Your host is %s, running version %s",
- server->config->server_info->server_name,
- server_version));
+ server->server_name, server_version));
if (server->server_type == SILC_ROUTER) {
SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
("There are %d clients on %d servers in SILC "