39 int len, ns, elem, attr;
116 log_write(sm->
log, LOG_NOTICE,
"connection to router established");
133 if (strlen(sm->
id) == len && strncmp(sm->
id, domain, len) == 0)
141 log_debug(
ZONE,
"requesting domain bind for '%.*s'", len, domain);
160 log_debug(
ZONE,
"got a non-features packet on an unauth'd stream, dropping");
176 log_write(sm->
log, LOG_NOTICE,
"unable to establish encrypted session with router");
197 log_debug(
ZONE,
"got a packet from router, but we're not online, dropping");
249 ioctl(fd->
fd, FIONREAD, &nbytes);
263 log_write(sm->
log, LOG_NOTICE,
"connection to router closed");
295 if (dest->
c2s_id[0] !=
'\0')
297 if (dest->
sm_id[0] !=
'\0')
305 "routing nad to %s from %s c2s %s s2s %s action %s target %s",
316 sm->
siglen += strlen(str);
319 sm->
siglen += strlen(str) + 1;
343 }
else if (refcount > 1) {
376 for (sess = user->
sessions; sess != NULL; sess = sess->
next) {
391 log_debug(
ZONE,
"Error: could not get user data for %s", owner);
user_t user
user this session belongs to
xht roster
roster for this user (key is full jid of item, value is item_t)
int sm_register_ns(sm_t sm, const char *uri)
register a new global ns
nad_t nad_new(void)
create a new nad
int nad_append_attr(nad_t nad, int ns, const char *name, const char *val)
attach new attr to the last elem
data structures and prototypes for the session manager
const char * id
component id
#define sx_nad_write(s, nad)
void sm_unregister_ns(sm_t sm, const char *uri)
unregister a global ns
const char * jid_full(jid_t jid)
expand and return the full
void rate_add(rate_t rt, int count)
Add a number of events to the counter.
int nad_find_elem(nad_t nad, int elem, int ns, const char *name, int depth)
locate the next elem at a given depth with an optional matching name
void log_write(log_t log, int level, const char *msgfmt,...)
rate_t rate_new(int total, int seconds, int wait)
error info for event_ERROR
void sm_c2s_action(sess_t dest, const char *action, const char *target)
send a new action route
int nad_add_namespace(nad_t nad, const char *uri, const char *prefix)
bring a new namespace into scope
mio_action_t
these are the actions and a handler type assigned by the applicaiton using mio
int nad_append_elem(nad_t nad, int ns, const char *name, int depth)
create a new elem on the list
void nad_free(nad_t nad)
free that nad
int xhash_iter_next(xht h)
char c2s_id[44]
remote id (for session control)
sx_plugin_t sx_ssl
SX SSL plugin.
xht users
pointers to currently loaded users (key is user@domain)
void rate_free(rate_t rt)
#define mio_read(m, fd)
process read events for this fd
int siglen
length of signature
sess_t next
next session (in a list of sessions)
void nad_set_attr(nad_t nad, int elem, int ns, const char *name, const char *val, int vallen)
create, update, or zap any matching attr on this elem
#define MIO_ERROR
all MIO related routines should use those for error reporting
pkt_t pkt_new(sm_t sm, nad_t nad)
void pool_cleanup(pool_t p, pool_cleanup_t f, void *arg)
public cleanup utils, insert in a way that they are run FIFO, before mem frees
int sx_can_read(sx_t s)
we can read
int retry_left
number of tries left before failure
holds the state for a single stream
sess_t sessions
list of action sessions
sx_t router
SX of router connection.
packet summary data wrapper
xht xmlns_refcount
ref-counting for modules namespaces
int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
#define NAD_ENAME_L(N, E)
#define NAD_NURI_L(N, NS)
session manager global context
void xhash_put(xht h, const char *key, void *val)
int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg)
our master callback
char sm_id[41]
local id (for session control)
int xhash_iter_get(xht h, const char **key, int *keylen, void **val)
void sm_signature(sm_t sm, const char *str)
this is gratuitous, but apache gets one, so why not?
void pkt_router(pkt_t pkt)
void xhash_zap(xht h, const char *key)
const char * router_user
username to authenticate to the router as
const char * router_pass
password to authenticate to the router with
int rate_check(rate_t rt)
struct _sx_buf_st * sx_buf_t
utility: buffer
int retry_lost
number of times to try reconnecting to the router if the connection drops
JABBERD2_API int sx_sasl_auth(sx_plugin_t p, sx_t s, const char *appname, const char *mech, const char *user, const char *pass)
trigger for client auth
There is one instance of this struct per user who is logged in to this c2s instance.
char signature[2048]
server signature
int sm_get_ns(sm_t sm, const char *uri)
get a globally registered ns
int xhash_count(xht h)
return the total number of entries in this xht
int xhash_iter_first(xht h)
iteration
mio_fd_t fd
file descriptor of router connection
sig_atomic_t sm_lost_router
int started
true if we've connected to the router at least once
pool_t xhash_pool(xht h)
get our pool
int online
true if we're currently bound in the router
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...
jid_t jid
user jid (user@host)
void * xhash_get(xht h, const char *key)
#define mio_close(m, fd)
request that mio close this fd
#define mio_write(m, fd)
mio should try the write action on this fd now
sx_event_t
things that can happen
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
int nad_find_attr(nad_t nad, int elem, int ns, const char *name, const char *val)
get a matching attr on this elem, both name and optional val
int query_rate_total
Database query rate limits.
pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
void dispatch(sm_t sm, pkt_t pkt)
main packet dispatcher
int sx_ssl_client_starttls(sx_plugin_t p, sx_t s, const char *pemfile, const char *private_key_password)
int sm_storage_rate_limit(sm_t sm, const char *owner)
sx_plugin_t sx_sasl
SX SASL plugin.
int nad_find_scoped_namespace(nad_t nad, const char *uri, const char *prefix)
find a namespace in scope