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));
/* 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);
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);
/* 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);
/* 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);
/* 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
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
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 */
SilcClientEntry client;
SilcChannelEntry channel;
SilcChannelClientEntry chl;
- SilcIDList id_list;
- SilcServerEntry tmpserver, router;
- SilcSocketConnection router_sock;
SilcBuffer clidp;
- void *tmpid;
SILC_LOG_DEBUG(("Start"));
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);
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);
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,
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. */
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,
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,
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,
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 */
/* 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,
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);
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)
{
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);
SilcSocketConnection sock,
SilcPacketContext *packet);
void silc_server_packet_send_to_channel(SilcServer server,
+ SilcSocketConnection sender,
SilcChannelEntry channel,
SilcPacketType type,
unsigned char route,
SilcNotifyType type,
unsigned int argc, ...);
void silc_server_send_notify_to_channel(SilcServer server,
+ SilcSocketConnection sender,
SilcChannelEntry channel,
unsigned char route_notify,
SilcNotifyType type,
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,
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);
/* 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);
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);
/* 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;
/*
* $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.
*
*
*/
(*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 */
(*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 */
(*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)));
}