void uas_e2e_ack_cb(struct cell* t, int type,struct tmcb_params *rcvd_params) { struct as_uac_param *ev_info; int mylen; as_msg_p my_as_ev=NULL; char *buffer=NULL; ev_info=(struct as_uac_param*)*rcvd_params->param; if(!(type & TMCB_E2EACK_IN)) return; if(!(my_as_ev=shm_malloc(sizeof(as_msg_t)))){ LM_ERR("no more shared mem\n"); goto error; } if(!(buffer=create_as_event_t(t,rcvd_params->req,ev_info->processor_id,&mylen,E2E_ACK))){ LM_ERR("unable to create event code\n"); goto error; } my_as_ev->as = ev_info->who; my_as_ev->msg = buffer; my_as_ev->len = mylen; my_as_ev->type = RES_IN; my_as_ev->transaction = t; if(write(write_pipe,&my_as_ev,sizeof(as_msg_p))<=0){ goto error; } goto exit; error: if(my_as_ev){ shm_free(my_as_ev); } if(buffer) shm_free(buffer); exit: return ; }
/** * wrapper for the AS transaction-stateful relay script function. * */ 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; static str msg100={"Your call is important to us",sizeof("Your call is important to us")-1}; static str msg500={"Server Internal Error!",sizeof("Server Internal Error!")-1}; 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 = 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 with dst port:%d\n",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){ /* 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; done: 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; }