diff --git a/src/modules/seas/cluster.h b/src/modules/seas/cluster.h index 6c18116d6c2..b3e596736f1 100644 --- a/src/modules/seas/cluster.h +++ b/src/modules/seas/cluster.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ diff --git a/src/modules/seas/encode_allow.h b/src/modules/seas/encode_allow.h index e48ace7a7df..b4663e13f5d 100644 --- a/src/modules/seas/encode_allow.h +++ b/src/modules/seas/encode_allow.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,11 +13,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef __ENCODE_ALLOW_H__ +#define __ENCODE_ALLOW_H__ int encode_allow(char *hdrstart,int hdrlen,unsigned int *bodi,char *where); int print_encoded_allow(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); +#endif diff --git a/src/modules/seas/encode_content_disposition.h b/src/modules/seas/encode_content_disposition.h index 63d81de366d..48045289f6c 100644 --- a/src/modules/seas/encode_content_disposition.h +++ b/src/modules/seas/encode_content_disposition.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,11 +13,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef __ENCODE_CONTENT_DISPOSITION_H__ +#define __ENCODE_CONTENT_DISPOSITION_H__ int encode_content_disposition(char *hdrstart,int hdrlen,struct disposition *body,unsigned char *where); int print_encoded_content_disposition(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); +#endif diff --git a/src/modules/seas/encode_content_length.h b/src/modules/seas/encode_content_length.h index fc58dbcf9ce..deb1cc40467 100644 --- a/src/modules/seas/encode_content_length.h +++ b/src/modules/seas/encode_content_length.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,11 +13,13 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - +#ifndef __ENCODE_CONTENT_LENGHT_H__ +#define __ENCODE_CONTENT_LENGHT_H__ int encode_contentlength(char *hdr,int hdrlen,long int len,char *where); int print_encoded_contentlength(FILE* fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix); +#endif diff --git a/src/modules/seas/encode_content_type.h b/src/modules/seas/encode_content_type.h index e52d81d3b4f..b3d359c86a6 100644 --- a/src/modules/seas/encode_content_type.h +++ b/src/modules/seas/encode_content_type.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,15 +13,17 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - +#ifndef __ENCODE_CONTENT_TYPE_H__ +#define __ENCODE_CONTENT_TYPE_H__ int encode_content_type(char *hdrstart,int hdrlen,unsigned int bodi,char *where); int encode_accept(char *hdrstart,int hdrlen,unsigned int *bodi,char *where); int encode_mime_type(char *hdrstart,int hdrlen,unsigned int bodi,char *where); int print_encoded_mime_type(FILE* fd,char *hdr,int hdrlen,unsigned int* payload,int paylen,char *prefix); int print_encoded_content_type(FILE* fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); int print_encoded_accept(FILE* fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); +#endif diff --git a/src/modules/seas/encode_cseq.h b/src/modules/seas/encode_cseq.h index 54aaed1022a..bcba4b864c9 100644 --- a/src/modules/seas/encode_cseq.h +++ b/src/modules/seas/encode_cseq.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,13 +13,15 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - +#ifndef __ENCODE_CSEQ_H__ +#define __ENCODE_CSEQ_H__ #include "../../core/str.h" #include "../../core/parser/msg_parser.h" int encode_cseq(char *hdrstart,int hdrlen,struct cseq_body *body,unsigned char *where); int print_encoded_cseq(FILE* fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); +#endif diff --git a/src/modules/seas/encode_digest.h b/src/modules/seas/encode_digest.h index e91ff12180d..26952c22822 100644 --- a/src/modules/seas/encode_digest.h +++ b/src/modules/seas/encode_digest.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,12 +13,14 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ - +#ifndef __ENCODE_DIGEST_H__ +#define __ENCODE_DIGEST_H__ int encode_digest(char *hdrstart,int hdrlen,dig_cred_t *digest,unsigned char *where); int print_encoded_digest(FILE* fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix); int dump_digest_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,FILE* fd,char segregationLevel); +#endif diff --git a/src/modules/seas/seas.c b/src/modules/seas/seas.c index 0c162db5df7..c6c99a9b8b9 100644 --- a/src/modules/seas/seas.c +++ b/src/modules/seas/seas.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -89,20 +88,20 @@ struct seas_functions seas_f; static cmd_export_t cmds[]= { {"as_relay_t", (cmd_function)w_as_relay_t, 1, fixup_as_relay, - 0, REQUEST_ROUTE}, + 0, REQUEST_ROUTE}, {"as_relay_sl", (cmd_function)w_as_relay_sl, 1, fixup_as_relay, - 0, REQUEST_ROUTE}, + 0, REQUEST_ROUTE}, {0,0,0,0,0,0} }; static param_export_t params[]= { - {"listen_sockets",PARAM_STRING, &seas_listen_socket}, - {"stats_socket", PARAM_STRING, &seas_stats_socket}, - {"jain_ping", PARAM_STRING, &jain_ping_config}, - {"servlet_ping", PARAM_STRING, &servlet_ping_config}, - {"clusters", PARAM_STRING, &cluster_cfg}, - {0,0,0} + {"listen_sockets",PARAM_STRING, &seas_listen_socket}, + {"stats_socket", PARAM_STRING, &seas_stats_socket}, + {"jain_ping", PARAM_STRING, &jain_ping_config}, + {"servlet_ping", PARAM_STRING, &servlet_ping_config}, + {"clusters", PARAM_STRING, &cluster_cfg}, + {0,0,0} }; static proc_export_t seas_procs[] = { @@ -110,65 +109,65 @@ static proc_export_t seas_procs[] = { {0,0,0,0,0} }; -struct module_exports exports= +struct module_exports exports= { - "seas", - DEFAULT_DLFLAGS, - cmds, /* exported commands */ - params, /* exported parameters */ - 0, /* exported statistics */ - 0, /* exported mi commands */ - 0, /* exported module-items (pseudo variables) */ - seas_procs, /* extra processes */ - seas_init, /* module initialization function */ - 0, /* response function */ - (destroy_function) seas_exit, /* module exit function */ - (child_init_function) seas_child_init /* per-child init function */ + "seas", + DEFAULT_DLFLAGS, + cmds, /* exported commands */ + params, /* exported parameters */ + 0, /* exported statistics */ + 0, /* exported mi commands */ + 0, /* exported module-items (pseudo variables) */ + seas_procs, /* extra processes */ + seas_init, /* module initialization function */ + 0, /* response function */ + (destroy_function) seas_exit, /* module exit function */ + (child_init_function) seas_child_init /* per-child init function */ }; static int fixup_as_relay(void** param, int param_no) { - int len; - char *parameter; - struct as_entry **entry,*tmp; - - parameter=(char *)(*param); - - if (param_no!=1) - return 0; - len=strlen(parameter); - - for (entry=&as_list;*entry;entry=&((*entry)->next)) { - if (len== (*entry)->name.len && - !memcmp((*entry)->name.s,parameter,len)) { - pkg_free(*param); - *param=*entry; - return 1; - } - } - if (!(*entry)) { - if (!(*entry=(struct as_entry *)shm_malloc(sizeof(struct as_entry)))) { - LM_ERR("no more shm_mem\n"); - goto error; - } - memset(*entry,0,sizeof(struct as_entry)); - if(!((*entry)->name.s=shm_malloc(len))){ - LM_ERR("no more share mem\n"); - goto error; - } - (*entry)->name.len=len; - memcpy((*entry)->name.s,parameter,len); - (*entry)->u.as.name=(*entry)->name; - (*entry)->u.as.event_fd=(*entry)->u.as.action_fd=-1; - (*entry)->type=AS_TYPE; - pkg_free(*param); - *param=*entry; - } - for (tmp=as_list;tmp;tmp=tmp->next) - LM_DBG("%.*s\n",tmp->name.len,tmp->name.s); - return 1; + int len; + char *parameter; + struct as_entry **entry,*tmp; + + parameter=(char *)(*param); + + if (param_no!=1) + return 0; + len=strlen(parameter); + + for (entry=&as_list;*entry;entry=&((*entry)->next)) { + if (len== (*entry)->name.len && + !memcmp((*entry)->name.s,parameter,len)) { + pkg_free(*param); + *param=*entry; + return 1; + } + } + if (!(*entry)) { + if (!(*entry=(struct as_entry *)shm_malloc(sizeof(struct as_entry)))) { + LM_ERR("no more shm_mem\n"); + goto error; + } + memset(*entry,0,sizeof(struct as_entry)); + if(!((*entry)->name.s=shm_malloc(len))){ + LM_ERR("no more share mem\n"); + goto error; + } + (*entry)->name.len=len; + memcpy((*entry)->name.s,parameter,len); + (*entry)->u.as.name=(*entry)->name; + (*entry)->u.as.event_fd=(*entry)->u.as.action_fd=-1; + (*entry)->type=AS_TYPE; + pkg_free(*param); + *param=*entry; + } + for (tmp=as_list;tmp;tmp=tmp->next) + LM_DBG("%.*s\n",tmp->name.len,tmp->name.s); + return 1; error: - return -1; + return -1; } /** @@ -176,57 +175,57 @@ static int fixup_as_relay(void** param, int param_no) */ void seas_sighandler(int signo) { - struct as_entry *as; - if(is_dispatcher) - sig_flag=signo; - switch(signo){ - case SIGPIPE: - if(is_dispatcher) - return; - LM_INFO("%s exiting\n",whoami); - if(my_as->u.as.ac_buffer.s){ - pkg_free(my_as->u.as.ac_buffer.s); - my_as->u.as.ac_buffer.s=0; - } - if(my_as->u.as.action_fd!=-1){ - close(my_as->u.as.action_fd); - my_as->u.as.action_fd=-1; - } - exit(0); - break; - case SIGCHLD: - LM_INFO("Child stopped or terminated\n"); - break; - case SIGUSR1: - case SIGUSR2: - LM_DBG("Memory status (pkg):\n"); + struct as_entry *as; + if(is_dispatcher) + sig_flag=signo; + switch(signo){ + case SIGPIPE: + if(is_dispatcher) + return; + LM_INFO("%s exiting\n",whoami); + if(my_as->u.as.ac_buffer.s){ + pkg_free(my_as->u.as.ac_buffer.s); + my_as->u.as.ac_buffer.s=0; + } + if(my_as->u.as.action_fd!=-1){ + close(my_as->u.as.action_fd); + my_as->u.as.action_fd=-1; + } + exit(0); + break; + case SIGCHLD: + LM_INFO("Child stopped or terminated\n"); + break; + case SIGUSR1: + case SIGUSR2: + LM_DBG("Memory status (pkg):\n"); #ifdef PKG_MALLOC - pkg_status(); + pkg_status(); #endif - break; - case SIGINT: - case SIGTERM: - LM_INFO("INFO: signal %d received\n",signo); + break; + case SIGINT: + case SIGTERM: + LM_INFO("INFO: signal %d received\n",signo); #ifdef PKG_MALLOC - pkg_status(); + pkg_status(); #endif - if(is_dispatcher){ - for (as=as_list;as;as=as->next) { - if(as->type==AS_TYPE && as->connected) - kill(as->u.as.action_pid,signo); - } - while(wait(0) > 0); - exit(0); - }else{ - LM_INFO("%s exiting\n",whoami); - if(my_as && my_as->u.as.ac_buffer.s) - pkg_free(my_as->u.as.ac_buffer.s); - if(my_as && my_as->u.as.action_fd!=-1) - close(my_as->u.as.action_fd); - exit(0); - } - break; - } + if(is_dispatcher){ + for (as=as_list;as;as=as->next) { + if(as->type==AS_TYPE && as->connected) + kill(as->u.as.action_pid,signo); + } + while(wait(0) > 0); + exit(0); + }else{ + LM_INFO("%s exiting\n",whoami); + if(my_as && my_as->u.as.ac_buffer.s) + pkg_free(my_as->u.as.ac_buffer.s); + if(my_as && my_as->u.as.action_fd!=-1) + close(my_as->u.as.action_fd); + exit(0); + } + break; + } } /** @@ -235,112 +234,112 @@ void seas_sighandler(int signo) */ static int w_as_relay_t(struct sip_msg *msg, char *entry, char *foo) { - as_msg_p my_as_ev; - int new_tran,ret=0,len; - char *buffer,processor_id; - struct cell *mycel; - struct as_entry *as; - char *msg100="Your call is important to us"; - char *msg500="Server Internal Error!"; - - buffer=(char*)0; - my_as_ev=(as_msg_p)0; - - /** - * returns <0 on error - * 1 if (new transaction was created) or if (ACK for locally replied 200 with totag) or if (ACK for code>=300) - * 0 if it was a retransmission - */ - new_tran = seas_f.tmb.t_newtran(msg); - if(new_tran<0) { - ret = (ser_error==E_BAD_VIA && reply_to_via) ? 0 : new_tran; - goto done; - } - /*retransmission: script processing should be stopped*/ - if (new_tran==0 && !(msg->REQ_METHOD==METHOD_ACK)){ - ret = 0; - goto done; - } - /*new transaction created, let's pass it to an APP SERVER*/ - if (msg->REQ_METHOD==METHOD_INVITE ) - { - LM_DBG("new INVITE\n"); - if(!seas_f.tmb.t_reply(msg,100,msg100)){ - LM_DBG("t_reply (100)\n"); - goto error; - } - } - as=(struct as_entry *)entry; - if(!as->connected){ - LM_ERR("app server %.*s not connected\n",as->name.len,as->name.s); - goto error; - } - if(as->type==AS_TYPE){ - if((processor_id=get_processor_id(&msg->rcv,&(as->u.as)))<0){ - LM_ERR("no processor found for packet dst %s:%d\n",ip_addr2a(&msg->rcv.dst_ip),msg->rcv.dst_port); - goto error; - } - }else if(as->type==CLUSTER_TYPE){ - LM_ERR("clustering not fully implemented\n"); - return 0; - }else{ - LM_ERR("unknown type of as (neither cluster nor as)\n"); - return -1; - } - LM_DBG("as found ! (%.*s) processor id = %d\n",as->name.len,as->name.s,processor_id); - if(new_tran==1 && msg->REQ_METHOD==METHOD_ACK){ - LM_DBG("message handled in transaction callbacks. skipping\n"); - ret = 0; - goto done; - /* core should forward statelessly (says t_newtran) - LM_DBG("forwarding statelessly !!!\n"); - if(!(buffer=create_as_event_sl(msg,processor_id,&len,0))){ - LM_ERR("create_as_event_sl() unable to create event code\n"); - goto error; - } - */ - }else if(!(buffer=create_as_event_t(seas_f.tmb.t_gett(),msg,processor_id,&len,0))){ - LM_ERR("unable to create event code\n"); - goto error; - } - if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))){ - LM_ERR("Out of shared mem!\n"); - goto error; - } - my_as_ev->msg = buffer; - my_as_ev->as = as; - my_as_ev->type = T_REQ_IN; - my_as_ev->len = len; - my_as_ev->transaction=seas_f.tmb.t_gett(); /*does not refcount*/ - if(use_stats && new_tran>0) - as_relay_stat(seas_f.tmb.t_gett()); + as_msg_p my_as_ev; + int new_tran,ret=0,len; + char *buffer,processor_id; + struct cell *mycel; + struct as_entry *as; + char *msg100="Your call is important to us"; + char *msg500="Server Internal Error!"; + + buffer=(char*)0; + my_as_ev=(as_msg_p)0; + + /** + * returns <0 on error + * 1 if (new transaction was created) or if (ACK for locally replied 200 with totag) or if (ACK for code>=300) + * 0 if it was a retransmission + */ + new_tran = seas_f.tmb.t_newtran(msg); + if(new_tran<0) { + ret = (ser_error==E_BAD_VIA && reply_to_via) ? 0 : new_tran; + goto done; + } + /*retransmission: script processing should be stopped*/ + if (new_tran==0 && !(msg->REQ_METHOD==METHOD_ACK)){ + ret = 0; + goto done; + } + /*new transaction created, let's pass it to an APP SERVER*/ + if (msg->REQ_METHOD==METHOD_INVITE ) + { + LM_DBG("new INVITE\n"); + if(!seas_f.tmb.t_reply(msg,100,msg100)){ + LM_DBG("t_reply (100)\n"); + goto error; + } + } + as=(struct as_entry *)entry; + if(!as->connected){ + LM_ERR("app server %.*s not connected\n",as->name.len,as->name.s); + goto error; + } + if(as->type==AS_TYPE){ + if((processor_id=get_processor_id(&msg->rcv,&(as->u.as)))<0){ + LM_ERR("no processor found for packet dst %s:%d\n",ip_addr2a(&msg->rcv.dst_ip),msg->rcv.dst_port); + goto error; + } + }else if(as->type==CLUSTER_TYPE){ + LM_ERR("clustering not fully implemented\n"); + return 0; + }else{ + LM_ERR("unknown type of as (neither cluster nor as)\n"); + return -1; + } + LM_DBG("as found ! (%.*s) processor id = %d\n",as->name.len,as->name.s,processor_id); + if(new_tran==1 && msg->REQ_METHOD==METHOD_ACK){ + LM_DBG("message handled in transaction callbacks. skipping\n"); + ret = 0; + goto done; + /* core should forward statelessly (says t_newtran) + * LM_DBG("forwarding statelessly !!!\n"); + * if(!(buffer=create_as_event_sl(msg,processor_id,&len,0))){ + * LM_ERR("create_as_event_sl() unable to create event code\n"); + * goto error; + * } + */ + }else if(!(buffer=create_as_event_t(seas_f.tmb.t_gett(),msg,processor_id,&len,0))){ + LM_ERR("unable to create event code\n"); + goto error; + } + if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))){ + LM_ERR("Out of shared mem!\n"); + goto error; + } + my_as_ev->msg = buffer; + my_as_ev->as = as; + my_as_ev->type = T_REQ_IN; + my_as_ev->len = len; + my_as_ev->transaction=seas_f.tmb.t_gett(); /*does not refcount*/ + if(use_stats && new_tran>0) + as_relay_stat(seas_f.tmb.t_gett()); again: - ret=write(write_pipe,&my_as_ev,sizeof(as_msg_p)); - if(ret==-1){ - if(errno==EINTR) - goto again; - else if(errno==EPIPE){ - LM_ERR("SEAS Event Dispatcher has closed the pipe. Invalidating it !\n"); - goto error; - /** TODO handle this correctly !!!*/ - } - } - /* seas_f.tmb.t_setkr(REQ_FWDED); */ - ret=0; + ret=write(write_pipe,&my_as_ev,sizeof(as_msg_p)); + if(ret==-1){ + if(errno==EINTR) + goto again; + else if(errno==EPIPE){ + LM_ERR("SEAS Event Dispatcher has closed the pipe. Invalidating it !\n"); + goto error; + /** TODO handle this correctly !!!*/ + } + } + /* seas_f.tmb.t_setkr(REQ_FWDED); */ + ret=0; done: - return ret; + return ret; error: - mycel=seas_f.tmb.t_gett(); - if(mycel && mycel!=T_UNDEFINED){ - if(!seas_f.tmb.t_reply(msg,500,msg500)){ - LM_ERR("t_reply (500)\n"); - } - } - if(my_as_ev) - shm_free(my_as_ev); - if(buffer) - shm_free(buffer); - return ret; + mycel=seas_f.tmb.t_gett(); + if(mycel && mycel!=T_UNDEFINED){ + if(!seas_f.tmb.t_reply(msg,500,msg500)){ + LM_ERR("t_reply (500)\n"); + } + } + if(my_as_ev) + shm_free(my_as_ev); + if(buffer) + shm_free(buffer); + return ret; } @@ -350,274 +349,274 @@ static int w_as_relay_t(struct sip_msg *msg, char *entry, char *foo) */ static int w_as_relay_sl(struct sip_msg *msg, char *as_name, char *foo) { - as_msg_p my_as_ev=0; - int ret=0,len; - char *buffer=0,processor_id; - struct as_entry *as; - - as=(struct as_entry *)as_name; - - if(as->type==AS_TYPE){ - if((processor_id=get_processor_id(&msg->rcv,&(as->u.as)))<0){ - LM_ERR("no processor found for packet with dst port:%d\n",msg->rcv.dst_port); - goto error; - } - }else if (as->type==CLUSTER_TYPE) { - LM_ERR("clustering not fully implemented\n"); - goto error; - }else{ - LM_ERR("unknown type of as\n"); - goto error; - } - - LM_DBG("as found ! (%.*s) processor id = %d\n",as->name.len,as->name.s,processor_id); - if(!(buffer=create_as_event_sl(msg,processor_id,&len,0))){ - LM_ERR("unable to create event code\n"); - goto error; - } - if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))) - goto error; - my_as_ev->msg = buffer; - my_as_ev->as = as; - my_as_ev->type = SL_REQ_IN; - my_as_ev->len = len; - my_as_ev->transaction=seas_f.tmb.t_gett(); /*does not refcount*/ - if(use_stats) - as_relay_stat(seas_f.tmb.t_gett()); + as_msg_p my_as_ev=0; + int ret=0,len; + char *buffer=0,processor_id; + struct as_entry *as; + + as=(struct as_entry *)as_name; + + if(as->type==AS_TYPE){ + if((processor_id=get_processor_id(&msg->rcv,&(as->u.as)))<0){ + LM_ERR("no processor found for packet with dst port:%d\n",msg->rcv.dst_port); + goto error; + } + }else if (as->type==CLUSTER_TYPE) { + LM_ERR("clustering not fully implemented\n"); + goto error; + }else{ + LM_ERR("unknown type of as\n"); + goto error; + } + + LM_DBG("as found ! (%.*s) processor id = %d\n",as->name.len,as->name.s,processor_id); + if(!(buffer=create_as_event_sl(msg,processor_id,&len,0))){ + LM_ERR("unable to create event code\n"); + goto error; + } + if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))) + goto error; + my_as_ev->msg = buffer; + my_as_ev->as = as; + my_as_ev->type = SL_REQ_IN; + my_as_ev->len = len; + my_as_ev->transaction=seas_f.tmb.t_gett(); /*does not refcount*/ + if(use_stats) + as_relay_stat(seas_f.tmb.t_gett()); again: - ret=write(write_pipe,&my_as_ev,sizeof(as_msg_p)); - if(ret==-1){ - if(errno==EINTR) - goto again; - else if(errno==EPIPE){ - LM_ERR("SEAS Event Dispatcher has closed the pipe. Invalidating it !\n"); - return -2; - /** TODO handle this correctly !!!*/ - } - } - //this shouln't be here, because it will remove the transaction from memory, but - //if transaction isn't unref'ed iw will be released anyway at t_unref if kr (killreason)==0 - // a wait timer will be put to run with WT_TIME_OUT (5 seconds, within which the AS should respond) - // this is a bug !!! I think this is why we lose calls at high load !! - //t_release(msg, 0, 0); - /* seas_f.tmb.t_setkr(REQ_FWDED); */ - - ret=0; - return ret; + ret=write(write_pipe,&my_as_ev,sizeof(as_msg_p)); + if(ret==-1){ + if(errno==EINTR) + goto again; + else if(errno==EPIPE){ + LM_ERR("SEAS Event Dispatcher has closed the pipe. Invalidating it !\n"); + return -2; + /** TODO handle this correctly !!!*/ + } + } + //this shouln't be here, because it will remove the transaction from memory, but + //if transaction isn't unref'ed iw will be released anyway at t_unref if kr (killreason)==0 + // a wait timer will be put to run with WT_TIME_OUT (5 seconds, within which the AS should respond) + // this is a bug !!! I think this is why we lose calls at high load !! + //t_release(msg, 0, 0); + /* seas_f.tmb.t_setkr(REQ_FWDED); */ + + ret=0; + return ret; error: - if(my_as_ev) - shm_free(my_as_ev); - if(buffer) - shm_free(buffer); - return ret; + if(my_as_ev) + shm_free(my_as_ev); + if(buffer) + shm_free(buffer); + return ret; } /** * creates an as_event in shared memory and returns its address or NULL if error. * event_length(4) UNSIGNED INT includes the length 4 bytes itself - * type(1), + * type(1), * flags(4), * transport(1). - * src_ip_len(1), - * src_ip(4 or 16), - * dst_ip_len(1), - * dst_ip(4 or 16), - * src_port(2), - * dst_port(2), - * hash index(4), - * label(4), + * src_ip_len(1), + * src_ip(4 or 16), + * dst_ip_len(1), + * dst_ip(4 or 16), + * src_port(2), + * dst_port(2), + * hash index(4), + * label(4), * [cancelled hash_index,label] * */ char * create_as_event_t(struct cell *t,struct sip_msg *msg,char processor_id,int *evt_len,int flags) { - unsigned int i,hash_index,label; - unsigned short int port; - unsigned int k,len; - char *buffer=NULL; - struct cell *originalT; - - originalT=0; - - if(!(buffer=shm_malloc(ENCODED_MSG_SIZE))){ - LM_ERR("Out Of Memory !!\n"); - return 0; - } - *evt_len=0; - if(t){ - hash_index=t->hash_index; - label=t->label; - }else{ - /**seas_f.tmb.t_get_trans_ident(msg,&hash_index,&label); this is bad, because it ref-counts !!!*/ - LM_ERR("no transaction provided...\n"); - goto error; - } - - k=4; - /*type*/ - buffer[k++]=(unsigned char)T_REQ_IN; - /*processor_id*/ - buffer[k++]=(unsigned char)processor_id; - /*flags*/ - if(is_e2e_ack(t,msg)){ - flags|=E2E_ACK; - }else if(msg->REQ_METHOD==METHOD_CANCEL){ - LM_DBG("new CANCEL\n"); - originalT=seas_f.tmb.t_lookup_original(msg); - if(!originalT || originalT==T_UNDEFINED){ - /** we dont even pass the unknown CANCEL to JAIN*/ - LM_WARN("CANCEL does not match any existing transaction!!\n"); - goto error; - }else{ - flags|=CANCEL_FOUND; - //seas_f.tmb.unref_cell(originalT); - } - LM_DBG("Cancelling transaction !!\n"); - } - flags=htonl(flags); - memcpy(buffer+k,&flags,4); - k+=4; - /*protocol should be UDP,TCP,TLS or whatever*/ - buffer[k++]=(unsigned char)msg->rcv.proto; - /*src ip len + src ip*/ - len=msg->rcv.src_ip.len; - buffer[k++]=(unsigned char)len; - memcpy(buffer+k,&(msg->rcv.src_ip.u),len); - k+=len; - /*dst ip len + dst ip*/ - len=msg->rcv.dst_ip.len; - buffer[k++]=(unsigned char)len; - memcpy(buffer+k,&(msg->rcv.dst_ip.u),len); - k+=len; - /*src port */ - port=htons(msg->rcv.src_port); - memcpy(buffer+k,&port,2); - k+=2; - /*dst port */ - port=htons(msg->rcv.dst_port); - memcpy(buffer+k,&port,2); - k+=2; - /*hash_index*/ - i=htonl(hash_index); - memcpy(buffer+k,&i,4); - k+=4; - /*label (is the collision slot in the hash-table)*/ - i=htonl(label); - memcpy(buffer+k,&i,4); - k+=4; - if(msg->REQ_METHOD==METHOD_CANCEL && originalT){ - LM_DBG("Cancelled transaction: Hash_Index=%d, Label=%d\n",originalT->hash_index,originalT->label); - /*hash_index*/ - i=htonl(originalT->hash_index); - memcpy(buffer+k,&i,4); - k+=4; - /*label (is the collision slot in the hash-table)*/ - i=htonl(originalT->label); - memcpy(buffer+k,&i,4); - k+=4; - } - - /*length of event (hdr+payload-4), copied at the beginning*/ - if(encode_msg(msg,buffer+k,ENCODED_MSG_SIZE-k)<0){ - LM_ERR("Unable to encode msg\n"); - goto error; - } - i = GET_PAY_SIZE(buffer+k); - k+=i; - *evt_len=k; - k=htonl(k); - memcpy(buffer,&k,4); - return buffer; + unsigned int i,hash_index,label; + unsigned short int port; + unsigned int k,len; + char *buffer=NULL; + struct cell *originalT; + + originalT=0; + + if(!(buffer=shm_malloc(ENCODED_MSG_SIZE))){ + LM_ERR("Out Of Memory !!\n"); + return 0; + } + *evt_len=0; + if(t){ + hash_index=t->hash_index; + label=t->label; + }else{ + /**seas_f.tmb.t_get_trans_ident(msg,&hash_index,&label); this is bad, because it ref-counts !!!*/ + LM_ERR("no transaction provided...\n"); + goto error; + } + + k=4; + /*type*/ + buffer[k++]=(unsigned char)T_REQ_IN; + /*processor_id*/ + buffer[k++]=(unsigned char)processor_id; + /*flags*/ + if(is_e2e_ack(t,msg)){ + flags|=E2E_ACK; + }else if(msg->REQ_METHOD==METHOD_CANCEL){ + LM_DBG("new CANCEL\n"); + originalT=seas_f.tmb.t_lookup_original(msg); + if(!originalT || originalT==T_UNDEFINED){ + /** we dont even pass the unknown CANCEL to JAIN*/ + LM_WARN("CANCEL does not match any existing transaction!!\n"); + goto error; + }else{ + flags|=CANCEL_FOUND; + //seas_f.tmb.unref_cell(originalT); + } + LM_DBG("Cancelling transaction !!\n"); + } + flags=htonl(flags); + memcpy(buffer+k,&flags,4); + k+=4; + /*protocol should be UDP,TCP,TLS or whatever*/ + buffer[k++]=(unsigned char)msg->rcv.proto; + /*src ip len + src ip*/ + len=msg->rcv.src_ip.len; + buffer[k++]=(unsigned char)len; + memcpy(buffer+k,&(msg->rcv.src_ip.u),len); + k+=len; + /*dst ip len + dst ip*/ + len=msg->rcv.dst_ip.len; + buffer[k++]=(unsigned char)len; + memcpy(buffer+k,&(msg->rcv.dst_ip.u),len); + k+=len; + /*src port */ + port=htons(msg->rcv.src_port); + memcpy(buffer+k,&port,2); + k+=2; + /*dst port */ + port=htons(msg->rcv.dst_port); + memcpy(buffer+k,&port,2); + k+=2; + /*hash_index*/ + i=htonl(hash_index); + memcpy(buffer+k,&i,4); + k+=4; + /*label (is the collision slot in the hash-table)*/ + i=htonl(label); + memcpy(buffer+k,&i,4); + k+=4; + if(msg->REQ_METHOD==METHOD_CANCEL && originalT){ + LM_DBG("Cancelled transaction: Hash_Index=%d, Label=%d\n",originalT->hash_index,originalT->label); + /*hash_index*/ + i=htonl(originalT->hash_index); + memcpy(buffer+k,&i,4); + k+=4; + /*label (is the collision slot in the hash-table)*/ + i=htonl(originalT->label); + memcpy(buffer+k,&i,4); + k+=4; + } + + /*length of event (hdr+payload-4), copied at the beginning*/ + if(encode_msg(msg,buffer+k,ENCODED_MSG_SIZE-k)<0){ + LM_ERR("Unable to encode msg\n"); + goto error; + } + i = GET_PAY_SIZE(buffer+k); + k+=i; + *evt_len=k; + k=htonl(k); + memcpy(buffer,&k,4); + return buffer; error: - if(buffer) - shm_free(buffer); - return 0; + if(buffer) + shm_free(buffer); + return 0; } /** * creates an as_event in shared memory and returns its address or NULL if error. * event_length(4) UNSIGNED INT includes the length 4 bytes itself - * type(1), - * processor_id(4), + * type(1), + * processor_id(4), * flags(4), * transport(1). - * src_ip_len(1), - * src_ip(4 or 16), - * dst_ip_len(1), - * dst_ip(4 or 16), - * src_port(2), - * dst_port(2), + * src_ip_len(1), + * src_ip(4 or 16), + * dst_ip_len(1), + * dst_ip(4 or 16), + * src_port(2), + * dst_port(2), * */ char * create_as_event_sl(struct sip_msg *msg,char processor_id,int *evt_len,int flags) { - unsigned int i; - unsigned short int port; - unsigned int k,len; - char *buffer=NULL; - - if(!(buffer=shm_malloc(ENCODED_MSG_SIZE))){ - LM_ERR("create_as_event_t Out Of Memory !!\n"); - return 0; - } - *evt_len=0; - - /*leave 4 bytes for event length*/ - k=4; - /*type*/ - buffer[k++]=(unsigned char)SL_REQ_IN; - /*processor_id*/ - buffer[k++]=(unsigned char)processor_id; - /*flags*/ - flags=htonl(flags); - memcpy(buffer+k,&flags,4); - k+=4; - /*protocol should be UDP,TCP,TLS or whatever*/ - buffer[k++]=(unsigned char)msg->rcv.proto; - /*src ip len + src ip*/ - len=msg->rcv.src_ip.len; - buffer[k++]=(unsigned char)len; - memcpy(buffer+k,&(msg->rcv.src_ip.u),len); - k+=len; - /*dst ip len + dst ip*/ - len=msg->rcv.dst_ip.len; - buffer[k++]=(unsigned char)len; - memcpy(buffer+k,&(msg->rcv.dst_ip.u),len); - k+=len; - /*src port */ - port=htons(msg->rcv.src_port); - memcpy(buffer+k,&port,2); - k+=2; - /*dst port */ - port=htons(msg->rcv.dst_port); - memcpy(buffer+k,&port,2); - k+=2; - /*length of event (hdr+payload-4), copied at the beginning*/ - if(encode_msg(msg,buffer+k,ENCODED_MSG_SIZE-k)<0){ - LM_ERR("Unable to encode msg\n"); - goto error; - } - i = GET_PAY_SIZE(buffer+k); - k+=i; - *evt_len=k; - k=htonl(k); - memcpy(buffer,&k,4); - return buffer; + unsigned int i; + unsigned short int port; + unsigned int k,len; + char *buffer=NULL; + + if(!(buffer=shm_malloc(ENCODED_MSG_SIZE))){ + LM_ERR("create_as_event_t Out Of Memory !!\n"); + return 0; + } + *evt_len=0; + + /*leave 4 bytes for event length*/ + k=4; + /*type*/ + buffer[k++]=(unsigned char)SL_REQ_IN; + /*processor_id*/ + buffer[k++]=(unsigned char)processor_id; + /*flags*/ + flags=htonl(flags); + memcpy(buffer+k,&flags,4); + k+=4; + /*protocol should be UDP,TCP,TLS or whatever*/ + buffer[k++]=(unsigned char)msg->rcv.proto; + /*src ip len + src ip*/ + len=msg->rcv.src_ip.len; + buffer[k++]=(unsigned char)len; + memcpy(buffer+k,&(msg->rcv.src_ip.u),len); + k+=len; + /*dst ip len + dst ip*/ + len=msg->rcv.dst_ip.len; + buffer[k++]=(unsigned char)len; + memcpy(buffer+k,&(msg->rcv.dst_ip.u),len); + k+=len; + /*src port */ + port=htons(msg->rcv.src_port); + memcpy(buffer+k,&port,2); + k+=2; + /*dst port */ + port=htons(msg->rcv.dst_port); + memcpy(buffer+k,&port,2); + k+=2; + /*length of event (hdr+payload-4), copied at the beginning*/ + if(encode_msg(msg,buffer+k,ENCODED_MSG_SIZE-k)<0){ + LM_ERR("Unable to encode msg\n"); + goto error; + } + i = GET_PAY_SIZE(buffer+k); + k+=i; + *evt_len=k; + k=htonl(k); + memcpy(buffer,&k,4); + return buffer; error: - if(buffer) - shm_free(buffer); - return 0; + if(buffer) + shm_free(buffer); + return 0; } static inline int is_e2e_ack(struct cell *t,struct sip_msg *msg) { - if(msg->REQ_METHOD != METHOD_ACK) - return 0; - if (t->uas.status<300) - return 1; - return 0; + if(msg->REQ_METHOD != METHOD_ACK) + return 0; + if (t->uas.status<300) + return 1; + return 0; } /** Initializes seas module. It first parses the listen_sockets parameter @@ -626,75 +625,75 @@ static inline int is_e2e_ack(struct cell *t,struct sip_msg *msg) */ static int seas_init(void) { - char *p,*port; - struct hostent *he; - struct socket_info *si; - int c_pipe[2],mierr,i; - /** Populate seas_functions*/ - if (load_tm_api(&seas_f.tmb)!=0) { - LM_ERR( "can't load TM API\n"); - return -1; - } - if(!(seas_f.t_check_orig_trans = find_export("t_check_trans", 0, 0))){ - LM_ERR( "Seas requires transaction module (t_check_trans not found)\n"); - return -1; - } - /** Populate seas_functions*/ - c_pipe[0]=c_pipe[1]=-1; - p=seas_listen_socket; - port=(char *)0; - seas_listen_port=5080; - /*if the seas_listen_socket configuration string is empty, use default values*/ - if(p==NULL || *p==0){ - si=get_first_socket(); - seas_listen_ip=&si->address; - } else {/*if config string is not empty, then try to find host first, and maybe port..*/ - while(*p){ - if(*p == ':'){ - *p=0; - port=p+1; - break; - } - p++; - } - if(!(he=resolvehost(seas_listen_socket))) - goto error; - if(!(seas_listen_ip=pkg_malloc(sizeof(struct ip_addr)))) - goto error; - hostent2ip_addr(seas_listen_ip, he, 0); - if(port!=(char *)0 && (seas_listen_port=str2s(port,strlen(port),&mierr))==0){ - LM_ERR("invalid port %s \n",port); - goto error; - } - } - memset(unc_as_t,0,2*MAX_UNC_AS_NR*sizeof(struct unc_as));//useless because unc_as_t is in bss? - if (pipe(c_pipe)==-1) { - LM_ERR("cannot create pipe!\n"); - goto error; - } - read_pipe=c_pipe[0]; - write_pipe=c_pipe[1]; - seas_init_tags(); - if(0>start_stats_server(seas_stats_socket)) - goto error; - if(0>prepare_ha()) - goto error; - if(0>parse_cluster_cfg()) - goto error; - register_procs(1); + char *p,*port; + struct hostent *he; + struct socket_info *si; + int c_pipe[2],mierr,i; + /** Populate seas_functions*/ + if (load_tm_api(&seas_f.tmb)!=0) { + LM_ERR( "can't load TM API\n"); + return -1; + } + if(!(seas_f.t_check_orig_trans = find_export("t_check_trans", 0, 0))){ + LM_ERR( "Seas requires transaction module (t_check_trans not found)\n"); + return -1; + } + /** Populate seas_functions*/ + c_pipe[0]=c_pipe[1]=-1; + p=seas_listen_socket; + port=(char *)0; + seas_listen_port=5080; + /*if the seas_listen_socket configuration string is empty, use default values*/ + if(p==NULL || *p==0){ + si=get_first_socket(); + seas_listen_ip=&si->address; + } else {/*if config string is not empty, then try to find host first, and maybe port..*/ + while(*p){ + if(*p == ':'){ + *p=0; + port=p+1; + break; + } + p++; + } + if(!(he=resolvehost(seas_listen_socket))) + goto error; + if(!(seas_listen_ip=pkg_malloc(sizeof(struct ip_addr)))) + goto error; + hostent2ip_addr(seas_listen_ip, he, 0); + if(port!=(char *)0 && (seas_listen_port=str2s(port,strlen(port),&mierr))==0){ + LM_ERR("invalid port %s \n",port); + goto error; + } + } + memset(unc_as_t,0,2*MAX_UNC_AS_NR*sizeof(struct unc_as));//useless because unc_as_t is in bss? + if (pipe(c_pipe)==-1) { + LM_ERR("cannot create pipe!\n"); + goto error; + } + read_pipe=c_pipe[0]; + write_pipe=c_pipe[1]; + seas_init_tags(); + if(0>start_stats_server(seas_stats_socket)) + goto error; + if(0>prepare_ha()) + goto error; + if(0>parse_cluster_cfg()) + goto error; + register_procs(1); /* add child to update local config framework structures */ cfg_register_child(1); - return 0; + return 0; error: - for(i=0;i<2;i++) - if(c_pipe[i]!=-1) - close(c_pipe[i]); - if(seas_listen_ip!=0) - pkg_free(seas_listen_ip); - if(use_stats) - stop_stats_server(); - return -1; + for(i=0;i<2;i++) + if(c_pipe[i]!=-1) + close(c_pipe[i]); + if(seas_listen_ip!=0) + pkg_free(seas_listen_ip); + if(use_stats) + stop_stats_server(); + return -1; } @@ -702,8 +701,8 @@ static int seas_init(void) */ static void seas_init_tags(void) { - init_tags(seas_tags, &seas_tag_suffix,"VozTele-Seas/tags",'-'); - LM_DBG("seas_init_tags, seas_tags=%s\n",seas_tags); + init_tags(seas_tags, &seas_tag_suffix,"VozTele-Seas/tags",'-'); + LM_DBG("seas_init_tags, seas_tags=%s\n",seas_tags); } /** @@ -716,30 +715,30 @@ static void seas_init_tags(void) */ static int seas_child_init(int rank) { - int pid; - - /* only the child 1 will execute this */ - if (rank != PROC_MAIN){ - /* only dispatcher needs to read from the pipe, so close reading fd*/ - /*close(read_pipe);*/ - return 0; - } - if ((pid=fork_process(PROC_NOCHLDINIT,"SEAS",0))<0) { - LM_ERR("forking failed\n"); - return -1; - } - if (!pid) { - /*dispatcher child. we leave writing end open so that new childs spawned - * by event dispatcher can also write to pipe.. */ + int pid; + + /* only the child 1 will execute this */ + if (rank != PROC_MAIN){ + /* only dispatcher needs to read from the pipe, so close reading fd*/ + /*close(read_pipe);*/ + return 0; + } + if ((pid=fork_process(PROC_NOCHLDINIT,"SEAS",0))<0) { + LM_ERR("forking failed\n"); + return -1; + } + if (!pid) { + /*dispatcher child. we leave writing end open so that new childs spawned + * by event dispatcher can also write to pipe.. */ /* initialize the config framework */ if (cfg_child_init()) return -1; - /* close(write_pipe); */ - return dispatcher_main_loop(); - } - return 0; + /* close(write_pipe); */ + return dispatcher_main_loop(); + } + return 0; } /* this should close the sockets open to any of the application servers, and @@ -748,27 +747,27 @@ static int seas_child_init(int rank) */ static int seas_exit(void) { - if( seas_listen_ip!=NULL && seas_listen_ip!=&(get_first_socket()->address)) - pkg_free(seas_listen_ip); - return 0; + if( seas_listen_ip!=NULL && seas_listen_ip!=&(get_first_socket()->address)) + pkg_free(seas_listen_ip); + return 0; } /** * search within a given AS, if any of the registered processors is bound - * to the receive_info structure passed. If there is one, it returns its + * to the receive_info structure passed. If there is one, it returns its * identifier (number between 0 and 128), otherwise it returns -1; */ char get_processor_id(struct receive_info *rcv,as_p as) { - int i; - for(i=0;ibound_processor[i]!=0 && - (rcv->dst_ip.len == as->binds[i]->address.len) && - (rcv->dst_ip.af==as->binds[i]->address.af) && - (!memcmp(rcv->dst_ip.u.addr,as->binds[i]->address.u.addr,rcv->dst_ip.len))/* && - (rcv->dst_port==as->binds[i].dst_port) && - (rcv->proto==as->binds[i].proto)*/) - return as->bound_processor[i]; - } - return -1; + int i; + for(i=0;ibound_processor[i]!=0 && + (rcv->dst_ip.len == as->binds[i]->address.len) && + (rcv->dst_ip.af==as->binds[i]->address.af) && + (!memcmp(rcv->dst_ip.u.addr,as->binds[i]->address.u.addr,rcv->dst_ip.len))/* && + (rcv->dst_port==as->binds[i].dst_port) && + (rcv->proto==as->binds[i].proto)*/) + return as->bound_processor[i]; + } + return -1; } diff --git a/src/modules/seas/seas.h b/src/modules/seas/seas.h index 6a7c03a0c18..9f525f48c40 100644 --- a/src/modules/seas/seas.h +++ b/src/modules/seas/seas.h @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,8 +13,8 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ @@ -67,9 +66,9 @@ #define SPIRAL_FLAG 0x00000001 #define net2hostL(dst,from,index) do{ \ - memcpy(&(dst),(from)+(index),4); \ - dst=ntohl(dst); \ - (index)+=4; \ + memcpy(&(dst),(from)+(index),4); \ + dst=ntohl(dst); \ + (index)+=4; \ }while(0); @@ -94,32 +93,32 @@ extern int servlet_pings_lost; extern struct as_entry *as_table; struct seas_functions{ - struct tm_binds tmb; - cmd_function t_check_orig_trans; + struct tm_binds tmb; + cmd_function t_check_orig_trans; }; /*TODO listen_points should be dynamically allocated ?*/ typedef struct app_server { - int event_fd; - int action_fd; - str name; - pid_t action_pid; - struct socket_info *binds[MAX_BINDS]; - char bound_processor[MAX_BINDS]; - int num_binds; - str ev_buffer; - str ac_buffer; - struct ha jain_pings; - struct ha servlet_pings; - struct cluster *cluster; + int event_fd; + int action_fd; + str name; + pid_t action_pid; + struct socket_info *binds[MAX_BINDS]; + char bound_processor[MAX_BINDS]; + int num_binds; + str ev_buffer; + str ac_buffer; + struct ha jain_pings; + struct ha servlet_pings; + struct cluster *cluster; }as_t, *as_p; struct cluster{ - str name; - int num; - int registered; - str as_names[MAX_AS_PER_CLUSTER]; - as_p servers[MAX_AS_PER_CLUSTER]; + str name; + int num; + int registered; + str as_names[MAX_AS_PER_CLUSTER]; + as_p servers[MAX_AS_PER_CLUSTER]; }; /** @@ -127,32 +126,32 @@ struct cluster{ * when one matches, they will put the as pointer inside the event that should process * that event. * If eventually the as becomes unavailable, the dispatcher will set valid=false, which should be - * atomic operation. This way, we prevent having to put a mutex on the array, which would make + * atomic operation. This way, we prevent having to put a mutex on the array, which would make * it slower , as only one process could be accessing it at a time. */ struct as_entry{ - str name; - int type; - int connected; - union{ - struct app_server as; - struct cluster cs; - }u; - struct as_entry *next; + str name; + int type; + int connected; + union{ + struct app_server as; + struct cluster cs; + }u; + struct as_entry *next; }; extern struct as_entry *my_as; -extern struct seas_functions seas_f; +extern struct seas_functions seas_f; extern struct as_entry *as_list; typedef struct as_msg { - struct cell *transaction; - char *msg; - int len; - int type; - int id; - struct as_entry *as; + struct cell *transaction; + char *msg; + int len; + int type; + int id; + struct as_entry *as; }as_msg_t,*as_msg_p; char get_processor_id(struct receive_info *rcv,as_p as); @@ -162,17 +161,17 @@ char* create_as_event_sl(struct sip_msg *msg,char processor_id,int *evt_len,int static inline void print_ip_buf(struct ip_addr* ip, char *where,int len) { - switch(ip->af){ - case AF_INET: - snprintf(where,len,"%d.%d.%d.%d", ip->u.addr[0], ip->u.addr[1], ip->u.addr[2], ip->u.addr[3]); - break; - case AF_INET6: - snprintf(where,len,"%x:%x:%x:%x:%x:%x:%x:%x",htons(ip->u.addr16[0]),htons(ip->u.addr16[1]),htons(ip->u.addr16[2]), - htons(ip->u.addr16[3]), htons(ip->u.addr16[4]), htons(ip->u.addr16[5]), htons(ip->u.addr16[6]), - htons(ip->u.addr16[7])); - break; - default: - break; - } + switch(ip->af){ + case AF_INET: + snprintf(where,len,"%d.%d.%d.%d", ip->u.addr[0], ip->u.addr[1], ip->u.addr[2], ip->u.addr[3]); + break; + case AF_INET6: + snprintf(where,len,"%x:%x:%x:%x:%x:%x:%x:%x",htons(ip->u.addr16[0]),htons(ip->u.addr16[1]),htons(ip->u.addr16[2]), + htons(ip->u.addr16[3]), htons(ip->u.addr16[4]), htons(ip->u.addr16[5]), htons(ip->u.addr16[6]), + htons(ip->u.addr16[7])); + break; + default: + break; + } } #endif diff --git a/src/modules/seas/seas_action.c b/src/modules/seas/seas_action.c index 3cb5513fbd1..7c963e6fe7a 100644 --- a/src/modules/seas/seas_action.c +++ b/src/modules/seas/seas_action.c @@ -1,5 +1,4 @@ -/* $Id$ - * +/* * Copyright (C) 2006-2007 VozTelecom Sistemas S.L * * This file is part of Kamailio, a free SIP server. @@ -14,15 +13,10 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - * History: - * ------- - * 2008-04-04 added support for local and remote dispaly name in TM dialogs - * (by Andrei Pisau ) - * */ #include @@ -496,7 +490,7 @@ int ac_cancel(as_p the_as,unsigned char processor_id,unsigned int flags,char *ac the_param->uac_id=uac_id; the_param->processor_id=processor_id; the_param->destroy_cb_set=0; - + /* registers TMCB_RESPONSE_IN|TMCB_LOCAL_COMPLETED tm callbacks */ ret=seas_f.tmb.t_cancel_uac(&headers,&body,cancelled_hashIdx,cancelled_label,uac_cb,(void*)the_param); if (ret == 0) { @@ -901,15 +895,15 @@ int forward_sl_request(struct sip_msg *msg,str *uri,int proto) if ((uri2dst(NULL,&dst, msg, uri, proto)==0) || (dst.send_sock==0)) #else if ((uri2dst(&dst, msg, uri, proto)==0) || (dst.send_sock==0)) -#endif +#endif { - LOG(L_ERR, "forward_sl_request: no socket found\n"); + LM_ERR("no socket found\n"); return -1; } LM_DBG("Sending:\n%.*s.\n", (int)msg->len,msg->buf); if (msg_send(&dst, msg->buf,msg->len)<0){ - LM_ERR("ERROR:seas:forward_sl_request: Error sending message !!\n"); + LM_ERR("Error sending message !!\n"); return -1; } return ret;