+ va_end(ap);
+}
+
+/* Sends notify message and gets the arguments from the `args' Argument
+ Payloads. */
+
+void silc_server_send_notify_args(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcNotifyType type,
+ uint32 argc,
+ SilcBuffer args)
+{
+ SilcBuffer packet;
+
+ packet = silc_notify_payload_encode_args(type, argc, args);
+ silc_server_packet_send(server, sock, SILC_PACKET_NOTIFY,
+ broadcast ? SILC_PACKET_FLAG_BROADCAST : 0,
+ packet->data, packet->len, FALSE);
+ silc_buffer_free(packet);
+}
+
+/* Send CHANNEL_CHANGE notify type. This tells the receiver to replace the
+ `old_id' with the `new_id'. */
+
+void silc_server_send_notify_channel_change(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelID *old_id,
+ SilcChannelID *new_id)
+{
+ SilcBuffer idp1, idp2;
+
+ idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CHANNEL);
+ idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CHANNEL);
+
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_CHANNEL_CHANGE,
+ 2, idp1->data, idp1->len, idp2->data, idp2->len);
+ silc_buffer_free(idp1);
+ silc_buffer_free(idp2);
+}
+
+/* Send NICK_CHANGE notify type. This tells the receiver to replace the
+ `old_id' with the `new_id'. */
+
+void silc_server_send_notify_nick_change(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcClientID *old_id,
+ SilcClientID *new_id)
+{
+ SilcBuffer idp1, idp2;
+
+ idp1 = silc_id_payload_encode((void *)old_id, SILC_ID_CLIENT);
+ idp2 = silc_id_payload_encode((void *)new_id, SILC_ID_CLIENT);
+
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_NICK_CHANGE,
+ 2, idp1->data, idp1->len, idp2->data, idp2->len);
+ silc_buffer_free(idp1);
+ silc_buffer_free(idp2);
+}
+
+/* Sends JOIN notify type. This tells that new client by `client_id' ID
+ has joined to the `channel'. */
+
+void silc_server_send_notify_join(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ SilcClientID *client_id)
+{
+ SilcBuffer idp1, idp2;
+
+ idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ idp2 = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
+ silc_server_send_notify(server, sock, broadcast, SILC_NOTIFY_TYPE_JOIN,
+ 2, idp1->data, idp1->len,
+ idp2->data, idp2->len);
+ silc_buffer_free(idp1);
+ silc_buffer_free(idp2);
+}
+
+/* Sends LEAVE notify type. This tells that `client_id' has left the
+ `channel'. The Notify packet is always destined to the channel. */
+
+void silc_server_send_notify_leave(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ SilcClientID *client_id)
+{
+ SilcBuffer idp;
+
+ idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
+ SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_LEAVE,
+ 1, idp->data, idp->len);
+ silc_buffer_free(idp);
+}
+
+/* Sends CMODE_CHANGE notify type. This tells that `client_id' changed the
+ `channel' mode to `mode. The Notify packet is always destined to
+ the channel. */
+
+void silc_server_send_notify_cmode(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ uint32 mode_mask,
+ void *id, SilcIdType id_type,
+ char *cipher, char *hmac,
+ char *passphrase)
+{
+ SilcBuffer idp;
+ unsigned char mode[4];
+
+ idp = silc_id_payload_encode((void *)id, id_type);
+ SILC_PUT32_MSB(mode_mask, mode);
+
+ silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
+ SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_CMODE_CHANGE,
+ 5, idp->data, idp->len,
+ mode, 4,
+ cipher, cipher ? strlen(cipher) : 0,
+ hmac, hmac ? strlen(hmac) : 0,
+ passphrase, passphrase ?
+ strlen(passphrase) : 0);
+ silc_buffer_free(idp);
+}
+
+/* Sends CUMODE_CHANGE notify type. This tells that `client_id' changed the
+ `target' client's mode on `channel'. The notify packet is always
+ destined to the channel. */
+
+void silc_server_send_notify_cumode(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ uint32 mode_mask,
+ void *id, SilcIdType id_type,
+ SilcClientID *target)
+{
+ SilcBuffer idp1, idp2;
+ unsigned char mode[4];
+
+ idp1 = silc_id_payload_encode((void *)id, id_type);
+ idp2 = silc_id_payload_encode((void *)target, SILC_ID_CLIENT);
+ SILC_PUT32_MSB(mode_mask, mode);
+
+ silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
+ SILC_ID_CHANNEL,
+ SILC_NOTIFY_TYPE_CUMODE_CHANGE, 3,
+ idp1->data, idp1->len,
+ mode, 4,
+ idp2->data, idp2->len);
+ silc_buffer_free(idp1);
+ silc_buffer_free(idp2);
+}
+
+/* Sends SIGNOFF notify type. This tells that `client_id' client has
+ left SILC network. This function is used only between server and router
+ traffic. This is not used to send the notify to the channel for
+ client. The `message may be NULL. */
+
+void silc_server_send_notify_signoff(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcClientID *client_id,
+ const char *message)
+{
+ SilcBuffer idp;
+
+ idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_SIGNOFF,
+ message ? 2 : 1, idp->data, idp->len,
+ message, message ? strlen(message): 0);
+ silc_buffer_free(idp);
+}
+
+/* Sends TOPIC_SET notify type. This tells that `id' changed
+ the `channel's topic to `topic'. The Notify packet is always destined
+ to the channel. This function is used to send the topic set notifies
+ between routers. */
+
+void silc_server_send_notify_topic_set(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ void *id, SilcIdType id_type,
+ char *topic)
+{
+ SilcBuffer idp;
+
+ idp = silc_id_payload_encode(id, id_type);
+ silc_server_send_notify_dest(server, sock, broadcast,
+ (void *)channel->id, SILC_ID_CHANNEL,
+ SILC_NOTIFY_TYPE_TOPIC_SET,
+ topic ? 2 : 1,
+ idp->data, idp->len,
+ topic, topic ? strlen(topic) : 0);
+ silc_buffer_free(idp);
+}
+
+/* Send KICKED notify type. This tells that the `client_id' on `channel'
+ was kicked off the channel. The `comment' may indicate the reason
+ for the kicking. This function is used only between server and router
+ traffic. */
+
+void silc_server_send_notify_kicked(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ SilcClientID *client_id,
+ SilcClientID *kicker,
+ char *comment)
+{
+ SilcBuffer idp1;
+ SilcBuffer idp2;
+
+ idp1 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ idp2 = silc_id_payload_encode((void *)kicker, SILC_ID_CLIENT);
+ silc_server_send_notify_dest(server, sock, broadcast, (void *)channel->id,
+ SILC_ID_CHANNEL, SILC_NOTIFY_TYPE_KICKED, 3,
+ idp1->data, idp1->len,
+ comment, comment ? strlen(comment) : 0,
+ idp2->data, idp2->len);
+ silc_buffer_free(idp1);
+ silc_buffer_free(idp2);
+}
+
+/* Send KILLED notify type. This tells that the `client_id' client was
+ killed from the network. The `comment' may indicate the reason
+ for the killing. */
+
+void silc_server_send_notify_killed(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcClientID *client_id,
+ char *comment)
+{
+ SilcBuffer idp;
+
+ idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ silc_server_send_notify_dest(server, sock, broadcast, (void *)client_id,
+ SILC_ID_CLIENT, SILC_NOTIFY_TYPE_KILLED,
+ comment ? 2 : 1, idp->data, idp->len,
+ comment, comment ? strlen(comment) : 0);
+ silc_buffer_free(idp);
+}
+
+/* Sends UMODE_CHANGE notify type. This tells that `client_id' client's
+ user mode in the SILC Network was changed. This function is used to
+ send the packet between routers as broadcast packet. */
+
+void silc_server_send_notify_umode(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcClientID *client_id,
+ uint32 mode_mask)
+{
+ SilcBuffer idp;
+ unsigned char mode[4];
+
+ idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ SILC_PUT32_MSB(mode_mask, mode);
+
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_UMODE_CHANGE, 2,
+ idp->data, idp->len,
+ mode, 4);
+ silc_buffer_free(idp);
+}
+
+/* Sends BAN notify type. This tells that ban has been either `add'ed
+ or `del'eted on the `channel. This function is used to send the packet
+ between routers as broadcast packet. */
+
+void silc_server_send_notify_ban(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ char *add, char *del)
+{
+ SilcBuffer idp;
+
+ idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_BAN, 3,
+ idp->data, idp->len,
+ add, add ? strlen(add) : 0,
+ del, del ? strlen(del) : 0);
+ silc_buffer_free(idp);
+}
+
+/* Sends INVITE notify type. This tells that invite has been either `add'ed
+ or `del'eted on the `channel. The sender of the invite is the `client_id'.
+ This function is used to send the packet between routers as broadcast
+ packet. */
+
+void silc_server_send_notify_invite(SilcServer server,
+ SilcSocketConnection sock,
+ bool broadcast,
+ SilcChannelEntry channel,
+ SilcClientID *client_id,
+ char *add, char *del)
+{
+ SilcBuffer idp, idp2;
+
+ idp = silc_id_payload_encode((void *)channel->id, SILC_ID_CHANNEL);
+ idp2 = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+ silc_server_send_notify(server, sock, broadcast,
+ SILC_NOTIFY_TYPE_INVITE, 5,
+ idp->data, idp->len,
+ channel->channel_name, strlen(channel->channel_name),
+ idp2->data, idp2->len,
+ add, add ? strlen(add) : 0,
+ del, del ? strlen(del) : 0);
+ silc_buffer_free(idp);
+ silc_buffer_free(idp2);