From: Pekka Riikonen Date: Fri, 2 Feb 2001 13:34:45 +0000 (+0000) Subject: updates. X-Git-Tag: SILC.0.1~272 X-Git-Url: http://git.silc.fi/gitweb/?a=commitdiff_plain;h=f7042e8bb12f8c5f9bd255b9bd4c1345426d4281;p=silc.git updates. --- diff --git a/apps/silcd/command.c b/apps/silcd/command.c index 6d0a00e2..2f748cea 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -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); diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index 37575a32..3056be6d 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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); diff --git a/apps/silcd/packet_send.c b/apps/silcd/packet_send.c index e8d12b86..23c51d5c 100644 --- a/apps/silcd/packet_send.c +++ b/apps/silcd/packet_send.c @@ -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); diff --git a/apps/silcd/packet_send.h b/apps/silcd/packet_send.h index c60bace9..30833278 100644 --- a/apps/silcd/packet_send.h +++ b/apps/silcd/packet_send.h @@ -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, diff --git a/apps/silcd/server.c b/apps/silcd/server.c index ed05c9c9..05e19ad8 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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; diff --git a/apps/silcd/serverid.c b/apps/silcd/serverid.c index 26f010cb..89ea6b82 100644 --- a/apps/silcd/serverid.c +++ b/apps/silcd/serverid.c @@ -20,8 +20,11 @@ /* * $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))); }