36 #include "storage/storage.h"
41 #ifdef HAVE_SYS_STAT_H
47 #define DLLEXPORT __declspec(dllexport)
48 #define SM_API __declspec(dllimport)
50 #define DLLEXPORT __declspec(dllimport)
51 #define SM_API __declspec(dllexport)
70 #define ns_REGISTER (2)
76 #define ns_GATEWAY (8)
78 #define ns_SEARCH (10)
80 #define ns_DISCO_ITEMS (12)
81 #define ns_DISCO_INFO (13)
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)
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")
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(* module_init_fn)(mod_instance_t)
module init function
const char * log_facility
syslog facility (local0 - local7)
pkt_type_t type
packet type
jid_t jid
session jid (user@host/res)
mod_instance_t * pkt_user
pkt-user chain
user deletion, delete saved per-user data
mod_instance_t * sess_end
sess-end chain
int retry_init
number of times to try connecting to the router at startup
int nindex
counter for module instance sequence (!!! should be local to mm_new)
SM_API mod_ret_t mm_pkt_sm(mm_t mm, pkt_t pkt)
fire pkt-sm chain
SM_API void user_delete(sm_t sm, jid_t jid)
trash a user
const char * id
component id
pkt_t pres
copy of the last presence packet we received
mod_instance_t * pkt_sm
pkt-sm chain
SM_API void pres_deliver(sess_t sess, pkt_t pres)
outgoing directed presence
int pri
current priority of this session
mod_ret_t(* out_router)(mod_instance_t mi, pkt_t pkt)
out-router handler
disco request, extend sm disco::info
sig_atomic_t sm_lost_router
jid_t rfrom
addressing of enclosing route
SM_API void pres_roster(sess_t sess, item_t item)
send presence based on roster changes
single instance of a module in a chain
SM_API int mm_sess_start(mm_t mm, sess_t sess)
fire sess-start chain
SM_API int mm_user_load(mm_t mm, user_t user)
fire user-load chain
config_t config
config context
int init
number of times the module intialiser has been called
jid_t A
list of jids that this session has sent directed presence to
int ask
pending subscription (0 == none, 1 == subscribe, 2 == unsubscribe)
void(* sess_end)(mod_instance_t mi, sess_t sess)
sess-end handler
SM_API int mm_user_unload(mm_t mm, user_t user)
fire user-unload chain
SM_API void pkt_free(pkt_t pkt)
SM_API void pkt_sess(pkt_t pkt, sess_t sess)
mod_chain_t
module chain types
user loaded, load per-user data
mod_instance_t * in_sess
in-sess chain
void ** module_data
per-session module data
mod_ret_t(* out_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
out-sess handler
user creation, generate and save per-user data
SM_API int mm_user_create(mm_t mm, jid_t jid)
fire user-create chain
SM_API void pkt_id_new(pkt_t pkt)
create an id value for new iq packets
holder for the config hash and nad
SM_API user_t user_load(sm_t sm, jid_t jid)
fetch user data
mod_ret_t(* in_router)(mod_instance_t mi, pkt_t pkt)
in-router handler
session start, load per-session data
mio_action_t
these are the actions and a handler type assigned by the applicaiton using mio
SM_API void pres_in(user_t user, pkt_t pres)
presence updates from a remote jid - RFC 3921bis 4.3.2.
xht sessions
pointers to all connected sessions (key is random sm id)
char c2s_id[44]
remote id (for session control)
sx_plugin_t sx_ssl
SX SSL plugin.
SM_API int sm_storage_rate_limit(sm_t sm, const char *owner)
SM_API mod_ret_t mm_in_router(mm_t mm, pkt_t pkt)
fire in-router chain
xht users
pointers to currently loaded users (key is user@domain)
SM_API void pkt_delay(pkt_t pkt, time_t t, const char *from)
add an x:delay stamp
pool_t p
memory pool this session is allocated off
xht modules
pointers to module data (key is module name)
int siglen
length of signature
sess_t next
next session (in a list of sessions)
sess_t top
top priority session
SM_API int sm_get_ns(sm_t sm, const char *uri)
get a globally registered ns
mod_ret_t(* in_sess)(mod_instance_t mi, sess_t sess, pkt_t pkt)
in-sess handler
int retry_left
number of tries left before failure
mod_ret_t(* pkt_router)(mod_instance_t mi, pkt_t pkt)
pkt-router handler
SM_API void mm_user_delete(mm_t mm, jid_t jid)
fire user-delete chain
void * handle
module handle
pool_t p
memory pool this user is allocated off
SM_API pkt_t pkt_tofrom(pkt_t pkt)
swap a packet's to and from attributes
holds the state for a single stream
sess_t sessions
list of action sessions
SM_API mod_ret_t mm_out_sess(mm_t mm, sess_t sess, pkt_t pkt)
fire out-sess chain
module_t mod
module that this is an instance of
jid_t from
packet addressing (not used for routing)
sx_t router
SX of router connection.
mod_instance_t * out_router
out-router chain
packet summary data wrapper
SM_API pkt_t pkt_new(sm_t sm, nad_t nad)
SM_API sess_t sess_start(sm_t sm, jid_t jid)
xht xmlns_refcount
ref-counting for modules namespaces
storage_t st
storage subsystem
nad_t nad
nad of the entire packet
session manager global context
mod_instance_t * in_router
in-router chain
packet from an active session
advertisement (available)
SM_API pkt_t pkt_dup(pkt_t pkt, const char *to, const char *from)
duplicate pkt, replacing addresses
SM_API mod_ret_t mm_pkt_router(mm_t mm, pkt_t pkt)
fire pkt-router chain
log_type_t log_type
log type
SM_API void sess_end(sess_t sess)
const char * router_private_key_password
SM_API void sm_c2s_action(sess_t dest, const char *action, const char *target)
send a new action route
int ngroups
number of groups in groups array
char sm_id[41]
local id (for session control)
mod_instance_t * user_unload
user-unload chain
struct pkt_st * pkt_t
packet summary data wrapper
const char ** groups
groups this item is in
mod_ret_t(* pkt_user)(mod_instance_t mi, user_t user, pkt_t pkt)
pkt-user handler
SM_API pkt_t pkt_error(pkt_t pkt, int err)
const char * log_ident
log identifier
const char * router_user
username to authenticate to the router as
SM_API void sm_unregister_ns(sm_t sm, const char *uri)
unregister a global ns
SM_API void feature_register(sm_t sm, const char *feature)
register a feature
const char * router_pass
password to authenticate to the router with
SM_API int aci_check(xht acls, const char *type, jid_t jid)
see if a jid is in an acl
struct item_st * item_t
roster items
SM_API void mm_disco_extend(mm_t mm, pkt_t pkt)
fire disco-extend chain
sx_env_t sx_env
SX environment.
SM_API void aci_unload(xht acls)
unload aci table
packet was unhandled, should be passed to the next module
int retry_lost
number of times to try reconnecting to the router if the connection drops
mod_instance_t * disco_extend
disco-extend chain
SM_API void mm_free(mm_t mm)
free a mm instance
mod_instance_t * sess_start
sess-start chain
SM_API void feature_unregister(sm_t sm, const char *feature)
unregister feature
SM_API void user_free(user_t user)
packet was handled (and freed)
There is one instance of this struct per user who is logged in to this c2s instance.
char signature[2048]
server signature
SM_API void sess_route(sess_t sess, pkt_t pkt)
send a packet to the client for this session
int(* user_load)(mod_instance_t mi, user_t user)
user-load handler
SM_API void pres_probe(user_t user)
const char * router_ip
ip to connect to the router at
SM_API mod_ret_t mm_out_router(mm_t mm, pkt_t pkt)
fire out-router chain
int fake
true if session is fake (ie.
mio_fd_t fd
file descriptor of router connection
SM_API int sm_register_ns(sm_t sm, const char *uri)
register a new global ns
const char * router_pemfile
name of file containing a SSL certificate & key for channel to the router
void(* user_delete)(mod_instance_t mi, jid_t jid)
user-delete handler
mod_ret_t(* pkt_sm)(mod_instance_t mi, pkt_t pkt)
pkt-sm handler
mod_chain_t chain
chain this instance is in
int available
true if this session is available
SM_API void pkt_id(pkt_t src, pkt_t dest)
convenience - copy the packet id from src to dest
mio_t mio
password for private key if pemfile key is encrypted
SM_API pkt_t pkt_create(sm_t sm, const char *elem, const char *type, const char *to, const char *from)
SM_API int sm_mio_callback(mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg)
int from
subscription to this item (they get presence FROM us, they send presence TO us)
const char * arg
option arg that this instance was started with
mod_instance_t * pkt_router
pkt-router chain
int started
true if we've connected to the router at least once
session ended, save & free per-session data
mod_instance_t * user_delete
user-delete chain
int(* user_unload)(mod_instance_t mi, user_t user)
user-load handler
int online
true if we're currently bound in the router
SM_API void pres_update(sess_t sess, pkt_t pres)
presence updates from a session
int retry_sleep
sleep interval between retries
jid_t jid
user jid (user@host)
user is about to be unloaded
SM_API void dispatch(sm_t sm, pkt_t pkt)
main packet dispatcher
void(* disco_extend)(mod_instance_t mi, pkt_t pkt)
disco-extend handler
xht acls
access control lists (key is list name, value is jid_t list)
mod_instance_t * out_sess
out-sess chain
const char * name
name of module
int(* sess_start)(mod_instance_t mi, sess_t sess)
sess-start handler
advertisement (unavailable)
jid_t E
list of jids that bounced presence updates we sent them
SM_API int sm_sx_callback(sx_t s, sx_event_t e, void *data, void *arg)
our master callback
sx_event_t
things that can happen
void(* free)(module_t mod)
called when module is freed
xht xmlns
index of namespaces (for iq sub-namespace in pkt_t)
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
int query_rate_total
Database query rate limits.
SM_API mod_ret_t mm_pkt_user(mm_t mm, user_t user, pkt_t pkt)
fire pkt-user chain
void ** module_data
per-user module data
packet from the router (special purpose)
pool - base node for a pool.
packet to an active session
SM_API void mm_sess_end(mm_t mm, sess_t sess)
fire sess-end chain
SM_API mm_t mm_new(sm_t sm)
allocate a module manager instance, and loads the modules
SM_API sess_t sess_match(user_t user, const char *resource)
match a session by resource
mod_ret_t
module return values
SM_API void pkt_router(pkt_t pkt)
sess_t source
session this packet came from
int router_port
port to connect to the router at
struct mod_instance_st * mod_instance_t
int seq
number of this instance
mod_instance_t * user_load
user-load chain
int(* user_create)(mod_instance_t mi, jid_t jid)
user-create handler
int available
true if this user has any available session
mod_instance_t * user_create
user-create chain
int ver
roster item version number
SM_API xht aci_load(sm_t sm)
sx_plugin_t sx_sasl
SX SASL plugin.
time_t active
time that user first logged in (ever)
struct module_st * module_t
SM_API void pres_error(sess_t sess, jid_t jid)
SM_API int user_create(sm_t sm, jid_t jid)
initialise a user
const char * name
display name
SM_API void sm_signature(sm_t sm, const char *str)
this is gratuitous, but apache gets one, so why not?
session request failed (mask)
route_type_t rtype
type of enclosing route
xht features
feature index (key is feature string