int t_write_unix(struct sip_msg* msg, char* info, char* socket) { if (assemble_msg(msg, (struct tw_info*)info) < 0) { LM_ERR("failed to assemble_msg\n"); return -1; } if (write_to_unixsock(socket, TWRITE_PARAMS) == -1) { LM_ERR("write_to_unixsock failed\n"); return -1; } /* make sure that if voicemail does not initiate a reply * timely, a SIP timeout will be sent out */ if (add_blind_uac() == -1) { LM_ERR("add_blind failed\n"); return -1; } return 1; }
int t_write_req(struct sip_msg* msg, char* vm_fifo, char* info) { if (assemble_msg(msg, (struct tw_info*)info) < 0) { LOG(L_ERR, "ERROR:tm:t_write_req: Error int assemble_msg\n"); return -1; } if (write_to_fifo(vm_fifo, TWRITE_PARAMS) == -1) { LOG(L_ERR, "ERROR:tm:t_write_req: write_to_fifo failed\n"); return -1; } /* make sure that if voicemail does not initiate a reply * timely, a SIP timeout will be sent out */ if (add_blind_uac() == -1) { LOG(L_ERR, "ERROR:tm:t_write_req: add_blind failed\n"); return -1; } return 1; }
/* Suspends the transaction for later use. * Save the returned hash_index and label to get * back to the SIP request processing, see the readme. * * Return value: * 0 - success * <0 - failure */ int t_suspend(struct sip_msg *msg, unsigned int *hash_index, unsigned int *label) { struct cell *t; int branch; int sip_msg_len; t = get_t(); if (!t || t == T_UNDEFINED) { LM_ERR("transaction has not been created yet\n"); return -1; } if (t->flags & T_CANCELED) { /* The transaction has already been canceled */ LM_DBG("trying to suspend an already canceled transaction\n"); ser_error = E_CANCELED; return 1; } if (t->uas.status >= 200) { LM_DBG("trasaction sent out a final response already - %d\n", t->uas.status); return -3; } if (msg->first_line.type != SIP_REPLY) { /* send a 100 Trying reply, because the INVITE processing will probably take a long time */ if (msg->REQ_METHOD==METHOD_INVITE && (t->flags&T_AUTO_INV_100) && (t->uas.status < 100) ) { if (!t_reply( t, msg , 100 , cfg_get(tm, tm_cfg, tm_auto_inv_100_r))) LM_DBG("suspending request processing - sending 100 reply\n"); } if ((t->nr_of_outgoings==0) && /* if there had already been an UAC created, then the lumps were saved as well */ save_msg_lumps(t->uas.request, msg) ) { LM_ERR("failed to save the message lumps\n"); return -1; } /* save the message flags */ t->uas.request->flags = msg->flags; /* add a blind UAC to let the fr timer running */ if (add_blind_uac() < 0) { LM_ERR("failed to add the blind UAC\n"); return -1; } /* propagate failure route to new branch * - failure route to be executed if the branch is not continued * before timeout */ t->uac[t->async_backup.blind_uac].on_failure = t->on_failure; t->flags |= T_ASYNC_SUSPENDED; } else { LM_DBG("this is a suspend on reply - setting msg flag to SUSPEND\n"); msg->msg_flags |= FL_RPL_SUSPENDED; /* this is a reply suspend find which branch */ if (t_check( msg , &branch )==-1){ LOG(L_ERR, "ERROR: t_suspend_reply: " \ "failed find UAC branch\n"); return -1; } LM_DBG("found a a match with branch id [%d] - " "cloning reply message to t->uac[branch].reply\n", branch); sip_msg_len = 0; t->uac[branch].reply = sip_msg_cloner( msg, &sip_msg_len ); if (! t->uac[branch].reply ) { LOG(L_ERR, "can't alloc' clone memory\n"); return -1; } t->uac[branch].end_reply = ((char*)t->uac[branch].reply) + sip_msg_len; LM_DBG("saving transaction data\n"); t->uac[branch].reply->flags = msg->flags; t->flags |= T_ASYNC_SUSPENDED; } *hash_index = t->hash_index; *label = t->label; /* backup some extra info that can be used in continuation logic */ t->async_backup.backup_route = get_route_type(); t->async_backup.backup_branch = get_t_branch(); t->async_backup.ruri_new = ruri_get_forking_state(); return 0; }