updates.
authorPekka Riikonen <priikone@silcnet.org>
Fri, 2 Feb 2001 13:34:45 +0000 (13:34 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Fri, 2 Feb 2001 13:34:45 +0000 (13:34 +0000)
apps/silcd/command.c
apps/silcd/packet_receive.c
apps/silcd/packet_send.c
apps/silcd/packet_send.h
apps/silcd/server.c
apps/silcd/serverid.c

index 6d0a00e23c7d3d6f4690d624d19270aeabffd54b..2f748cea5c32a2c92970eedffa9d3c4f498d1d4d 100644 (file)
@@ -1356,7 +1356,7 @@ SILC_SERVER_CMD_FUNC(topic)
     idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
     /* Send notify about topic change to all clients on the channel */
-    silc_server_send_notify_to_channel(server, channel, TRUE,
+    silc_server_send_notify_to_channel(server, NULL, channel, TRUE,
                                       SILC_NOTIFY_TYPE_TOPIC_SET, 2,
                                       idp->data, idp->len,
                                       channel->topic, strlen(channel->topic));
@@ -1790,7 +1790,7 @@ static void silc_server_command_join_channel(SilcServer server,
 
   /* Send the channel key. This is broadcasted to the channel but is not
      sent to the client who is joining to the channel. */
-  silc_server_send_channel_key(server, channel, 
+  silc_server_send_channel_key(server, NULL, channel, 
                               server->server_type == SILC_ROUTER ? 
                               FALSE : server->standalone);
 
@@ -1847,7 +1847,7 @@ static void silc_server_command_join_channel(SilcServer server,
 
   if (!cmd->pending) {
     /* Send JOIN notify to locally connected clients on the channel */
-    silc_server_send_notify_to_channel(server, channel, FALSE,
+    silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
                                       SILC_NOTIFY_TYPE_JOIN, 1,
                                       clidp->data, clidp->len);
 
@@ -2470,7 +2470,7 @@ SILC_SERVER_CMD_FUNC(cmode)
 
   /* Send CMODE_CHANGE notify */
   cidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-  silc_server_send_notify_to_channel(server, channel, TRUE,
+  silc_server_send_notify_to_channel(server, NULL, channel, TRUE,
                                     SILC_NOTIFY_TYPE_CMODE_CHANGE, 2,
                                     cidp->data, cidp->len, 
                                     tmp_mask, tmp_len);
@@ -2636,7 +2636,7 @@ SILC_SERVER_CMD_FUNC(cumode)
   /* Send notify to channel, notify only if mode was actually changed. */
   if (notify) {
     idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-    silc_server_send_notify_to_channel(server, channel, TRUE,
+    silc_server_send_notify_to_channel(server, NULL, channel, TRUE,
                                       SILC_NOTIFY_TYPE_CUMODE_CHANGE, 3,
                                       idp->data, idp->len,
                                       tmp_mask, 4, tmp_id, tmp_len);
index 37575a32b828bbbfb6ed095106cb33da231dff19..3056be6d58500907bf128b8c4b7cb9d410cbcc50 100644 (file)
@@ -277,7 +277,7 @@ void silc_server_channel_key(SilcServer server,
 
   /* Distribute the key to everybody who is on the channel. If we are router
      we will also send it to locally connected servers. */
-  silc_server_send_channel_key(server, channel, FALSE);
+  silc_server_send_channel_key(server, sock, channel, FALSE);
 }
 
 /* Received packet to replace a ID. This checks that the requested ID
@@ -894,8 +894,8 @@ void silc_server_notify(SilcServer server,
     client_id = silc_id_payload_parse_id(tmp, tmp_len);
 
     /* Send to channel */
-    silc_server_packet_send_to_channel(server, channel, packet->type, FALSE,
-                                      packet->buffer->data, 
+    silc_server_packet_send_to_channel(server, NULL, channel, packet->type, 
+                                      FALSE, packet->buffer->data, 
                                       packet->buffer->len, FALSE);
 
     /* If the the client is not in local list we check global list (ie. the
@@ -953,8 +953,8 @@ void silc_server_notify(SilcServer server,
     client_id = silc_id_payload_parse_id(tmp, tmp_len);
 
     /* Send to channel */
-    silc_server_packet_send_to_channel(server, channel, packet->type, FALSE,
-                                      packet->buffer->data, 
+    silc_server_packet_send_to_channel(server, NULL, channel, packet->type, 
+                                      FALSE, packet->buffer->data, 
                                       packet->buffer->len, FALSE);
 
     /* Get client entry */
@@ -1037,11 +1037,7 @@ void silc_server_new_channel_user(SilcServer server,
   SilcClientEntry client;
   SilcChannelEntry channel;
   SilcChannelClientEntry chl;
-  SilcIDList id_list;
-  SilcServerEntry tmpserver, router;
-  SilcSocketConnection router_sock;
   SilcBuffer clidp;
-  void *tmpid;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -1072,28 +1068,6 @@ void silc_server_new_channel_user(SilcServer server,
   if (!client_id)
     goto out;
 
-#if 0
-  /* If the packet is originated from the one who sent it to us we know
-     that the ID belongs to our cell, unless the sender was router. */
-  tmpid = silc_id_str2id(packet->src_id, SILC_ID_SERVER);
-  tmpserver = (SilcServerEntry)sock->user_data;
-
-  if (!SILC_ID_SERVER_COMPARE(tmpid, tmpserver->id) &&
-      sock->type == SILC_SOCKET_TYPE_SERVER) {
-    id_list = server->local_list;
-    router_sock = sock;
-    router = sock->user_data;
-  } else {
-    id_list = server->global_list;
-    router_sock = (SilcSocketConnection)server->router->connection;
-    router = server->router;
-  }
-  silc_free(tmpid);
-#endif
-
-  router_sock = sock;
-  router = sock->user_data;
-
   /* Find the channel */
   channel = silc_idlist_find_channel_by_id(server->local_list, 
                                           channel_id, NULL);
@@ -1136,7 +1110,7 @@ void silc_server_new_channel_user(SilcServer server,
      it is assured that this is sent only to our local clients and locally
      connected servers if needed. */
   clidp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
-  silc_server_send_notify_to_channel(server, channel, FALSE,
+  silc_server_send_notify_to_channel(server, sock, channel, FALSE,
                                     SILC_NOTIFY_TYPE_JOIN, 
                                     1, clidp->data, clidp->len);
   silc_buffer_free(clidp);
index e8d12b861d9744e6df6154c0f63a41d476cdfb42..23c51d5c38543cf53b0c1dc3df8de8d883de2efb 100644 (file)
@@ -300,9 +300,12 @@ silc_server_packet_send_to_channel_real(SilcServer server,
    the channel. Usually this is used to send notify messages to the
    channel, things like notify about new user joining to the channel. 
    If `route' is FALSE then the packet is sent only locally and will not
-   be routed anywhere (for router locally means cell wide). */
+   be routed anywhere (for router locally means cell wide). If `sender'
+   is provided then the packet is not sent to that connection since it
+   originally came from it. */
 
 void silc_server_packet_send_to_channel(SilcServer server,
+                                       SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        SilcPacketType type,
                                        unsigned char route,
@@ -349,11 +352,14 @@ void silc_server_packet_send_to_channel(SilcServer server,
     sock = (SilcSocketConnection)router->connection;
     idata = (SilcIDListData)router;
     
-    SILC_LOG_DEBUG(("Sending channel message to router for routing"));
-
-    silc_server_packet_send_to_channel_real(server, sock, &packetdata,
-                                           idata->send_key, idata->hmac, 
-                                           data, data_len, FALSE, force_send);
+    if (sock != sender) {
+      SILC_LOG_DEBUG(("Sending channel message to router for routing"));
+      
+      silc_server_packet_send_to_channel_real(server, sock, &packetdata,
+                                             idata->send_key, idata->hmac, 
+                                             data, data_len, FALSE, 
+                                             force_send);
+    }
   }
 
   /* Send the message to clients on the channel's client list. */
@@ -379,6 +385,9 @@ void silc_server_packet_send_to_channel(SilcServer server,
       sock = (SilcSocketConnection)client->router->connection;
       idata = (SilcIDListData)client->router;
 
+      if (sender && sock == sender)
+       continue;
+
       /* Send the packet */
       silc_server_packet_send_to_channel_real(server, sock, &packetdata,
                                              idata->send_key, idata->hmac, 
@@ -405,6 +414,9 @@ void silc_server_packet_send_to_channel(SilcServer server,
       sock = (SilcSocketConnection)client->connection;
       idata = (SilcIDListData)client;
 
+      if (sender && sock == sender)
+       continue;
+
       /* Send the packet */
       silc_server_packet_send_to_channel_real(server, sock, &packetdata,
                                              idata->send_key, idata->hmac, 
@@ -522,6 +534,13 @@ void silc_server_packet_relay_to_channel(SilcServer server,
        sock = (SilcSocketConnection)client->router->connection;
        idata = (SilcIDListData)client->router;
 
+       if (sender_sock && sock == sender_sock)
+         continue;
+
+       SILC_LOG_DEBUG(("Relaying packet to client ID(%s) %s (%s)", 
+                       silc_id_render(client->id, SILC_ID_CLIENT),
+                       sock->hostname, sock->ip));
+
        /* Send the packet */
        silc_server_packet_send_to_channel_real(server, sock, &packetdata,
                                                idata->send_key, idata->hmac, 
@@ -545,7 +564,11 @@ void silc_server_packet_relay_to_channel(SilcServer server,
       sock = (SilcSocketConnection)client->connection;
       idata = (SilcIDListData)client;
 
-      SILC_LOG_DEBUG(("Sending packet to client %s (%s)", 
+      if (sender_sock && sock == sender_sock)
+       continue;
+
+      SILC_LOG_DEBUG(("Sending packet to client ID(%s) %s (%s)", 
+                     silc_id_render(client->id, SILC_ID_CLIENT),
                      sock->hostname, sock->ip));
 
       /* Send the packet */
@@ -717,9 +740,12 @@ void silc_server_send_notify_dest(SilcServer server,
 /* Sends notify message to a channel. The notify message sent is 
    distributed to all clients on the channel. If `router_notify' is TRUE
    then the notify may be routed to primary route or to some other routers.
-   If FALSE it is assured that the notify is sent only locally. */
+   If FALSE it is assured that the notify is sent only locally. If `sender'
+   is provided then the packet is not sent to that connection since it
+   originally came from it. */
 
 void silc_server_send_notify_to_channel(SilcServer server,
+                                       SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        unsigned char route_notify,
                                        SilcNotifyType type,
@@ -731,7 +757,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
   va_start(ap, argc);
 
   packet = silc_notify_payload_encode(type, argc, ap);
-  silc_server_packet_send_to_channel(server, channel, 
+  silc_server_packet_send_to_channel(server, sender, channel, 
                                     SILC_PACKET_NOTIFY, route_notify,
                                     packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
@@ -1079,9 +1105,12 @@ void silc_server_send_new_channel_user(SilcServer server,
    sends this to the local server who sent the join command in case where
    the channel did not exist yet. Both normal and router servers uses this
    also to send this to locally connected clients on the channel. This
-   must not be broadcasted packet. Routers do not send this to each other. */
+   must not be broadcasted packet. Routers do not send this to each other. 
+   If `sender is provided then the packet is not sent to that connection since
+   it originally came from it. */
 
 void silc_server_send_channel_key(SilcServer server,
+                                 SilcSocketConnection sender,
                                  SilcChannelEntry channel,
                                  unsigned char route)
 {
@@ -1101,7 +1130,8 @@ void silc_server_send_channel_key(SilcServer server,
                                            channel->channel_key->cipher->name,
                                            channel->key_len / 8, channel->key);
  
-  silc_server_packet_send_to_channel(server, channel, SILC_PACKET_CHANNEL_KEY,
+  silc_server_packet_send_to_channel(server, sender, channel, 
+                                    SILC_PACKET_CHANNEL_KEY,
                                      route, packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
   silc_free(chid);
index c60bace93980e88f4603cf31480ff35decc58408..30833278003c81bd1ff5255080d7b75d664c3cac 100644 (file)
@@ -49,6 +49,7 @@ void silc_server_packet_route(SilcServer server,
                              SilcSocketConnection sock,
                              SilcPacketContext *packet);
 void silc_server_packet_send_to_channel(SilcServer server,
+                                       SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        SilcPacketType type,
                                        unsigned char route,
@@ -91,6 +92,7 @@ void silc_server_send_notify_dest(SilcServer server,
                                  SilcNotifyType type,
                                  unsigned int argc, ...);
 void silc_server_send_notify_to_channel(SilcServer server,
+                                       SilcSocketConnection sender,
                                        SilcChannelEntry channel,
                                        unsigned char route_notify,
                                        SilcNotifyType type,
@@ -129,6 +131,7 @@ void silc_server_send_new_channel_user(SilcServer server,
                                       void *client_id,
                                       unsigned int client_id_len);
 void silc_server_send_channel_key(SilcServer server,
+                                 SilcSocketConnection sender,
                                  SilcChannelEntry channel,
                                  unsigned char route);
 void silc_server_send_command(SilcServer server, 
index ed05c9c95a85ff438088ec7d3f3028d77ce19713..05e19ad8448602b47164e6ddb191699d3788f430 100644 (file)
@@ -1744,7 +1744,7 @@ void silc_server_remove_from_channels(SilcServer server,
         channel globally from SILC network, in this case we will
         notify that this client has left the channel. */
       if (channel->global_users)
-       silc_server_send_notify_to_channel(server, channel, FALSE,
+       silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
                                           SILC_NOTIFY_TYPE_SIGNOFF, 1,
                                           clidp->data, clidp->len);
       
@@ -1758,7 +1758,7 @@ void silc_server_remove_from_channels(SilcServer server,
 
     /* Send notify to channel about client leaving SILC and thus
        the entire channel. */
-    silc_server_send_notify_to_channel(server, channel, FALSE,
+    silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
                                       SILC_NOTIFY_TYPE_SIGNOFF, 1,
                                       clidp->data, clidp->len);
     silc_buffer_free(chidp);
@@ -1804,7 +1804,7 @@ int silc_server_remove_from_one_channel(SilcServer server,
     if (silc_list_count(channel->user_list) < 2) {
       /* Notify about leaving client if this channel has global users. */
       if (notify && channel->global_users)
-       silc_server_send_notify_to_channel(server, channel, FALSE,
+       silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
                                           SILC_NOTIFY_TYPE_LEAVE, 1,
                                           clidp->data, clidp->len);
       
@@ -1834,7 +1834,7 @@ int silc_server_remove_from_one_channel(SilcServer server,
 
     /* Send notify to channel about client leaving the channel */
     if (notify)
-      silc_server_send_notify_to_channel(server, channel, FALSE,
+      silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
                                         SILC_NOTIFY_TYPE_LEAVE, 1,
                                         clidp->data, clidp->len);
     break;
index 26f010cb5db046d80cb19d435f5c84165bafac2f..89ea6b82a5807e40970eb343d62d7afabf138efa 100644 (file)
 /*
  * $Id$
  * $Log$
- * Revision 1.1  2000/06/27 11:36:56  priikone
- * Initial revision
+ * Revision 1.2  2001/02/02 13:34:45  priikone
+ *     updates.
+ *
+ * Revision 1.1.1.1  2000/06/27 11:36:56  priikone
+ *     Importet from internal CVS/Added Log headers.
  *
  *
  */
@@ -58,6 +61,8 @@ void silc_id_create_server_id(int sock, SilcRng rng, SilcServerID **new_id)
   (*new_id)->ip = server.sin_addr;
   (*new_id)->port = server.sin_port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
+
+  SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_SERVER)));
 }
 
 /* Creates Client ID */
@@ -83,6 +88,8 @@ void silc_id_create_client_id(SilcServerID *server_id, SilcRng rng,
   (*new_id)->ip.s_addr = server_id->ip.s_addr;
   (*new_id)->rnd = silc_rng_get_byte(rng);
   memcpy((*new_id)->hash, hash, CLIENTID_HASH_LEN);
+
+  SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_CLIENT)));
 }
 
 /* Creates Channel ID */
@@ -102,4 +109,6 @@ void silc_id_create_channel_id(SilcServerID *router_id, SilcRng rng,
   (*new_id)->ip.s_addr = router_id->ip.s_addr;
   (*new_id)->port = router_id->port;
   (*new_id)->rnd = silc_rng_get_rn16(rng);
+
+  SILC_LOG_DEBUG(("New ID (%s)", silc_id_render(*new_id, SILC_ID_CHANNEL)));
 }