Code auditing weekend results and fixes committing.
[silc.git] / apps / silcd / packet_send.c
index 23c51d5c38543cf53b0c1dc3df8de8d883de2efb..12e689462455dc4180442be54cc3ffed08a66446 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
 
-  Copyright (C) 1997 - 2000 Pekka Riikonen
+  Copyright (C) 1997 - 2001 Pekka Riikonen
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -197,7 +197,7 @@ void silc_server_packet_broadcast(SilcServer server,
 
   /* If the packet is originated from our primary route we are
      not allowed to send the packet. */
-  id = silc_id_str2id(packet->src_id, packet->src_id_type);
+  id = silc_id_str2id(packet->src_id, packet->src_id_len, packet->src_id_type);
   if (id && SILC_ID_SERVER_COMPARE(id, server->router->id)) {
     idata = (SilcIDListData)sock->user_data;
 
@@ -1177,3 +1177,33 @@ void silc_server_send_remove_id(SilcServer server,
                          idp->data, idp->len, FALSE);
   silc_buffer_free(idp);
 }
+
+/* Function used to send SET_MODE packet. The packet is used to notify routers
+   that channel's or client's channel mode was changed. If the argument
+   `broadcast' is TRUE then the packet is sent as broadcast packet. */
+
+void silc_server_send_set_mode(SilcServer server,
+                              SilcSocketConnection sock,
+                              int broadcast,
+                              int mode_type, unsigned int mode_mask,
+                              unsigned int argc, ...)
+{
+  SilcBuffer packet;
+  va_list ap;
+
+  SILC_LOG_DEBUG(("Start"));
+
+  va_start(ap, argc);
+
+  /* Encode Set Mode payload */
+  packet = silc_set_mode_payload_encode(mode_type, mode_mask, argc, ap);
+  if (!packet)
+    return;
+
+  /* Send the packet */
+  silc_server_packet_send(server, sock, SILC_PACKET_SET_MODE, 
+                         broadcast ? SILC_PACKET_FLAG_BROADCAST : 0, 
+                         packet->data, packet->len, FALSE);
+
+  silc_buffer_free(packet);
+}