Logo Search packages:      
Sourcecode: jabberd14 version File versions  Download package

result js_packet ( instance  i,
dpacket  p,
void *  arg 

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
always r_DONE

Definition at line 491 of file deliver.cc.

References _js_routed_packet(), dpacket_struct::host, jsmi_struct::hosts, jpacket_new(), js_config(), js_deliver_local(), log_warn(), jsmi_struct::p, pstrdup(), 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().

    jsmi si = (jsmi)arg;
    jpacket jp = NULL;
    xht ht = NULL;

    log_debug2(ZONE, LOGT_DELIVER, "(%X)incoming packet %s",si,xmlnode_serialize_string(p->x, xmppd::ns_decl_list(), 0));

    /* make sure this hostname is in the master table */
    if ((ht = (xht)xhash_get(si->hosts,p->host)) == NULL) {
      xmlnode maxusers = js_config(si, "jsm:maxusers", NULL);
        ht = xhash_new(j_atoi(xmlnode_get_data(maxusers), USERS_PRIME));
      maxusers = NULL;
        log_debug2(ZONE, LOGT_DELIVER, "creating user hash %X for %s", ht,p->host);
        xhash_put(si->hosts,pstrdup(si->p,p->host), (void *)ht);
        log_debug2(ZONE, LOGT_DELIVER, "checking %X", xhash_get(si->hosts, p->host));

    /* if this is a routed packet */
    if (p->type == p_ROUTE) {
      return _js_routed_packet(i, p, si, ht);

    /* normal server-server packet, should we make sure it's not spoofing us?  if so, if xhash_get(p->to->server) then bounce w/ security error */

    jp = jpacket_new(p->x);
    if (jp == NULL) {
        log_warn(p->host, "Dropping invalid incoming packet: %s", xmlnode_serialize_string(p->x, xmppd::ns_decl_list(), 0));
        return r_DONE;

    js_deliver_local(si, jp, ht);

    return r_DONE;

Generated by  Doxygen 1.6.0   Back to index