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

Function ospReportOrigSetupUsage

modules/osp/usage.c:690–763  ·  view source on GitHub ↗

* Report originate call setup usage */

Source from the content-addressed store, hash-verified

688 * Report originate call setup usage
689 */
690void ospReportOrigSetupUsage(void)
691{
692 osp_inbound* inbound = ospGetInboundInfo();
693 struct usr_avp* destavp = NULL;
694 int_str destval;
695 osp_dest* dest = NULL;
696 osp_dest* lastused = NULL;
697 OSPTTRANHANDLE trans = -1;
698 int lastcode = 0;
699 OSPE_ROLE_STATE rstate;
700 int errcode;
701
702 errcode = OSPPTransactionNew(_osp_provider, &trans);
703 if (errcode != OSPC_ERR_NO_ERROR) {
704 return;
705 }
706
707 if (inbound == NULL) {
708 return;
709 }
710
711 for (destavp = search_first_avp(AVP_VAL_STR, _osp_origdest_avpid, NULL, 0);
712 destavp != NULL;
713 destavp = search_next_avp(destavp, NULL))
714 {
715 get_avp_val(destavp, &destval);
716
717 /* OSP destination is wrapped in a string */
718 dest = (osp_dest*)destval.s.s;
719
720 if (dest->used == 1) {
721 LM_DBG("iterating through used destination\n");
722
723 if (dest->reported == 1) {
724 LM_DBG("orig setup already reported\n");
725 break;
726 } else {
727 dest->reported = 1;
728 ospDumpDestination(dest);
729 lastused = dest;
730 if (dest->lastcode == 200) {
731 rstate = OSPC_RSTATE_START;
732 } else if (dest->lastcode == 300) {
733 rstate = OSPC_RSTATE_REDIRECT;
734 } else {
735 rstate = OSPC_RSTATE_STOP;
736 }
737 /* RoleInfo must be set before BuildUsageFromScratch */
738 OSPPTransactionSetRoleInfo(trans, rstate, OSPC_RFORMAT_OSP, OSPC_RVENDOR_OPENSIPS);
739 ospBuildUsageFromDestination(trans, inbound, dest, lastcode);
740 OSPPTransactionSetProtocol(trans, OSPC_PROTTYPE_SOURCE, OSPC_PROTNAME_SIP);
741 OSPPTransactionSetProtocol(trans, OSPC_PROTTYPE_DESTINATION, dest->protocol);
742 lastcode = dest->lastcode;
743 }
744 } else {
745 LM_DBG("destination has not been used, breaking out\n");
746 break;
747 }

Callers 3

ospCheckOrigDestinationFunction · 0.85
ospRecordEventFunction · 0.85
ospPrepareDestinationFunction · 0.85

Calls 7

ospGetInboundInfoFunction · 0.85
search_first_avpFunction · 0.85
search_next_avpFunction · 0.85
get_avp_valFunction · 0.85
ospDumpDestinationFunction · 0.85

Tested by

no test coverage detected