|
jabberd14
1.6.2
|
handle incoming packets and check how they can be delivered More...
#include "jsm.h"Functions | |
| result | _js_routed_session_packet (instance i, dpacket p, jsmi si) |
| result | _js_routed_auth_packet (instance i, dpacket p, jsmi si, jpacket jp) |
| result | _js_routed_error_packet (instance i, dpacket p, jsmi si, xht ht, jpacket jp, session s, udata u) |
| result | _js_routed_session_control_packet (instance i, dpacket p, xmlnode sc_session, jsmi si) |
| result | _js_routed_packet (instance i, dpacket p, jsmi si, xht ht) |
| result | js_packet (instance i, dpacket p, void *arg) |
| void | js_deliver (jsmi si, jpacket p, session sending_s) |
| void | js_psend (jsmi si, jpacket p, mtq_callback f) |
handle incoming packets and check how they can be delivered
| result _js_routed_auth_packet | ( | instance | i, |
| dpacket | p, | ||
| jsmi | si, | ||
| jpacket | jp | ||
| ) |
handle incoming <route type='auth'/> packets, we get passed from jabberd: authentication or registration requests
Check if another component is configured to handle the auth packets using the <auth/> element containing the other component's address in jsm's configuration.
If not let js_authreg process the request.
| i | the jsm instance we are running in |
| p | the packet we should receive |
| si | our jsm instance internal data |
| jp | the wrapped packet we received |
References jsmi_struct::auth, deliver(), dpacket_new(), jpacket_reset(), js_authreg(), mtq_send(), r_DONE, dpacket_struct::x, xmlnode_get_attrib_ns(), and xmlnode_put_attrib_ns().
Referenced by _js_routed_packet().
| result _js_routed_error_packet | ( | instance | i, |
| dpacket | p, | ||
| jsmi | si, | ||
| xht | ht, | ||
| jpacket | jp, | ||
| session | s, | ||
| udata | u | ||
| ) |
handle incoming <route type='error'/> packets, we get passed from jabberd: most likely returned packets we sent to the client connection manager - the user seems to have disconnected (or the component has crashed *g*)
Cancel the session, store bounced messages offline again.
| i | the jsm instance we are running in |
| p | the packet we should receive |
| si | our jsm instance internal data |
| ht | the hash table containing the users of the relevant host |
| jp | the wrapped packet we received |
| s | the session this packet is for |
| u | the user data for the receipient |
References dpacket_struct::host, dpacket_struct::id, jid_full(), js_session_end(), log_notice(), session_struct::next, r_DONE, udata_struct::sessions, session_struct::sid, dpacket_struct::x, xmlnode_free(), and xmlnode_get_firstchild().
Referenced by _js_routed_packet().
| result _js_routed_packet | ( | instance | i, |
| dpacket | p, | ||
| jsmi | si, | ||
| xht | ht | ||
| ) |
handle incoming <route/> packets, we get passed from the XML router (jabberd)
<route/> packets are normally received from the client connection manager, that puts the stanzas received from the client inside the <route/> packet to ensure, that the packet is routed to the session manager component instead of directly to the destination address. This is necessary as the session manager might want to trigger actions, drop the stanza, or just has to ensure, that the client is not spoofing the source address.
The function checks if it is a special stanza used to establish sessions of a user (in which case the client connection manager also tells the session manager, how it has to identify the connection on packets it sends to the client connection manager to get delivered to the client), or if it is a forwarded stanza of a user for an existing connection.
In case of a special stanza to establish sessions, this function has to check which protocol is used by this session. This version of the session manager supports two protocols for this. On the one hand the traditional jabberd 1.x protocol (handled by _js_routed_session_packet()), and on the other hand the session control protocol introduced by jabberd2 (handled by _js_routed_session_control_packet()).
In case of the traditional jabberd 1.x protocol establishing a session consists of multiple steps and before the session is really established, the authentication has to be done by the session manager (for the new jabberd2 protocol, authentication has to be done by the client connection manager itself). For handling packets of the traditional protocol until authentication has been done, the packet is passed to _js_routed_auth_packet().
If it is no session establishment packet, it is then checked if the stanza is an error stanza, in which case it is passed to _js_routed_error_packet(). If it is no error stanza, the session of this packet is identified. If there is no such session, the stanza gets bounced back to the forwarder of it (which normally will be the client connection manager, which then closes the corresponding connection to the user). If there is such a session, the stanza is passed together with the corresponding session data to the function js_session_from().
| i | the jsm instance we are running in |
| p | the packet we should receive |
| si | our jsm instance internal data |
| ht | the hash table containing the users of the relevant host |
References _js_routed_auth_packet(), _js_routed_error_packet(), _js_routed_session_control_packet(), _js_routed_session_packet(), deliver_fail(), dpacket_new(), dpacket_struct::host, dpacket_struct::id, j_strcmp(), jid_full(), jid_new(), jpacket_new(), js_session_from(), js_user(), log_notice(), session_struct::next, r_DONE, session_struct::route, jsmi_struct::sc_sessions, session_struct::sc_sm, udata_struct::sessions, dpacket_struct::x, xhash_get(), xmlnode_free(), xmlnode_get_attrib_ns(), xmlnode_get_firstchild(), xmlnode_get_localname(), xmlnode_get_namespace(), xmlnode_get_nextsibling(), xmlnode_get_type(), xmlnode_hide_attrib_ns(), xmlnode_pool(), and xmlnode_serialize_string().
Referenced by js_packet().
| result _js_routed_session_control_packet | ( | instance | i, |
| dpacket | p, | ||
| xmlnode | sc_session, | ||
| jsmi | si | ||
| ) |
handle incoming route packets, that contain sc:session elements for the new session control protocol
| i | the jsm instance we are running in |
| p | the route packet |
| sc_session | the xmlnode containing the sc:session element |
| si | the session manager instance |
References deliver(), dpacket_new(), dpacket_struct::host, dpacket_struct::id, j_strcmp(), jid_full(), jid_new(), js_sc_session_new(), js_session_end(), js_user_create(), js_user_delete(), jutil_tofrom(), log_warn(), messages_get(), session_struct::next, dpacket_struct::p, r_DONE, jsmi_struct::sc_sessions, session_struct::sc_sm, udata_struct::sessions, dpacket_struct::x, xhash_get(), xmlnode_get_attrib_ns(), xmlnode_get_lang(), and xmlnode_put_attrib_ns().
Referenced by _js_routed_packet().
| result _js_routed_session_packet | ( | instance | i, |
| dpacket | p, | ||
| jsmi | si | ||
| ) |
handle incoming <route type='session'/> packets, we get passed from jabberd: create a new session
| i | the jsm instance we are running in |
| p | the packet we should receive |
| si | our jsm instance internal data |
References deliver(), dpacket_new(), dpacket_struct::host, dpacket_struct::id, jid_full(), js_session_new(), jutil_tofrom(), log_warn(), messages_get(), r_DONE, session_struct::route, dpacket_struct::x, xmlnode_get_lang(), and xmlnode_put_attrib_ns().
Referenced by _js_routed_packet().
| void js_deliver | ( | jsmi | si, |
| jpacket | p, | ||
| session | sending_s | ||
| ) |
take a packet and deliver it either locally if it has ourself as the destination or deliver it using jabberd if it is for a non-instance-local host
This function checks if the packet is local, and will then call j_deliver_local() to deliver it. If it is not instance-local it will call deliver() to deliver it using jabberd.
| si | the session manager instance this is called in |
| p | the packet to deliver |
| sending_s | the sending session of the packet (used to select the correct outgoing filter), NULL if packet is not related to a session |
References deliver(), dpacket_new(), e_FILTER_OUT, es_FILTER_OUT, jsmi_struct::hosts, jsmi_struct::i, jid_cmpx(), jid_full(), js_bounce_xmpp(), js_mapi_call(), js_user(), log_debug2, log_warn(), LOGT_DELIVER, PACKET_PASS_FILTERS_MAGIC, session_struct::u, xhash_get(), xmlnode_free(), and xmlnode_serialize_string().
Referenced by _js_session_from(), _js_session_to(), and js_bounce_xmpp().
handle packets we get passed from the XML router (jabberd)
The JSM component receives the packets from the XML router by a call to this function. Therefore each incoming stanza (either from other servers received by the dialback component or from a client connection received by the client connection manager) generates a call of this function.
This function ensures, that there is a hash table for the destination domain containing all users, that are currently online on this host (it might be the first packet addresses to this host in which case this hash is not present before). After this is done, it checks if it is either a stanza, that has been forwarded by an other component on the XML router (typically this is the client connection manager) in which case the stanza is passed to _js_routed_packet(), or if it is a non-forwarded packet, which typically means it is an incoming stanza from either a remote server or another session manager instance on the same XML router, or a stanza from a transport/gateway. In the second case of a non-forwarded stanza, the stanza is passed to the function js_deliver_local().
| i | the jsm instance we are running in |
| p | the packet we should receive |
| arg | our jsm instance internal data |
References _js_routed_packet(), dpacket_struct::host, jsmi_struct::hosts, j_atoi(), jpacket_new(), js_config(), log_debug2, log_warn(), LOGT_DELIVER, jsmi_struct::p, p_ROUTE, pstrdup(), r_DONE, dpacket_struct::type, USERS_PRIME, dpacket_struct::x, xhash_get(), xhash_new(), xhash_put(), xmlnode_free(), xmlnode_get_data(), and xmlnode_serialize_string().
Referenced by jsm().
| void js_psend | ( | jsmi | si, |
| jpacket | p, | ||
| mtq_callback | f | ||
| ) |
send a packet to a function
| si | the instance local data |
| p | the packet to send |
| f | the function to send the packet to |
References log_debug2, LOGT_DELIVER, mtq_send(), jpq_struct::p, pmalloco(), and jpq_struct::si.
1.7.6.1