jabberd2  2.3.4
main.c
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 
21 #include "sm.h"
22 #include <stringprep.h>
23 
31 static sig_atomic_t sm_shutdown = 0;
32 static sig_atomic_t sm_logrotate = 0;
33 static sm_t sm = NULL;
34 static char* config_file;
35 
36 static void _sm_signal(int signum)
37 {
38  sm_shutdown = 1;
39  sm_lost_router = 0;
40 }
41 
42 static void _sm_signal_hup(int signum)
43 {
44  config_t conf;
45 
46  log_write(sm->log, LOG_NOTICE, "HUP handled. reloading modules...");
47 
48  sm_logrotate = 1;
49 
50  /* reload dynamic modules */
51  conf = config_new();
52  if (conf && config_load(conf, config_file) == 0) {
53  config_free(sm->config);
54  sm->config = conf;
55  /*_sm_config_expand(sm);*/ /* we want to reload modules only */
56  } else {
57  log_write(sm->log, LOG_WARNING, "couldn't reload config (%s)", config_file);
58  if (conf) config_free(conf);
59  }
60  mm_free(sm->mm);
61  sm->mm = mm_new(sm);
62 }
63 
64 static void _sm_signal_usr1(int signum)
65 {
66  set_debug_flag(0);
67 }
68 
69 static void _sm_signal_usr2(int signum)
70 {
71  set_debug_flag(1);
72 }
73 
75 static void _sm_pidfile(sm_t sm) {
76  const char *pidfile;
77  FILE *f;
78  pid_t pid;
79 
80  pidfile = config_get_one(sm->config, "pidfile", 0);
81  if(pidfile == NULL)
82  return;
83 
84  pid = getpid();
85 
86  if((f = fopen(pidfile, "w+")) == NULL) {
87  log_write(sm->log, LOG_ERR, "couldn't open %s for writing: %s", pidfile, strerror(errno));
88  return;
89  }
90 
91  if(fprintf(f, "%d", pid) < 0) {
92  log_write(sm->log, LOG_ERR, "couldn't write to %s: %s", pidfile, strerror(errno));
93  fclose(f);
94  return;
95  }
96 
97  fclose(f);
98 
99  log_write(sm->log, LOG_INFO, "process id is %d, written to %s", pid, pidfile);
100 }
101 
103 static void _sm_config_expand(sm_t sm)
104 {
105  char *str;
106  config_elem_t elem;
107 
109 
110  sm->id = config_get_one(sm->config, "id", 0);
111  if(sm->id == NULL)
112  sm->id = "sm";
113 
114  sm->router_ip = config_get_one(sm->config, "router.ip", 0);
115  if(sm->router_ip == NULL)
116  sm->router_ip = "127.0.0.1";
117 
118  sm->router_port = j_atoi(config_get_one(sm->config, "router.port", 0), 5347);
119 
120  sm->router_user = config_get_one(sm->config, "router.user", 0);
121  if(sm->router_user == NULL)
122  sm->router_user = "jabberd";
123  sm->router_pass = config_get_one(sm->config, "router.pass", 0);
124  if(sm->router_pass == NULL)
125  sm->router_pass = "secret";
126 
127  sm->router_pemfile = config_get_one(sm->config, "router.pemfile", 0);
128 
129  sm->router_private_key_password = config_get_one(sm->config, "router.private_key_password", 0);
130  sm->router_ciphers = config_get_one(sm->config, "router.ciphers", 0);
131 
132  sm->retry_init = j_atoi(config_get_one(sm->config, "router.retry.init", 0), 3);
133  sm->retry_lost = j_atoi(config_get_one(sm->config, "router.retry.lost", 0), 3);
134  if((sm->retry_sleep = j_atoi(config_get_one(sm->config, "router.retry.sleep", 0), 2)) < 1)
135  sm->retry_sleep = 1;
136 
137  sm->log_type = log_STDOUT;
138  if(config_get(sm->config, "log") != NULL) {
139  if((str = config_get_attr(sm->config, "log", 0, "type")) != NULL) {
140  if(strcmp(str, "file") == 0)
141  sm->log_type = log_FILE;
142  else if(strcmp(str, "syslog") == 0)
143  sm->log_type = log_SYSLOG;
144  }
145  }
146 
147  if(sm->log_type == log_SYSLOG) {
148  sm->log_facility = config_get_one(sm->config, "log.facility", 0);
149  sm->log_ident = config_get_one(sm->config, "log.ident", 0);
150  if(sm->log_ident == NULL)
151  sm->log_ident = "jabberd/sm";
152  } else if(sm->log_type == log_FILE)
153  sm->log_ident = config_get_one(sm->config, "log.file", 0);
154 
155  elem = config_get(sm->config, "storage.limits.queries");
156  if(elem != NULL)
157  {
158  sm->query_rate_total = j_atoi(elem->values[0], 0);
159  if(sm->query_rate_total != 0)
160  {
161  sm->query_rate_seconds = j_atoi(j_attr((const char **) elem->attrs[0], "seconds"), 5);
162  sm->query_rate_wait = j_atoi(j_attr((const char **) elem->attrs[0], "throttle"), 60);
163  }
164  }
165 }
166 
167 static void _sm_hosts_expand(sm_t sm)
168 {
169  config_elem_t elem;
170  char id[1024];
171  int i;
172 
173  elem = config_get(sm->config, "local.id");
174  if(!elem) {
175  /* use SM id */
176  xhash_put(sm->hosts, pstrdup(xhash_pool(sm->hosts), sm->id), sm);
177  log_write(sm->log, LOG_NOTICE, "id: %s", sm->id);
178  return;
179  }
180 
181  for(i = 0; i < elem->nvalues; i++) {
182  /* stringprep ids (domain names) so that they are in canonical form */
183  strncpy(id, elem->values[i], 1024);
184  id[1023] = '\0';
185  if (stringprep_nameprep(id, 1024) != 0) {
186  log_write(sm->log, LOG_ERR, "cannot stringprep id %s, aborting", id);
187  exit(1);
188  }
189 
190  /* insert into vHosts xhash */
191  xhash_put(sm->hosts, pstrdup(xhash_pool(sm->hosts), id), sm);
192 
193  log_write(sm->log, LOG_NOTICE, "[%s] configured", id);
194  }
195 }
196 
197 static int _sm_router_connect(sm_t sm) {
198  log_write(sm->log, LOG_NOTICE, "attempting connection to router at %s, port=%d", sm->router_ip, sm->router_port);
199 
200  sm->fd = mio_connect(sm->mio, sm->router_port, sm->router_ip, NULL, sm_mio_callback, (void *) sm);
201  if(sm->fd == NULL) {
202  if(errno == ECONNREFUSED)
203  sm_lost_router = 1;
204  log_write(sm->log, LOG_NOTICE, "connection attempt to router failed: %s (%d)", MIO_STRERROR(MIO_ERROR), MIO_ERROR);
205  return 1;
206  }
207 
208  sm->router = sx_new(sm->sx_env, sm->fd->fd, sm_sx_callback, (void *) sm);
209  sx_client_init(sm->router, 0, NULL, NULL, NULL, "1.0");
210 
211  return 0;
212 }
213 
214 JABBER_MAIN("jabberd2sm", "Jabber 2 Session Manager", "Jabber Open Source Server: Session Manager", "jabberd2router\0")
215 {
216  int optchar;
217  sess_t sess;
218  char id[1024];
219 #ifdef POOL_DEBUG
220  time_t pool_time = 0;
221 #endif
222  const char *cli_id = 0;
223 
224 #ifdef HAVE_UMASK
225  umask((mode_t) 0027);
226 #endif
227 
228  srand(time(NULL));
229 
230 #ifdef HAVE_WINSOCK2_H
231 /* get winsock running */
232  {
233  WORD wVersionRequested;
234  WSADATA wsaData;
235  int err;
236 
237  wVersionRequested = MAKEWORD( 2, 2 );
238 
239  err = WSAStartup( wVersionRequested, &wsaData );
240  if ( err != 0 ) {
241  /* !!! tell user that we couldn't find a usable winsock dll */
242  return 0;
243  }
244  }
245 #endif
246 
247  jabber_signal(SIGINT, _sm_signal);
248  jabber_signal(SIGTERM, _sm_signal);
249 #ifdef SIGHUP
250  jabber_signal(SIGHUP, _sm_signal_hup);
251 #endif
252 #ifdef SIGPIPE
253  jabber_signal(SIGPIPE, SIG_IGN);
254 #endif
255  jabber_signal(SIGUSR1, _sm_signal_usr1);
256  jabber_signal(SIGUSR2, _sm_signal_usr2);
257 
258 
259  sm = (sm_t) calloc(1, sizeof(struct sm_st));
260 
261  /* load our config */
262  sm->config = config_new();
263 
264  config_file = CONFIG_DIR "/sm.xml";
265 
266  /* cmdline parsing */
267  while((optchar = getopt(argc, argv, "Dc:hi:?")) >= 0)
268  {
269  switch(optchar)
270  {
271  case 'c':
272  config_file = optarg;
273  break;
274  case 'D':
275 #ifdef DEBUG
276  set_debug_flag(1);
277 #else
278  printf("WARN: Debugging not enabled. Ignoring -D.\n");
279 #endif
280  break;
281  case 'i':
282  cli_id = optarg;
283  break;
284  case 'h': case '?': default:
285  fputs(
286  "sm - jabberd session manager (" VERSION ")\n"
287  "Usage: sm <options>\n"
288  "Options are:\n"
289  " -c <config> config file to use [default: " CONFIG_DIR "/sm.xml]\n"
290  " -i id Override <id> config element\n"
291 #ifdef DEBUG
292  " -D Show debug output\n"
293 #endif
294  ,
295  stdout);
296  config_free(sm->config);
297  free(sm);
298  return 1;
299  }
300  }
301 
302  if(config_load_with_id(sm->config, config_file, cli_id) != 0)
303  {
304  fputs("sm: couldn't load config, aborting\n", stderr);
305  config_free(sm->config);
306  free(sm);
307  return 2;
308  }
309 
310  _sm_config_expand(sm);
311 
312  sm->log = log_new(sm->log_type, sm->log_ident, sm->log_facility);
313  log_write(sm->log, LOG_NOTICE, "starting up");
314 
315  /* stringprep id (domain name) so that it's in canonical form */
316  strncpy(id, sm->id, 1024);
317  id[sizeof(id)-1] = '\0';
318  if (stringprep_nameprep(id, 1024) != 0) {
319  log_write(sm->log, LOG_ERR, "cannot stringprep id %s, aborting", sm->id);
320  exit(1);
321  }
322  sm->id = id;
323 
324  _sm_pidfile(sm);
325 
326  sm_signature(sm, PACKAGE " sm " VERSION);
327 
328  /* start storage */
329  sm->st = storage_new(sm->config, sm->log);
330  if (sm->st == NULL) {
331  log_write(sm->log, LOG_ERR, "failed to initialise one or more storage drivers, aborting");
332  exit(1);
333  }
334 
335  /* pre-index known namespaces */
336  sm->xmlns = xhash_new(101);
337  xhash_put(sm->xmlns, uri_AUTH, (void *) ns_AUTH);
338  xhash_put(sm->xmlns, uri_REGISTER, (void *) ns_REGISTER);
339  xhash_put(sm->xmlns, uri_ROSTER, (void *) ns_ROSTER);
340  xhash_put(sm->xmlns, uri_AGENTS, (void *) ns_AGENTS);
341  xhash_put(sm->xmlns, uri_DELAY, (void *) ns_DELAY);
342  xhash_put(sm->xmlns, uri_BROWSE, (void *) ns_BROWSE);
343  xhash_put(sm->xmlns, uri_EVENT, (void *) ns_EVENT);
344  xhash_put(sm->xmlns, uri_GATEWAY, (void *) ns_GATEWAY);
345  xhash_put(sm->xmlns, uri_EXPIRE, (void *) ns_EXPIRE);
346  xhash_put(sm->xmlns, uri_SEARCH, (void *) ns_SEARCH);
347  xhash_put(sm->xmlns, uri_DISCO, (void *) ns_DISCO);
350  sm->xmlns_refcount = xhash_new(101);
351 
352  /* supported features */
353  sm->features = xhash_new(101);
354 
355  /* load acls */
356  sm->acls = aci_load(sm);
357 
358  /* the core supports iq, everything else is handled by the modules */
359  feature_register(sm, "iq");
360 
361  /* startup the modules */
362  sm->mm = mm_new(sm);
363 
364  log_write(sm->log, LOG_NOTICE, "version: %s", sm->signature);
365 
366  sm->sessions = xhash_new(401);
367 
368  sm->users = xhash_new(401);
369 
370  sm->query_rates = xhash_new(101);
371 
372  sm->sx_env = sx_env_new();
373 
374 #ifdef HAVE_SSL
375  if(sm->router_pemfile != NULL) {
377  if(sm->sx_ssl == NULL) {
378  log_write(sm->log, LOG_ERR, "failed to load SSL pemfile, SSL disabled");
379  sm->router_pemfile = NULL;
380  }
381  }
382 #endif
383 
384  /* get sasl online */
385  sm->sx_sasl = sx_env_plugin(sm->sx_env, sx_sasl_init, "xmpp", NULL, NULL);
386  if(sm->sx_sasl == NULL) {
387  log_write(sm->log, LOG_ERR, "failed to initialise SASL context, aborting");
388  exit(1);
389  }
390 
391  sm->mio = mio_new(MIO_MAXFD);
392 
393  /* vHosts map */
394  sm->hosts = xhash_new(1021);
395  _sm_hosts_expand(sm);
396 
397  sm->retry_left = sm->retry_init;
398  _sm_router_connect(sm);
399 
400  while(!sm_shutdown) {
401  mio_run(sm->mio, 5);
402 
403  if(sm_logrotate) {
405 
406  log_write(sm->log, LOG_NOTICE, "reopening log ...");
407  log_free(sm->log);
408  sm->log = log_new(sm->log_type, sm->log_ident, sm->log_facility);
409  log_write(sm->log, LOG_NOTICE, "log started");
410 
411  sm_logrotate = 0;
412  }
413 
414  if(sm_lost_router) {
415  if(sm->retry_left < 0) {
416  log_write(sm->log, LOG_NOTICE, "attempting reconnect");
417  sleep(sm->retry_sleep);
418  sm_lost_router = 0;
419  if (sm->router) sx_free(sm->router);
420  _sm_router_connect(sm);
421  }
422 
423  else if(sm->retry_left == 0) {
424  sm_shutdown = 1;
425  }
426 
427  else {
428  log_write(sm->log, LOG_NOTICE, "attempting reconnect (%d left)", sm->retry_left);
429  sm->retry_left--;
430  sleep(sm->retry_sleep);
431  sm_lost_router = 0;
432  if (sm->router) sx_free(sm->router);
433  _sm_router_connect(sm);
434  }
435  }
436 
437 #ifdef POOL_DEBUG
438  if(time(NULL) > pool_time + 60) {
439  pool_stat(1);
440  pool_time = time(NULL);
441  }
442 #endif
443  }
444 
445  log_write(sm->log, LOG_NOTICE, "shutting down");
446 
447  /* shut down sessions */
448  if(xhash_iter_first(sm->sessions))
449  do {
450  xhash_iter_get(sm->sessions, NULL, NULL, (void *) &sess);
451  sm_c2s_action(sess, "ended", NULL);
452  sess_end(sess);
453  } while (xhash_iter_next(sm->sessions));
454 
455  xhash_free(sm->sessions);
456 
457  if (sm->fd) mio_close(sm->mio, sm->fd);
458  mio_free(sm->mio);
459 
460  mm_free(sm->mm);
461  storage_free(sm->st);
462 
463  aci_unload(sm->acls);
464  xhash_free(sm->acls);
465  xhash_free(sm->features);
466  xhash_free(sm->xmlns);
468  xhash_free(sm->users);
469  xhash_free(sm->hosts);
470  xhash_free(sm->query_rates);
471 
472  sx_free(sm->router);
473 
474  sx_env_free(sm->sx_env);
475 
476  log_free(sm->log);
477 
478  config_free(sm->config);
479 
480  free(sm);
481 
482 #ifdef POOL_DEBUG
483  pool_stat(1);
484 #endif
485 
486 #ifdef HAVE_WINSOCK2_H
487  WSACleanup();
488 #endif
489 
490  return 0;
491 }
const char * log_facility
syslog facility (local0 - local7)
Definition: sm.h:203
static sm_t sm
Definition: main.c:33
xht query_rates
Definition: sm.h:230
data structures and prototypes for the session manager
int retry_init
number of times to try connecting to the router at startup
Definition: sm.h:206
#define ns_DISCO_INFO
Definition: sm.h:81
#define uri_BROWSE
Definition: uri.h:70
#define ns_GATEWAY
Definition: sm.h:76
const char ** values
Definition: util.h:209
#define uri_DISCO
Definition: uri.h:79
int query_rate_seconds
Definition: sm.h:228
#define ns_EXPIRE
Definition: sm.h:77
int config_load_with_id(config_t c, const char *file, const char *id)
turn an xml file into a config hash
Definition: config.c:80
const char * id
component id
Definition: sm.h:168
#define ns_DISCO_ITEMS
Definition: sm.h:80
void xhash_free(xht h)
Definition: xhash.c:241
static sig_atomic_t sm_shutdown
Definition: main.c:31
xht aci_load(router_t r)
Definition: aci.c:31
static void _sm_signal_usr1(int signum)
Definition: main.c:64
void config_free(config_t c)
cleanup
Definition: config.c:410
#define uri_AUTH
Definition: uri.h:61
log_t log
log context
Definition: sm.h:200
mio_t mio_new(int maxfd)
create/free the mio subsytem
Definition: mio.c:38
#define mio_run(m, timeout)
give some cpu time to mio to check it's sockets, 0 is non-blocking
Definition: mio.h:164
static void _sm_signal(int signum)
Definition: main.c:36
config_t config
config context
Definition: sm.h:198
void log_write(log_t log, int level, const char *msgfmt,...)
Definition: log.c:104
mm_t mm
module subsystem
Definition: sm.h:213
xht hosts
vHosts map
Definition: sm.h:224
void sm_c2s_action(sess_t dest, const char *action, const char *target)
send a new action route
Definition: sm.c:280
sx_t sx_new(sx_env_t env, int tag, sx_callback_t cb, void *arg)
Definition: sx.c:23
config_t config_new(void)
new config structure
Definition: config.c:25
#define MIO_STRERROR(e)
Definition: mio.h:170
static void _sm_hosts_expand(sm_t sm)
Definition: main.c:167
#define mio_free(m)
Definition: mio.h:137
static char * config_file
Definition: main.c:34
holder for the config hash and nad
Definition: util.h:200
int j_atoi(const char *a, int def)
Definition: str.c:87
void log_free(log_t log)
Definition: log.c:174
int xhash_iter_next(xht h)
Definition: xhash.c:320
static void _sm_pidfile(sm_t sm)
store the process id
Definition: main.c:75
mm_t mm_new(sm_t sm)
allocate a module manager instance, and loads the modules
Definition: mm.c:47
xht sessions
pointers to all connected sessions (key is random sm id)
Definition: sm.h:191
sx_env_t sx_env_new(void)
Definition: env.c:23
#define mio_connect(m, port, hostip, srcip, app, arg)
for creating a new socket connected to this ip:port (returns new fd or <0, use mio_read/write first) ...
Definition: mio.h:144
sx_plugin_t sx_ssl
SX SSL plugin.
Definition: sm.h:184
xht users
pointers to currently loaded users (key is user@domain)
Definition: sm.h:189
static void _sm_signal_hup(int signum)
Definition: main.c:42
char * config_get_attr(config_t c, const char *key, int num, const char *attr)
get an attr for this value
Definition: config.c:314
Definition: log.h:42
#define MIO_ERROR
all MIO related routines should use those for error reporting
Definition: mio.h:168
static void _sm_config_expand(sm_t sm)
pull values out of the config file
Definition: main.c:103
#define ns_ROSTER
Definition: sm.h:71
int retry_left
number of tries left before failure
Definition: sm.h:209
void sess_end(sess_t sess)
Definition: sess.c:85
#define ns_REGISTER
Definition: sm.h:70
sx_plugin_t sx_env_plugin(sx_env_t env, sx_plugin_init_t init,...)
load a plugin into the environment
Definition: env.c:48
sx_t router
SX of router connection.
Definition: sm.h:186
xht xmlns_refcount
ref-counting for modules namespaces
Definition: sm.h:194
void sx_client_init(sx_t s, unsigned int flags, const char *ns, const char *to, const char *from, const char *version)
Definition: client.c:111
int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
Definition: sm.c:241
#define uri_ROSTER
Definition: uri.h:63
void set_debug_log_from_config(config_t c)
Definition: log.c:267
storage_t st
storage subsystem
Definition: sm.h:211
session manager global context
Definition: sm.h:167
void pool_stat(int full)
Definition: pool.c:285
void xhash_put(xht h, const char *key, void *val)
Definition: xhash.c:163
const char * router_ciphers
password for private key if pemfile key is encrypted
Definition: sm.h:178
static sig_atomic_t sm_logrotate
Definition: main.c:32
int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg)
our master callback
Definition: sm.c:33
log_type_t log_type
log type
Definition: sm.h:202
const char * router_private_key_password
Definition: sm.h:176
#define uri_AGENTS
Definition: uri.h:64
void mm_free(mm_t mm)
free a mm instance
Definition: mm.c:291
#define ns_DISCO
Definition: sm.h:79
int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
Definition: xhash.c:374
#define uri_REGISTER
Definition: uri.h:62
void sm_signature(sm_t sm, const char *str)
this is gratuitous, but apache gets one, so why not?
Definition: sm.c:313
void sx_free(sx_t s)
Definition: sx.c:70
struct sm_st * sm_t
Definition: sm.h:59
const char * log_ident
log identifier
Definition: sm.h:204
JABBER_MAIN("jabberd2c2s","Jabber 2 C2S","Jabber Open Source Server: Client to Server","jabberd2router\0")
Definition: main.c:654
jsighandler_t * jabber_signal(int signo, jsighandler_t *func)
Definition: jsignal.c:33
const char * router_user
username to authenticate to the router as
Definition: sm.h:172
void feature_register(sm_t sm, const char *feature)
register a feature
Definition: feature.c:37
const char * router_pass
password to authenticate to the router with
Definition: sm.h:173
#define uri_SEARCH
Definition: uri.h:77
sx_env_t sx_env
SX environment.
Definition: sm.h:182
#define uri_GATEWAY
Definition: uri.h:72
int retry_lost
number of times to try reconnecting to the router if the connection drops
Definition: sm.h:207
JABBERD2_API int sx_sasl_init(sx_env_t env, sx_plugin_t p, va_list args)
init function
Definition: sasl.c:855
config_elem_t config_get(config_t c, const char *key)
get the config element for this key
Definition: config.c:271
There is one instance of this struct per user who is logged in to this c2s instance.
Definition: c2s.h:74
char signature[2048]
server signature
Definition: sm.h:217
#define uri_DELAY
Definition: uri.h:65
const char * router_ip
ip to connect to the router at
Definition: sm.h:170
#define ns_EVENT
Definition: sm.h:75
int xhash_iter_first(xht h)
iteration
Definition: xhash.c:311
mio_fd_t fd
file descriptor of router connection
Definition: sm.h:187
static void _sm_signal_usr2(int signum)
Definition: main.c:69
int fd
Definition: mio.h:102
const char * router_pemfile
name of file containing a SSL certificate & key for channel to the router
Definition: sm.h:174
void set_debug_flag(int v)
Definition: log.c:264
mio_t mio
TLS ciphers.
Definition: sm.h:180
int sx_ssl_init(sx_env_t env, sx_plugin_t p, va_list args)
args: name, pemfile, cachain, mode
Definition: ssl.c:904
sig_atomic_t sm_lost_router
Definition: sm.c:30
int query_rate_wait
Definition: sm.h:229
int config_load(config_t c, const char *file)
turn an xml file into a config hash
Definition: config.c:74
const char *** attrs
Definition: util.h:211
pool_t xhash_pool(xht h)
get our pool
Definition: xhash.c:305
int retry_sleep
sleep interval between retries
Definition: sm.h:208
char * pstrdup(pool_t p, const char *src)
XXX efficient: move this to const char * and then loop throug the existing heaps to see if src is wit...
Definition: pool.c:191
Definition: log.h:43
#define MIO_MAXFD
Definition: mio.h:46
#define ns_AUTH
Definition: sm.h:69
Definition: log.h:44
#define mio_close(m, fd)
request that mio close this fd
Definition: mio.h:155
xht acls
access control lists (key is list name, value is jid_t list)
Definition: sm.h:215
char * j_attr(const char **atts, const char *attr)
Definition: str.c:95
log_t log_new(log_type_t type, const char *ident, const char *facility)
Definition: log.c:69
const char * config_get_one(config_t c, const char *key, int num)
get config value n for this key
Definition: config.c:277
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
Definition: sm.h:193
xht xhash_new(int prime)
Definition: xhash.c:96
#define uri_DISCO_INFO
Definition: uri.h:81
int query_rate_total
Database query rate limits.
Definition: sm.h:227
#define uri_DISCO_ITEMS
Definition: uri.h:80
#define uri_EXPIRE
Definition: uri.h:73
void sx_env_free(sx_env_t env)
Definition: env.c:31
#define uri_EVENT
Definition: uri.h:71
a single element
Definition: util.h:207
#define ns_AGENTS
Definition: sm.h:72
#define ns_DELAY
Definition: sm.h:73
int router_port
port to connect to the router at
Definition: sm.h:171
#define ns_BROWSE
Definition: sm.h:74
#define ns_SEARCH
Definition: sm.h:78
int nvalues
Definition: util.h:210
sx_plugin_t sx_sasl
SX SASL plugin.
Definition: sm.h:183
static int _sm_router_connect(sm_t sm)
Definition: main.c:197
void aci_unload(xht aci)
unload aci table
Definition: aci.c:114
xht features
feature index (key is feature string
Definition: sm.h:196