jabberd14  1.6.2
Data Structures | Namespaces | Defines | Typedefs | Enumerations | Functions | Variables
jabberd.h File Reference
#include <jabberdlib.h>
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>

Go to the source code of this file.

Data Structures

struct  dpacket_struct
struct  handel_struct
struct  register_notifier_struct
struct  instance_struct
struct  xdbcache_struct
struct  mtqueue_struct
struct  mth_struct
struct  mio_wb_q_st
struct  mio_st
struct  mio_main_st
 structure that holds the global mio data More...
struct  mio_handlers_st
class  xmppd::logmessage
class  xmppd::logging
class  xmppd::instance_base

Namespaces

namespace  xmppd

Defines

#define LOGT_LEGACY   1
#define LOGT_DELIVER   2
#define LOGT_REGISTER   4
#define LOGT_STATUS   8
#define LOGT_EVENT   16
#define LOGT_CONFIG   32
#define LOGT_DYNAMIC   64
#define LOGT_IO   128
#define LOGT_INIT   256
#define LOGT_EXECFLOW   512
#define LOGT_CLEANUP   1024
#define LOGT_STRANGE   2048
#define LOGT_XML   4096
#define LOGT_THREAD   8192
#define LOGT_STORAGE   16384
#define LOGT_AUTH   32768
#define LOGT_SESSION   65536
#define LOGT_ROSTER   131072
#define LOGT_BYTES   262144
#define MAX_LOG_SIZE   1024
#define log_debug   if(debug_flag&1) debug_log
#define log_debug2   if(debug_flag) debug_log2
#define log_error   log_alert
#define SERROR_NAMESPACE   "<stream:error><invalid-namespace xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Invalid namespace specified.</text></stream:error>"
#define SERROR_INVALIDHOST   "<stream:error><invalid-from xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Invalid hostname used.</text></stream:error>"
#define MTQ_THREADS   10
#define MIO_RAW_READ   (mio_read_func)&_mio_raw_read
#define MIO_RAW_WRITE   (mio_write_func)&_mio_raw_write
#define MIO_RAW_ACCEPTED   (mio_accepted_func)NULL
#define MIO_RAW_PARSER   (mio_parser_func)&_mio_raw_parser
#define MIO_XML_PARSER   (mio_parser_func)&_mio_xml_parser
#define MIO_LISTEN_RAW   mio_handlers_new(NULL, NULL, NULL)
#define MIO_CONNECT_RAW   mio_handlers_new(NULL, NULL, NULL)
#define MIO_LISTEN_XML   mio_handlers_new(NULL, NULL, MIO_XML_PARSER)
#define MIO_CONNECT_XML   mio_handlers_new(NULL, NULL, MIO_XML_PARSER)
#define MIO_SSL_READ   _mio_ssl_read
#define MIO_SSL_WRITE   _mio_ssl_write
#define MIO_SSL_ACCEPTED   _mio_ssl_accepted
#define MIO_NEW   0
#define MIO_BUFFER   1
#define MIO_XML_ROOT   2
#define MIO_XML_NODE   3
#define MIO_CLOSED   4
#define MIO_ERROR   5
#define mio_pool(m)   (m->p)
#define mio_ip(m)   (m ? m->peer_ip : NULL)
#define mio_connect_errmsg(m)   (m->connect_errmsg)
#define HTTP_BOUNCE_URI   "http://jabberd.org/get-bounce"

Typedefs

typedef struct instance_structinstance
typedef struct instance_struct _instance
typedef struct dpacket_structdpacket
typedef struct dpacket_struct _dpacket
typedef result(* phandler )(instance id, dpacket p, void *arg)
typedef struct handel_structhandel
typedef struct handel_struct _handel
typedef void(* register_notify )(instance i, const char *destination, int is_register, void *arg)
typedef struct
register_notifier_struct
register_notifier
typedef struct
register_notifier_struct 
_register_notifier
typedef result(* cfhandler )(instance id, xmlnode x, void *arg)
typedef result(* beathandler )(void *arg)
typedef void(* shutdown_func )(void *arg)
typedef struct xdbcache_structxdbcache
typedef struct xdbcache_struct _xdbcache
typedef void(* mtq_callback )(void *arg)
typedef struct mtqueue_structmtq
typedef struct mtqueue_struct _mtq
typedef struct mth_structmth
typedef struct mth_struct _mth
typedef struct mio_wb_q_st _mio_wbq
typedef struct mio_wb_q_stmio_wbq
typedef void(* mio_std_cb )(mio_st *m, int state, void *arg, xmlnode x, char *buffer, int bufsz)
typedef struct mio_stmio
typedef struct mio_st _mio
typedef struct mio_main_st _ios
 structure that holds the global mio data
typedef struct mio_main_stios
typedef ssize_t(* mio_read_func )(mio m, void *buf, size_t count)
typedef ssize_t(* mio_write_func )(mio m, void const *buf, size_t count)
typedef void(* mio_parser_func )(mio m, void const *buf, size_t bufsz)
typedef int(* mio_accepted_func )(mio m)
typedef int(* mio_handshake_func )(mio m)
typedef void(* mio_close_func )(mio m, bool close_read)
typedef struct mio_handlers_st _mio_handlers
typedef struct mio_handlers_stmio_handlers

Enumerations

enum  ptype {
  p_NONE, p_NORM, p_XDB, p_LOG,
  p_ROUTE
}
enum  order { o_PRECOND, o_COND, o_PREDELIVER, o_DELIVER }
enum  result {
  r_UNREG, r_NONE, r_PASS, r_LAST,
  r_ERR, r_DONE
}
enum  mio_queue_type { queue_XMLNODE, queue_CDATA }
enum  mio_state { state_ACTIVE, state_CLOSE }
enum  mio_type { type_LISTEN, type_NORMAL, type_NUL, type_HTTP }
enum  xmppd::loglevel { xmppd::notice, xmppd::warn, xmppd::error, xmppd::alert }

Functions

