xjab_worker.c File Reference

#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"

Include dependency graph for xjab_worker.c:

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


Define Documentation

#define _PADDR (  )     ((a)->aliases->proxy)

#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

#define XJ_MSG_POOL_SIZE   10

Definition at line 72 of file xjab_worker.c.

Referenced by xj_worker_process().

#define XJAB_RESOURCE   "serXjab"

Definition at line 65 of file xjab_worker.c.

Referenced by xj_worker_process().


Function Documentation

int xj_address_translation ( str src,
str dst,
xj_jalias  als,
int  flag 
)

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().

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 
)

send a SIP MESSAGE message

  • to : destination
  • from : origin
  • contact : contact header
  • msg : body of the message return : 0 on success or <0 on error

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().

int xj_send_sip_msgz ( str proxy,
str to,
str from,
char *  msg,
int *  cbp 
)

send a SIP MESSAGE message

  • to : destination
  • from : origin
  • contact : contact header
  • msg : body of the message, string terminated by zero return : 0 on success or <0 on error

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 
)

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 
)

worker implementation

  • jwl : pointer to the workers list
  • jaddress : address of the jabber server
  • jport : port of the jabber server
  • rank : worker's rank
  • db_con : connection to database
  • priority: jabber's priority dbf: database module callbacks structure return : 0 on success or <0 on error

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().


Variable Documentation

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

char* registrar

Definition at line 99 of file jabber.c.

Referenced by xj_worker_process().

struct tm_binds tmb

TM bind

Definition at line 87 of file acc_mod.c.


Generated on Fri May 25 00:00:45 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6