Initial revision
[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   SilcServerList *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 public_key;
64
65   /* Hash objects for general hashing */
66   SilcHash md5hash;
67   SilcHash sha1hash;
68
69   /* HMAC objects for MAC's. */
70   SilcHmac md5hmac;
71   SilcHmac sha1hmac;
72
73   /* Configuration object */
74   SilcConfigServer config;
75
76   /* Random pool */
77   SilcRng rng;
78
79   /* Server statistics */
80   SilcServerStatistics stats;
81
82 #ifdef SILC_SIM
83   /* SIM (SILC Module) table */
84   SilcSimContext **sim;
85   unsigned int sim_count;
86 #endif
87 } SilcServerObject;
88
89 /* Macros */
90
91 /* Registers generic task for file descriptor for reading from network and
92    writing to network. As being generic task the actual task is allocated 
93    only once and after that the same task applies to all registered fd's. */
94 #define SILC_REGISTER_CONNECTION_FOR_IO(fd)                             \
95 do {                                                                    \
96   SilcTask tmptask = silc_task_register(server->generic_queue, (fd),    \
97                                         silc_server_packet_process,     \
98                                         context, 0, 0,                  \
99                                         SILC_TASK_GENERIC,              \
100                                         SILC_TASK_PRI_NORMAL);          \
101   silc_task_set_iotype(tmptask, SILC_TASK_WRITE);                       \
102 } while(0)
103
104 #define SILC_SET_CONNECTION_FOR_INPUT(fd)                               \
105 do {                                                                    \
106   silc_schedule_set_listen_fd((fd), (1L << SILC_TASK_READ));            \
107 } while(0)
108      
109 #define SILC_SET_CONNECTION_FOR_OUTPUT(fd)                              \
110 do {                                                                    \
111   silc_schedule_set_listen_fd((fd), ((1L << SILC_TASK_READ) |           \
112                                      (1L << SILC_TASK_WRITE)));         \
113 } while(0)
114
115 /* Prototypes */
116
117 #endif