void register_config (pool p, char const *node, cfhandler f, void *arg)
void register_beat (int freq, beathandler f, void *arg)
void register_shutdown (shutdown_func f, void *arg)
void register_instance (instance i, char const *host)
void unregister_instance (instance i, char const *host)
void register_routing_update_callback (instance i, register_notify f, void *arg)
void register_phandler (instance id, order o, phandler f, void *arg)
dpacket dpacket_new (xmlnode x)
dpacket dpacket_copy (dpacket p)
void deliver (dpacket p, instance i)
void deliver_fail (dpacket p, const char *err)
bool deliver_is_delivered_to (Glib::ustring const &host, _instance const *i)
bool deliver_is_uplink (instance i)
std::set< Glib::ustring > deliver_routed_hosts (ptype type, instance i)
void deliver_config_filter (xmlnode greymatter)
int log_get_facility (char const *facility)
int log_get_level (char const *level)
int get_debug_flag (void)
void set_debug_flag (int v)
void set_cmdline_debug_flag (int v)
void set_debug_facility (int facility)
void debug_log (char const *zone, char const *msgfmt,...)
void debug_log2 (char const *zone, int type, char const *msgfmt,...)
void log_notice (char const *host, char const *msgfmt,...)
void log_warn (char const *host, char const *msgfmt,...)
void log_alert (char const *host, char const *msgfmt,...)
void logger (char const *type, char const *host, char const *message)
void log_record (char const *id, char const *type, char const *action, char const *msgfmt,...)
void log_generic (char const *logtype, char const *id, char const *type, char const *action, char const *msgfmt,...)
xdbcache xdb_cache (instance i)
xmlnode xdb_get (xdbcache xc, jid owner, const char *ns)
int xdb_act (xdbcache xc, jid owner, const char *ns, char *act, char const *match, xmlnode data)
int xdb_act_path (xdbcache xc, jid owner, const char *ns, char const *act, char const *matchpath, xht namespaces, xmlnode data)
int xdb_set (xdbcache xc, jid owner, const char *ns, xmlnode data)
mtq mtq_new (pool p)
void mtq_send (mtq q, pool p, mtq_callback f, void *arg)
ssize_t _mio_raw_read (mio m, void *buf, size_t count)
ssize_t _mio_raw_write (mio m, void *buf, size_t count)
void _mio_raw_parser (mio m, const void *buf, size_t bufsz)
void mio_xml_reset (mio m)
int mio_xml_starttls (mio m, int originator, const char *identity)
void _mio_xml_parser (mio m, const void *buf, size_t bufsz)
void mio_ssl_init (xmlnode x)
bool mio_tls_early_init ()
int mio_ssl_starttls (mio m, int originator, const char *identity)
int mio_ssl_starttls_possible (mio m, const char *identity)
int mio_ssl_verify (mio m, const char *id_on_xmppAddr)
ssize_t _mio_ssl_read (mio m, void *buf, size_t count)
ssize_t _mio_ssl_write (mio m, const void *buf, size_t count)
int _mio_ssl_accepted (mio m)
void mio_tls_get_characteristics (mio m, char *buffer, size_t len)
void mio_tls_get_certtype (mio m, char *buffer, size_t len)
void mio_tls_get_compression (mio m, char *buffer, size_t len)
int mio_is_encrypted (mio m)
mio_handlers mio_handlers_new (mio_read_func rf, mio_write_func wf, mio_parser_func pf)
void mio_handlers_free (mio_handlers mh)
void mio_set_handlers (mio m, mio_handlers mh)
void mio_init (void)
void mio_stop (void)
mio mio_new (int fd, mio_std_cb cb, void *cb_arg, mio_handlers mh)
void mio_reset (mio m, mio_std_cb cb, void *arg)
void mio_close (mio m)
void mio_write (mio m, xmlnode stanza, char const *buffer, int len)
void mio_write_root (mio m, xmlnode root, int stream_type)
void mio_karma (mio m, int val, int max, int inc, int dec, int penalty, int restore)
void mio_karma2 (mio m, struct karma *k)
void mio_rate (mio m, int rate_time, int max_points)
xmlnode mio_cleanup (mio m)
void mio_connect (char *host, int port, mio_std_cb cb, void *cb_arg, int timeout, mio_handlers mh)
mio mio_listen (int port, char const *sourceip, mio_std_cb cb, void *cb_arg, mio_handlers mh)
int _mio_write_dump (mio m)
int acl_check_access (xdbcache xdb, const char *function, const jid user)
jid acl_get_users (xdbcache xdb, const char *function)

Variables

int debug_flag

Define Documentation

#define HTTP_BOUNCE_URI   "http://jabberd.org/get-bounce"

Referenced by _mio_xml_parser().

#define log_debug   if(debug_flag&1) debug_log

Referenced by js_session_from(), and js_session_to().

#define log_debug2   if(debug_flag) debug_log2

