/** * Forwards the message to the application server. * - Marks the message * - fills routes * - replaces dst_uri * @param msg - the SIP message * @param m - the isc_match that matched with info about where to forward it * @param mark - the isc_mark that should be used to mark the message * @returns #ISC_RETURN_TRUE if OK, #ISC_RETURN_ERROR if not */ int isc_forward(struct sip_msg *msg, isc_match *m, isc_mark *mark) { struct cell *t; unsigned int hash, label; ticks_t fr_timeout, fr_inv_timeout; LM_DBG("marking for AS <%.*s>\n", m->server_name.len, m->server_name.s); isc_mark_set(msg, m, mark); /* change destination so it forwards to the app server */ if (msg->dst_uri.s) pkg_free(msg->dst_uri.s); msg->dst_uri.s = pkg_malloc(m->server_name.len); if (!msg->dst_uri.s) { LM_ERR("error allocating %d bytes\n", m->server_name.len); return ISC_RETURN_ERROR; } msg->dst_uri.len = m->server_name.len; memcpy(msg->dst_uri.s, m->server_name.s, m->server_name.len); /* append branch if last trigger failed */ if (is_route_type(FAILURE_ROUTE)) append_branch(msg, &(msg->first_line.u.request.uri), &(msg->dst_uri), 0, Q_UNSPECIFIED, 0, 0, 0, 0, 0, 0); // Determines the tm transaction identifiers. // If no transaction, then creates one if (isc_tmb.t_get_trans_ident(msg, &hash, &label) < 0) { LM_DBG("SIP message without transaction. OK - first request\n"); if (isc_tmb.t_newtran(msg) < 0) LM_INFO("Failed creating SIP transaction\n"); if (isc_tmb.t_get_trans_ident(msg, &hash, &label) < 0) { LM_INFO("SIP message still without transaction\n"); } else { LM_DBG("New SIP message transaction %u %u\n", hash, label); } } else { LM_INFO("Transaction %u %u exists. Retransmission?\n", hash, label); } /* set the timeout timers to a lower value */ t = isc_tmb.t_gett(); fr_timeout = t->fr_timeout; fr_inv_timeout = t->fr_inv_timeout; t->fr_timeout = S_TO_TICKS(isc_fr_timeout) / 1000; t->fr_inv_timeout = S_TO_TICKS(isc_fr_inv_timeout) / 1000; /* send it */ isc_tmb.t_relay(msg, 0, 0); /* recover the timeouts */ t->fr_timeout = fr_timeout; t->fr_inv_timeout = fr_inv_timeout; LM_INFO(">> msg was fwded to AS\n"); return ISC_RETURN_TRUE; }
/** * Forwards the message to the application server. * - Marks the message * - fills routes * - replaces dst_uri * @param msg - the SIP message * @param m - the isc_match that matched with info about where to forward it * @param mark - the isc_mark that should be used to mark the message * @returns #ISC_RETURN_TRUE if OK, #ISC_RETURN_ERROR if not */ int isc_forward( struct sip_msg *msg, isc_match *m,isc_mark *mark) { struct cell *t; unsigned int hash,label; ticks_t fr_timeout,fr_inv_timeout; DBG( "DEBUG:"M_NAME":isc_forward(): marking for AS <%.*s>\n", m->server_name.len, m->server_name.s ); isc_mark_set(msg,m,mark); /* change destination so it forwards to the app server */ if (msg->dst_uri.s) pkg_free(msg->dst_uri.s); msg->dst_uri.s = pkg_malloc(m->server_name.len); if (!msg->dst_uri.s) { LOG(L_ERR,"ERR:"M_NAME":isc_forward(): error allocating %d bytes\n",m->server_name.len); return ISC_RETURN_ERROR; } msg->dst_uri.len = m->server_name.len; memcpy(msg->dst_uri.s,m->server_name.s,m->server_name.len); /* append branch if last trigger failed */ if (*isc_tmb.route_mode == MODE_ONFAILURE) append_branch(msg,msg->first_line.u.request.uri.s,msg->first_line.u.request.uri.len, msg->dst_uri.s,msg->dst_uri.len,0,0); /* set the timeout timers to a lower value */ cscf_get_transaction(msg,&hash,&label); t = isc_tmb.t_gett(); fr_timeout = t->fr_timeout; fr_inv_timeout = t->fr_inv_timeout; t->fr_timeout=S_TO_TICKS(isc_fr_timeout)/1000; t->fr_inv_timeout=S_TO_TICKS(isc_fr_inv_timeout)/1000; /* send it */ isc_tmb.t_relay(msg,0,0); /* recover the timeouts */ t->fr_timeout=fr_timeout; t->fr_inv_timeout=fr_inv_timeout; LOG(L_INFO,"INFO:"M_NAME">> msg was fwded to AS\n"); // LOG(L_INFO,"INFO:"M_NAME":isc_forward: fw relayed with marking [%8X]\n",rc->mark.cnt); // DBG( "DEBUG:"M_NAME":isc_forward: Forward sending finished, resuming operation\n" ); return ISC_RETURN_TRUE; }