updates.
[silc.git] / apps / silcd / server_internal.h
index cc0b00e3c586723fb9dedd7c2b4c31a9e8a723aa..e50340b839c88f4fea73433686170124d8999ec2 100644 (file)
@@ -56,21 +56,6 @@ typedef struct {
   uint32 packets_received;       /* Received packets */
 } SilcServerStatistics;
 
-typedef struct {
-  SilcSocketConnection sock;
-
-  /* Remote host name and port */
-  char *remote_host;
-  int remote_port;
-  
-  /* Current connection retry info */
-  uint32 retry_count;
-  uint32 retry_timeout;
-
-  /* Back pointer to server */
-  SilcServer server;
-} *SilcServerConnection;
-
 /* 
    SILC Server Object.
 
@@ -79,22 +64,28 @@ struct SilcServerStruct {
   char *server_name;
   int server_type;
   int sock;
-  int standalone;
-  int listenning;
   SilcServerID *id;
   unsigned char *id_string;
   uint32 id_string_len;
   SilcIdType id_type;
 
+  bool standalone;                  /* TRUE if server is standalone, and
+                                       does not have connection to network. */
+  bool listenning;                  /* TRUE if server is listenning for
+                                       incoming connections. */
+  SilcServerEntry id_entry;         /* Server's own ID entry */
+  SilcServerEntry router;           /* Pointer to the primary router */
+  unsigned long router_connect;             /* Time when router was connected */
+  SilcServerBackup backup;          /* Backup routers */
+  bool backup_router;               /* TRUE if this is backup router */
+  bool backup_primary;              /* TRUE if we've switched our primary
+                                       router to a backup router. */
+  SilcServerConnection router_conn; /* non-NULL when connecting to the
+                                      primary router, and NULL otherwise. */
+
   /* Current command identifier, 0 not used */
   uint16 cmd_ident;
 
-  /* Server's own ID entry. */
-  SilcServerEntry id_entry;
-
-  /* Back pointer to the primary router of this server. */
-  SilcServerEntry router;
-
   /* SILC server scheduler */
   SilcSchedule schedule;
 
@@ -182,6 +173,16 @@ do {                                                                             \
   silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE)); \
 } while(0)
 
+#define SILC_OPER_STATS_UPDATE(c, type, mod)   \
+do {                                           \
+  if ((c)->mode & (mod)) {                     \
+    if ((c)->connection)                       \
+      server->stat.my_ ## type ## _ops--;      \
+    if (server->server_type == SILC_ROUTER)    \
+      server->stat. type ## _ops--;            \
+  }                                            \
+} while(0)
+
 /* Prototypes */
 SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_final);