Fixed silc_server_packet_broadcast to sen correct broadcast
[silc.git] / apps / silcd / server_internal.h
1 /*
2
3   server_internal.h
4
5   Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
6
7   Copyright (C) 1997 - 2000 Pekka Riikonen
8
9   This program is free software; you can redistribute it and/or modify
10   it under the terms of the GNU General Public License as published by
11   the Free Software Foundation; either version 2 of the License, or
12   (at your option) any later version.
13   
14   This program is distributed in the hope that it will be useful,
15   but WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   GNU General Public License for more details.
18
19 */
20
21 #ifndef SERVER_INTERNAL_H
22 #define SERVER_INTERNAL_H
23
24 /* Server statistics structure. This holds various statistics about
25    various things. */
26 /* XXX TODO */
27 typedef struct {
28
29 } SilcServerStatistics;
30
31 typedef struct {
32   void *id_entry;
33   SilcSocketConnection sock;
34
35   /* Remote host name and port */
36   char *remote_host;
37   int remote_port;
38   
39   /* Current connection retry info */
40   unsigned int retry_count;
41   unsigned int retry_timeout;
42
43   /* Back pointer to server */
44   SilcServer server;
45 } *SilcServerConnection;
46
47 /* 
48    SILC Server Object.
49
50 */
51 struct SilcServerStruct {
52   char *server_name;
53   int server_type;
54   int sock;
55   int standalone;
56   int listenning;
57   SilcServerID *id;
58   SilcIdType id_type;
59
60   /* Server's own ID entry. */
61   SilcServerEntry id_entry;
62
63   /* Back pointer to the primary router of this server. */
64   SilcServerEntry router;
65
66   /* SILC server task queues */
67   SilcTaskQueue io_queue;
68   SilcTaskQueue timeout_queue;
69   SilcTaskQueue generic_queue;
70
71   /* ID lists. */
72   SilcIDList local_list;
73   SilcIDList global_list;
74
75   /* Table of connected sockets */
76   SilcSocketConnection *sockets;
77
78   /* Server keys */
79   SilcCipher send_key;
80   SilcCipher receive_key;
81   SilcCipher none_cipher;
82
83   /* Server public key */
84   SilcPKCS pkcs;
85   SilcPublicKey public_key;
86   SilcPrivateKey private_key;
87
88   /* Hash objects for general hashing */
89   SilcHash md5hash;
90   SilcHash sha1hash;
91
92   /* HMAC objects for MAC's. */
93   SilcHmac md5hmac;
94   SilcHmac sha1hmac;
95
96   /* Configuration object */
97   SilcConfigServer config;
98
99   /* Random pool */
100   SilcRng rng;
101
102   /* Server statistics */
103   SilcServerStatistics stats;
104
105   /* Pending command queue */
106   SilcDList pending_commands;
107
108   /* Default parameteres for server */
109   SilcServerParams params;
110
111 #ifdef SILC_SIM
112   /* SIM (SILC Module) list */
113   SilcDList sim;
114 #endif
115 };
116
117 /* Macros */
118
119 /* Registers generic task for file descriptor for reading from network and
120    writing to network. As being generic task the actual task is allocated 
121    only once and after that the same task applies to all registered fd's. */
122 #define SILC_REGISTER_CONNECTION_FOR_IO(fd)                             \
123 do {                                                                    \
124   SilcTask tmptask = silc_task_register(server->generic_queue, (fd),    \
125                                         silc_server_packet_process,     \
126                                         context, 0, 0,                  \
127                                         SILC_TASK_GENERIC,              \
128                                         SILC_TASK_PRI_NORMAL);          \
129   silc_task_set_iotype(tmptask, SILC_TASK_WRITE);                       \
130 } while(0)
131
132 #define SILC_SET_CONNECTION_FOR_INPUT(fd)                               \
133 do {                                                                    \
134   silc_schedule_set_listen_fd((fd), (1L << SILC_TASK_READ));            \
135 } while(0)
136      
137 #define SILC_SET_CONNECTION_FOR_OUTPUT(fd)                              \
138 do {                                                                    \
139   silc_schedule_set_listen_fd((fd), ((1L << SILC_TASK_READ) |           \
140                                      (1L << SILC_TASK_WRITE)));         \
141 } while(0)
142
143 /* Prototypes */
144
145 #endif