/* * 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; }
/* * Append route specific OSP headers * This function only works in branch route block. * This function is only for SER. SER does not support rewrite_uri in BRANCH_ROUTE. * param msg SIP message * param ignore1 * param ignore2 * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failed */ int ospAppendHeaders( struct sip_msg* msg, char* ignore1, char* ignore2) { osp_dest* dest; int result = MODULE_RETURNCODE_FALSE; LOG(L_DBG, "osp: ospAppendHeaders\n"); dest = ospGetLastOrigDestination(); if (dest != NULL) { ospAddOspHeader(msg, dest->token, dest->tokensize); result = MODULE_RETURNCODE_TRUE; } else { LOG(L_ERR, "osp: ERROR: failed to get last used destination\n"); } return result; }