#include <string.h>#include <unistd.h>#include <stdio.h>#include <sys/time.h>#include <sys/types.h>#include <fcntl.h>#include <errno.h>#include <signal.h>#include "../../dprint.h"#include "../../timer.h"#include "../../mem/mem.h"#include "../../mem/shm_mem.h"#include "../tm/tm_load.h"#include "xjab_worker.h"#include "xjab_util.h"#include "xjab_jcon.h"#include "xjab_dmsg.h"#include "xode.h"#include "xjab_presence.h"#include "mdefines.h"

Go to the source code of this file.
Defines | |
| #define | _PADDR(a) ((a)->aliases->proxy) |
| #define | XJ_ADDRTR_CON 4 |
| #define | XJ_ADDRTR_J2S 2 |
| #define | XJ_ADDRTR_NUL 0 |
| #define | XJ_ADDRTR_S2J 1 |
| #define | XJ_MSG_POOL_SIZE 10 |
| #define | XJAB_RESOURCE "serXjab" |
Functions | |
| int | xj_address_translation (str *src, str *dst, xj_jalias als, int flag) |
| int | xj_manage_jab (char *buf, int len, int *pos, xj_jalias als, xj_jcon jbc) |
| int | xj_send_sip_msg (str *proxy, str *to, str *from, str *msg, int *cbp) |
| int | xj_send_sip_msgz (str *proxy, str *to, str *from, char *msg, int *cbp) |
| void | xj_sig_handler (int s) |
| void | xj_tuac_callback (struct cell *t, int type, struct tmcb_params *ps) |
| int | xj_wlist_clean_jobs (xj_wlist jwl, int idx, int fl) |
| void | xj_worker_check_jcons (xj_wlist jwl, xj_jcon_pool jcp, int ltime, fd_set *pset) |
| void | xj_worker_check_qmsg (xj_wlist jwl, xj_jcon_pool jcp) |
| void | xj_worker_check_watcher (xj_wlist jwl, xj_jcon_pool jcp, xj_jcon jbc, xj_sipmsg jsmsg) |
| int | xj_worker_process (xj_wlist jwl, char *jaddress, int jport, char *priority, int rank, db_con_t *db_con, db_func_t *dbf) |
Variables | |
| int | _xj_pid = 0 |
| static str | jab_gw_name = {"jabber_gateway@127.0.0.1", 24} |
| int | main_loop = 1 |
| char * | registrar |
| struct tm_binds | tmb |
Definition at line 75 of file xjab_worker.c.
Referenced by xj_wlist_clean_jobs(), xj_worker_check_jcons(), xj_worker_check_qmsg(), and xj_worker_process().
| #define XJ_ADDRTR_CON 4 |
Definition at line 70 of file xjab_worker.c.
Referenced by xj_address_translation(), xj_worker_check_qmsg(), and xj_worker_process().
| #define XJ_ADDRTR_J2S 2 |
Definition at line 69 of file xjab_worker.c.
Referenced by xj_address_translation(), and xj_manage_jab().
| #define XJ_ADDRTR_NUL 0 |
Definition at line 67 of file xjab_worker.c.
| #define XJ_ADDRTR_S2J 1 |
Definition at line 68 of file xjab_worker.c.
Referenced by xj_address_translation(), xj_worker_check_qmsg(), xj_worker_check_watcher(), and xj_worker_process().
| #define XJ_MSG_POOL_SIZE 10 |
| #define XJAB_RESOURCE "serXjab" |
address correction alias A~B: flag == 0 => A->B, otherwise B->A
Definition at line 92 of file xjab_worker.c.
References _xj_pid, _xj_jalias::a, _xj_jalias::d, _xj_jalias::dlm, _xj_jalias::jdm, _str::len, LM_DBG, NULL, s, _str::s, _xj_jalias::size, XJ_ADDRTR_CON, XJ_ADDRTR_J2S, and XJ_ADDRTR_S2J.
Referenced by xj_manage_jab(), xj_worker_check_qmsg(), xj_worker_check_watcher(), and xj_worker_process().
parse incoming message from Jabber server
Definition at line 734 of file xjab_worker.c.
References _xj_jcon::allowed, _xj_pres_cell::cbf, _xj_pres_cell::cbp, _xj_jkey::flag, _xj_jkey::id, _xj_jcon::jkey, _str::len, LM_DBG, LM_ERR, _xj_jconf::nick, NULL, _xj_jcon::plist, _xj_jalias::proxy, _xj_jcon::ready, _str::s, _xj_pres_cell::state, _xj_jconf::status, _xj_jconf::uri, xj_address_translation(), XJ_ADDRTR_J2S, XJ_AIM_LEN, XJ_AIM_NAME, XJ_DMSG_ERR_JCONFNICK, XJ_DMSG_ERR_JCONFREFUSED, XJ_ICQ_LEN, XJ_ICQ_NAME, xj_jcon_check_jconf(), xj_jcon_jconf_presence(), xj_jcon_send_presence(), XJ_JCONF_NULL, XJ_JCONF_READY, XJ_MSN_LEN, XJ_MSN_NAME, XJ_NET_AIM, XJ_NET_ICQ, XJ_NET_MSN, XJ_NET_YAH, xj_pres_cell_free(), xj_pres_cell_init(), xj_pres_cell_new(), xj_pres_list_add(), xj_pres_list_check(), XJ_PS_OFFLINE, XJ_PS_ONLINE, XJ_PS_REFUSED, xj_send_sip_msg(), xj_send_sip_msgz(), XJ_YAH_LEN, XJ_YAH_NAME, xode_free(), xode_from_strx(), xode_get_attrib(), xode_get_data(), xode_get_firstchild(), xode_get_name(), xode_get_nextsibling(), and xode_get_tag().
Referenced by xj_worker_process().
send a SIP MESSAGE message
Definition at line 1147 of file xjab_worker.c.
References buf, CRLF, CRLF_LEN, _str::len, LM_DBG, msg_type, _str::s, tm_binds::t_request, tmb, and xj_tuac_callback().
Referenced by xj_manage_jab(), and xj_send_sip_msgz().
send a SIP MESSAGE message
Definition at line 1201 of file xjab_worker.c.
References _str::len, LM_DBG, LM_ERR, _str::s, and xj_send_sip_msg().
Referenced by xj_manage_jab(), xj_wlist_clean_jobs(), xj_worker_check_jcons(), xj_worker_check_qmsg(), and xj_worker_process().
| void xj_sig_handler | ( | int | s | ) |
Definition at line 1127 of file xjab_worker.c.
References _xj_pid, LM_DBG, main_loop, and xj_sig_handler().
Referenced by xj_sig_handler(), and xj_worker_process().
| void xj_tuac_callback | ( | struct cell * | t, | |
| int | type, | |||
| struct tmcb_params * | ps | |||
| ) |
callback function for TM
Definition at line 1252 of file xjab_worker.c.
References tmcb_params::code, LM_DBG, tmcb_params::param, and XJ_FLAG_CLOSE.
Referenced by xj_send_sip_msg().
| int xj_wlist_clean_jobs | ( | xj_wlist | jwl, | |
| int | idx, | |||
| int | fl | |||
| ) |
send disconnected info to all SIP users associated with worker idx and clean the entries from wlist
Definition at line 1224 of file xjab_worker.c.
References _PADDR, delpos234(), _xj_jkey::id, _str::len, _xj_wlist::len, LM_DBG, _xj_worker::nr, NULL, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, XJ_DMSG_INF_DISCONNECTED, xj_jkey_free_p(), and xj_send_sip_msgz().
Referenced by xjab_check_workers().
| void xj_worker_check_jcons | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp, | |||
| int | ltime, | |||
| fd_set * | pset | |||
| ) |
check for expired connections
Definition at line 1277 of file xjab_worker.c.
References _PADDR, _xj_pid, delpos234(), _xj_jcon::expire, _xj_jkey::flag, _xj_jkey::id, _xj_jcon::jconf, _xj_jcon::jkey, _str::len, _xj_jcon_pool::len, LM_DBG, main_loop, _xj_jcon::nrjconf, NULL, _xj_jcon_pool::ojc, _xj_jcon::plist, _str::s, _xj_jcon::sock, XJ_DMSG_INF_JOFFLINE, XJ_FLAG_OPEN, xj_jcon_disconnect(), xj_jcon_free(), xj_jcon_jconf_presence(), xj_jconf_free(), xj_pres_list_notifyall(), XJ_PS_TERMINATED, xj_send_sip_msgz(), and xj_wlist_del().
Referenced by xj_worker_process().
| void xj_worker_check_qmsg | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp | |||
| ) |
check if there are msg to send or delete from queue
check the msg queue AND if the target connection is ready
delete message from queue
send message from queue
delete message from queue
Definition at line 1338 of file xjab_worker.c.
References _PADDR, _xj_wlist::aliases, _xj_jalias::dlm, _xj_jmsg_queue::expire, _xj_jkey::flag, get_ticks(), _xj_jkey::id, _xj_jcon::jkey, _xj_sipmsg::jkey, _xj_jcon_pool::jmqueue, _xj_jmsg_queue::jsm, _str::len, LM_DBG, LM_ERR, main_loop, _xj_sipmsg::msg, NULL, _xj_jmsg_queue::ojc, _str::s, _xj_jmsg_queue::size, _xj_sipmsg::to, xj_address_translation(), XJ_ADDRTR_CON, XJ_ADDRTR_S2J, XJ_DMSG_ERR_SENDIM, xj_jcon_is_ready(), xj_jcon_pool_del_jmsg(), xj_jcon_send_msg(), xj_jconf_check_addr(), XJ_JMSG_CHAT, XJ_JMSG_GROUPCHAT, xj_send_sip_msgz(), and xj_sipmsg_free().
Referenced by xj_worker_process().
| void xj_worker_check_watcher | ( | xj_wlist | jwl, | |
| xj_jcon_pool | jcp, | |||
| xj_jcon | jbc, | |||
| xj_sipmsg | jsmsg | |||
| ) |
update or register a presence watcher
Definition at line 1434 of file xjab_worker.c.
References _xj_wlist::aliases, _xj_pres_cell::cbf, _xj_sipmsg::cbf, _xj_pres_cell::cbp, _xj_jalias::dlm, _str::len, LM_DBG, NULL, _xj_sipmsg::p, _xj_jcon::plist, _str::s, _xj_pres_cell::state, _xj_pres_cell::status, _xj_sipmsg::to, xj_address_translation(), XJ_ADDRTR_S2J, xj_jcon_send_subscribe(), xj_jconf_check_addr(), xj_pres_cell_free(), xj_pres_cell_init(), xj_pres_cell_new(), xj_pres_cell_update(), xj_pres_list_add(), xj_pres_list_check(), XJ_PRES_STATUS_WAIT, and XJ_PS_OFFLINE.
Referenced by xj_worker_process().
| int xj_worker_process | ( | xj_wlist | jwl, | |
| char * | jaddress, | |||
| int | jport, | |||
| char * | priority, | |||
| int | rank, | |||
| db_con_t * | db_con, | |||
| db_func_t * | dbf | |||
| ) |
worker implementation
add socket descriptor to select
wait for a while - the worker is tired
flush out the socket - set it to nonblocking
flush out the socket - set it back to blocking
Definition at line 252 of file xjab_worker.c.
References _PADDR, _xj_pid, _xj_wlist::aliases, _xj_wlist::cachet, DB_INT, DB_STRING, _xj_wlist::delayt, _xj_jalias::dlm, _xj_jcon::expire, _xj_jkey::flag, db_func::free_result, get_ticks(), _xj_jkey::id, db_val_t::int_val, _xj_jalias::jdm, _xj_jcon::jkey, _xj_sipmsg::jkey, _xj_jcon_pool::jmqueue, _xj_jcon_pool::len, _xj_wlist::len, _str::len, LM_DBG, LM_ERR, main_loop, _xj_wlist::maxj, _xj_sipmsg::msg, _xj_jcon::nrjconf, db_val_t::nul, NULL, _xj_jcon_pool::ojc, db_func::query, registrar, RES_ROW_N, RES_ROWS, ROW_VALUES, _xj_worker::rpipe, _str::s, _xj_jmsg_queue::size, _xj_wlist::sleept, _xj_jcon::sock, _xj_jconf::status, str_init, db_val_t::string_val, _xj_sipmsg::to, _xj_sipmsg::type, db_val_t::type, db_val_t::val, vals, _xj_wlist::workers, xj_address_translation(), XJ_ADDRTR_CON, XJ_ADDRTR_S2J, XJ_DEL_WATCHER, XJ_DMSG_ERR_DISCONNECTED, XJ_DMSG_ERR_JAUTH, XJ_DMSG_ERR_JGWFORB, XJ_DMSG_ERR_JGWFULL, XJ_DMSG_ERR_JOINJCONF, XJ_DMSG_ERR_NEWJCONF, XJ_DMSG_ERR_NOJSRV, XJ_DMSG_ERR_NOREGIM, XJ_DMSG_ERR_NOTJCONF, XJ_DMSG_ERR_SENDJMSG, XJ_DMSG_ERR_STOREJMSG, XJ_DMSG_INF_JCONFEXIT, XJ_EXIT_JCONF, XJ_GO_OFFLINE, XJ_GO_ONLINE, XJ_JCMD_UNSUBSCRIBE, xj_jcon_connect(), xj_jcon_del_jconf(), xj_jcon_disconnect(), xj_jcon_free(), xj_jcon_get_jconf(), xj_jcon_get_roster(), xj_jcon_init(), xj_jcon_is_ready(), xj_jcon_jconf_presence(), xj_jcon_pool_add(), xj_jcon_pool_add_jmsg(), xj_jcon_pool_get(), xj_jcon_pool_init(), xj_jcon_send_msg(), xj_jcon_send_presence(), xj_jcon_set_attrs(), xj_jcon_update(), xj_jcon_user_auth(), xj_jconf_check_addr(), XJ_JCONF_READY, XJ_JCONF_WAITING, XJ_JMSG_CHAT, XJ_JMSG_GROUPCHAT, XJ_JOIN_JCONF, xj_manage_jab(), XJ_MSG_POOL_SIZE, XJ_REG_WATCHER, XJ_SEND_MESSAGE, xj_send_sip_msgz(), xj_sig_handler(), xj_sipmsg_free(), xj_wlist_del(), xj_worker_check_jcons(), xj_worker_check_qmsg(), xj_worker_check_watcher(), and XJAB_RESOURCE.
Referenced by child_init(), and xjab_check_workers().
| int _xj_pid = 0 |
debug info
Definition at line 81 of file xjab_worker.c.
Referenced by xj_address_translation(), xj_sig_handler(), xj_worker_check_jcons(), and xj_worker_process().
str jab_gw_name = {"jabber_gateway@127.0.0.1", 24} [static] |
Definition at line 86 of file xjab_worker.c.
| int main_loop = 1 |
Definition at line 82 of file xjab_worker.c.
Referenced by main(), xj_sig_handler(), xj_worker_check_jcons(), xj_worker_check_qmsg(), and xj_worker_process().
| char* registrar |
1.5.6