Some bugfixes.
[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 /* 
32    SILC Server Object.
33
34 */
35 typedef struct SilcServerObjectStruct {
36   char *server_name;
37   int server_type;
38   int sock;
39   int standalone;
40   int listenning;
41   SilcServerID *id;
42   SilcIdType id_type;
43   SilcServerEntry id_entry;
44
45   /* SILC server task queues */
46   SilcTaskQueue io_queue;
47   SilcTaskQueue timeout_queue;
48   SilcTaskQueue generic_queue;
49
50   /* ID lists. */
51   SilcIDList local_list;
52   SilcIDList global_list;
53
54   /* Table of connected sockets */
55   SilcSocketConnection *sockets;
56
57   /* Server keys */
58   SilcCipher send_key;
59   SilcCipher receive_key;
60   SilcCipher none_cipher;
61
62   /* Server public key */
63   SilcPKCS pkcs;
64   SilcPublicKey public_key;
65   SilcPrivateKey private_key;
66
67   /* Hash objects for general hashing */
68   SilcHash md5hash;
69   SilcHash sha1hash;
70
71   /* HMAC objects for MAC's. */
72   SilcHmac md5hmac;
73   SilcHmac sha1hmac;
74
75   /* Configuration object */
76   SilcConfigServer config;
77
78   /* Random pool */
79   SilcRng rng;
80
81   /* Server statistics */
82   SilcServerStatistics stats;
83
84 #ifdef SILC_SIM
85   /* SIM (SILC Module) list */
86   SilcDList sim;
87 #endif
88 } SilcServerObject;
89
90 /* Macros */
91
92 /* Registers generic task for file descriptor for reading from network and
93    writing to network. As being generic task the actual task is allocated 
94    only once and after that the same task applies to all registered fd's. */
95 #define SILC_REGISTER_CONNECTION_FOR_IO(fd)                             \
96 do {                                                                    \
97   SilcTask tmptask = silc_task_register(server->generic_queue, (fd),    \
98                                         silc_server_packet_process,     \
99                                         context, 0, 0,                  \
100                                         SILC_TASK_GENERIC,              \
101                                         SILC_TASK_PRI_NORMAL);          \
102   silc_task_set_iotype(tmptask, SILC_TASK_WRITE);                       \
103 } while(0)
104
105 #define SILC_SET_CONNECTION_FOR_INPUT(fd)                               \
106 do {                                                                    \
107   silc_schedule_set_listen_fd((fd), (1L << SILC_TASK_READ));            \
108 } while(0)
109      
110 #define SILC_SET_CONNECTION_FOR_OUTPUT(fd)                              \
111 do {                                                                    \
112   silc_schedule_set_listen_fd((fd), ((1L << SILC_TASK_READ) |           \
113                                      (1L << SILC_TASK_WRITE)));         \
114 } while(0)
115
116 /* Prototypes */
117
118 #endif