deliver.cc File Reference

implements the XML stanza routing of jabberd More...

#include "jabberd.h"
#include <set>

Data Structures

struct  deliver_mp_st
struct  ilist_struct
struct  deliver_routed_hosts_walk_args

Typedefs

typedef struct deliver_mp_st _deliver_msg
typedef struct deliver_mp_stdeliver_msg
typedef struct ilist_structilist
typedef struct ilist_struct _ilist

Functions

void deliver_config_filter (xmlnode greymatter)
std::set< Glib::ustring > deliver_routed_hosts (ptype type, instance i)
bool deliver_is_uplink (instance i)
void register_instance (instance i, char const *host)
void unregister_instance (instance i, char const *host)
void deliver (dpacket p, instance i)
bool deliver_is_delivered_to (Glib::ustring const &host, _instance const *i)
void deliver_init (pool p)
void deliver_shutdown (void)
void register_phandler (instance id, order o, phandler f, void *arg)
void deliver_fail (dpacket p, const char *err)
dpacket dpacket_new (xmlnode x)
dpacket dpacket_copy (dpacket p)
void register_routing_update_callback (instance i, register_notify f, void *arg)
void deliver_pool_debug ()

Variables

xmlnode greymatter__
int deliver__flag = 0
pth_msgport_t deliver__mp = NULL
xht filter_namespaces = NULL
std::list< Glib::ustring > filter_expressions
xht deliver__hnorm = NULL
xht deliver__hxdb = NULL
xht deliver__hlog = NULL
xht deliver__ns = NULL
xht deliver__logtype = NULL
std::set< Glib::ustring > null_sources
instance deliver__uplink = NULL
pool global_routing_update_pool = NULL
register_notifier global_routing_update_callbacks

Detailed Description

implements the XML stanza routing of jabberd

The jabberd execuatable is mainly a router for XML stanzas, that routes stanzas between the base handlers, that connect the components of the jabberd server to this XML routing. Inside this file the XML routing inside the jabberd server is implemented.

There are actually three routings, that are defined: One routing for <log/> stanzas (used to send log messages to a component, that logs the message to a file or the syslog), the second for <xdb/> stanzas (used to abstract database access into xdb handlers), and the third routing for other stanzas (<route/>, <message/>, <presence/>, and <iq/>).

The basic routing is defined on startup using the configuration file. <xdb/> sections in the configuration are registered in the routing for <xdb/> stanzas, <log/> sections in the configuration are registered in the routing for <log/> stanzas, <service/> sections are registered in the routing for the other stanzas.

Routing is done based on the domain part of a JID. The components can be registered to get stanzas for domains. On startup the component is registered for the domain contained in the value of the id attribute of the configuration file element as well as for all domains configured with <host/> elements inside the section of the component. Where each <host/> element contains a single additional domain, and an empty <host/> registers the component to be a default handler if no other component has explicitly registered to handle the domain. (Additionally there is the <uplink/> element, which is nearly the same as an empty <host/> element, but registers a routing not only in a single routing, but in all three XML routings. To be more precise: It is the fallback if there is even no default component for a given routing. There can be only one uplink in a single instance of jabberd.)

After a component has started, it can register for additional routings using the register_instance() function, or unregister an existing routing using the unregister_instance() function.


Typedef Documentation

typedef struct deliver_mp_st _deliver_msg

queue item for the list of queued messages for later delivery, used while deliver__flag = 0

typedef struct ilist_struct _ilist
typedef struct deliver_mp_st* deliver_msg
typedef struct ilist_struct * ilist

list of all instances of instance


Function Documentation

void deliver ( dpacket  p,
instance  i 
)
void deliver_config_filter ( xmlnode  greymatter  ) 

initializes or updates the dump filters of the router

Parameters:
greymatter the parsed configuration file

References filter_expressions, log_debug2, LOGT_DELIVER, NS_JABBERD_CONFIGFILE, xmlnode_t::p, pool_free(), pool_new, pstrdup(), xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_tags(), and ZONE.

Referenced by configurate().

void deliver_fail ( dpacket  p,
const char *  err 
)
void deliver_init ( pool  p  ) 

initialize the XML delivery system

Parameters:
p memory pool that can be used to register config handlers (must be available for the livetime of jabberd)

References register_config(), and xhash_new().

Referenced by main().

bool deliver_is_delivered_to ( Glib::ustring const &  host,
_instance const *  i 
)

