updates. New data types.
[silc.git] / apps / silcd / packet_send.c
index 69bd04cd7bafad2e0470750f58f43b2be9f845d7..a88eedbeac363bf0ce46ab0694529d98d77cb539 100644 (file)
@@ -65,7 +65,7 @@ void silc_server_packet_send(SilcServer server,
                             SilcPacketType type, 
                             SilcPacketFlags flags,
                             unsigned char *data, 
-                            unsigned int data_len,
+                            uint32 data_len,
                             int force_send)
 {
   void *dst_id = NULL;
@@ -107,7 +107,7 @@ void silc_server_packet_send_dest(SilcServer server,
                                  void *dst_id,
                                  SilcIdType dst_id_type,
                                  unsigned char *data, 
-                                 unsigned int data_len,
+                                 uint32 data_len,
                                  int force_send)
 {
   SilcPacketContext packetdata;
@@ -115,7 +115,7 @@ void silc_server_packet_send_dest(SilcServer server,
   SilcCipher cipher = NULL;
   SilcHmac hmac = NULL;
   unsigned char *dst_id_data = NULL;
-  unsigned int dst_id_len = 0;
+  uint32 dst_id_len = 0;
 
   SILC_LOG_DEBUG(("Sending packet, type %d", type));
 
@@ -196,7 +196,7 @@ void silc_server_packet_send_srcdest(SilcServer server,
                                     void *dst_id,
                                     SilcIdType dst_id_type,
                                     unsigned char *data, 
-                                    unsigned int data_len,
+                                    uint32 data_len,
                                     int force_send)
 {
   SilcPacketContext packetdata;
@@ -204,9 +204,9 @@ void silc_server_packet_send_srcdest(SilcServer server,
   SilcCipher cipher = NULL;
   SilcHmac hmac = NULL;
   unsigned char *dst_id_data = NULL;
-  unsigned int dst_id_len = 0;
+  uint32 dst_id_len = 0;
   unsigned char *src_id_data = NULL;
-  unsigned int src_id_len = 0;
+  uint32 src_id_len = 0;
 
   SILC_LOG_DEBUG(("Sending packet, type %d", type));
 
@@ -355,7 +355,7 @@ silc_server_packet_send_to_channel_real(SilcServer server,
                                        SilcCipher cipher,
                                        SilcHmac hmac,
                                        unsigned char *data,
-                                       unsigned int data_len,
+                                       uint32 data_len,
                                        int channel_message,
                                        int force_send)
 {
@@ -405,7 +405,7 @@ void silc_server_packet_send_to_channel(SilcServer server,
                                        SilcPacketType type,
                                        unsigned char route,
                                        unsigned char *data,
-                                       unsigned int data_len,
+                                       uint32 data_len,
                                        int force_send)
 {
   SilcSocketConnection sock = NULL;
@@ -414,7 +414,7 @@ void silc_server_packet_send_to_channel(SilcServer server,
   SilcServerEntry *routed = NULL;
   SilcChannelClientEntry chl;
   SilcIDListData idata;
-  unsigned int routed_count = 0;
+  uint32 routed_count = 0;
 
   /* This doesn't send channel message packets */
   if (type == SILC_PACKET_CHANNEL_MESSAGE)
@@ -540,7 +540,7 @@ void silc_server_packet_relay_to_channel(SilcServer server,
                                         void *sender, 
                                         SilcIdType sender_type,
                                         unsigned char *data,
-                                        unsigned int data_len,
+                                        uint32 data_len,
                                         int force_send)
 {
   int found = FALSE;
@@ -549,7 +549,7 @@ void silc_server_packet_relay_to_channel(SilcServer server,
   SilcClientEntry client = NULL;
   SilcServerEntry *routed = NULL;
   SilcChannelClientEntry chl;
-  unsigned int routed_count = 0;
+  uint32 routed_count = 0;
   SilcIDListData idata;
 
   SILC_LOG_DEBUG(("Relaying packet to channel"));
@@ -655,9 +655,9 @@ void silc_server_packet_relay_to_channel(SilcServer server,
            memcpy(tmp, data, data_len);
 
            /* Decrypt the channel message (we don't check the MAC) */
-           if (!silc_channel_payload_decrypt(tmp, data_len, 
-                                             channel->channel_key,
-                                             NULL)) {
+           if (!silc_channel_message_payload_decrypt(tmp, data_len, 
+                                                     channel->channel_key,
+                                                     NULL)) {
              memset(tmp, 0, data_len);
              silc_free(tmp);
              continue;
@@ -676,10 +676,11 @@ void silc_server_packet_relay_to_channel(SilcServer server,
          } else {
            /* Private key mode is set, we don't have the channel key, so
               just re-encrypt the entire packet and send it to the router. */
-           silc_server_packet_send_dest(server, sock, 
-                                        SILC_PACKET_CHANNEL_MESSAGE, 0,
-                                        channel->id, SILC_ID_CHANNEL,
-                                        data, data_len, force_send);
+           silc_server_packet_send_srcdest(server, sock, 
+                                           SILC_PACKET_CHANNEL_MESSAGE, 0,
+                                           sender, sender_type,
+                                           channel->id, SILC_ID_CHANNEL,
+                                           data, data_len, force_send);
          }
          continue;
        }
@@ -731,7 +732,7 @@ void silc_server_packet_send_local_channel(SilcServer server,
                                           SilcPacketType type,
                                           SilcPacketFlags flags,
                                           unsigned char *data,
-                                          unsigned int data_len,
+                                          uint32 data_len,
                                           int force_send)
 {
   SilcChannelClientEntry chl;
@@ -782,11 +783,17 @@ void silc_server_send_private_message(SilcServer server,
     silc_server_packet_send_real(server, dst_sock, FALSE);
 
   } else {
-    /* Key exist so just send it */
+    /* Key exist so encrypt just header and send it */
     silc_buffer_push(buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len 
                     + packet->dst_id_len + packet->padlen);
     silc_packet_send_prepare(dst_sock, 0, 0, buffer->len);
     silc_buffer_put(dst_sock->outbuf, buffer->data, buffer->len);
+
+    /* Encrypt header */
+    silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, 
+                       SILC_PACKET_HEADER_LEN + packet->src_id_len + 
+                       packet->dst_id_len + packet->padlen);
+
     silc_server_packet_send_real(server, dst_sock, FALSE);
   }
 }
@@ -797,7 +804,7 @@ void silc_server_send_motd(SilcServer server,
                           SilcSocketConnection sock)
 {
   char *motd;
-  int motd_len;
+  uint32 motd_len;
 
   if (server->config && server->config->motd && 
       server->config->motd->motd_file) {
@@ -840,7 +847,7 @@ void silc_server_send_notify(SilcServer server,
                             SilcSocketConnection sock,
                             int broadcast,
                             SilcNotifyType type,
-                            unsigned int argc, ...)
+                            uint32 argc, ...)
 {
   va_list ap;
   SilcBuffer packet;
@@ -853,6 +860,24 @@ void silc_server_send_notify(SilcServer server,
   silc_buffer_free(packet);
 }
 
+/* Sends notify message and gets the arguments from the `args' Argument
+   Payloads. */
+
+void silc_server_send_notify_args(SilcServer server,
+                                 SilcSocketConnection sock,
+                                 int 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, 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'. */
 
@@ -861,7 +886,7 @@ void silc_server_send_notify_channel_change(SilcServer server,
                                            int broadcast,
                                            SilcChannelID *old_id,
                                            SilcChannelID *new_id,
-                                           unsigned int id_len)
+                                           uint32 id_len)
 {
   SilcBuffer idp1, idp2;
 
@@ -883,7 +908,7 @@ void silc_server_send_notify_nick_change(SilcServer server,
                                         int broadcast,
                                         SilcClientID *old_id,
                                         SilcClientID *new_id,
-                                        unsigned int id_len)
+                                        uint32 id_len)
 {
   SilcBuffer idp1, idp2;
 
@@ -905,7 +930,7 @@ void silc_server_send_notify_join(SilcServer server,
                                  int broadcast,
                                  SilcChannelEntry channel,
                                  SilcClientID *client_id,
-                                 unsigned int client_id_len)
+                                 uint32 client_id_len)
 {
   SilcBuffer idp1, idp2;
 
@@ -926,7 +951,7 @@ void silc_server_send_notify_leave(SilcServer server,
                                   int broadcast,
                                   SilcChannelEntry channel,
                                   SilcClientID *client_id,
-                                  unsigned int client_id_len)
+                                  uint32 client_id_len)
 {
   SilcBuffer idp;
 
@@ -945,20 +970,23 @@ void silc_server_send_notify_cmode(SilcServer server,
                                   SilcSocketConnection sock,
                                   int broadcast,
                                   SilcChannelEntry channel,
-                                  unsigned int mode_mask,
-                                  SilcClientID *client_id,
-                                  unsigned int client_id_len)
+                                  uint32 mode_mask,
+                                  void *id, SilcIdType id_type,
+                                  uint32 id_len,
+                                  char *cipher, char *hmac)
 {
   SilcBuffer idp;
   unsigned char mode[4];
 
-  idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
+  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,
-                              2, idp->data, idp->len,
-                              mode, 4);
+                              4, idp->data, idp->len,
+                              mode, 4,
+                              cipher, cipher ? strlen(cipher) : 0,
+                              hmac, hmac ? strlen(hmac) : 0);
   silc_buffer_free(idp);
 }
 
@@ -970,11 +998,11 @@ void silc_server_send_notify_cumode(SilcServer server,
                                    SilcSocketConnection sock,
                                    int broadcast,
                                    SilcChannelEntry channel,
-                                   unsigned int mode_mask,
+                                   uint32 mode_mask,
                                    SilcClientID *client_id,
-                                   unsigned int client_id_len,
+                                   uint32 client_id_len,
                                    SilcClientID *target,
-                                   unsigned int target_len)
+                                   uint32 target_len)
 {
   SilcBuffer idp1, idp2;
   unsigned char mode[4];
@@ -1002,7 +1030,7 @@ void silc_server_send_notify_signoff(SilcServer server,
                                     SilcSocketConnection sock,
                                     int broadcast,
                                     SilcClientID *client_id,
-                                    unsigned int client_id_len,
+                                    uint32 client_id_len,
                                     char *message)
 {
   SilcBuffer idp;
@@ -1015,24 +1043,6 @@ void silc_server_send_notify_signoff(SilcServer server,
   silc_buffer_free(idp);
 }
 
-/* Sends SERVER_SIGNOFF notify type. This tells that `server_id' server
-   has quit SILC network. */
-
-void silc_server_send_notify_server_signoff(SilcServer server,
-                                           SilcSocketConnection sock,
-                                           int broadcast,
-                                           SilcServerID *server_id,
-                                           unsigned int server_id_len)
-{
-  SilcBuffer idp;
-
-  idp = silc_id_payload_encode((void *)server_id, SILC_ID_SERVER);
-  silc_server_send_notify(server, sock, broadcast,
-                         SILC_NOTIFY_TYPE_SERVER_SIGNOFF,
-                         1, idp->data, idp->len);
-  silc_buffer_free(idp);
-}
-
 /* Sends TOPIC_SET notify type. This tells that `client_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
@@ -1043,7 +1053,7 @@ void silc_server_send_notify_topic_set(SilcServer server,
                                       int broadcast,
                                       SilcChannelEntry channel,
                                       SilcClientID *client_id,
-                                      unsigned int client_id_len,
+                                      uint32 client_id_len,
                                       char *topic)
 {
   SilcBuffer idp;
@@ -1067,7 +1077,7 @@ void silc_server_send_notify_kicked(SilcServer server,
                                    int broadcast,
                                    SilcChannelEntry channel,
                                    SilcClientID *client_id,
-                                   unsigned int client_id_len,
+                                   uint32 client_id_len,
                                    char *comment)
 {
   SilcBuffer idp;
@@ -1080,6 +1090,100 @@ void silc_server_send_notify_kicked(SilcServer server,
   silc_buffer_free(idp);
 }
 
+/* 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,
+                                   int broadcast,
+                                   SilcClientID *client_id,
+                                   uint32 client_id_len,
+                                   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,
+                                  int broadcast,
+                                  SilcClientID *client_id,
+                                  uint32 client_id_len,
+                                  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,
+                                int 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,
+                                   int broadcast,
+                                   SilcChannelEntry channel,
+                                   SilcClientID *client_id,
+                                   uint32 client_id_len,
+                                   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);
+}
+
 /* Sends notify message destined to specific entity. */
 
 void silc_server_send_notify_dest(SilcServer server,
@@ -1088,7 +1192,7 @@ void silc_server_send_notify_dest(SilcServer server,
                                  void *dest_id,
                                  SilcIdType dest_id_type,
                                  SilcNotifyType type,
-                                 unsigned int argc, ...)
+                                 uint32 argc, ...)
 {
   va_list ap;
   SilcBuffer packet;
@@ -1114,7 +1218,7 @@ void silc_server_send_notify_to_channel(SilcServer server,
                                        SilcChannelEntry channel,
                                        unsigned char route_notify,
                                        SilcNotifyType type,
-                                       unsigned int argc, ...)
+                                       uint32 argc, ...)
 {
   va_list ap;
   SilcBuffer packet;
@@ -1128,31 +1232,33 @@ void silc_server_send_notify_to_channel(SilcServer server,
   silc_buffer_free(packet);
 }
 
-/* Send notify message to all clients the client has joined. It is quaranteed
+/* Send notify message to all channels the client has joined. It is quaranteed
    that the message is sent only once to a client (ie. if a client is joined
    on two same channel it will receive only one notify message). Also, this
    sends only to local clients (locally connected if we are server, and to
-   local servers if we are router). */
+   local servers if we are router). If `sender' is provided the packet is
+   not sent to that client at all. */
 
 void silc_server_send_notify_on_channels(SilcServer server,
+                                        SilcClientEntry sender,
                                         SilcClientEntry client,
                                         SilcNotifyType type,
-                                        unsigned int argc, ...)
+                                        uint32 argc, ...)
 {
   int k;
   SilcSocketConnection sock = NULL;
   SilcPacketContext packetdata;
   SilcClientEntry c;
   SilcClientEntry *sent_clients = NULL;
-  unsigned int sent_clients_count = 0;
+  uint32 sent_clients_count = 0;
   SilcServerEntry *routed = NULL;
-  unsigned int routed_count = 0;
+  uint32 routed_count = 0;
   SilcChannelEntry channel;
   SilcChannelClientEntry chl, chl2;
   SilcIDListData idata;
   SilcBuffer packet;
   unsigned char *data;
-  unsigned int data_len;
+  uint32 data_len;
   int force_send = FALSE;
   va_list ap;
 
@@ -1182,6 +1288,9 @@ void silc_server_send_notify_on_channels(SilcServer server,
     while ((chl2 = silc_list_get(channel->user_list)) != SILC_LIST_END) {
       c = chl2->client;
       
+      if (sender && c == sender)
+       continue;
+
       /* Check if we have sent the packet to this client already */
       for (k = 0; k < sent_clients_count; k++)
        if (sent_clients[k] == c)
@@ -1280,7 +1389,7 @@ void silc_server_send_new_id(SilcServer server,
                             SilcSocketConnection sock,
                             int broadcast,
                             void *id, SilcIdType id_type, 
-                            unsigned int id_len)
+                            uint32 id_len)
 {
   SilcBuffer idp;
 
@@ -1303,11 +1412,12 @@ void silc_server_send_new_channel(SilcServer server,
                                  int broadcast,
                                  char *channel_name,
                                  void *channel_id, 
-                                 unsigned int channel_id_len)
+                                 uint32 channel_id_len,
+                                 uint32 mode)
 {
   SilcBuffer packet;
   unsigned char *cid;
-  unsigned int name_len = strlen(channel_name);
+  uint32 name_len = strlen(channel_name);
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -1315,15 +1425,9 @@ void silc_server_send_new_channel(SilcServer server,
   if (!cid)
     return;
 
-  packet = silc_buffer_alloc(2 + 2 + name_len + channel_id_len);
-  silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
-  silc_buffer_format(packet,
-                    SILC_STR_UI_SHORT(name_len),
-                    SILC_STR_UI_XNSTRING(channel_name, name_len),
-                    SILC_STR_UI_SHORT(channel_id_len),
-                    SILC_STR_UI_XNSTRING(cid, channel_id_len),
-                    SILC_STR_END);
-
+  /* Encode the channel payload */
+  packet = silc_channel_payload_encode(channel_name, name_len,
+                                      cid, channel_id_len, mode);
 
   silc_server_packet_send(server, sock, SILC_PACKET_NEW_CHANNEL, 
                          broadcast ? SILC_PACKET_FLAG_BROADCAST : 0, 
@@ -1349,7 +1453,7 @@ void silc_server_send_channel_key(SilcServer server,
 {
   SilcBuffer packet;
   unsigned char *chid;
-  unsigned int tmp_len;
+  uint32 tmp_len;
  
   SILC_LOG_DEBUG(("Start"));
  
@@ -1376,7 +1480,7 @@ void silc_server_send_channel_key(SilcServer server,
 void silc_server_send_command(SilcServer server, 
                              SilcSocketConnection sock,
                              SilcCommand command, 
-                             unsigned int argc, ...)
+                             uint32 argc, ...)
 {
   SilcBuffer packet;
   va_list ap;
@@ -1398,17 +1502,19 @@ void silc_server_send_heartbeat(SilcServer server,
                          NULL, 0, FALSE);
 }
 
-/* Routine used to send (relay, route) key agreement packets to some 
-   destination. */
+/* Generic function to relay packet we've received. This is used to relay
+   packets to a client but generally can be used to other purposes as well. */
 
-void silc_server_send_key_agreement(SilcServer server,
-                                   SilcSocketConnection dst_sock,
-                                   SilcCipher cipher,
-                                   SilcHmac hmac,
-                                   SilcPacketContext *packet)
+void silc_server_relay_packet(SilcServer server,
+                             SilcSocketConnection dst_sock,
+                             SilcCipher cipher,
+                             SilcHmac hmac,
+                             SilcPacketContext *packet,
+                             int force_send)
 {
   silc_buffer_push(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len 
                   + packet->dst_id_len + packet->padlen);
+
   silc_packet_send_prepare(dst_sock, 0, 0, packet->buffer->len);
   silc_buffer_put(dst_sock->outbuf, packet->buffer->data, packet->buffer->len);
   
@@ -1416,26 +1522,29 @@ void silc_server_send_key_agreement(SilcServer server,
   silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, packet->buffer->len);
   
   /* Send the packet */
-  silc_server_packet_send_real(server, dst_sock, FALSE);
+  silc_server_packet_send_real(server, dst_sock, force_send);
+
+  silc_buffer_pull(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len 
+                  + packet->dst_id_len + packet->padlen);
 }
 
-/* Routine used to send (relay, route) private message key packets to some 
-   destination. */
+/* Routine used to send the connection authentication packet. */
 
-void silc_server_send_private_message_key(SilcServer server,
-                                         SilcSocketConnection dst_sock,
-                                         SilcCipher cipher,
-                                         SilcHmac hmac,
-                                         SilcPacketContext *packet)
+void silc_server_send_connection_auth_request(SilcServer server,
+                                             SilcSocketConnection sock,
+                                             uint16 conn_type,
+                                             SilcAuthMethod auth_meth)
 {
-  silc_buffer_push(packet->buffer, SILC_PACKET_HEADER_LEN + packet->src_id_len 
-                  + packet->dst_id_len + packet->padlen);
-  silc_packet_send_prepare(dst_sock, 0, 0, packet->buffer->len);
-  silc_buffer_put(dst_sock->outbuf, packet->buffer->data, packet->buffer->len);
-  
-  /* Re-encrypt packet */
-  silc_packet_encrypt(cipher, hmac, dst_sock->outbuf, packet->buffer->len);
-  
-  /* Send the packet */
-  silc_server_packet_send_real(server, dst_sock, FALSE);
+  SilcBuffer packet;
+
+  packet = silc_buffer_alloc(4);
+  silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
+  silc_buffer_format(packet,
+                    SILC_STR_UI_SHORT(conn_type),
+                    SILC_STR_UI_SHORT(auth_meth),
+                    SILC_STR_END);
+
+  silc_server_packet_send(server, sock, SILC_PACKET_CONNECTION_AUTH_REQUEST,
+                         0, packet->data, packet->len, FALSE);
+  silc_buffer_free(packet);
 }