MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / ospPrepareDestination

Function ospPrepareDestination

modules/osp/orig_transaction.c:957–1081  ·  view source on GitHub ↗

* Build SIP message for destination * param msg SIP message * param isfirst Is first destination * param route Main or branch route block * param response Is for response * param rsptype SIP response type * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure */

Source from the content-addressed store, hash-verified

955 * return MODULE_RETURNCODE_TRUE success MODULE_RETURNCODE_FALSE failure
956 */
957static int ospPrepareDestination(
958 struct sip_msg* msg,
959 int isfirst,
960 int route,
961 int response,
962 int* rsptype)
963{
964 str cnam;
965 char buffer[OSP_HEADERBUF_SIZE];
966 str newuri = { buffer, sizeof(buffer) };
967 osp_inbound* inbound = ospGetInboundInfo();
968 osp_dest* dest = ospGetNextOrigDestination();
969 int result = MODULE_RETURNCODE_TRUE;
970 struct msg_branch branch;
971
972 if (inbound != NULL) {
973 if (dest != NULL) {
974 if (response) {
975 /* SIP 300 or 380 response */
976 if (route == OSP_MAIN_ROUTE) {
977 if (dest->srvtype == OSPC_SERVICE_CNAMQUERY) {
978 LM_INFO("prepare CNAM for call_id '%.*s' transaction_id '%llu'\n",
979 dest->callidsize,
980 dest->callid,
981 dest->transid);
982
983 if (dest->cnam[0] != '\0') {
984 cnam.s = dest->cnam;
985 cnam.len = strlen(dest->cnam);
986 add_avp(_osp_cnam_avptype | AVP_VAL_STR, _osp_cnam_avpid, (int_str)cnam);
987 }
988
989 dest->lastcode = 380;
990
991 *rsptype = 380;
992 } else {
993 /* For default service, voice service, ported number query service or STIR query service */
994 ospRebuildDestUri(&newuri, dest);
995
996 LM_INFO("prepare route to URI '%.*s' for call_id '%.*s' transaction_id '%llu'\n",
997 newuri.len,
998 newuri.s,
999 dest->callidsize,
1000 dest->callid,
1001 dest->transid);
1002
1003 int qvalue = MAX_Q * (_osp_max_dests + 1 - dest->destcount) / (_osp_max_dests + 1);
1004 if (isfirst == OSP_FIRST_ROUTE) {
1005 set_ruri(msg, &newuri);
1006 set_ruri_q(msg, qvalue);
1007 } else {
1008 memset( &branch, 0, sizeof branch);
1009 branch.uri = newuri;
1010 branch.q = qvalue;
1011 append_msg_branch( &branch );
1012 }
1013
1014 /* Do not add route specific OSP information */

Callers 3

ospPrepareRouteFunction · 0.85
ospPrepareResponseFunction · 0.85
ospPrepareAllRoutesFunction · 0.85

Calls 10

ospGetInboundInfoFunction · 0.85
add_avpFunction · 0.85
ospRebuildDestUriFunction · 0.85
set_ruriFunction · 0.85
append_msg_branchFunction · 0.85
ospAddOspTokenFunction · 0.85
ospRecordOrigTransactionFunction · 0.85
ospSetCallingFunction · 0.85
ospReportOrigSetupUsageFunction · 0.85

Tested by

no test coverage detected