Referenced by _dialback_beat_idle(), _dialback_beat_in_idle(), _dialback_beat_out_idle(), _dialback_miod_hash_cleanup(), _js_authreg_auth(), _js_authreg_register(), _js_hosts_del(), _js_session_end(), _js_session_from(), _js_session_to(), _js_users_del(), _jsm_shutdown(), _mio_ssl_cleanup(), _mio_ssl_read(), _mio_ssl_write(), _mio_tls_cont_handshake_server(), _mio_write_dump(), _mio_xml_parser(), _xdb_file_purge(), _xdb_get_hashes(), acl_check_access(), base_accept(), base_connect(), base_dir(), base_file(), base_format(), base_importspool(), base_load(), base_stderr(), base_stdout(), base_syslog(), base_syslog_config(), base_to(), base_unsubscribe(), xmppd::proxy65::connected_sockets::connected_sockets(), deliver(), deliver_config_filter(), deliver_fail(), dialback(), dialback_beat_idle(), dialback_check_settings(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_ip_get(), dialback_ip_set(), dialback_merlin(), dialback_miod_hash(), dialback_out_connect(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dnsrv(), dnsrv_child_main(), dnsrv_child_process_xstream_io(), dnsrv_lookup(), dnsrv_process_io(), dnsrv_process_xstream_io(), dnsrv_resend(), js_bounce_xmpp(), js_config(), js_deliver(), js_mapi_call2(), js_mapi_register(), js_mapi_session(), js_offline_main(), js_packet(), js_psend(), js_sc_session_new(), js_server_main(), js_session_end(), js_session_new(), js_user(), js_users_gc(), jsm(), jsm_shutdown(), log_generic(), logger(), main(), mio_close(), mio_listen(), mio_new(), mio_ssl_init(), mio_ssl_starttls(), mio_stop(), mio_write(), mio_xml_starttls(), mod_agents(), mod_auth_crypt(), mod_auth_digest(), mod_auth_plain(), mod_last(), mod_log(), mod_offline(), mod_presence(), mod_privacy(), mod_register(), mod_useridpolicy(), mtq_new(), mtq_send(), pthsock_client(), register_instance(), register_routing_update_callback(), xmppd::proxy65::socks5stub::socks5stub(), srv_lookup(), unregister_instance(), xdb_convert_spool(), xdb_file(), xdb_file_load(), xdb_file_phandler(), xdb_file_purge(), xdb_get(), and xdb_sql().

#define log_error   log_alert
#define LOGT_AUTH   32768
#define LOGT_BYTES   262144

Referenced by _mio_write_dump().

#define LOGT_CLEANUP   1024
#define LOGT_CONFIG   32
#define LOGT_DELIVER   2
#define LOGT_DYNAMIC   64

Referenced by base_load().

#define LOGT_EVENT   16

Referenced by main().

#define LOGT_EXECFLOW   512
#define LOGT_INIT   256
#define LOGT_IO   128
#define LOGT_LEGACY   1
#define LOGT_REGISTER   4
#define LOGT_ROSTER   131072
#define LOGT_SESSION   65536
#define LOGT_STATUS   8

Referenced by js_users_gc(), and main().

#define LOGT_STORAGE   16384
#define LOGT_STRANGE   2048
#define LOGT_THREAD   8192

Referenced by mtq_new(), mtq_send(), and xdb_get().

#define LOGT_XML   4096

Referenced by _mio_xml_parser().

#define MAX_LOG_SIZE   1024

Referenced by debug_log(), debug_log2(), and deliver_fail().

#define MIO_BUFFER   1

Referenced by _mio_raw_parser().

#define MIO_CLOSED   4

Referenced by dialback_out_read().

#define mio_connect_errmsg (   m)    (m->connect_errmsg)

Referenced by dialback_out_read().

#define MIO_CONNECT_RAW   mio_handlers_new(NULL, NULL, NULL)
#define MIO_CONNECT_XML   mio_handlers_new(NULL, NULL, MIO_XML_PARSER)

Referenced by dialback_out_connect().

#define MIO_ERROR   5

Referenced by _mio_write_dump(), and _mio_xml_parser().

#define mio_ip (   m)    (m ? m->peer_ip : NULL)
#define MIO_LISTEN_RAW   mio_handlers_new(NULL, NULL, NULL)
#define MIO_LISTEN_XML   mio_handlers_new(NULL, NULL, MIO_XML_PARSER)

Referenced by dialback(), and pthsock_client().

#define MIO_NEW   0

Referenced by dialback_out_read().

#define mio_pool (   m)    (m->p)
#define MIO_RAW_ACCEPTED   (mio_accepted_func)NULL

Referenced by mio_handlers_new().

Referenced by mio_handlers_new().

Referenced by mio_handlers_new().

Referenced by pthsock_client().

Referenced by mio_ssl_starttls(), and pthsock_client().

Referenced by mio_ssl_starttls(), and pthsock_client().

#define MIO_XML_NODE   3

Referenced by pthsock_client().

#define MIO_XML_ROOT   2
#define MTQ_THREADS   10

Referenced by mtq_send().

#define SERROR_INVALIDHOST   "<stream:error><invalid-from xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Invalid hostname used.</text></stream:error>"
#define SERROR_NAMESPACE   "<stream:error><invalid-namespace xmlns='urn:ietf:params:xml:ns:xmpp-streams'/><text xmlns='urn:ietf:params:xml:ns:xmpp-streams' xml:lang='en'>Invalid namespace specified.</text></stream:error>"

Typedef Documentation

typedef struct dpacket_struct _dpacket
typedef struct handel_struct _handel
typedef struct instance_struct _instance
typedef struct mio_main_st _ios

structure that holds the global mio data

MIO internal use only

typedef struct mio_st _mio

The MIO handlers data type

typedef struct mio_wb_q_st _mio_wbq
typedef struct mth_struct _mth
typedef struct mtqueue_struct _mtq
typedef struct xdbcache_struct _xdbcache
typedef result(* beathandler)(void *arg)

Heartbeat function callback definition

typedef result(* cfhandler)(instance id, xmlnode x, void *arg)

Config file handler function callback definition

typedef struct dpacket_struct * dpacket

Packet wrapper, d as in delivery or daemon, whichever pleases you

typedef struct handel_struct * handel

Delivery handler list. See register_phandler().

typedef struct instance_struct* instance
typedef struct mio_main_st* ios
typedef struct mio_st * mio

Representation of a managed TCP socket

typedef int(* mio_accepted_func)(mio m)
typedef void(* mio_close_func)(mio m, bool close_read)
typedef struct mio_handlers_st * mio_handlers
typedef int(* mio_handshake_func)(mio m)
typedef void(* mio_parser_func)(mio m, void const *buf, size_t bufsz)
typedef ssize_t(* mio_read_func)(mio m, void *buf, size_t count)
typedef void(* mio_std_cb)(mio_st *m, int state, void *arg, xmlnode x, char *buffer, int bufsz)
typedef struct mio_wb_q_st* mio_wbq
typedef ssize_t(* mio_write_func)(mio m, void const *buf, size_t count)
typedef struct mth_struct * mth

Managed thread queue. Has the message port for the running thread, and the current queue it's processing.

typedef struct mtqueue_struct * mtq

Managed thread queue. Has a pointer to the currently assigned thread for this queue.

typedef void(* mtq_callback)(void *arg)

mtq callback simple function definition

typedef result(* phandler)(instance id, dpacket p, void *arg)

Delivery handler function callback definition

List of functions, that get notified of registering/unregistering hosts

typedef void(* register_notify)(instance i, const char *destination, int is_register, void *arg)

Callback function that gets notified of registering/unregistering hosts for an instance

typedef void(* shutdown_func)(void *arg)
typedef struct xdbcache_struct * xdbcache

Ring for handling cached structures


Enumeration Type Documentation

Struct to handle the write queue

Enumerator:
queue_XMLNODE 
queue_CDATA 
enum mio_state
Enumerator:
state_ACTIVE 
state_CLOSE 
enum mio_type
Enumerator:
type_LISTEN 
type_NORMAL 
type_NUL 
type_HTTP 
enum order

the stages of packet delivery - the order in which packet handlers gets called.

Delivery starts with o_PRECOND handlers, then o_COND handlers, then o_PREDELIVER handlers, and o_DELIVER handlers last

Enumerator:
o_PRECOND 

o_PRECOND handlers always get called first - used by xdb.cc to filter out xdb results

o_COND 

currently not used by jabberd14

o_PREDELIVER 

handlers that should get called before o_DELIVER handlers - used by base_format.cc to reformat messages

o_DELIVER 

normal deliveries

enum ptype

Packet types

Enumerator:
p_NONE 
p_NORM 
p_XDB 
p_LOG 
p_ROUTE 
enum result

Result types, unregister me, I pass, I should be last, I suck, I rock

In case of r_DONE or r_LAST the passed data is consumed (i.e. freed), if of the other values is returned, the data has not been consumed and the caller must free it if necessary.

Enumerator:
r_UNREG 

unregister the packet handler and keep delivering the packet

r_NONE 

unused value ... might get removed

r_PASS 

packet has not been handled nor did it cause an error, keep delivering the packet to later handlers

r_LAST 

can only be returned by o_COND handlers in which case delivery is not continued with later handlers -- currently not used by jabberd14

r_ERR 

final delivery error, create error bounce and do not call later handlers

r_DONE 

packet has been handled, if o_DELIVER handler other handlers are called as well, else delivery is stopped


Function Documentation

void _mio_raw_parser ( mio  m,
const void *  buf,
size_t  bufsz 
)

receiving bytes on a network socket

the _mio_raw_parser implements a mio parser, that does not parse the received data at all, but just passes the received data as bytes to the application callback function, that registered for this mio object

Parameters:
mthe mio object where the data has been read
bufthe data that has been read
bufszthe number of bytes, that have been read on the socket

References mio_st::cb, mio_st::cb_arg, and MIO_BUFFER.

ssize_t _mio_raw_read ( mio  m,
void *  buf,
size_t  count 
)

read data from a network socket, that does not use TLS encryption

m->flags.recall_read_when_writeable is cleared, m->flags.recall_read_when_readable is updated by this function

Parameters:
mthe mio representing this socket
bufthe buffer where to read data to
countsize of the buffer, how many data should be read at most
Returns:
0 < ret < count: ret bytes read and no more bytes to read; ret = count: ret bytes read, possibly more bytes to read; ret = 0: currently nothing to read; ret < 0: non-recoverable error or connection closed

References mio_st::fd.

ssize_t _mio_raw_write ( mio  m,
void *  buf,
size_t  count 
)

write data to a network socket, that does not use TLS encryption

m->flags.recall_write_when_readable is clared, m->flags.recall_write_when_writeable is updated by this function

Parameters:
mthe mio representing this socket
bufthe data that should be written
counthow many bytes should be written (at most)
Returns:
ret > 0: ret bytes written; ret == 0: no bytes could be written; ret < 0: non-recoverable error or connection closed

References mio_st::fd.

int _mio_ssl_accepted ( mio  m)

accepted a new incoming connection, where we have to start the TLS layer without a STARTTLS command, e.g. on port 5223

Parameters:
mthe mio of the listening socket
Returns:
-1 on error, 0 if the handshake has not yet finished, 1 on success

References mio_ssl_starttls(), and mio_st::our_ip.

ssize_t _mio_ssl_read ( mio  m,
void *  buf,
size_t  count 
)

read data from a socket, that is TLS protected

The m->flags.recall_read_when_readable and m->flags.recall_read_when_writeable is updated by this function.

Parameters:
mthe mio where data might be available
bufwhere to write the written data to
counthow many bytes should be read at most
Returns:
0 < ret < count: ret bytes read and no more bytes to read; ret = count: ret bytes read, possibly more bytes to read; ret = 0: currently nothing to read; ret < 0: non-recoverable error or connection closed

References mio_st::fd, mio_st::flags, log_debug2, log_notice(), LOGT_IO, mio_st::recall_read_when_readable, mio_st::recall_read_when_writeable, and mio_st::ssl.

ssize_t _mio_ssl_write ( mio  m,
const void *  buf,
size_t  count 
)

write data to a socket, that is TLS protected

The m->flags.recall_write_when_readable and m->flags.recall_write_when_writeable is updated by this function.

Parameters:
mthe mio where writing is possible
bufdata that should be written
counthow many bytes should be written at most
Returns:
ret > 0: ret bytes written; ret == 0: no bytes could be written; ret < 0: non-recoverable error or connection closed

References mio_st::fd, mio_st::flags, log_debug2, log_notice(), LOGT_IO, mio_st::recall_write_when_readable, mio_st::recall_write_when_writeable, and mio_st::ssl.

int _mio_write_dump ( mio  m)

Dump this socket's write queue.

Tries to write * as much of the write queue as it can, before the write call would block the server

Parameters:
mthe connection that should get it's write queue dumped
Returns:
-1 on error, 0 on success, and 1 if more data to write

References mio_st::cb, mio_st::cb_arg, mio_wb_q_st::cur, mio_st::fd, mio_wb_q_st::len, log_debug2, LOGT_BYTES, LOGT_IO, mio_st::mh, MIO_ERROR, mio_wb_q_st::next, mio_wb_q_st::p, pool_free(), mio_st::queue, mio_st::tail, and mio_handlers_st::write.

Referenced by mio_xml_starttls().

void _mio_xml_parser ( mio  m,
const void *  vbuf,
size_t  bufsz 
)

receiving an XML document on a network socket

This parser implements an XML parser reading on a network socket. Stanzas (second level XML document elements) are passed to the application callback function, that registered with this mio object

Parameters:
mthe mio where data has been read
vbufthe buffer containing the read data
bufszthe number of bytes, that have been read

References _mio_xstream_cleanup(), _mio_xstream_init(), mio_main_st::bounce_uri, mio_st::cb, mio_st::cb_arg, mio_st::flags, mio_main_st::flash_policy, HTTP_BOUNCE_URI, log_debug2, log_error, log_notice(), log_warn(), LOGT_IO, LOGT_XML, mio_close(), MIO_ERROR, mio_write(), mio_st::parser, mio_st::reset_stream, mio_st::root, mio_st::type, type_HTTP, type_NORMAL, type_NUL, and mio_main_st::webserver_path.

int acl_check_access ( xdbcache  xdb,
const char *  function,
const jid  user 
)

check if a user has access to a given functionality

Parameters:
xdbinstance of an xdbcache used to check the access
functionfunctionality for which access should be checked
useruser for which access should be checked
Returns:
1 if access is granted, 0 if access is denied

References acl_get_users(), jid_cmpx(), jid_full(), log_debug2, LOGT_AUTH, and pool_free().

Referenced by js_trust().

jid acl_get_users ( xdbcache  xdb,
const char *  function 
)

get the list of users, that have access to a given functionality

Parameters:
xdbinstance of an xdbcache used to check the access
functionfunctionality for which access should be checked
Returns:
list of jid_struct instances, that hold the users having access to the functionality; must be freed by the caller; NULL if no user has access

References greymatter__, j_strcmp(), jid_append(), jid_new(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), and xmlnode_get_tags().

Referenced by acl_check_access().

void debug_log ( char const *  zone,
char const *  msgfmt,
  ... 
)

Generate a debug log message

This generates a debugging message. The function should not be called directly. Instead the macro log_debug should be called, which first checks if debugging is enabled.

Do not use this function or log_debug at all. Better use log_debug2.

Parameters:
zonethe zone (file) the function is called from. __ZONE__ should be used here.
msgfmtthe format string for the log message, parameters like for printf() are given afterwards

References _debug_facility, and MAX_LOG_SIZE.

void debug_log2 ( char const *  zone,
int  type,
char const *  msgfmt,
  ... 
)

Generate a debug log message

This generates a debugging message. The function should not be called directly. Instead the macro log_debug2 should be called, which first checks if debugging is enabled.

Parameters:
zonethe zone (file) the function is called from. __ZONE__ should be used here.
typeLOGT_* constent telling which type of debug log message is passed
msgfmtthe format string for the log message, parameters like for printf() are given afterwards

References _debug_facility, get_debug_flag(), and MAX_LOG_SIZE.

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

initializes or updates the dump filters of the router

Parameters:
greymatterthe parsed configuration file

References filter_expressions, filter_namespaces, log_debug2, LOGT_DELIVER, pool_free(), pstrdup(), xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), and xmlnode_get_tags().

Referenced by configurate().

void deliver_fail ( dpacket  p,
const char *  err 
)
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:
hostthe hostname to get checked
Returns:
the instance packets of this host get mapped to

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

checks if an instance is configured to be the uplink

Parameters:
ithe instance to check
Returns:
true if uplink, else false

References deliver__uplink.

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

get list of hosts with explicit routing

Parameters:
typethe type to get the routing for
ithe 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().

create a clone of a deliverable packet

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

dpacket dpacket_new ( xmlnode  x)
int get_debug_flag ( void  ) [inline]

get the current debugging mask

References debug_flag.

Referenced by debug_log2().

void log_alert ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "alert"

Parameters:
hostthe sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmtthe format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by dialback_out_read(), main(), and mio_listen().

void log_generic ( char const *  logtype,
char const *  id,
char const *  type,
char const *  action,
char const *  msgfmt,
  ... 
)

writing log messages of arbitrary logging type

Parameters:
logtypelogging type (e.g. "record")
idto which id is the message related
typetype of the log message (e.g. "session")
actionaction that is logged (e.g. a failed auth)
msgfmtprintf()-like format string, parameters are following

References deliver(), dpacket_new(), j_strlen(), log_debug2, LOGT_DELIVER, xmlnode_insert_cdata(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), and xmlnode_serialize_string().

Referenced by log_record().

int log_get_facility ( char const *  facility)

get the facility value for a syslog facility

Parameters:
facilityas a string
Returns:
numerical facility value or -1 on error

References j_strcmp().

int log_get_level ( char const *  level)

get the level value for a syslog level

Parameters:
levelas a string
Returns:
numerical level value or -1 on error

References j_strcmp().

void log_notice ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "notice"

Parameters:
hostthe sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmtthe format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by _dnsrv_beat_packets(), _js_routed_error_packet(), _js_routed_packet(), _mio_ssl_read(), _mio_ssl_write(), _mio_xml_parser(), _xdb_convert_hostspool(), deliver(), deliver_fail(), dialback_check_settings(), dialback_in_read_db(), dialback_out_connection_cleanup(), dialback_out_read(), dnsrv_deliver(), js_users_gc(), jsm_deserialize(), main(), mio_ssl_starttls(), mio_ssl_verify(), mod_dynamic(), unregister_instance(), and xdb_file_phandler().

void log_record ( char const *  id,
char const *  type,
char const *  action,
char const *  msgfmt,
  ... 
)

generic log record support

Parameters:
idto which id is the message related
typethe type of the log message (e.g. "session")
actionaction that is logged (e.g. a failed auth)
msgfmtprintf()-like format string, parameters are following

References log_generic().

Referenced by _dialback_miod_hash_cleanup().

void log_warn ( char const *  host,
char const *  msgfmt,
  ... 
)

generate a log message of type "warn"

Parameters:
hostthe sending host (domain) of the log message - NULL if the host is not known, in that case the message is logged as jabberd internal
msgfmtthe format string for the message, parameters are passed afterwards like for the printf() function

References logger().

Referenced by _js_routed_session_control_packet(), _js_routed_session_packet(), _mio_xml_parser(), deliver_fail(), dialback_check_settings(), dialback_in_read_db(), dialback_in_verify(), dialback_miod_read(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), dpacket_new(), js_deliver(), js_packet(), mio_init(), mio_ssl_init(), mod_auth_crypt(), pthsock_client(), set_debug_facility(), xdb_file_load(), and xdb_file_phandler().

void logger ( char const *  type,
char const *  host,
char const *  message 
)

send a log message to the logging components

Parameters:
typethe type of log message (one of "notice"+/"record", "warn"+, "alert", "stat"+, "info", "emerg", "crit", or "err"+ - in jabberd only the marked ones are used - "debug" should not be used as debugging messages should not be routed on the XML router)
hostthe sending host (domain) of the message, or NULL if no sending host is known (the message are than logged as jabberd internal)
messageThe message to be logged

References deliver(), dpacket_new(), j_strlen(), log_debug2, LOGT_DELIVER, xmlnode_insert_cdata(), xmlnode_new_tag_ns(), xmlnode_put_attrib_ns(), and xmlnode_serialize_string().

Referenced by log_alert(), log_notice(), and log_warn().

xmlnode mio_cleanup ( mio  m)

pops the last xmlnode from the queue

This function removes the last xmlnode from a write queue. This is normally used to get unsent stanzas from the queue in case of an error happens and the stanzas cannot be delivered.

The returned xmlnodes have to be freed by the caller.

Elements in the write queue, that have no xmlnode attached, but are just character data are deleted by this function and the memory associated with these items is freed by mio_cleanup().

Parameters:
mthe mio stream to get the last xmlnode stanza in the write queue for.
Returns:
last stanza item in the write queue (has to be freed by the caller), or NULL if no further stanzas

References mio_wb_q_st::next, mio_wb_q_st::p, pool_free(), mio_st::queue, mio_st::tail, and mio_wb_q_st::x.

void mio_close ( mio  m)
void mio_connect ( char *  host,
int  port,
mio_std_cb  cb,
void *  cb_arg,
int  timeout,
mio_handlers  mh 
)

request to connect to a remote host

Parameters:
hostthe host where to connect to (either a IPv4 or IPv6)
portthe port number to connect to
cbthe application callback function
cb_argargument to pass to the application callback function
timeouthow long to wait for a connection to be established (0 for using the default value)
mhthe mio_handlers used to select the desired type of socket (e.g. an XML stream or a TLS protected socket)

References mio_connect_st::cb, mio_connect_st::cb_arg, mio_connect_st::ip, mio_connect_st::mh, mio_handlers_new(), mio_connect_st::p, pmalloco(), mio_connect_st::port, pstrdup(), register_beat(), and mio_connect_st::t.

Referenced by dialback_out_connect().

free a mio_handlers structure

Parameters:
mhthe mio_handlers structure that should be freed

References mio_handlers_st::p, and pool_free().

Referenced by mio_set_handlers().

create a mio_handlers instance, that can be passed to mio_listen() or mio_accept()

The mio_handlers can be used to setup different 'types' of sockets

Default is to have an unencrypted socket reading plain bytes.

If you are requesting a TLS protected socket (using MIO_SSL_READ and MIO_SSL_WRITE), you also have to modify the accepted function in the returned mio_handlers afterwards!

Parameters:
rfhandler used for reading, NULL for default (may be MIO_RAW_READ or MIO_SSL_READ)
wfhandler used for writing, NULL for default (may be MIO_RAW_WRITE or MIO_SSL_WRITE)
pfhandler used for parsing, NULL for default (may be MIO_RAW_PARSER or MIO_XML_PARSER)
Returns:
new instance of mio_handlers

References MIO_RAW_PARSER, MIO_RAW_READ, MIO_RAW_WRITE, mio_handlers_st::p, mio_handlers_st::parser, pmalloco(), mio_handlers_st::read, and mio_handlers_st::write.

Referenced by mio_connect(), mio_listen(), and pthsock_client().

void mio_init ( void  )
int mio_is_encrypted ( mio  m)

check if a connection is encrypted

Parameters:
mthe connection
Returns:
0 if the connection is unprotected, 1 if the connection is integrity protected, >1 if the connection is encrypted

References mio_st::ssl.

Referenced by dialback_check_settings(), and dialback_in_read().

void mio_karma ( mio  m,
int  val,
int  max,
int  inc,
int  dec,
int  penalty,
int  restore 
)

sets karma values

References mio_st::k.

void mio_karma2 ( mio  m,
struct karma *  k 
)

copy karma to a mio socket

Parameters:
mthe mio to copy the karma to
kthe karma to copy to the mio

References mio_st::k, and karma_copy().

Referenced by dialback(), mio_new(), and pthsock_client().

mio mio_listen ( int  port,
char const *  listen_host,
mio_std_cb  cb,
void *  arg,
mio_handlers  mh 
)

call to start listening with select

Parameters:
portport to listen at
listen_hostIPv4 or IPv6 address to listen at
cbapplication callback function
argargument to pass to the application callback function
mhmio_handlers used for this connection
Returns:
the listening mio object that has been created, NULL on failure

References log_alert(), log_debug2, LOGT_IO, make_netsocket(), mio_handlers_new(), mio_new(), mio_st::our_ip, mio_st::p, pstrdup(), mio_st::type, and type_LISTEN.

Referenced by dialback(), xmppd::proxy65::proxy65::proxy65(), and pthsock_client().

mio mio_new ( int  fd,
mio_std_cb  cb,
void *  arg,
mio_handlers  mh 
)

creates a new mio object from a file descriptor

Parameters:
fdthe file descriptor the caller already has
cbthe callback function, MIO should call on events
argthe argument MIO should pass to the callback function, when calling it
mhwhich mio_handlers MIO should use for this connection
Returns:
pointer to the new MIO object, NULL on failure

References mio_st::cb, mio_st::cb_arg, mio_st::fd, mio_main_st::k, log_debug2, LOGT_EXECFLOW, mio_karma2(), mio_rate(), mio_set_handlers(), mio_st::p, pmalloco(), mio_main_st::rate_p, mio_main_st::rate_t, mio_st::state, state_ACTIVE, mio_st::type, type_NORMAL, mio_main_st::zzz, and mio_main_st::zzz_active.

Referenced by mio_listen().

void mio_rate ( mio  m,
int  rate_time,
int  max_points 
)

sets connection rate limits

References mio_st::flags, jlimit_free(), jlimit_new(), mio_st::rate, and mio_st::rated.

Referenced by dialback(), mio_new(), and pthsock_client().

void mio_reset ( mio  m,
mio_std_cb  cb,
void *  arg 
)

resets the callback function

Parameters:
mthe mio to update the callback function for
cbthe new callback function
argthe new argument MIO should pass to the callback function

References mio_st::cb, and mio_st::cb_arg.

Referenced by xmppd::proxy65::connected_sockets::connected_sockets(), dialback_in_read(), dialback_in_read_db(), dialback_out_read(), and xmppd::proxy65::socks5stub::socks5stub().

void mio_set_handlers ( mio  m,
mio_handlers  mh 
)

reset the handlers of a mio structure

Parameters:
mthe mio to set the handlers for
mhthe new handlers to set

References mio_st::mh, and mio_handlers_free().

Referenced by mio_new().

void mio_ssl_init ( xmlnode  x)

initialize the mio SSL/TLS module using the GNU TLS library

Parameters:
xxmlnode containing the configuration information (the io/tls element)

References j_strcmp(), log_debug2, log_error, log_warn(), LOGT_IO, mio_tls_pool, xhash_free(), xhash_new(), xhash_put(), xmlnode_get_attrib_ns(), xmlnode_get_data(), xmlnode_get_firstchild(), xmlnode_get_localname(), xmlnode_get_namespace(), and xmlnode_get_nextsibling().

Referenced by mio_init().

int mio_ssl_starttls ( mio  m,
int  originator,
const char *  identity 
)

start a TLS layer on a connection and set the appropriate mio handlers for SSL/TLS

Parameters:
mthe connection on which the TLS layer should be established
originator1 if this side is the originating side, 0 else
identityour own identity (selector for the used certificate)
Returns:
0 on success, non-zero on failure

References _mio_ssl_cleanup(), _mio_tls_cont_handshake_server(), mio_handlers_st::close, mio_st::fd, mio_st::flags, mio_handlers_st::handshake, mio_st::k, log_debug2, log_error, log_notice(), LOGT_EXECFLOW, LOGT_IO, mio_st::mh, mio_close(), MIO_SSL_READ, MIO_SSL_WRITE, mio_tls_certtypes, mio_tls_ciphers, mio_tls_compression, mio_tls_credentials, mio_tls_kx, mio_tls_mac, mio_tls_protocols, mio_st::our_ip, mio_st::p, mio_st::peer_ip, pool_cleanup(), mio_handlers_st::read, mio_st::recall_handshake_when_readable, mio_st::recall_handshake_when_writeable, mio_st::ssl, and mio_handlers_st::write.

Referenced by _mio_ssl_accepted(), and mio_xml_starttls().

int mio_ssl_starttls_possible ( mio  m,
const char *  identity 
)

check if it would be possible to start TLS on a connection

Parameters:
mthe connection
identityour own identity (check if certificate is present)
Returns:
0 if it is impossible, 1 if it is possible

References mio_tls_credentials, and mio_st::ssl.

Referenced by dialback_in_read(), dialback_in_read_db(), and dialback_out_read().

int mio_ssl_verify ( mio  m,
const char *  id_on_xmppAddr 
)

verify the SSL/TLS certificate of the peer for the given MIO connection

Parameters:
mthe connection for which the peer should be verified
id_on_xmppAddrthe JabberID, that the certificate should be checked for, if NULL it is only checked if the certificate is valid and trusted
Returns:
0 the certificate is invalid, 1 the certificate is valid

References log_notice(), and mio_st::ssl.

Referenced by dialback_check_settings(), dialback_in_read(), and dialback_in_read_db().

void mio_stop ( void  )

Cleanup function when server is shutting down, closes all sockets, so that everything can be cleaned up properly.

References log_debug2, LOGT_CLEANUP, mio_main_st::master__list, mio_st::next, mio_main_st::p, pool_free(), mio_main_st::shutdown, and mio_main_st::t.

early initiatizations for GnuTLS

This has to be called as soon as possible after application startup

Returns:
true on success, false on failure

References mio_tls_asn1_tree, mio_tls_gcrypt_init(), and subjectAltName_asn1_tab.

Referenced by main().

void mio_tls_get_certtype ( mio  m,
char *  buffer,
size_t  len 
)

References mio_st::ssl.

Referenced by dialback_check_settings().

void mio_tls_get_characteristics ( mio  m,
char *  buffer,
size_t  len 
)

get some information on what protocols are used inside the TLS layer

Parameters:
mthe mio object to request the information for
bufferwhere to write the result
lensize of the buffer to place the information in

References mio_st::ssl.

Referenced by dialback_check_settings().

void mio_tls_get_compression ( mio  m,
char *  buffer,
size_t  len 
)

References mio_st::ssl.

Referenced by dialback_check_settings().

void mio_write ( mio  m,
xmlnode  stanza,
char const *  buffer,
int  len 
)

writes a str, or XML stanza to the client socket

You can only write the xmlnode OR the buffer to the mio. If the buffer argument is not equal to NULL, the buffer is used and the xmlnode is ignored.

Parameters:
mthe mio to write the data to
stanza::xmlnode containing the stanza, that should be written to a stream (gets freed after the data has been written)
bufferpointer to a buffer of characters, that should be written to the connection
lennumber of bytes contained in the buffer, that should be written (-1 to write a zero terminated string contained in the buffer)

References mio_wb_q_st::cur, mio_wb_q_st::data, mio_wb_q_st::len, log_debug2, LOGT_EXECFLOW, LOGT_IO, LOGT_STRANGE, mio_wb_q_st::next, mio_st::out_ns, mio_wb_q_st::p, pmalloco(), pool_free(), mio_st::queue, queue_CDATA, queue_XMLNODE, mio_st::tail, mio_wb_q_st::type, mio_st::type, type_NUL, mio_wb_q_st::x, xmlnode_pool(), xmlnode_serialize_string(), mio_main_st::zzz, and mio_main_st::zzz_active.

Referenced by _dialback_beat_idle(), _dialback_beat_in_idle(), _dialback_beat_out_idle(), _mio_xml_parser(), xmppd::proxy65::connected_sockets::connected_sockets(), dialback_check_settings(), dialback_in_read(), dialback_in_read_db(), dialback_in_verify(), dialback_miod_write(), dialback_out_connection(), dialback_out_packet(), dialback_out_read(), dialback_out_read_db(), mio_write_root(), and xmppd::resolver::resolver::send_query().

void mio_write_root ( mio  m,
xmlnode  root,
int  stream_type 
)

write the start tag for the root element to a stream

Parameters:
mthe mio of the stream where to write the start tag for the root element to
rootthe root element (freed by this function)
stream_typetype of stream: 0 for 'jabber:server', 1 for 'jabber:client', 2 for 'jabber:component:accept'

References mio_write(), mio_st::out_ns, xmlnode_free(), xmlnode_get_attrib_ns(), and xstream_header_char().

Referenced by dialback_in_read(), and dialback_out_read().

void mio_xml_reset ( mio  m)

reset a stream (restart it)

Parameters:
mthe stream to reset

References mio_st::flags, and mio_st::reset_stream.

Referenced by dialback_in_read_db(), dialback_out_read(), and mio_xml_starttls().

int mio_xml_starttls ( mio  m,
int  originator,
const char *  identity 
)

restart a stream, starting the use of a TLS layer

Parameters:
mthe connection
originator1 if we are the originator, 0 else
identityidentity to use for selecting the certificate
Returns:
0 on success, non-zero on failure

References _mio_write_dump(), log_debug2, LOGT_IO, mio_ssl_starttls(), and mio_xml_reset().

Referenced by dialback_in_read_db(), and dialback_out_read().

mtq mtq_new ( pool  p)

Creates a new queue, is automatically cleaned up when p frees

public queue creation function, queue lives as long as the pool

Create a new job queue

The queue gets destroyed automatically when the passed pool gets freed.

For more information on what a queue is and how it is used, please see the information about mtq.cc.

Parameters:
pthe memory pool where some memory can be allocated from and with that the new queue will share the lifetime.
Returns:
the new queue

References log_debug2, LOGT_THREAD, mtqueue_struct::mp, pmalloco(), and pool_cleanup().

Referenced by js_sc_session_new(), and js_session_new().

void mtq_send ( mtq  q,
pool  p,
mtq_callback  f,
void *  arg 
)

appends the arg to the queue to be run on a thread

initiate that a function is executed asyncronously to the calling thread

This will arrange that the function f is executed in one of the threads managed by mtq.

Parameters:
qthread queue to which f should be added (NULL if f should be called as soon as possible and no thread queue is used)
pmemory pool that can be used to allocate some memory used to manage this job (should not get freed before the job has been finished)
fthe function to execute
argargument to pass to f

References mtqmaster_struct::all, mtqcall_struct::arg, mth_struct::busy, mtqcall_struct::f, mth_struct::id, log_debug2, LOGT_THREAD, mtqmaster_struct::mp, mtqueue_struct::mp, mth_struct::mp, MTQ_THREADS, mtqmaster_struct::overflow, mth_struct::p, pmalloco(), mtqcall_struct::q, and mtqueue_struct::routed.

Referenced by _js_routed_auth_packet(), js_psend(), js_sc_session_new(), js_session_end(), js_session_from(), js_session_new(), and js_session_to().

void register_beat ( int  freq,
beathandler  f,
void *  arg 
)
void register_config ( pool  p,
char const *  node,
cfhandler  f,
void *  arg 
)

register a function to handle that node in the config file

Parameters:
pmemory pool used to allocate data belonging to this registration
nodethe node that should be handled by the handler
fthe handler function that should be registered
argargument, that should be passed to the handler function

References cfg_struct::arg, cfhandlers__, cfg_struct::f, cfg_struct::next, cfg_struct::node, pmalloco(), and pstrdup().

Referenced by base_accept(), base_connect(), base_dir(), base_file(), base_format(), base_importspool(), base_load(), base_null(), base_stderr(), base_stdout(), base_syslog(), base_to(), base_unsubscribe(), deliver_init(), mod_auth_crypt(), mod_auth_digest(), mod_auth_plain(), and mod_last().

void register_instance ( instance  i,
char const *  host 
)

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

Parameters:
ithe instance to register
hostthe 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, 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(), and xmlnode_get_tags().

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

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

Parameters:
ithe instance to get register/unregister events for (NULL for a global registration)
fthe callback method to call
argargument 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(), and instance_struct::routing_update_callbacks.

Referenced by jsm().

void register_shutdown ( shutdown_func  f,
void *  arg 
)

register a function to be called on shutdown

Parameters:
fthe function to be called on shutdown
argthe argument to be passed to the callback function

References shutdown_list::arg, cfg_struct::arg, shutdown_list::f, cfg_struct::f, shutdown_list::next, shutdown_list::p, pmalloco(), and shutdown__list.

void set_cmdline_debug_flag ( int  v)

set the value of the cmdline_debug_flag which is always ORed to the value that is set by set_debug_flag() this will reset the mask set with set_debug_flag(), so set_cmdline_debug_flag() should be called first.

Parameters:
vthe debug mask given on the command line

References cmdline_debug_flag, and debug_flag.

Referenced by main().

void set_debug_facility ( int  facility)

set the facility used to write debugging messages to syslog

Parameters:
facilitythe facility to use, -1 if writing to the standard output is requested

References _debug_facility, and log_warn().

void set_debug_flag ( int  v)

set the debugging mask, if 0 no debugging is requested for other values debugging is enabled, the different bits in the value enable different log message types the value set with set_cmdline_debug_flag() (what the user specified on the command line) is always ORed to this value

Parameters:
vthe new debugging mask

References cmdline_debug_flag, and debug_flag.

void unregister_instance ( instance  i,
char const *  host 
)

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

Parameters:
ithe instance to unregister
hostthe 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(), and xhash_zap().

Referenced by _dialback_miod_hash_cleanup(), and instance_shutdown().

int xdb_act ( xdbcache  xc,
jid  owner,
const char *  ns,
char *  act,
char const *  match,
xmlnode  data 
)

sends new xml action, returns non-zero if failure

Referenced by _js_session_to().

int xdb_act_path ( xdbcache  xc,
jid  owner,
const char *  ns,
char const *  act,
char const *  matchpath,
xht  namespaces,
xmlnode  data 
)

sends new xml action, returns non-zero if failure

Referenced by _js_session_from().

create a new xdb cache for this instance

create an xdbcache for the specified instance

This creates the _xdbcache structure from the memory pool of the instance, and registers two handlers: One handler is registered to get/handle the xdb responses that are delivered to the instance. The other handler is registered to get called regularily every 10 seconds.

Parameters:
idthe instance to create the _xdbcache for.
Returns:
the newly created xdbcache

References xdbcache_struct::i, xdbcache_struct::mutex, xdbcache_struct::next, o_PRECOND, instance_struct::p, pmalloco(), xdbcache_struct::prev, register_beat(), and register_phandler().

Referenced by dialback(), dnsrv(), jsm(), pthsock_client(), xdb_file(), and xdb_sql().

xmlnode xdb_get ( xdbcache  xc,
jid  owner,
const char *  ns 
)

blocks until namespace is retrieved, returns xmlnode or NULL if failed

query data from the xdb

blocks until namespace is retrieved, host must map back to this service!

Parameters:
xcthe xdbcache used for this query
ownerfor which JID the query should be made
nswhich namespace to query
Returns:
NULL if nothing found, result else (has to be freed by the caller!)

References xdbcache_struct::cond, xdbcache_struct::data, xdbcache_struct::i, xdbcache_struct::id, jid_full(), log_debug2, LOGT_STORAGE, LOGT_THREAD, xdbcache_struct::mutex, xdbcache_struct::next, xdbcache_struct::ns, xdbcache_struct::owner, xdbcache_struct::preblock, xdbcache_struct::prev, xdbcache_struct::sent, xdbcache_struct::set, xmlnode_free(), xmlnode_get_firstchild(), xmlnode_get_nextsibling(), and xmlnode_get_type().

Referenced by _js_authreg_register(), dialback(), dnsrv(), js_config(), js_user(), mod_dynamic(), pthsock_client(), xdb_file(), and xdb_sql().

int xdb_set ( xdbcache  xc,
jid  owner,
const char *  ns,
xmlnode  data 
)

sends new xml to replace old, returns non-zero if failure


Variable Documentation

the active debugging mask (this is a bitmask of ORed LOGT_* constents)

Referenced by get_debug_flag(), set_cmdline_debug_flag(), and set_debug_flag().