util to check and see which instance this hostname is going to get mapped to for normal packets

Parameters:
host the hostname to get checked
Returns:
the instance packets of this host get mapped to

References ilist_struct::i, and ilist_struct::next.

bool deliver_is_uplink ( instance  i  ) 

checks if an instance is configured to be the uplink

Parameters:
i the instance to check
Returns:
true if uplink, else false
void deliver_pool_debug (  ) 

Referenced by main().

std::set<Glib::ustring> deliver_routed_hosts ( ptype  type,
instance  i 
)

get list of hosts with explicit routing

Parameters:
type the type to get the routing for
i the instance to exclude from the result (NULL for not excluding any instance)
Returns:
list of the hosts that have explicit routings to other components than i for the given type

References deliver_routed_hosts_walk_args::i, deliver_routed_hosts_walk_args::result, and xhash_walk().

void deliver_shutdown ( void   ) 

free the delivery structures ... this is called when we already have shutdown the server therefore we cannot register it with register_shutdown()

References xhash_free().

Referenced by main().

dpacket dpacket_copy ( dpacket  p  ) 

create a clone of a deliverable packet

References dpacket_new(), dpacket_struct::x, and xmlnode_dup().

dpacket dpacket_new ( xmlnode  x  ) 
void register_instance ( instance  i,
char const *  host 
)

register this instance as a possible recipient of packets to this host

Parameters:
i the instance to register
host the domain to register this instance for (or "*" to register as the default routing)

References register_notifier_struct::arg, register_notifier_struct::callback, instance_struct::id, log_debug2, LOGT_REGISTER, register_notifier_struct::next, NS_JABBERD_CONFIGFILE, instance_struct::p, p_LOG, p_XDB, pstrdup(), instance_struct::routing_update_callbacks, instance_struct::type, instance_struct::x, xhash_free(), xhash_get(), xhash_new(), xhash_put(), xmlnode_get_list_item(), xmlnode_get_tags(), and ZONE.

Referenced by dialback_miod_hash(), dialback_out_packet(), and mod_dynamic().

void register_phandler ( instance  id,
order  o,
phandler  f,
void *  arg 
)
void register_routing_update_callback ( instance  i,
register_notify  f,
void *  arg 
)

register a function that gets called on registering/unregistering a host for an instance

Parameters:
i the instance to get register/unregister events for (NULL for a global registration)
f the callback method to call
arg argument to pass to the callback

References register_notifier_struct::arg, register_notifier_struct::callback, log_debug2, LOGT_EXECFLOW, register_notifier_struct::next, instance_struct::p, pmalloco(), pool_new, instance_struct::routing_update_callbacks, and ZONE.

Referenced by jsm().

void unregister_instance ( instance  i,
char const *  host 
)

unregister an instance as a possible recipient of packets for a domain

Parameters:
i the instance to unregister
host the domain to unregister (or "*" to unregister as the default routing)

References register_notifier_struct::arg, register_notifier_struct::callback, instance_struct::id, log_debug2, log_notice(), LOGT_REGISTER, register_notifier_struct::next, instance_struct::p, pstrdup(), instance_struct::routing_update_callbacks, instance_struct::static_hosts, instance_struct::type, xhash_get(), xhash_put(), xhash_zap(), and ZONE.

Referenced by _dialback_miod_hash_cleanup(), and instance_shutdown().


Variable Documentation

int deliver__flag = 0

0 = pause delivery on startup and queue for later delivery, 1 = normal operation, -1 = shutdown: no delivery, no queueing

Referenced by deliver(), and main().

host filters for logging

hosts for normal packets, important and most frequently used one

host filters for xdb requests

log types, fixed set, but it's easier (wussier) to just be consistent and use a hashtable

pth_msgport_t deliver__mp = NULL

message port, that contains all queued messages for later delivery while deliver__flag = 0

Referenced by deliver().

xht deliver__ns = NULL

namespace filters for xdb

uplink instance, only one

std::list<Glib::ustring> filter_expressions

xpath expressions used for logging routed packets

Referenced by deliver(), and deliver_config_filter().

namespaces using in dump filters of the router

list of callback functions, that should be called on all routing updates

memory pool to hold the entries in the global_routing_update_callbacks list

this holds the parsed configuration file

std::set<Glib::ustring> null_sources

source addresses that get null-routes


Generated on Fri Mar 12 06:00:07 2010 for jabberd14 by  doxygen 1.6.1