/* * Build SIP message for destination * param msg SIP message * param isfirst Is first destination * param type Main or branch route block * param format URI format * param redirect Is for redirect * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure */ static int ospPrepareDestination( struct sip_msg* msg, int isfirst, int type, int format, int redirect) { char buffer[OSP_HEADERBUF_SIZE]; str newuri = { buffer, sizeof(buffer) }; osp_dest* dest = ospGetNextOrigDestination(); int result = MODULE_RETURNCODE_FALSE; if (dest != NULL) { ospRebuildDestionationUri(&newuri, dest, format); LM_INFO("prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%llu'\n", newuri.len, newuri.s, dest->callidsize, dest->callid, dest->transid); if (type == OSP_MAIN_ROUTE) { if (redirect) { dest->lastcode = 300; } if (isfirst == OSP_FIRST_ROUTE) { set_ruri(msg, &newuri); } else { append_branch(msg, &newuri, NULL, NULL, Q_UNSPECIFIED, 0, NULL); } /* Do not add route specific OSP information */ result = MODULE_RETURNCODE_TRUE; } else if (type == OSP_BRANCH_ROUTE) { /* For branch route, add route specific OSP information */ /* Update the Request-Line */ set_ruri(msg, &newuri); /* Add OSP token header */ ospAddOspHeader(msg, dest->token, dest->tokensize); /* Add branch-specific OSP Cookie */ ospRecordOrigTransaction(msg, dest->transid, dest->srcdev, dest->calling, dest->called, dest->authtime, dest->destcount); /* Handle calling number translation */ ospSetCalling(msg, dest); result = MODULE_RETURNCODE_TRUE; } else { LM_ERR("unsupported route block type\n"); } } else { LM_DBG("there is no more routes\n"); ospReportOrigSetupUsage(); } return result; }
/* * Build SIP message for destination * param msg SIP message * param isfirst Is first destination * param type Main or branch route block * param format URI format * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure */ static int ospPrepareDestination( struct sip_msg* msg, int isfirst, int type, int format) { str newuri = {NULL, 0}; int result = MODULE_RETURNCODE_FALSE; LOG(L_DBG, "osp: ospPrepareDestination\n"); osp_dest *dest = ospGetNextOrigDestination(); if (dest != NULL) { ospRebuildDestionationUri(&newuri, dest->called, dest->host, "", format); LOG(L_INFO, "osp: prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%llu'\n", newuri.len, newuri.s, dest->callidsize, dest->callid, dest->transid); if (type == OSP_MAIN_ROUTE) { if (isfirst == OSP_FIRST_ROUTE) { rewrite_uri(msg, &newuri); } else { append_branch(msg, &newuri, NULL, NULL, Q_UNSPECIFIED, 0, NULL); } result = MODULE_RETURNCODE_TRUE; } else { LOG(L_ERR, "osp: ERROR: unsupported route block type\n"); } } else { LOG(L_DBG, "osp: there is no more routes\n"); ospReportOrigSetupUsage(); } if (newuri.len > 0) { pkg_free(newuri.s); } return result; }