the channel (but not to clients).
+Wed Oct 8 09:32:12 CEST 2003 Pekka Riikonen <priikone@silcnet.org>
+
+ * INVITE and BAN notifys are now delivered from routers to
+ servers (but not clients) on the channel. Updated specs and
+ code. Affected files silcd/packet_[send|receive].[ch],
+ command.c, server.c and server_util.c.
+
Sun Oct 5 20:22:08 EEST 2003 Pekka Riikonen <priikone@silcnet.org>
* Backup router protocol version 1.2 implemented. Testing still
/* Send notify about topic change to all clients on the channel */
idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_TOPIC_SET, 2,
idp->data, idp->len,
channel->topic,
silc_hash_table_list_reset(&htl);
}
- /* Send notify to the primary router */
+ /* The notify is sent to local servers (not clients), and to network. */
if (atype && tmp && len2) {
silc_buffer_set(&alist, tmp, len2);
+
+ /* Send to local servers if we are router */
+ if (server->server_type == SILC_ROUTER) {
+ SilcBuffer idp, idp2;
+ idp = silc_id_payload_encode(channel_id, SILC_ID_CHANNEL);
+ idp2 = silc_id_payload_encode(sender->id, SILC_ID_CLIENT);
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, FALSE,
+ SILC_NOTIFY_TYPE_INVITE, 5,
+ idp->data, idp->len,
+ channel->channel_name,
+ strlen(channel->channel_name),
+ idp2->data, idp2->len,
+ atype, 1,
+ tmp ? alist.data : NULL,
+ tmp ? alist.len : 0);
+ silc_buffer_free(idp);
+ silc_buffer_free(idp2);
+ }
+
+ /* Send to network */
silc_server_send_notify_invite(server, SILC_PRIMARY_ROUTE(server),
SILC_BROADCAST(server), channel,
sender->id, atype,
we are router then this will send it to local clients and local
servers. */
SILC_LOG_DEBUG(("Send JOIN notify to channel"));
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_JOIN, 2,
clidp->data, clidp->len,
chidp->data, chidp->len);
if (founder) {
SILC_PUT32_MSB(chl->mode, mode);
SILC_LOG_DEBUG(("Send CUMODE_CHANGE notify to channel"));
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CUMODE_CHANGE, 4,
clidp->data, clidp->len,
mode, 4, 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, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
cidp->data, cidp->len,
tmp_mask, 4,
/* Send notify to channel, notify only if mode was actually changed. */
if (notify) {
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CUMODE_CHANGE, 4,
idp->data, idp->len,
tmp_mask, 4,
/* Send KICKED notify to local clients on the channel */
idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_KICKED, 3,
target_idp, target_idp_len,
comment, comment ? strlen(comment) : 0,
silc_hash_table_list_reset(&htl);
}
- /* Send the BAN notify type to our primary router. */
+ /* Send BAN notify type to local servers (but not clients) and to
+ network. */
if (atype && tmp && len2) {
silc_buffer_set(&blist, tmp, len2);
+
+ /* Send to local servers if we are router */
+ if (server->server_type == SILC_ROUTER)
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, FALSE,
+ SILC_NOTIFY_TYPE_BAN, 3,
+ id, id_len,
+ atype, 1,
+ tmp ? blist.data : NULL,
+ tmp ? blist.len : 0);
+
+ /* Send to network. */
silc_server_send_notify_ban(server, SILC_PRIMARY_ROUTE(server),
SILC_BROADCAST(server), channel, atype,
&blist);
/* Send to channel */
silc_server_packet_send_to_channel(server, sock, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
if (server->server_type != SILC_ROUTER &&
/* Send the leave notify to channel */
silc_server_packet_send_to_channel(server, sock, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
/* Remove the user from channel */
/* Send the same notify to the channel */
silc_server_packet_send_to_channel(server, NULL, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
break;
break;
sidp = silc_id_payload_encode(server->router->id, SILC_ID_SERVER);
SILC_PUT32_MSB(channel->mode, mask);
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
sidp->data, sidp->len,
mask, 4,
/* Send the same notify to the channel */
silc_server_packet_send_to_channel(server, NULL, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
/* Change mode */
if (!notify_sent)
silc_server_packet_send_to_channel(server, NULL, channel,
packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
silc_free(channel_id);
silc_free(client_id);
/* Get user's channel entry and check that inviting is allowed. */
- if (!silc_server_client_on_channel(client, channel, &chl))
- goto out;
- if (channel->mode & SILC_CHANNEL_MODE_INVITE &&
- !(chl->mode & SILC_CHANNEL_UMODE_CHANOP) &&
- !(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
- SILC_LOG_DEBUG(("Inviting is not allowed"));
- goto out;
+ if (server->server_type == SILC_ROUTER) {
+ if (!silc_server_client_on_channel(client, channel, &chl))
+ goto out;
+ if (channel->mode & SILC_CHANNEL_MODE_INVITE &&
+ !(chl->mode & SILC_CHANNEL_UMODE_CHANOP) &&
+ !(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
+ SILC_LOG_DEBUG(("Inviting is not allowed"));
+ goto out;
+ }
}
/* Get the invite action */
silc_server_inviteban_process(server, channel->invite_list, action,
iargs);
silc_argument_payload_free(iargs);
+
+ /* If we are router we must send this notify to our local servers on
+ the channel. Normal server does nothing. The notify is not
+ sent to clients. */
+ if (server->server_type == SILC_ROUTER)
+ silc_server_packet_send_to_channel(server, sock, channel,
+ packet->type, FALSE, FALSE,
+ packet->buffer->data,
+ packet->buffer->len, FALSE);
}
break;
/* Send the notify to the channel */
silc_server_packet_send_to_channel(server, sock, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
/* Get the new Channel ID */
/* Send to channel */
silc_server_packet_send_to_channel(server, sock, channel, packet->type,
- FALSE, packet->buffer->data,
+ FALSE, TRUE, packet->buffer->data,
packet->buffer->len, FALSE);
/* Remove the client from channel's invite list */
silc_server_inviteban_process(server, channel->ban_list, action,
iargs);
silc_argument_payload_free(iargs);
+
+ /* If we are router we must send this notify to our local servers on
+ the channel. Normal server does nothing. The notify is not
+ sent to clients. */
+ if (server->server_type == SILC_ROUTER)
+ silc_server_packet_send_to_channel(server, sock, channel,
+ packet->type, FALSE, FALSE,
+ packet->buffer->data,
+ packet->buffer->len, FALSE);
}
break;
SilcChannelEntry channel,
SilcPacketType type,
bool route,
+ bool send_to_clients,
unsigned char *data,
SilcUInt32 data_len,
bool force_send)
continue;
}
- if (client->router)
+ if (client->router || !send_to_clients)
continue;
/* Send to locally connected client */
SilcSocketConnection sender,
SilcChannelEntry channel,
bool route_notify,
+ bool send_to_clients,
SilcNotifyType type,
SilcUInt32 argc, ...)
{
packet = silc_notify_payload_encode(type, argc, ap);
silc_server_packet_send_to_channel(server, sender, channel,
SILC_PACKET_NOTIFY, route_notify,
+ send_to_clients,
packet->data, packet->len, FALSE);
silc_buffer_free(packet);
va_end(ap);
channel->key_len / 8, channel->key);
silc_server_packet_send_to_channel(server, sender, channel,
SILC_PACKET_CHANNEL_KEY,
- route, packet->data, packet->len,
+ route, TRUE, packet->data, packet->len,
FALSE);
silc_buffer_free(packet);
silc_free(chid);
SilcChannelEntry channel,
SilcPacketType type,
bool route,
+ bool send_to_clients,
unsigned char *data,
SilcUInt32 data_len,
bool force_send);
SilcSocketConnection sender,
SilcChannelEntry channel,
bool route_notify,
+ bool send_to_clients,
SilcNotifyType type,
SilcUInt32 argc, ...);
void silc_server_send_notify_on_channels(SilcServer server,
!silc_server_channel_has_local(channel)) {
/* Notify about leaving client if this channel has global users. */
if (notify && channel->global_users)
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_SIGNOFF,
signoff_message ? 2 : 1,
clidp->data, clidp->len,
/* Send notify to channel about client leaving SILC and channel too */
if (notify)
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_SIGNOFF,
signoff_message ? 2 : 1,
clidp->data, clidp->len,
!silc_server_channel_has_local(channel)) {
/* Notify about leaving client if this channel has global users. */
if (notify && channel->global_users)
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
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, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_LEAVE, 1,
clidp->data, clidp->len);
idp1 = silc_id_payload_encode(server->id, SILC_ID_SERVER);
idp2 = silc_id_payload_encode(chl->client->id, SILC_ID_CLIENT);
SILC_PUT32_MSB(forced_mode, cumode);
- silc_server_send_notify_to_channel(server, sock, channel, FALSE,
+ silc_server_send_notify_to_channel(server, sock, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CUMODE_CHANGE,
3, idp1->data, idp1->len,
cumode, sizeof(cumode),
/* Send notify that removes the old list */
sidp = silc_id_payload_encode(server->id, SILC_ID_SERVER);
SILC_PUT32_MSB((channel->mode & (~SILC_CHANNEL_MODE_CHANNEL_AUTH)), mask);
- silc_server_send_notify_to_channel(server, NULL, channel, FALSE,
+ silc_server_send_notify_to_channel(server, NULL, channel, FALSE, TRUE,
SILC_NOTIFY_TYPE_CMODE_CHANGE, 7,
sidp->data, sidp->len,
mask, 4,