xjab_worker.h File Reference

#include "../../str.h"
#include "../../db/db.h"
#include "../../locking.h"
#include "../tm/tm_load.h"
#include "xjab_util.h"
#include "tree234.h"

Include dependency graph for xjab_worker.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _xj_jalias
struct  _xj_wlist
struct  _xj_worker

Typedefs

typedef struct _xj_jalias t_xj_jalias
typedef struct _xj_wlist t_xj_wlist
typedef struct _xj_worker t_xj_worker
typedef struct _xj_jaliasxj_jalias
typedef struct _xj_wlistxj_wlist
typedef struct _xj_workerxj_worker

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 *, str *, str *, str *, int *)
int xj_send_sip_msgz (str *, str *, str *, char *, int *)
void xj_sig_handler (int s)
void xj_tuac_callback (struct cell *t, int type, struct tmcb_params *ps)
int xj_wlist_check (xj_wlist, xj_jkey, xj_jkey *)
int xj_wlist_check_aliases (xj_wlist, str *)
int xj_wlist_clean_jobs (xj_wlist, int, int)
void xj_wlist_del (xj_wlist, xj_jkey, int)
void xj_wlist_free (xj_wlist)
int xj_wlist_get (xj_wlist, xj_jkey, xj_jkey *)
xj_wlist xj_wlist_init (int **, int, int, int, int, int)
int xj_wlist_set_aliases (xj_wlist, char *, char *, char *)
int xj_wlist_set_flag (xj_wlist, xj_jkey, int)
int xj_wlist_set_pid (xj_wlist, int, int)
void xj_worker_check_jcons (xj_wlist, xj_jcon_pool, int, fd_set *)
void xj_worker_check_qmsg (xj_wlist, xj_jcon_pool)
void xj_worker_check_watcher (xj_wlist, xj_jcon_pool, xj_jcon, xj_sipmsg)
int xj_worker_process (xj_wlist, char *, int, char *, int, db_con_t *, db_func_t *)


Typedef Documentation

typedef struct _xj_jalias t_xj_jalias

typedef struct _xj_wlist t_xj_wlist

typedef struct _xj_worker t_xj_worker

typedef struct _xj_jalias * xj_jalias

typedef struct _xj_wlist * xj_wlist

typedef struct _xj_worker * xj_worker


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_check ( xj_wlist  jwl,
xj_jkey  jkey,
xj_jkey p 
)

return communication pipe with the worker that will process the message for the id 'sid' only if it exists, or -1 if error

  • jwl : pointer to the workers list
  • sid : id of the entity (connection to Jabber - usually SHOULD be FROM header of the incoming SIP message)
  • p : will point to the SHM location of the 'sid' in jwl

Definition at line 205 of file xjab_wlist.c.

References find234(), _xj_jkey::id, _str::len, len, LM_DBG, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and _xj_worker::wpipe.

Referenced by xjab_manage_sipmsg().

int xj_wlist_check_aliases ( xj_wlist  jwl,
str addr 
)

check if the addr contains jdomain or an alias

  • jwl : pointer to the workers list
  • addr: the address to check against jdomain and aliases returns 0 - if contains or !=0 if not

Definition at line 582 of file xjab_wlist.c.

References _xj_jalias::a, _xj_wlist::aliases, _xj_jalias::jdm, _str::len, s, _str::s, and _xj_jalias::size.

Referenced by xjab_manage_sipmsg().

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_wlist_del ( xj_wlist  jwl,
xj_jkey  jkey,
int  _pid 
)

delete an entity from working list of a worker

  • jwl : pointer to the workers list
  • sid : id of the entity (connection to Jabber - usually SHOULD be FROM header of the incoming SIP message
  • _pid : process id of the worker

Definition at line 628 of file xjab_wlist.c.

References del234(), _xj_jkey::id, _str::len, _xj_wlist::len, LM_DBG, _xj_worker::nr, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and xj_jkey_free_p().

Referenced by xj_worker_check_jcons(), and xj_worker_process().

void xj_wlist_free ( xj_wlist  jwl  ) 

int xj_wlist_get ( xj_wlist  jwl,
xj_jkey  jkey,
xj_jkey p 
)

return communication pipe with the worker that will process the message for the id 'sid', or -1 if error

  • jwl : pointer to the workers list
  • sid : id of the entity (connection to Jabber - usually SHOULD be FROM header of the incoming SIP message)
  • p : will point to the SHM location of the 'sid' in jwl

Definition at line 250 of file xjab_wlist.c.

References _M_SHM_FREE, _M_SHM_MALLOC, add234(), find234(), _xj_jkey::flag, _xj_jkey::hash, _xj_jkey::id, _str::len, len, LM_DBG, _xj_wlist::maxj, min, _xj_worker::nr, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, _xj_worker::wpipe, and XJ_FLAG_OPEN.

Referenced by xj_register_watcher(), and xjab_manage_sipmsg().

xj_wlist xj_wlist_init ( int **  pipes,
int  size,
int  max,
int  cache_time,
int  sleep_time,
int  delay_time 
)

init a workers list

  • pipes : communication pipes
  • size : size of list - number of workers
  • max : maximum number of jobs per worker return : pointer to workers list or NULL on error

Definition at line 54 of file xjab_wlist.c.

References _M_SHM_FREE, _M_SHM_MALLOC, _xj_wlist::aliases, _xj_wlist::cachet, _xj_wlist::delayt, free2tree234(), jwl, _xj_wlist::len, LM_CRIT, LM_DBG, _xj_wlist::maxj, newtree234(), _xj_worker::nr, NULL, _xj_worker::pid, _xj_worker::rpipe, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::sleept, _xj_wlist::workers, _xj_worker::wpipe, xj_jkey_cmp(), and xj_jkey_free_p().

Referenced by mod_init().

int xj_wlist_set_aliases ( xj_wlist  jwl,
char *  als,
char *  jd,
char *  pa 
)

set IM aliases, jdomain and outbound proxy

return 0 if OK

Definition at line 392 of file xjab_wlist.c.

References _M_SHM_FREE, _M_SHM_MALLOC, _xj_jalias::a, _xj_wlist::aliases, _xj_jalias::d, _xj_jalias::dlm, _xj_jalias::jdm, _str::len, LM_DBG, NULL, _xj_jalias::proxy, _str::s, _xj_jalias::size, and XJ_DEF_JDELIM.

Referenced by mod_init().

int xj_wlist_set_flag ( xj_wlist  jwl,
xj_jkey  jkey,
int  fl 
)

set the flag of the connection identified by 'jkey'

Definition at line 344 of file xjab_wlist.c.

References find234(), _xj_jkey::flag, _xj_jkey::hash, _xj_jkey::id, len, _str::len, LM_DBG, NULL, _xj_worker::pid, _str::s, _xj_wlist::sems, _xj_worker::sip_ids, _xj_wlist::workers, and _xj_worker::wpipe.

int xj_wlist_set_pid ( xj_wlist  jwl,
int  pid,
int  idx 
)

set the p.id's of the workers

  • jwl : pointer to the workers list
  • pids : p.id's array
  • size : number of pids return : 0 on success or <0 on error

Definition at line 134 of file xjab_wlist.c.

References _xj_wlist::len, NULL, _xj_worker::pid, _xj_wlist::sems, and _xj_wlist::workers.

Referenced by child_init(), and 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().


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