jabber_s/xjab_worker.h

00001 /*
00002  * $Id$
00003  *
00004  * eXtended JABber module
00005  *
00006  *
00007  * Copyright (C) 2001-2003 FhG Fokus
00008  *
00009  * This file is part of ser, a free SIP server.
00010  *
00011  * ser is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version
00015  *
00016  * For a license to use the ser software under conditions
00017  * other than those described here, or to purchase support for this
00018  * software, please contact iptel.org by e-mail at the following addresses:
00019  *    info@iptel.org
00020  *
00021  * ser is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00024  * GNU General Public License for more details.
00025  *
00026  * You should have received a copy of the GNU General Public License
00027  * along with this program; if not, write to the Free Software
00028  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00029  */
00030 /*
00031  * History:
00032  * --------
00033  *  2003-03-11  major locking changes - uses locking.h (andrei)
00034  *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
00035  *              on darwin (andrei)
00036  */
00037 
00038 
00039 #ifndef _XJAB_WORKER_H_
00040 #define _XJAB_WORKER_H_
00041 
00042 #include "../../str.h"
00043 #include "../../lib/srdb2/db.h"
00044 #include "../../locking.h"
00045 #include "../../modules/tm/tm_load.h"
00046 
00047 #include "xjab_util.h"
00048 #include "tree234.h"
00049 
00050 /**********             ***/
00051 typedef struct _xj_jalias
00052 {
00053         int size;       // number of aliases
00054         str *jdm;       // Jabber domain
00055         char dlm;       // user part delimiter
00056         str *proxy; // outbound proxy
00057         str *a;         // aliases
00058         char *d;        // user part delimiter for aliases
00059 } t_xj_jalias, *xj_jalias;
00060 
00061 typedef struct _xj_worker
00062 {
00063         int pid;                        // process id
00064         int wpipe;                      // communication pipe - write
00065         int rpipe;                      // communication pipe - read
00066         int nr;                         // number of jobs
00067         tree234 *sip_ids;   // sip ids allocated for the worker
00068 } t_xj_worker, *xj_worker;
00069 
00070 typedef struct _xj_wlist
00071 {
00072         int len;                        // length of the list
00073         int maxj;                       // maximum jobs / worker
00074         int cachet;
00075         int delayt;
00076         int sleept;
00077         gen_lock_set_t   *sems;  // semaphores
00078         xj_jalias       aliases; // added aliases
00079         xj_worker       workers; // the list of workers
00080 } t_xj_wlist, *xj_wlist;
00081 
00082 /**********   LOOK AT IMPLEMENTATION OF FUNCTIONS FOR DESCRIPTION    ***/
00083 
00084 xj_wlist xj_wlist_init(int **, int, int, int, int, int);
00085 int  xj_wlist_set_pid(xj_wlist, int, int);
00086 int  xj_wlist_get(xj_wlist, xj_jkey, xj_jkey*);
00087 int  xj_wlist_check(xj_wlist, xj_jkey, xj_jkey*);
00088 int  xj_wlist_set_flag(xj_wlist, xj_jkey, int);
00089 void xj_wlist_del(xj_wlist, xj_jkey, int);
00090 void xj_wlist_free(xj_wlist);
00091 int  xj_wlist_set_aliases(xj_wlist, char *, char *, char *);
00092 int  xj_wlist_check_aliases(xj_wlist, str*);
00093 int  xj_wlist_clean_jobs(xj_wlist, int, int); 
00094 
00095 int xj_worker_process(xj_wlist, char*, int, int, db_cmd_t*);
00096 
00097 int xj_address_translation(str *src, str *dst, xj_jalias als, int flag);
00098 int xj_manage_jab(char *buf, int len, int *pos, xj_jalias als, xj_jcon jbc);
00099 
00100 void xj_sig_handler(int s);
00101 
00102 /**********             ***/
00103 
00104 int xj_send_sip_msg(str *, str *, str *, str *, int *);
00105 int xj_send_sip_msgz(str *,str *, str *, char *, int *);
00106 void xj_tuac_callback( struct cell *t, int type, struct tmcb_params *ps);
00107 void xj_worker_check_jcons(xj_wlist, xj_jcon_pool, int, fd_set*);
00108 void xj_worker_check_qmsg(xj_wlist, xj_jcon_pool);
00109 void xj_worker_check_watcher(xj_wlist, xj_jcon_pool, xj_jcon, xj_sipmsg);
00110 
00111 #endif
00112