Moved all the generic packet sending, encryption, reception,
[silc.git] / apps / silcd / server.h
1 /*
2
3   server.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_H
22 #define SERVER_H
23
24 /* Forward declaration for SILC Server object. The actual object is
25    defined in internal header file for server routines. I want to keep
26    the object private hence this declaration. */
27 typedef struct SilcServerObjectStruct *SilcServer;
28
29 #define SILC_SERVER_MAX_CONNECTIONS 10000
30
31 /* General definitions */
32
33 #define SILC_SERVER 0
34 #define SILC_ROUTER 1
35
36 /* Prototypes */
37 int silc_server_alloc(SilcServer *new_server);
38 void silc_server_free(SilcServer server);
39 int silc_server_init(SilcServer server);
40 void silc_server_run(SilcServer server);
41 void silc_server_stop(SilcServer server);
42 void silc_server_packet_parse(SilcPacketParserContext *parser_context);
43 void silc_server_packet_parse_type(SilcServer server, 
44                                    SilcSocketConnection sock,
45                                    SilcPacketContext *packet);
46 void silc_server_packet_send(SilcServer server,
47                              SilcSocketConnection sock, 
48                              SilcPacketType type, 
49                              SilcPacketFlags flags,
50                              unsigned char *data, 
51                              unsigned int data_len,
52                              int force_send);
53 void silc_server_packet_send_dest(SilcServer server,
54                                   SilcSocketConnection sock, 
55                                   SilcPacketType type, 
56                                   SilcPacketFlags flags,
57                                   void *dst_id,
58                                   SilcIdType dst_id_type,
59                                   unsigned char *data, 
60                                   unsigned int data_len,
61                                   int force_send);
62 void silc_server_packet_forward(SilcServer server,
63                                 SilcSocketConnection sock,
64                                 unsigned char *data, unsigned int data_len,
65                                 int force_send);
66 void silc_server_packet_send_to_channel(SilcServer server,
67                                         SilcChannelEntry channel,
68                                         unsigned char *data,
69                                         unsigned int data_len,
70                                         int force_send);
71 void silc_server_packet_relay_to_channel(SilcServer server,
72                                          SilcSocketConnection sender_sock,
73                                          SilcChannelEntry channel,
74                                          void *sender, 
75                                          SilcIdType sender_type,
76                                          unsigned char *data,
77                                          unsigned int data_len,
78                                          int force_send);
79 void silc_server_packet_send_local_channel(SilcServer server,
80                                            SilcChannelEntry channel,
81                                            SilcPacketType type,
82                                            SilcPacketFlags flags,
83                                            unsigned char *data,
84                                            unsigned int data_len,
85                                            int force_send);
86 void silc_server_packet_relay_command_reply(SilcServer server,
87                                             SilcSocketConnection sock,
88                                             SilcPacketContext *packet);
89 void silc_server_close_connection(SilcServer server,
90                                   SilcSocketConnection sock);
91 void silc_server_free_sock_user_data(SilcServer server, 
92                                      SilcSocketConnection sock);
93 void silc_server_remove_from_channels(SilcServer server, 
94                                       SilcSocketConnection sock,
95                                       SilcClientEntry client);
96 int silc_server_remove_from_one_channel(SilcServer server, 
97                                         SilcSocketConnection sock,
98                                         SilcChannelEntry channel,
99                                         SilcClientEntry client);
100 int silc_server_client_on_channel(SilcClientEntry client,
101                                   SilcChannelEntry channel);
102 void silc_server_disconnect_remote(SilcServer server,
103                                    SilcSocketConnection sock,
104                                    const char *fmt, ...);
105 void silc_server_private_message(SilcServer server,
106                                  SilcSocketConnection sock,
107                                  SilcPacketContext *packet);
108 void silc_server_channel_message(SilcServer server,
109                                  SilcSocketConnection sock,
110                                  SilcPacketContext *packet);
111 void silc_server_channel_key(SilcServer server,
112                              SilcSocketConnection sock,
113                              SilcPacketContext *packet);
114 void silc_server_send_error(SilcServer server,
115                             SilcSocketConnection sock,
116                             const char *fmt, ...);
117 void silc_server_send_notify(SilcServer server,
118                              SilcSocketConnection sock,
119                              const char *fmt, ...);
120 void silc_server_send_notify_dest(SilcServer server,
121                                   SilcSocketConnection sock,
122                                   void *dest_id,
123                                   SilcIdType dest_id_type,
124                                   const char *fmt, ...);
125 void silc_server_send_notify_to_channel(SilcServer server,
126                                         SilcChannelEntry channel,
127                                         const char *fmt, ...);
128 void silc_server_send_new_id(SilcServer server,
129                              SilcSocketConnection sock,
130                              int broadcast,
131                              void *id, SilcIdType id_type, 
132                              unsigned int id_len);
133 void silc_server_send_replace_id(SilcServer server,
134                                  SilcSocketConnection sock,
135                                  int broadcast,
136                                  void *old_id, SilcIdType old_id_type,
137                                  unsigned int old_id_len,
138                                  void *new_id, SilcIdType new_id_type,
139                                  unsigned int new_id_len);
140 SilcChannelEntry silc_server_new_channel(SilcServer server, 
141                                          SilcServerID *router_id,
142                                          char *cipher, char *channel_name);
143 SilcClientEntry silc_server_new_client(SilcServer server,
144                                        SilcSocketConnection sock,
145                                        SilcPacketContext *packet);
146 SilcServerEntry silc_server_new_server(SilcServer server,
147                                        SilcSocketConnection sock,
148                                        SilcPacketContext *packet);
149 void silc_server_new_id(SilcServer server, SilcSocketConnection sock,
150                         SilcPacketContext *packet);
151
152 #endif