jabberd2  2.3.3
sm.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 drvify
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 
29 #ifdef HAVE_CONFIG_H
30  #include <config.h>
31 #endif
32 
33 #include "sx/sx.h"
34 #include "mio/mio.h"
35 #include "util/util.h"
36 #include "storage/storage.h"
37 
38 #ifdef HAVE_SIGNAL_H
39  #include <signal.h>
40 #endif
41 #ifdef HAVE_SYS_STAT_H
42  #include <sys/stat.h>
43 #endif
44 
45 #ifdef _WIN32
46  #ifdef _USRDLL
47  #define DLLEXPORT __declspec(dllexport)
48  #define SM_API __declspec(dllimport)
49  #else
50  #define DLLEXPORT __declspec(dllimport)
51  #define SM_API __declspec(dllexport)
52  #endif
53 #else
54  #define DLLEXPORT
55  #define SM_API
56 #endif
57 
58 /* forward declarations */
59 typedef struct sm_st *sm_t;
60 typedef struct user_st *user_t;
61 typedef struct sess_st *sess_t;
62 typedef struct aci_st *aci_t;
63 typedef struct mm_st *mm_t;
64 
65 /* namespace uri strings */
66 #include "util/uri.h"
67 
68 /* indexed known namespace values */
69 #define ns_AUTH (1)
70 #define ns_REGISTER (2)
71 #define ns_ROSTER (3)
72 #define ns_AGENTS (4)
73 #define ns_DELAY (5)
74 #define ns_BROWSE (6)
75 #define ns_EVENT (7)
76 #define ns_GATEWAY (8)
77 #define ns_EXPIRE (9)
78 #define ns_SEARCH (10)
79 #define ns_DISCO (11)
80 #define ns_DISCO_ITEMS (12)
81 #define ns_DISCO_INFO (13)
82 
83 #define ns_AMP (14)
84 #define ns_AMP_ERRORS (15)
85 #define ns_AMP_ACTION_DROP (16)
86 #define ns_AMP_ACTION_ERROR (17)
87 #define ns_AMP_ACTION_NOTIFY (18)
88 #define ns_AMP_CONDITION_DELIVER (19)
89 #define ns_AMP_CONDITION_EXPIREAT (20)
90 #define ns_AMP_CONDITION_MATCHRESOURCE (21)
91 
93 typedef enum {
94  pkt_NONE = 0x00,
95  pkt_MESSAGE = 0x10,
99  pkt_PRESENCE = 0x20,
102  pkt_S10N = 0x40,
103  pkt_S10N_ED = 0x41,
104  pkt_S10N_UN = 0x42,
105  pkt_S10N_UNED = 0x44,
106  pkt_IQ = 0x80,
107  pkt_IQ_SET = 0x81,
108  pkt_IQ_RESULT = 0x82,
109  pkt_SESS = 0x100,
110  pkt_SESS_END = 0x101,
111  pkt_SESS_CREATE = 0x102,
112  pkt_SESS_DELETE = 0x104,
114  pkt_SESS_MASK = 0x10f,
115  pkt_ERROR = 0x200
116 } pkt_type_t;
117 
119 typedef enum {
120  route_NONE = 0x00,
121  route_UNICAST = 0x10,
123  route_ADV = 0x20,
124  route_ADV_UN = 0x21,
125  route_ERROR = 0x40
126 } route_type_t;
127 
129 typedef struct pkt_st {
130  sm_t sm;
132  sess_t source;
142  int ns;
144  int pri;
147 } *pkt_t;
148 
150 typedef struct item_st {
153  const char *name;
155  const char **groups;
157  int ngroups;
159  int to, from;
161  int ask;
163  int ver;
164 } *item_t;
165 
167 struct sm_st {
168  const char *id;
170  const char *router_ip;
172  const char *router_user;
173  const char *router_pass;
174  const char *router_pemfile;
202  const char *log_facility;
203  const char *log_ident;
210  storage_t st;
212  mm_t mm;
216  char signature[2048];
217  int siglen;
219  int started;
221  int online;
230 };
231 
233 struct user_st {
236  sm_t sm;
242  sess_t sessions;
243  sess_t top;
244  int available;
246  time_t active;
248  void **module_data;
249 };
250 
252 struct sess_st {
255  user_t user;
259  char c2s[1024];
261  char sm_id[41];
262  char c2s_id[44];
266  int available;
267  int pri;
268  int fake;
273  void **module_data;
275  sess_t next;
276 };
277 
278 extern sig_atomic_t sm_lost_router;
279 
280 /* functions */
281 SM_API xht aci_load(sm_t sm);
282 SM_API int aci_check(xht acls, const char *type, jid_t jid);
283 SM_API void aci_unload(xht acls);
284 
285 SM_API int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg);
286 SM_API int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg);
287 SM_API void sm_timestamp(time_t t, char timestamp[18]);
288 SM_API void sm_c2s_action(sess_t dest, const char *action, const char *target);
289 SM_API void sm_signature(sm_t sm, const char *str);
290 
291 SM_API int sm_register_ns(sm_t sm, const char *uri);
292 SM_API void sm_unregister_ns(sm_t sm, const char *uri);
293 SM_API int sm_get_ns(sm_t sm, const char *uri);
294 
295 SM_API int sm_storage_rate_limit(sm_t sm, const char *owner);
296 
297 SM_API void dispatch(sm_t sm, pkt_t pkt);
298 
299 SM_API pkt_t pkt_error(pkt_t pkt, int err);
301 SM_API pkt_t pkt_dup(pkt_t pkt, const char *to, const char *from);
302 SM_API pkt_t pkt_new(sm_t sm, nad_t nad);
303 SM_API void pkt_free(pkt_t pkt);
304 SM_API pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from);
305 SM_API void pkt_id(pkt_t src, pkt_t dest);
306 SM_API void pkt_id_new(pkt_t pkt);
307 SM_API void pkt_delay(pkt_t pkt, time_t t, const char *from);
308 
309 SM_API void pkt_router(pkt_t pkt);
310 SM_API void pkt_sess(pkt_t pkt, sess_t sess);
311 
312 SM_API int pres_trust(user_t user, jid_t jid);
313 SM_API void pres_roster(sess_t sess, item_t item);
314 SM_API void pres_update(sess_t sess, pkt_t pres);
315 SM_API void pres_error(sess_t sess, jid_t jid);
316 SM_API void pres_deliver(sess_t sess, pkt_t pres);
317 SM_API void pres_in(user_t user, pkt_t pres);
318 SM_API void pres_probe(user_t user);
319 
320 SM_API void sess_route(sess_t sess, pkt_t pkt);
321 SM_API sess_t sess_start(sm_t sm, jid_t jid);
322 SM_API void sess_end(sess_t sess);
323 SM_API sess_t sess_match(user_t user, const char *resource);
324 
325 SM_API user_t user_load(sm_t sm, jid_t jid);
326 SM_API void user_free(user_t user);
327 SM_API int user_create(sm_t sm, jid_t jid);
328 SM_API void user_delete(sm_t sm, jid_t jid);
329 
330 SM_API void feature_register(sm_t sm, const char *feature);
331 SM_API void feature_unregister(sm_t sm, const char *feature);
332 
333 
334 /* driver module manager */
335 
337 typedef enum {
340 } mod_ret_t;
341 
343 typedef enum {
358 } mod_chain_t;
359 
360 typedef struct module_st *module_t;
362 
364 struct mm_st {
365  sm_t sm;
369  int nindex;
372  mod_instance_t *sess_start; int nsess_start;
374  mod_instance_t *sess_end; int nsess_end;
376  mod_instance_t *in_sess; int nin_sess;
378  mod_instance_t *in_router; int nin_router;
380  mod_instance_t *out_sess; int nout_sess;
382  mod_instance_t *out_router; int nout_router;
384  mod_instance_t *pkt_sm; int npkt_sm;
386  mod_instance_t *pkt_user; int npkt_user;
388  mod_instance_t *pkt_router; int npkt_router;
390  mod_instance_t *user_load; int nuser_load;
392  mod_instance_t *user_create; int nuser_create;
394  mod_instance_t *user_delete; int nuser_delete;
396  mod_instance_t *disco_extend; int ndisco_extend;
398  mod_instance_t *user_unload; int nuser_unload;
399 };
400 
402 struct module_st {
403  mm_t mm;
405  const char *name;
407  int index;
411  void *handle;
415  int init;
417  void *private;
419  int (*sess_start)(mod_instance_t mi, sess_t sess);
420  void (*sess_end)(mod_instance_t mi, sess_t sess);
422  mod_ret_t (*in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt);
423  mod_ret_t (*in_router)(mod_instance_t mi, pkt_t pkt);
425  mod_ret_t (*out_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt);
426  mod_ret_t (*out_router)(mod_instance_t mi, pkt_t pkt);
428  mod_ret_t (*pkt_sm)(mod_instance_t mi, pkt_t pkt);
429  mod_ret_t (*pkt_user)(mod_instance_t mi, user_t user, pkt_t pkt);
431  mod_ret_t (*pkt_router)(mod_instance_t mi, pkt_t pkt);
433  int (*user_load)(mod_instance_t mi, user_t user);
434  int (*user_unload)(mod_instance_t mi, user_t user);
436  int (*user_create)(mod_instance_t mi, jid_t jid);
437  void (*user_delete)(mod_instance_t mi, jid_t jid);
439  void (*disco_extend)(mod_instance_t mi, pkt_t pkt);
441  void (*free)(module_t mod);
442 };
443 
446  sm_t sm;
448  module_t mod;
450  int seq;
454  const char *arg;
455 };
456 
458 SM_API mm_t mm_new(sm_t sm);
460 SM_API void mm_free(mm_t mm);
461 
463 SM_API int mm_sess_start(mm_t mm, sess_t sess);
465 SM_API void mm_sess_end(mm_t mm, sess_t sess);
466 
468 SM_API mod_ret_t mm_in_sess(mm_t mm, sess_t sess, pkt_t pkt);
470 SM_API mod_ret_t mm_in_router(mm_t mm, pkt_t pkt);
471 
473 SM_API mod_ret_t mm_out_sess(mm_t mm, sess_t sess, pkt_t pkt);
475 SM_API mod_ret_t mm_out_router(mm_t mm, pkt_t pkt);
476 
478 SM_API mod_ret_t mm_pkt_sm(mm_t mm, pkt_t pkt);
480 SM_API mod_ret_t mm_pkt_user(mm_t mm, user_t user, pkt_t pkt);
481 
483 SM_API mod_ret_t mm_pkt_router(mm_t mm, pkt_t pkt);
484 
486 SM_API int mm_user_load(mm_t mm, user_t user);
487 
489 SM_API int mm_user_unload(mm_t mm, user_t user);
490 
492 SM_API int mm_user_create(mm_t mm, jid_t jid);
494 SM_API void mm_user_delete(mm_t mm, jid_t jid);
495 
497 SM_API void mm_disco_extend(mm_t mm, pkt_t pkt);
SM_API int pres_trust(user_t user, jid_t jid)
see if the jid is trusted (ie in the roster with s10n="from" or "both")
Definition: pres.c:337
user_t user
user this session belongs to
Definition: sm.h:255
xht roster
roster for this user (key is full jid of item, value is item_t)
Definition: sm.h:240
int(* module_init_fn)(mod_instance_t)
module init function
Definition: sm.h:413
const char * log_facility
syslog facility (local0 - local7)
Definition: sm.h:202
pkt_type_t type
packet type
Definition: sm.h:138
jid_t jid
session jid (user@host/res)
Definition: sm.h:257
static sm_t sm
Definition: main.c:33
mod_instance_t * pkt_user
pkt-user chain
Definition: sm.h:386
Definition: nad.h:93
user deletion, delete saved per-user data
Definition: sm.h:355
struct mm_st * mm_t
Definition: sm.h:63
xht query_rates
Definition: sm.h:229
mod_instance_t * sess_end
sess-end chain
Definition: sm.h:374
int retry_init
number of times to try connecting to the router at startup
Definition: sm.h:205
session end request
Definition: sm.h:110
subscribe request
Definition: sm.h:102
int nindex
counter for module instance sequence (!!! should be local to mm_new)
Definition: sm.h:369
int query_rate_seconds
Definition: sm.h:227
packet error
Definition: sm.h:115
SM_API mod_ret_t mm_pkt_sm(mm_t mm, pkt_t pkt)
fire pkt-sm chain
Definition: mm.c:567
SM_API void user_delete(sm_t sm, jid_t jid)
trash a user
Definition: user.c:121
const char * id
component id
Definition: sm.h:168
pkt_t pres
copy of the last presence packet we received
Definition: sm.h:264
mod_instance_t * pkt_sm
pkt-sm chain
Definition: sm.h:384
session start request
Definition: sm.h:109
SM_API void pres_deliver(sess_t sess, pkt_t pres)
outgoing directed presence
Definition: pres.c:304
int pri
current priority of this session
Definition: sm.h:267
route_type_t
route types
Definition: router.h:200
mod_ret_t(* out_router)(mod_instance_t mi, pkt_t pkt)
out-router handler
Definition: sm.h:426
disco request, extend sm disco::info
Definition: sm.h:357
sig_atomic_t sm_lost_router
Definition: sm.c:30
int pri
presence priority
Definition: sm.h:144
jid_t rfrom
addressing of enclosing route
Definition: sm.h:134
SM_API void pres_roster(sess_t sess, item_t item)
send presence based on roster changes
Definition: pres.c:359
single instance of a module in a chain
Definition: sm.h:445
SM_API int mm_sess_start(mm_t mm, sess_t sess)
fire sess-start chain
Definition: mm.c:384
log_t log
log context
Definition: sm.h:199
packet for the sm itself
Definition: sm.h:350
int nuser_unload
Definition: sm.h:398
SM_API int mm_user_load(mm_t mm, user_t user)
fire user-load chain
Definition: mm.c:659
config_t config
config context
Definition: sm.h:197
int init
number of times the module intialiser has been called
Definition: sm.h:415
message (groupchat)
Definition: sm.h:98
jid_t A
list of jids that this session has sent directed presence to
Definition: sm.h:270
mm_t mm
module subsystem
Definition: sm.h:212
xht hosts
vHosts map
Definition: sm.h:223
an environment
Definition: sx.h:379
no route
Definition: sm.h:120
int ask
pending subscription (0 == none, 1 == subscribe, 2 == unsubscribe)
Definition: sm.h:161
route error
Definition: sm.h:125
void(* sess_end)(mod_instance_t mi, sess_t sess)
sess-end handler
Definition: sm.h:420
SM_API int mm_user_unload(mm_t mm, user_t user)
fire user-unload chain
Definition: mm.c:690
SM_API void pkt_free(pkt_t pkt)
Definition: pkt.c:315
info/query (set)
Definition: sm.h:107
SM_API void pkt_sess(pkt_t pkt, sess_t sess)
Definition: pkt.c:459
mod_chain_t
module chain types
Definition: sm.h:343
user loaded, load per-user data
Definition: sm.h:353
mod_instance_t * in_sess
in-sess chain
Definition: sm.h:376
void ** module_data
per-session module data
Definition: sm.h:273
jid_t rto
Definition: sm.h:134
no packet
Definition: sm.h:94
mod_ret_t(* out_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
out-sess handler
Definition: sm.h:425
int nsess_end
Definition: sm.h:374
session request (mask)
Definition: sm.h:114
user creation, generate and save per-user data
Definition: sm.h:354
SM_API int mm_user_create(mm_t mm, jid_t jid)
fire user-create chain
Definition: mm.c:721
a plugin
Definition: sx.h:344
sm_t sm
sm context
Definition: sm.h:236
info/query (result)
Definition: sm.h:108
SM_API void pkt_id_new(pkt_t pkt)
create an id value for new iq packets
Definition: pkt.c:364
holder for the config hash and nad
Definition: util.h:200
SM_API user_t user_load(sm_t sm, jid_t jid)
fetch user data
Definition: user.c:52
mod_ret_t(* in_router)(mod_instance_t mi, pkt_t pkt)
in-router handler
Definition: sm.h:423
session start, load per-session data
Definition: sm.h:344
common URIs
sm_t sm
sm context
Definition: sm.h:130
mio_action_t
these are the actions and a handler type assigned by the applicaiton using mio
Definition: mio.h:106
Definition: mio.h:109
SM_API void pres_in(user_t user, pkt_t pres)
presence updates from a remote jid - RFC 3921bis 4.3.2.
Definition: pres.c:212
int index
module index.
Definition: sm.h:407
xht sessions
pointers to all connected sessions (key is random sm id)
Definition: sm.h:190
char c2s_id[44]
remote id (for session control)
Definition: sm.h:262
sx_plugin_t sx_ssl
SX SSL plugin.
Definition: sm.h:183
SM_API int sm_storage_rate_limit(sm_t sm, const char *owner)
Definition: sm.c:355
SM_API mod_ret_t mm_in_router(mm_t mm, pkt_t pkt)
fire in-router chain
Definition: mm.c:473
xht users
pointers to currently loaded users (key is user@domain)
Definition: sm.h:188
SM_API void pkt_delay(pkt_t pkt, time_t t, const char *from)
add an x:delay stamp
Definition: pkt.c:508
pool_t p
memory pool this session is allocated off
Definition: sm.h:253
mm_t mm
module manager
Definition: sm.h:403
int npkt_sm
Definition: sm.h:384
xht modules
pointers to module data (key is module name)
Definition: sm.h:367
int ndisco_extend
Definition: sm.h:396
int siglen
length of signature
Definition: sm.h:217
sess_t next
next session (in a list of sessions)
Definition: sm.h:275
int npkt_user
Definition: sm.h:386
presence (unavailable)
Definition: sm.h:100
sess_t top
top priority session
Definition: sm.h:243
SM_API int sm_get_ns(sm_t sm, const char *uri)
get a globally registered ns
Definition: sm.c:349
sm_t sm
sm context
Definition: sm.h:365
mod_ret_t(* in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
in-sess handler
Definition: sm.h:422
int retry_left
number of tries left before failure
Definition: sm.h:208
mod_ret_t(* pkt_router)(mod_instance_t mi, pkt_t pkt)
pkt-router handler
Definition: sm.h:431
SM_API void mm_user_delete(mm_t mm, jid_t jid)
fire user-delete chain
Definition: mm.c:752
void * handle
module handle
Definition: sm.h:411
pool_t p
memory pool this user is allocated off
Definition: sm.h:234
int nuser_delete
Definition: sm.h:394
packet for a user
Definition: sm.h:351
SM_API pkt_t pkt_tofrom(pkt_t pkt)
swap a packet's to and from attributes
Definition: pkt.c:57
mio - manage i/o
holds the state for a single stream
Definition: sx.h:251
sess_t sessions
list of action sessions
Definition: sm.h:242
SM_API mod_ret_t mm_out_sess(mm_t mm, sess_t sess, pkt_t pkt)
fire out-sess chain
Definition: mm.c:505
int nuser_load
Definition: sm.h:390
module_t mod
module that this is an instance of
Definition: sm.h:448
jid_t from
packet addressing (not used for routing)
Definition: sm.h:140
pkt_type_t
packet types
Definition: sm.h:93
sx_t router
SX of router connection.
Definition: sm.h:185
mod_instance_t * out_router
out-router chain
Definition: sm.h:382
packet summary data wrapper
Definition: sm.h:129
SM_API pkt_t pkt_new(sm_t sm, nad_t nad)
Definition: pkt.c:113
SM_API sess_t sess_start(sm_t sm, jid_t jid)
Definition: sess.c:103
struct _log_st * log_t
Definition: log.h:48
xht xmlns_refcount
ref-counting for modules namespaces
Definition: sm.h:193
int npkt_router
Definition: sm.h:388
storage_t st
storage subsystem
Definition: sm.h:210
nad_t nad
nad of the entire packet
Definition: sm.h:146
log_type_t
Definition: log.h:41
packet from the router
Definition: sm.h:347
session manager global context
Definition: sm.h:167
mod_instance_t * in_router
in-router chain
Definition: sm.h:378
packet from an active session
Definition: sm.h:346
advertisement (available)
Definition: sm.h:123
message (chat)
Definition: sm.h:96
SM_API pkt_t pkt_dup(pkt_t pkt, const char *to, const char *from)
duplicate pkt, replacing addresses
Definition: pkt.c:84
session delete request
Definition: sm.h:112
SM_API mod_ret_t mm_pkt_router(mm_t mm, pkt_t pkt)
fire pkt-router chain
Definition: mm.c:628
log_type_t log_type
log type
Definition: sm.h:201
SM_API void sess_end(sess_t sess)
Definition: sess.c:85
const char * router_private_key_password
Definition: sm.h:176
SM_API void sm_c2s_action(sess_t dest, const char *action, const char *target)
send a new action route
Definition: sm.c:280
int ngroups
number of groups in groups array
Definition: sm.h:157
char sm_id[41]
local id (for session control)
Definition: sm.h:261
mod_instance_t * user_unload
user-unload chain
Definition: sm.h:398
Definition: jid.h:42
int nout_router
Definition: sm.h:382
broadcast
Definition: sm.h:122
int nsess_start
Definition: sm.h:372
int nuser_create
Definition: sm.h:392
struct pkt_st * pkt_t
packet summary data wrapper
const char ** groups
groups this item is in
Definition: sm.h:155
struct sm_st * sm_t
Definition: sm.h:59
mod_ret_t(* pkt_user)(mod_instance_t mi, user_t user, pkt_t pkt)
pkt-user handler
Definition: sm.h:429
SM_API pkt_t pkt_error(pkt_t pkt, int err)
Definition: pkt.c:30
const char * log_ident
log identifier
Definition: sm.h:203
struct sess_st * sess_t
Definition: sm.h:61
struct aci_st * aci_t
Definition: sm.h:62
int nout_sess
Definition: sm.h:380
const char * router_user
username to authenticate to the router as
Definition: sm.h:172
SM_API void sm_unregister_ns(sm_t sm, const char *uri)
unregister a global ns
Definition: sm.c:338
SM_API void feature_register(sm_t sm, const char *feature)
register a feature
Definition: feature.c:37
roster items
Definition: sm.h:150
const char * router_pass
password to authenticate to the router with
Definition: sm.h:173
SM_API int aci_check(xht acls, const char *type, jid_t jid)
see if a jid is in an acl
Definition: aci.c:86
info/query (get)
Definition: sm.h:106
struct item_st * item_t
roster items
SM_API void mm_disco_extend(mm_t mm, pkt_t pkt)
fire disco-extend chain
Definition: mm.c:778
sx_env_t sx_env
SX environment.
Definition: sm.h:181
SM_API void aci_unload(xht acls)
unload aci table
Definition: aci.c:114
presence
Definition: sm.h:99
struct user_st * user_t
Definition: sm.h:60
packet was unhandled, should be passed to the next module
Definition: sm.h:339
int ns
iq sub-namespace
Definition: sm.h:142
int retry_lost
number of times to try reconnecting to the router if the connection drops
Definition: sm.h:206
mod_instance_t * disco_extend
disco-extend chain
Definition: sm.h:396
SM_API void mm_free(mm_t mm)
free a mm instance
Definition: mm.c:291
mod_instance_t * sess_start
sess-start chain
Definition: sm.h:372
route_type_t
route types
Definition: sm.h:119
SM_API void feature_unregister(sm_t sm, const char *feature)
unregister feature
Definition: feature.c:45
SM_API void user_free(user_t user)
Definition: user.c:80
packet was handled (and freed)
Definition: sm.h:338
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:216
unsubscribe request
Definition: sm.h:104
int nin_router
Definition: sm.h:378
SM_API void sess_route(sess_t sess, pkt_t pkt)
send a packet to the client for this session
Definition: sess.c:31
int(* user_load)(mod_instance_t mi, user_t user)
user-load handler
Definition: sm.h:433
subscribed response
Definition: sm.h:103
SM_API void pres_probe(user_t user)
Definition: pres.c:380
const char * router_ip
ip to connect to the router at
Definition: sm.h:170
SM_API mod_ret_t mm_out_router(mm_t mm, pkt_t pkt)
fire out-router chain
Definition: mm.c:536
int fake
true if session is fake (ie.
Definition: sm.h:268
mio_fd_t fd
file descriptor of router connection
Definition: sm.h:186
module manager data
Definition: sm.h:364
SM_API int sm_register_ns(sm_t sm, const char *uri)
register a new global ns
Definition: sm.c:324
const char * router_pemfile
name of file containing a SSL certificate & key for channel to the router
Definition: sm.h:174
void(* user_delete)(mod_instance_t mi, jid_t jid)
user-delete handler
Definition: sm.h:437
mod_ret_t(* pkt_sm)(mod_instance_t mi, pkt_t pkt)
pkt-sm handler
Definition: sm.h:428
mod_chain_t chain
chain this instance is in
Definition: sm.h:452
int available
true if this session is available
Definition: sm.h:266
message
Definition: sm.h:95
SM_API void pkt_id(pkt_t src, pkt_t dest)
convenience - copy the packet id from src to dest
Definition: pkt.c:353
mio_t mio
password for private key if pemfile key is encrypted
Definition: sm.h:179
SM_API pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
Definition: pkt.c:328
SM_API int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
Definition: sm.c:241
jid_t to
Definition: sm.h:140
int from
subscription to this item (they get presence FROM us, they send presence TO us)
Definition: sm.h:159
const char * arg
option arg that this instance was started with
Definition: sm.h:454
int query_rate_wait
Definition: sm.h:228
mod_instance_t * pkt_router
pkt-router chain
Definition: sm.h:388
jid_t jid
id of this item
Definition: sm.h:151
int started
true if we've connected to the router at least once
Definition: sm.h:219
int to
Definition: sm.h:159
session ended, save & free per-session data
Definition: sm.h:345
mod_instance_t * user_delete
user-delete chain
Definition: sm.h:394
int(* user_unload)(mod_instance_t mi, user_t user)
user-load handler
Definition: sm.h:434
int online
true if we're currently bound in the router
Definition: sm.h:221
SM_API void pres_update(sess_t sess, pkt_t pres)
presence updates from a session
Definition: pres.c:72
int retry_sleep
sleep interval between retries
Definition: sm.h:207
Definition: mio.h:100
jid_t jid
user jid (user@host)
Definition: sm.h:238
user is about to be unloaded
Definition: sm.h:356
SM_API void dispatch(sm_t sm, pkt_t pkt)
main packet dispatcher
Definition: dispatch.c:31
void(* disco_extend)(mod_instance_t mi, pkt_t pkt)
disco-extend handler
Definition: sm.h:439
xht acls
access control lists (key is list name, value is jid_t list)
Definition: sm.h:214
mod_instance_t * out_sess
out-sess chain
Definition: sm.h:380
const char * name
name of module
Definition: sm.h:405
int(* sess_start)(mod_instance_t mi, sess_t sess)
sess-start handler
Definition: sm.h:419
advertisement (unavailable)
Definition: sm.h:124
message (headline)
Definition: sm.h:97
jid_t E
list of jids that bounced presence updates we sent them
Definition: sm.h:271
SM_API int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg)
our master callback
Definition: sm.c:33
sx_event_t
things that can happen
Definition: sx.h:56
void(* free)(module_t mod)
called when module is freed
Definition: sm.h:441
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
Definition: sm.h:192
data for a single module
Definition: sm.h:402
SM_API void sm_timestamp(time_t t, char timestamp[18])
SM_API mod_ret_t mm_in_sess(mm_t mm, sess_t sess, pkt_t pkt)
fire in-sess chain
Definition: mm.c:441
unicast
Definition: sm.h:121
int query_rate_total
Database query rate limits.
Definition: sm.h:226
int nin_sess
Definition: sm.h:376
c2s_t c2s
Definition: c2s.h:75
SM_API mod_ret_t mm_pkt_user(mm_t mm, user_t user, pkt_t pkt)
fire pkt-user chain
Definition: mm.c:597
packet to a router
Definition: sm.h:349
void ** module_data
per-user module data
Definition: sm.h:248
presence (probe)
Definition: sm.h:101
packet from the router (special purpose)
Definition: sm.h:352
#define SM_API
Definition: sm.h:55
pool - base node for a pool.
Definition: pool.h:80
session create request
Definition: sm.h:111
packet to an active session
Definition: sm.h:348
SM_API void mm_sess_end(mm_t mm, sess_t sess)
fire sess-end chain
Definition: mm.c:415
SM_API mm_t mm_new(sm_t sm)
allocate a module manager instance, and loads the modules
Definition: mm.c:47
SM_API sess_t sess_match(user_t user, const char *resource)
match a session by resource
Definition: sess.c:206
mod_ret_t
module return values
Definition: sm.h:337
SM_API void pkt_router(pkt_t pkt)
Definition: pkt.c:379
sess_t source
session this packet came from
Definition: sm.h:132
int router_port
port to connect to the router at
Definition: sm.h:171
struct mod_instance_st * mod_instance_t
Definition: sm.h:361
int seq
number of this instance
Definition: sm.h:450
sm_t sm
sm context
Definition: sm.h:446
mod_instance_t * user_load
user-load chain
Definition: sm.h:390
int(* user_create)(mod_instance_t mi, jid_t jid)
user-create handler
Definition: sm.h:436
int available
true if this user has any available session
Definition: sm.h:244
mod_instance_t * user_create
user-create chain
Definition: sm.h:392
int ver
roster item version number
Definition: sm.h:163
SM_API xht aci_load(sm_t sm)
Definition: aci.c:30
sx_plugin_t sx_sasl
SX SASL plugin.
Definition: sm.h:182
time_t active
time that user first logged in (ever)
Definition: sm.h:246
struct module_st * module_t
Definition: sm.h:360
SM_API void pres_error(sess_t sess, jid_t jid)
Definition: pres.c:296
SM_API int user_create(sm_t sm, jid_t jid)
initialise a user
Definition: user.c:88
data for a single user
Definition: sm.h:233
const char * name
display name
Definition: sm.h:153
SM_API void sm_signature(sm_t sm, const char *str)
this is gratuitous, but apache gets one, so why not?
Definition: sm.c:313
unsubscribed response
Definition: sm.h:105
session request failed (mask)
Definition: sm.h:113
route_type_t rtype
type of enclosing route
Definition: sm.h:136
xht features
feature index (key is feature string
Definition: sm.h:195