jabberd2  2.3.6
router.h
Go to the documentation of this file.
1 /*
2  * jabberd - Jabber Open Source Server
3  * Copyright (c) 2002 Jeremie Miller, Thomas Muldowney,
4  * Ryan Eatmon, Robert Norris
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
19  */
20 
36 #ifdef HAVE_CONFIG_H
37 # include <config.h>
38 #endif
39 
40 #include "sx/sx.h"
41 #include "mio/mio.h"
42 #include "util/util.h"
43 
44 #ifdef HAVE_SIGNAL_H
45 # include <signal.h>
46 #endif
47 #ifdef HAVE_SYS_STAT_H
48 # include <sys/stat.h>
49 #endif
50 
51 typedef struct router_st *router_t;
52 typedef struct component_st *component_t;
53 typedef struct routes_st *routes_t;
54 typedef struct alias_st *alias_t;
55 
56 typedef struct acl_s *acl_t;
57 struct acl_s {
58  int error;
59  char *redirect;
61  char *what;
62  char *from;
63  char *to;
64  char *dump;
65  int log;
66  acl_t next;
67 };
68 
69 struct router_st {
71  const char *id;
72 
75 
78  time_t users_load;
79 
81  acl_t filter;
82  time_t filter_load;
83 
86 
89  const char *log_facility;
90  const char *log_ident;
91 
93  const char *local_ip;
95  const char *local_secret;
96  const char *local_pemfile;
98  const char *local_ciphers;
99 
102 
105 
110 
112 
117 
122 
125 
128 
132 
133  time_t next_check;
134 
137 
140 
142  const char *default_route;
143 
146 
148  alias_t aliases;
149 
152 
155 
158 
161 
164  const char *message_logging_file;
165 };
166 
168 struct component_st {
169  router_t r;
170 
173 
176  int port;
177 
180 
183 
186  int rate_log;
187 
190 
192  int legacy;
193 
196 
199 };
200 
202 typedef enum {
203  route_SINGLE = 0x00,
204  route_MULTI_TO = 0x10,
206 } route_type_t;
207 
208 struct routes_st
209 {
210  const char *name;
212  component_t *comp;
213  int ncomp;
214 };
215 
216 struct alias_st {
217  const char *name;
218  const char *target;
219 
220  alias_t next;
221 };
222 
223 int router_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg);
224 void router_sx_handshake(sx_t s, sx_buf_t buf, void *arg);
225 
226 xht aci_load(router_t r);
227 void aci_unload(xht aci);
228 int aci_check(xht acls, const char *type, const char *name);
229 
230 int user_table_load(router_t r);
231 void user_table_unload(router_t r);
232 
233 int filter_load(router_t r);
234 void filter_unload(router_t r);
235 int filter_packet(router_t r, nad_t nad);
236 
237 int message_log(nad_t nad, router_t r, const char *msg_from, const char *msg_to);
238 
239 void routes_free(routes_t routes);
240 
241 /* union for xhash_iter_get to comply with strict-alias rules for gcc3 */
242 union xhashv
243 {
244  void **val;
245  char **char_val;
246  component_t *comp_val;
248 };
sx_env_t sx_env
sx environment
Definition: router.h:119
int filter_load(router_t r)
Definition: filter.c:43
int check_keepalive
Definition: router.h:131
jqueue_t closefd
list of mio_fd_t waiting to be closed
Definition: router.h:157
#define INET6_ADDRSTRLEN
maximum length of the string representation of an IPv6 address
Definition: util_compat.h:46
xht routes
valid routes, key is route name (packet "to" address), var is component_t
Definition: router.h:139
alias_t next
Definition: router.h:220
Definition: nad.h:93
struct router_st * router_t
Definition: router.h:51
Definition: sx.h:113
xht aci
access control lists
Definition: router.h:151
int message_log(nad_t nad, router_t r, const char *msg_from, const char *msg_to)
Definition: router.c:1132
jqueue_t deadroutes
list of routes_t waiting to be cleaned up
Definition: router.h:160
acl_t next
Definition: router.h:66
xht users
user table
Definition: router.h:77
const char * log_ident
Definition: router.h:90
const char * id
our id
Definition: router.h:71
route_type_t
route types
Definition: router.h:202
multi component route - route by 'from'
Definition: router.h:205
int filter_packet(router_t r, nad_t nad)
Definition: filter.c:192
char * what
Definition: router.h:61
char * to
Definition: router.h:63
int redirect_len
Definition: router.h:60
void routes_free(routes_t routes)
Definition: router.c:153
time_t filter_load
Definition: router.h:82
const char * default_route
default route, only one
Definition: router.h:142
an environment
Definition: sx.h:379
struct routes_st * routes_t
Definition: router.h:53
int legacy
true if this is an old component:accept stream
Definition: router.h:192
xht aci_load(router_t r)
Definition: aci.c:31
time_t users_load
Definition: router.h:78
a plugin
Definition: sx.h:344
holder for the config hash and nad
Definition: util.h:200
const char * local_private_key_password
Definition: router.h:97
access_t access
access controls
Definition: router.h:104
void router_sx_handshake(sx_t s, sx_buf_t buf, void *arg)
jqueue_t tq
throttle queue
Definition: router.h:195
mio_action_t
these are the actions and a handler type assigned by the applicaiton using mio
Definition: mio.h:106
rate_t * rt_val
Definition: router.h:247
Definition: mio.h:109
int message_logging_enabled
simple message logging
Definition: router.h:163
int local_port
Definition: router.h:94
int rate_log
Definition: router.h:186
struct component_st * component_t
Definition: router.h:52
char ip[INET6_ADDRSTRLEN]
remote ip and port
Definition: router.h:175
char ** char_val
Definition: router.h:245
time_t last_activity
timestamps for idle timeouts
Definition: router.h:198
rate_t rate
rate limits
Definition: router.h:185
mio_fd_t fd
listening socket
Definition: router.h:127
a single component
Definition: router.h:168
xht routes
valid routes to this component, key is route name
Definition: router.h:189
mio - manage i/o
holds the state for a single stream
Definition: sx.h:253
int conn_rate_wait
Definition: router.h:109
void ** val
Definition: c2s.h:401
struct _log_st * log_t
Definition: log.h:48
const char * local_pemfile
Definition: router.h:96
log_type_t
Definition: log.h:41
const char * target
Definition: router.h:218
sx_plugin_t sx_sasl
Definition: router.h:121
component_t * comp_val
Definition: router.h:246
int byte_rate_seconds
Definition: router.h:115
int ncomp
Definition: router.h:213
char ipport[INET6_ADDRSTRLEN+6]
ip:port pair
Definition: router.h:179
xht conn_rates
Definition: router.h:111
log_t log
logging
Definition: router.h:85
const char * local_ciphers
Definition: router.h:98
acl_t filter
user table
Definition: router.h:81
multi component route - route by 'to'
Definition: router.h:204
jqueue_t dead
list of sx_t waiting to be cleaned up
Definition: router.h:154
alias_t aliases
configured aliases
Definition: router.h:148
int byte_rate_total
default byte rates (karma)
Definition: router.h:114
mio_fd_t fd
file descriptor
Definition: router.h:172
int conn_rate_seconds
Definition: router.h:108
component_t * comp
Definition: router.h:212
Definition: router.h:57
char * dump
Definition: router.h:64
int error
Definition: router.h:58
int aci_check(xht acls, const char *type, const char *name)
see if a username is in an acl
Definition: aci.c:93
time_t next_check
Definition: router.h:133
router_t r
Definition: router.h:169
const char * log_facility
Definition: router.h:89
xht log_sinks
log sinks, key is route name, var is component_t
Definition: router.h:145
int check_interval
time checks
Definition: router.h:130
void user_table_unload(router_t r)
Definition: user.c:103
const char * name
Definition: router.h:210
int router_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
Definition: router.c:1028
const char * name
Definition: router.h:217
Definition: mio.h:100
Definition: util.h:258
int user_table_load(router_t r)
user table manager
Definition: user.c:25
session packet handling
Definition: c2s.h:399
int byte_rate_wait
Definition: router.h:116
route_type_t rtype
Definition: router.h:211
void aci_unload(xht aci)
unload aci table
Definition: aci.c:114
log_type_t log_type
log data
Definition: router.h:88
mio_t mio
managed io
Definition: router.h:124
sx_t s
our stream
Definition: router.h:182
int conn_rate_total
connection rates
Definition: router.h:107
config_t config
config
Definition: router.h:74
int log
Definition: router.h:65
const char * local_secret
Definition: router.h:95
char * redirect
Definition: router.h:59
sx_plugin_t sx_ssl
Definition: router.h:120
int io_max_fds
max file descriptors
Definition: router.h:101
xht components
attached components, key is 'ip:port', var is component_t
Definition: router.h:136
struct alias_st * alias_t
Definition: router.h:54
void filter_unload(router_t r)
filter manager
Definition: filter.c:25
single component route
Definition: router.h:203
struct acl_s * acl_t
Definition: router.h:56
const char * local_ip
how we listen for stuff
Definition: router.h:93
char * from
Definition: router.h:62
int port
Definition: router.h:176
const char * message_logging_file
Definition: router.h:164