updated copyright years and pekka's email on some files
[silc.git] / apps / silcd / server_backup.c
index 9591cade0aa9892a272b6cef4afd7a1e8674b2d8..6d12da6f741aaed808effdb7f43f1f1a6e923a05 100644 (file)
@@ -4,7 +4,7 @@
 
   Author: Pekka Riikonen <priikone@silcnet.org>
 
-  Copyright (C) 2001 Pekka Riikonen
+  Copyright (C) 2001 - 2002 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
@@ -27,7 +27,7 @@ SILC_TASK_CALLBACK(silc_server_protocol_backup_done);
 typedef struct {
   SilcServerEntry server;
   SilcIDIP ip;
-  uint16 port;
+  SilcUInt16 port;
   bool local;
 } SilcServerBackupEntry;
 
@@ -35,20 +35,20 @@ typedef struct {
    by backup router. */
 typedef struct {
   SilcIDIP ip;
-  uint16 port;
+  SilcUInt16 port;
   SilcServerEntry server;      /* Backup router that replaced the primary */
 } SilcServerBackupReplaced;
 
 /* Backup context */
 struct SilcServerBackupStruct {
   SilcServerBackupEntry *servers;
-  uint32 servers_count;
+  SilcUInt32 servers_count;
   SilcServerBackupReplaced **replaced;
-  uint32 replaced_count;
+  SilcUInt32 replaced_count;
 };
 
 typedef struct {
-  uint8 session;
+  SilcUInt8 session;
   bool connected;
   SilcServerEntry server_entry;
 } SilcServerBackupProtocolSession;
@@ -58,10 +58,10 @@ typedef struct {
   SilcServer server;
   SilcSocketConnection sock;
   bool responder;
-  uint8 type;
-  uint8 session;
+  SilcUInt8 type;
+  SilcUInt8 session;
   SilcServerBackupProtocolSession *sessions;
-  uint32 sessions_count;
+  SilcUInt32 sessions_count;
   long start;
 } *SilcServerBackupProtocolContext;
 
@@ -270,6 +270,7 @@ void silc_server_backup_broadcast(SilcServer server,
   SilcServerEntry backup;
   SilcSocketConnection sock;
   SilcBuffer buffer;
+  const SilcBufferStruct p;
   SilcIDListData idata;
   int i;
 
@@ -291,13 +292,16 @@ void silc_server_backup_broadcast(SilcServer server,
     idata = (SilcIDListData)backup;
     sock = backup->connection;
 
-    silc_packet_send_prepare(sock, 0, 0, buffer->len); 
-    silc_buffer_put(sock->outbuf, buffer->data, buffer->len);
+    if (!silc_packet_send_prepare(sock, 0, 0, buffer->len, idata->hmac_send,
+                                 (const SilcBuffer)&p)) {
+      SILC_LOG_ERROR(("Cannot send packet"));
+      return;
+    }
+    silc_buffer_put((SilcBuffer)&p, buffer->data, buffer->len);
     silc_packet_encrypt(idata->send_key, idata->hmac_send, idata->psn_send++, 
-                       sock->outbuf, sock->outbuf->len);
+                       (SilcBuffer)&p, p.len);
 
-    SILC_LOG_HEXDUMP(("Broadcasted packet, len %d", sock->outbuf->len),
-                    sock->outbuf->data, sock->outbuf->len);
+    SILC_LOG_HEXDUMP(("Broadcasted packet, len %d", p.len), p.data, p.len);
 
     /* Now actually send the packet */
     silc_server_packet_send_real(server, sock, FALSE);
@@ -319,7 +323,7 @@ void silc_server_backup_send(SilcServer server,
                             SilcPacketType type,
                             SilcPacketFlags flags,
                             unsigned char *data,
-                            uint32 data_len,
+                            SilcUInt32 data_len,
                             bool force_send,
                             bool local)
 {
@@ -361,7 +365,7 @@ void silc_server_backup_send_dest(SilcServer server,
                                  void *dst_id,
                                  SilcIdType dst_id_type,
                                  unsigned char *data,
-                                 uint32 data_len,
+                                 SilcUInt32 data_len,
                                  bool force_send,
                                  bool local)
 {
@@ -400,7 +404,7 @@ void silc_server_backup_resume_router(SilcServer server,
                                      SilcSocketConnection sock, 
                                      SilcPacketContext *packet)
 {
-  uint8 type, session;
+  SilcUInt8 type, session;
   SilcServerBackupProtocolContext ctx;
   int i, ret;
 
@@ -544,7 +548,7 @@ SILC_TASK_CALLBACK(silc_server_backup_connect_to_router)
    connection is created. */
 
 void silc_server_backup_reconnect(SilcServer server,
-                                 const char *ip, uint16 port,
+                                 const char *ip, SilcUInt16 port,
                                  SilcServerConnectRouterCallback callback,
                                  void *context)
 {
@@ -682,7 +686,7 @@ SILC_TASK_CALLBACK(silc_server_backup_send_resumed)
 
    SILC_PACKET_RESUME_ROUTER:
 
-   <uint8 type> <uint8 Session ID>
+   <SilcUInt8 type> <SilcUInt8 Session ID>
 
    <type>          = the protocol opcode
    <Session ID>    = Identifier for this packet and any subsequent reply