jabberd2
2.2.16
|
#include "router.h"
Go to the source code of this file.
Data Structures | |
struct | broadcast_st |
info for broadcasts More... | |
Defines | |
#define | MAX_JID 3072 |
#define | MAX_MESSAGE 65535 |
#define | SECS_PER_DAY 86400 |
#define | BYTES_PER_MEG 1048576 |
Typedefs | |
typedef struct broadcast_st * | broadcast_t |
info for broadcasts | |
Functions | |
static void | _router_broadcast (const char *key, int keylen, void *val, void *arg) |
broadcast a packet | |
static void | _router_advertise (router_t r, char *domain, component_t src, int unavail) |
domain advertisement | |
static void | _router_advertise_reverse (const char *key, int keylen, void *val, void *arg) |
tell a component about all the others | |
static void | _router_process_handshake (component_t comp, nad_t nad) |
void | routes_free (routes_t routes) |
static int | _route_add (xht hroutes, const char *name, component_t comp, route_type_t rtype) |
static void | _route_remove (xht hroutes, const char *name, component_t comp) |
static void | _router_process_bind (component_t comp, nad_t nad) |
static void | _router_process_unbind (component_t comp, nad_t nad) |
static void | _router_comp_write (component_t comp, nad_t nad) |
static void | _router_route_log_sink (const char *key, int keylen, void *val, void *arg) |
static void | _router_process_route (component_t comp, nad_t nad) |
static void | _router_process_throttle (component_t comp, nad_t nad) |
static int | _router_sx_callback (sx_t s, sx_event_t e, void *data, void *arg) |
static int | _router_accept_check (router_t r, mio_fd_t fd, char *ip) |
static void | _router_route_unbind_walker (const char *key, int keylen, void *val, void *arg) |
int | router_mio_callback (mio_t m, mio_action_t a, mio_fd_t fd, void *data, void *arg) |
int | message_log (nad_t nad, router_t r, const unsigned char *msg_from, const unsigned char *msg_to) |
#define MAX_MESSAGE 65535 |
Definition at line 24 of file router.c.
Referenced by message_log().
typedef struct broadcast_st * broadcast_t |
info for broadcasts
static void _router_broadcast | ( | const char * | key, |
int | keylen, | ||
void * | val, | ||
void * | arg | ||
) | [static] |
broadcast a packet
Definition at line 36 of file router.c.
References routes_st::ncomp, routes_st::comp, broadcast_st::src, component_st::legacy, sx_nad_write, component_st::s, nad_copy(), and broadcast_st::nad.
Referenced by _router_advertise().
static void _router_advertise | ( | router_t | r, |
char * | domain, | ||
component_t | src, | ||
int | unavail | ||
) | [static] |
domain advertisement
Definition at line 51 of file router.c.
References log_debug, ZONE, broadcast_st::r, broadcast_st::src, broadcast_st::nad, nad_new(), nad_add_namespace(), uri_COMPONENT, nad_append_elem(), nad_append_attr(), xhash_walk(), router_st::routes, _router_broadcast(), and nad_free().
Referenced by _router_process_bind(), _router_process_unbind(), _router_sx_callback(), and _router_route_unbind_walker().
static void _router_advertise_reverse | ( | const char * | key, |
int | keylen, | ||
void * | val, | ||
void * | arg | ||
) | [static] |
tell a component about all the others
Definition at line 74 of file router.c.
References broadcast_st::nad, routes_st::name, routes_st::comp, routes_st::ncomp, log_debug, ZONE, nad_new(), nad_add_namespace(), uri_COMPONENT, nad_append_elem(), nad_set_attr(), sx_nad_write, and component_st::s.
Referenced by _router_process_bind().
static void _router_process_handshake | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 100 of file router.c.
References NAD_CDATA_L, log_debug, ZONE, sx_error(), component_st::s, stream_err_NOT_AUTHORIZED, sx_close(), nad_free(), _sx_st::id, component_st::r, router_st::local_secret, shahash_r(), NAD_CDATA, nad_st::elems, nad_elem_st::icdata, nad_elem_st::itail, nad_elem_st::lcdata, nad_elem_st::ltail, sx_nad_write, sx_auth(), and _sx_st::req_to.
Referenced by _router_sx_callback().
void routes_free | ( | routes_t | routes | ) |
Definition at line 153 of file router.c.
References routes_st::name, and routes_st::comp.
Referenced by JABBER_MAIN().
static int _route_add | ( | xht | hroutes, |
const char * | name, | ||
component_t | comp, | ||
route_type_t | rtype | ||
) | [static] |
Definition at line 159 of file router.c.
References xhash_get(), routes_st::name, routes_st::rtype, routes_st::comp, routes_st::ncomp, xhash_put(), log_write(), component_st::r, and router_st::log.
Referenced by _router_process_bind(), and _router_sx_callback().
static void _route_remove | ( | xht | hroutes, |
const char * | name, | ||
component_t | comp | ||
) | [static] |
Definition at line 179 of file router.c.
References xhash_get(), routes_st::ncomp, routes_st::comp, jqueue_push(), component_st::r, router_st::deadroutes, and xhash_zap().
Referenced by _router_process_unbind(), and _router_route_unbind_walker().
static void _router_process_bind | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 202 of file router.c.
References nad_find_attr(), jid_new(), NAD_AVAL, NAD_AVAL_L, log_debug, ZONE, nad_set_attr(), sx_nad_write, component_st::s, _sx_st::auth_id, jid_st::domain, aci_check(), component_st::r, router_st::aci, log_write(), router_st::log, component_st::ip, component_st::port, jid_free(), xhash_get(), router_st::routes, router_st::aliases, alias_st::next, alias_st::name, nad_find_elem(), NAD_ENS, router_st::default_route, xhash_put(), router_st::log_sinks, pstrdup(), xhash_pool(), _route_add(), route_SINGLE, route_MULTI_TO, component_st::routes, _router_advertise(), xhash_walk(), _router_advertise_reverse(), and alias_st::target.
Referenced by _router_sx_callback().
static void _router_process_unbind | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 331 of file router.c.
References nad_find_attr(), jid_new(), NAD_AVAL, NAD_AVAL_L, log_debug, ZONE, nad_set_attr(), sx_nad_write, component_st::s, xhash_get(), component_st::routes, jid_st::domain, log_write(), component_st::r, router_st::log, component_st::ip, component_st::port, jid_free(), xhash_zap(), router_st::log_sinks, _route_remove(), router_st::routes, router_st::default_route, and _router_advertise().
Referenced by _router_sx_callback().
static void _router_comp_write | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 374 of file router.c.
References component_st::tq, log_debug, ZONE, component_st::ip, component_st::port, jqueue_push(), component_st::legacy, sx_nad_write, component_st::s, nad_find_attr(), NAD_AVAL_L, NAD_AVAL, stanza_error(), stanza_err_BAD_REQUEST, stanza_err_SERVICE_UNAVAILABLE, and sx_nad_write_elem().
Referenced by _router_route_log_sink(), _router_process_route(), and _router_process_throttle().
static void _router_route_log_sink | ( | const char * | key, |
int | keylen, | ||
void * | val, | ||
void * | arg | ||
) | [static] |
Definition at line 402 of file router.c.
References broadcast_st::nad, log_debug, ZONE, component_st::ip, component_st::port, nad_copy(), nad_set_attr(), and _router_comp_write().
Referenced by _router_process_route().
static void _router_process_route | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 413 of file router.c.
References jid_static(), nad_find_attr(), log_debug, ZONE, nad_free(), jid_reset(), NAD_AVAL, NAD_AVAL_L, nad_set_attr(), _router_comp_write(), jid_st::domain, xhash_get(), component_st::routes, log_write(), component_st::r, router_st::log, component_st::ip, component_st::port, router_st::filter, filter_packet(), stanza_err_REDIRECT, _stanza_errors, stanza_err_BAD_REQUEST, router_st::routes, router_st::default_route, xhash_count(), router_st::log_sinks, xhash_walk(), _router_route_log_sink(), routes_st::ncomp, routes_st::rtype, route_MULTI_TO, nad_print(), route_MULTI_FROM, routes_st::name, jid_st::node, xhashv::val, shahash_raw(), jid_user(), jid_st::_user, jid_st::_full, routes_st::comp, router_st::message_logging_enabled, router_st::message_logging_file, NAD_ENAME_L, NAD_ENAME, jid_new(), message_log(), jid_full(), jid_free(), xhash_iter_first(), router_st::components, xhashv::comp_val, xhash_iter_get(), nad_copy(), and xhash_iter_next().
Referenced by _router_sx_callback().
static void _router_process_throttle | ( | component_t | comp, |
nad_t | nad | ||
) | [static] |
Definition at line 646 of file router.c.
References component_st::tq, _router_comp_write(), log_write(), component_st::r, router_st::log, component_st::ip, component_st::port, jqueue_new(), jqueue_pull(), and jqueue_free().
Referenced by _router_sx_callback().
static int _router_sx_callback | ( | sx_t | s, |
sx_event_t | e, | ||
void * | data, | ||
void * | arg | ||
) | [static] |
Definition at line 671 of file router.c.
References jid_static(), event_WANT_READ, log_debug, ZONE, mio_read, component_st::r, router_st::mio, component_st::fd, event_WANT_WRITE, mio_write, event_READ, mio_fd_st::fd, component_st::rate, rate_check(), component_st::rate_log, log_write(), router_st::log, component_st::ip, component_st::port, _sx_buf_st::len, rate_left(), _sx_buf_st::data, rate_add(), MIO_WOULDBLOCK, sx_kill(), component_st::s, event_WRITE, event_ERROR, _sx_error_st::generic, _sx_error_st::specific, event_STREAM, _sx_st::ns, component_st::legacy, router_st::local_secret, sx_error(), stream_err_INVALID_NAMESPACE, sx_close(), _sx_st::req_to, stream_err_HOST_UNKNOWN, event_OPEN, _sx_st::auth_id, router_st::aliases, alias_st::next, alias_st::name, _route_add(), router_st::routes, route_MULTI_FROM, xhash_put(), component_st::routes, pstrdup(), xhash_pool(), _router_advertise(), alias_st::target, event_PACKET, _sx_st::state, state_STREAM, nad_free(), NAD_ENAME_L, NAD_ENAME, _router_process_handshake(), nad_find_attr(), jid_reset(), NAD_AVAL, NAD_AVAL_L, nad_find_namespace(), nad_st::elems, nad_elem_st::ns, nad_st::nss, nad_ns_st::next, uri_CLIENT, nad_add_namespace(), nad_st::scope, nad_elem_st::my_ns, uri_COMPONENT, nad_wrap_elem(), nad_set_attr(), jid_st::domain, NAD_ENS, NAD_NURI_L, NAD_NURI, _router_process_bind(), _router_process_unbind(), _router_process_route(), _router_process_throttle(), event_CLOSED, router_st::closefd, _jqueue_st::front, _jqueue_node_st::prev, _jqueue_node_st::data, and jqueue_push().
Referenced by router_mio_callback().
Definition at line 977 of file router.c.
References access_check(), router_st::access, log_write(), router_st::log, mio_fd_st::fd, router_st::conn_rate_total, xhash_get(), router_st::conn_rates, rate_new(), router_st::conn_rate_seconds, router_st::conn_rate_wait, xhash_put(), pstrdup(), xhash_pool(), rate_check(), and rate_add().
Referenced by router_mio_callback().
static void _router_route_unbind_walker | ( | const char * | key, |
int | keylen, | ||
void * | val, | ||
void * | arg | ||
) | [static] |
Definition at line 1003 of file router.c.
References xhash_zapx(), component_st::r, router_st::log_sinks, _route_remove(), router_st::routes, component_st::routes, router_st::default_route, log_write(), router_st::log, xhash_getx(), and _router_advertise().
Referenced by router_mio_callback().
int router_mio_callback | ( | mio_t | m, |
mio_action_t | a, | ||
mio_fd_t | fd, | ||
void * | data, | ||
void * | arg | ||
) |
Definition at line 1028 of file router.c.
References action_READ, log_debug, ZONE, mio_fd_st::fd, component_st::last_activity, sx_kill(), component_st::s, sx_can_read(), action_WRITE, sx_can_write(), action_CLOSE, component_st::r, log_write(), router_st::log, component_st::ip, component_st::port, xhash_walk(), component_st::routes, _router_route_unbind_walker(), xhash_zap(), router_st::components, xhash_free(), jqueue_free(), rate_free(), jqueue_push(), action_ACCEPT, j_inet_getport(), _router_accept_check(), router_st::fd, INET6_ADDRSTRLEN, sx_new(), router_st::sx_env, _router_sx_callback(), mio_app, router_mio_callback(), router_st::byte_rate_total, rate_new(), router_st::byte_rate_seconds, router_st::byte_rate_wait, xhash_new(), xhash_put(), sx_server_init(), SX_SSL_STARTTLS_OFFER, and SX_SASL_OFFER.
Referenced by JABBER_MAIN(), and router_mio_callback().
int message_log | ( | nad_t | nad, |
router_t | r, | ||
const unsigned char * | msg_from, | ||
const unsigned char * | msg_to | ||
) |
Definition at line 1131 of file router.c.
References MAX_MESSAGE, NAD_ENAME_L, NAD_ENAME, NAD_CDATA_L, NAD_CDATA, log_write(), router_st::log, and router_st::message_logging_file.
Referenced by _router_process_route().