Fixed KILLED notify handling in normal server.
[silc.git] / apps / silcd / server_internal.h
index c435c77622a9a0b46207d8557c643bbdf57ce4a7..1d679b0b30a5bbeaa2c127a226614fe654ccaeba 100644 (file)
@@ -55,8 +55,8 @@ typedef struct {
   SilcUInt32 conn_failures;              /* Connection failure */
   SilcUInt32 auth_attempts;              /* Authentication attempts */
   SilcUInt32 auth_failures;              /* Authentication failures */
-  SilcUInt32 packets_sent;               /* Sent packets */
-  SilcUInt32 packets_received;           /* Received packets */
+  SilcUInt32 packets_sent;               /* Sent SILC packets */
+  SilcUInt32 packets_received;           /* Received SILC packets */
 } SilcServerStatistics;
 
 /*
@@ -65,28 +65,28 @@ typedef struct {
 */
 struct SilcServerStruct {
   char *server_name;
-  int server_type;
   int sock;
+  SilcServerEntry id_entry;
   SilcServerID *id;
   unsigned char *id_string;
   SilcUInt32 id_string_len;
-  SilcIdType id_type;
-
   SilcUInt32 starttime;
-  bool standalone;                  /* TRUE if server is standalone, and
+
+  unsigned int server_type    : 2;   /* Server type (server.h) */
+  unsigned int standalone     : 1;   /* Set if server is standalone, and
                                        does not have connection to network. */
-  bool listenning;                  /* TRUE if server is listenning for
+  unsigned int listenning     : 1;   /* Set if server is listenning for
                                        incoming connections. */
-  bool background;
-  SilcServerEntry id_entry;         /* Server's own ID entry */
+  unsigned int background     : 1;   /* Set when server is on background */
+  unsigned int backup_router  : 1;   /* Set if this is backup router */
+  unsigned int backup_primary : 1;   /* Set if we've switched our primary
+                                       router to a backup router. */
+
   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. */
+  SilcServerBackup backup;          /* Backup routers */
 
   /* Current command identifier, 0 not used */
   SilcUInt16 cmd_ident;
@@ -129,6 +129,10 @@ struct SilcServerStruct {
   /* Pending command queue */
   SilcDList pending_commands;
 
+  /* Purge context for disconnected clients */
+  SilcIDListPurge purge_i;
+  SilcIDListPurge purge_g;
+
 #ifdef SILC_SIM
   /* SIM (SILC Module) list */
   SilcDList sim;
@@ -151,6 +155,18 @@ typedef struct {
 
 /* Macros */
 
+/* Return pointer to the primary router connection */
+#define SILC_PRIMARY_ROUTE(server) \
+  (!server->standalone && server->router ? server->router->connection : NULL)
+
+/* Return TRUE if a packet must be broadcasted (router broadcasts) */
+#define SILC_BROADCAST(server) (server->server_type == SILC_ROUTER) 
+
+/* Return TRUE if entry is locally connected or local to us */
+#define SILC_IS_LOCAL(entry)                                           \
+  ((entry)->connection ? TRUE :                                                \
+   (entry)->data.status & SILC_IDLIST_STATUS_LOCAL ? TRUE : FALSE)
+
 /* Registers generic task for file descriptor for reading from network and
    writing to network. As being generic task the actual task is allocated 
    only once and after that the same task applies to all registered fd's. */
@@ -176,7 +192,7 @@ do {                                                                              \
 #define SILC_OPER_STATS_UPDATE(c, type, mod)   \
 do {                                           \
   if ((c)->mode & (mod)) {                     \
-    if ((c)->connection)                       \
+    if (SILC_IS_LOCAL((c)))                    \
       server->stat.my_ ## type ## _ops--;      \
     if (server->server_type == SILC_ROUTER)    \
       server->stat. type ## _ops--;            \
@@ -188,14 +204,14 @@ do {                                              \
 do {                                           \
     if (client->mode & (mod)) {                        \
       if (!(mode & (mod))) {                   \
-       if (client->connection)                 \
+       if (SILC_IS_LOCAL(client))              \
          server->stat.my_ ## oper ## _ops--;   \
         if (server->server_type == SILC_ROUTER)        \
          server->stat. oper ## _ops--;         \
       }                                                \
     } else {                                   \
       if (mode & (mod)) {                      \
-       if (client->connection)                 \
+       if (SILC_IS_LOCAL(client))              \
          server->stat.my_ ## oper ## _ops++;   \
         if (server->server_type == SILC_ROUTER)        \
          server->stat. oper ## _ops++;         \