updated copyright years and pekka's email on some files
[silc.git] / apps / silcd / packet_receive.c
index 111f3b019ceaa1a0c536c41ec3070476a5cf485d..ab51f0e87c475b143902a251fc9bfa9222ecd6a4 100644 (file)
@@ -2,9 +2,9 @@
 
   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
@@ -73,7 +73,7 @@ void silc_server_notify(SilcServer server,
     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);
   }
 
@@ -378,9 +378,6 @@ void silc_server_notify(SilcServer server,
       goto out;
     }
 
-    if (channel->topic && !strcmp(channel->topic, tmp))
-      goto out;
-
     if (!channel_id) {
       channel_id = silc_id_str2id(packet->dst_id, packet->dst_id_len,
                                  packet->dst_id_type);
@@ -400,12 +397,17 @@ void silc_server_notify(SilcServer server,
       }
     }
 
+    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;
+    }
 
     /* Change the topic */
     silc_free(channel->topic);
@@ -540,8 +542,10 @@ void silc_server_notify(SilcServer server,
     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 */
@@ -685,16 +689,20 @@ void silc_server_notify(SilcServer server,
        
        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;
+         }
        }
       }
 
@@ -822,8 +830,10 @@ void silc_server_notify(SilcServer server,
     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);
@@ -1128,8 +1138,8 @@ void silc_server_notify(SilcServer server,
       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;
@@ -1140,8 +1150,10 @@ void silc_server_notify(SilcServer server,
       /* 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 */
@@ -1249,8 +1261,10 @@ void silc_server_notify(SilcServer server,
     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;
@@ -1863,8 +1877,7 @@ SilcClientEntry silc_server_new_client(SilcServer server,
                           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 "