| 3737 | |
| 3738 | |
| 3739 | static int route2_carrier(struct sip_msg* msg, str* ids, |
| 3740 | pv_spec_t* gw_att, pv_spec_t* carr_att, struct head_db *part) |
| 3741 | { |
| 3742 | static unsigned short *carrier_idx; |
| 3743 | static unsigned short carrier_idx_size; |
| 3744 | struct sip_uri uri; |
| 3745 | pgw_list_t *cdst; |
| 3746 | pgw_list_t dst; |
| 3747 | pcr_t *cr; |
| 3748 | pv_value_t pv_val; |
| 3749 | str ruri, id; |
| 3750 | str next_carrier_attrs = {NULL, 0}; |
| 3751 | str next_gw_attrs = {NULL, 0}; |
| 3752 | int i, j, n; |
| 3753 | struct head_db * current_partition = 0; |
| 3754 | char *ruri_buf=NULL, *p; |
| 3755 | |
| 3756 | if(part==NULL) { |
| 3757 | LM_ERR("Partition is mandatory for route_to_carrier.\n"); |
| 3758 | return -1; |
| 3759 | } |
| 3760 | current_partition = part; |
| 3761 | |
| 3762 | |
| 3763 | if (current_partition->rdata == 0 || |
| 3764 | current_partition->rdata->pgw_tree == 0) { |
| 3765 | LM_DBG("empty routing table\n"); |
| 3766 | return -1; |
| 3767 | } |
| 3768 | |
| 3769 | gw_attrs_spec = (pv_spec_p) gw_att; |
| 3770 | carrier_attrs_spec = (pv_spec_p) carr_att; |
| 3771 | |
| 3772 | /* do some cleanup first */ |
| 3773 | destroy_avps( 0, current_partition->ruri_avp, 1); |
| 3774 | destroy_avps( 0, current_partition->gw_id_avp, 1); |
| 3775 | destroy_avps( 0, current_partition->gw_sock_avp, 1); |
| 3776 | destroy_avps( 0, current_partition->gw_attrs_avp, 1); |
| 3777 | destroy_avps( 0, current_partition->rule_attrs_avp, 1); |
| 3778 | destroy_avps( 0, current_partition->carrier_attrs_avp, 1); |
| 3779 | |
| 3780 | if (current_partition->carrier_id_avp!=-1) |
| 3781 | destroy_avps( 0, current_partition->carrier_id_avp, 1); |
| 3782 | if (current_partition->gw_priprefix_avp!=-1) |
| 3783 | destroy_avps( 0, current_partition->gw_priprefix_avp, 1); |
| 3784 | if (current_partition->rule_id_avp!=-1) |
| 3785 | destroy_avps( 0, current_partition->rule_id_avp, 1); |
| 3786 | if (current_partition->rule_prefix_avp!=-1) |
| 3787 | destroy_avps( 0, current_partition->rule_prefix_avp, 1); |
| 3788 | |
| 3789 | /* get the RURI */ |
| 3790 | ruri = *GET_RURI(msg); |
| 3791 | ruri_buf = (char*)pkg_malloc(ruri.len); |
| 3792 | if (ruri_buf==NULL) { |
| 3793 | LM_ERR("no more pkg mem (needed %d)\n",ruri.len); |
| 3794 | return -1; |
| 3795 | } |
| 3796 | memcpy(ruri_buf, ruri.s, ruri.len); |
nothing calls this directly
no test coverage detected