| 3949 | |
| 3950 | |
| 3951 | static int route2_gw(struct sip_msg* msg, str* ids, pv_spec_t* gw_attr, |
| 3952 | pv_spec_t* cr_attr, struct head_db *part) |
| 3953 | { |
| 3954 | struct sip_uri uri; |
| 3955 | pgw_t *gw; |
| 3956 | pgw_list_t dst; |
| 3957 | pv_value_t pv_val; |
| 3958 | str ruri, id; |
| 3959 | char *p; |
| 3960 | int idx, i; |
| 3961 | struct head_db * current_partition = 0; |
| 3962 | char *ruri_buf = NULL; |
| 3963 | pcr_t *pcr = NULL; |
| 3964 | map_iterator_t cr_it; |
| 3965 | void** dest; |
| 3966 | |
| 3967 | if(part== NULL) { |
| 3968 | LM_ERR("Partition is mandatory for route_to_gw.\n"); |
| 3969 | return -1; |
| 3970 | } |
| 3971 | current_partition = part; |
| 3972 | |
| 3973 | if (current_partition->rdata == 0 || |
| 3974 | current_partition->rdata->pgw_tree == 0) { |
| 3975 | LM_DBG("empty routing table\n"); |
| 3976 | return -1; |
| 3977 | } |
| 3978 | |
| 3979 | gw_attrs_spec = (pv_spec_p)gw_attr; |
| 3980 | carrier_attrs_spec = (pv_spec_p)cr_attr; |
| 3981 | |
| 3982 | /* get the RURI */ |
| 3983 | ruri = *GET_RURI(msg); |
| 3984 | ruri_buf = (char*)pkg_malloc(ruri.len); |
| 3985 | if (ruri_buf==NULL) { |
| 3986 | LM_ERR("no more pkg mem (needed %d)\n",ruri.len); |
| 3987 | return -1; |
| 3988 | } |
| 3989 | memcpy(ruri_buf, ruri.s, ruri.len); |
| 3990 | ruri.s = ruri_buf; |
| 3991 | |
| 3992 | /* parse ruri */ |
| 3993 | if (parse_uri( ruri.s, ruri.len, &uri)!=0) { |
| 3994 | LM_ERR("unable to parse RURI\n"); |
| 3995 | goto error_free; |
| 3996 | } |
| 3997 | |
| 3998 | /* ref the data for reading */ |
| 3999 | lock_start_read( current_partition->ref_lock ); |
| 4000 | |
| 4001 | idx = 0; |
| 4002 | do { |
| 4003 | id.s = ids->s; |
| 4004 | p = q_memchr( ids->s , ',' , ids->len); |
| 4005 | id.len = (p==NULL)?ids->len:(p-ids->s); |
| 4006 | |
| 4007 | ids->len -= id.len + (p?1:0); |
| 4008 | ids->s += id.len + (p?1:0); |
nothing calls this directly
no test coverage detected