0-succes * -1 - erorr * */
| 1123 | * -1 - erorr |
| 1124 | * */ |
| 1125 | static int rtpengine_add_rtpengine_set( char * rtp_proxies, int set_id) |
| 1126 | { |
| 1127 | char *p,*p2; |
| 1128 | struct rtpe_set * rtpe_list; |
| 1129 | unsigned int my_current_id; |
| 1130 | str id_set; |
| 1131 | int new_list; |
| 1132 | |
| 1133 | /* empty definition? */ |
| 1134 | p= rtp_proxies; |
| 1135 | if(!p || *p=='\0'){ |
| 1136 | return 0; |
| 1137 | } |
| 1138 | |
| 1139 | for(;*p && isspace(*p);p++); |
| 1140 | if(*p=='\0'){ |
| 1141 | return 0; |
| 1142 | } |
| 1143 | |
| 1144 | if (set_id < 0) { |
| 1145 | rtp_proxies = strstr(p, "=="); |
| 1146 | if(rtp_proxies){ |
| 1147 | if(*(rtp_proxies +2)=='\0'){ |
| 1148 | LM_ERR("script error -invalid rtp proxy list!\n"); |
| 1149 | return -1; |
| 1150 | } |
| 1151 | |
| 1152 | *rtp_proxies = '\0'; |
| 1153 | p2 = rtp_proxies-1; |
| 1154 | for(;isspace(*p2); *p2 = '\0',p2--); |
| 1155 | id_set.s = p; id_set.len = p2 - p+1; |
| 1156 | |
| 1157 | if(id_set.len <= 0 ||str2int(&id_set, &my_current_id)<0 ){ |
| 1158 | LM_ERR("script error -invalid set_id value!\n"); |
| 1159 | return -1; |
| 1160 | } |
| 1161 | |
| 1162 | rtp_proxies+=2; |
| 1163 | }else{ |
| 1164 | rtp_proxies = p; |
| 1165 | my_current_id = DEFAULT_RTPE_SET_ID; |
| 1166 | } |
| 1167 | } else { |
| 1168 | rtp_proxies = p; |
| 1169 | my_current_id = set_id; |
| 1170 | } |
| 1171 | |
| 1172 | for(;*rtp_proxies && isspace(*rtp_proxies);rtp_proxies++); |
| 1173 | |
| 1174 | if(!(*rtp_proxies)){ |
| 1175 | LM_ERR("script error -empty rtpengine list\n"); |
| 1176 | return -1;; |
| 1177 | } |
| 1178 | |
| 1179 | /*search for the current_id*/ |
| 1180 | rtpe_list = (*rtpe_set_list) ? (*rtpe_set_list)->rset_first : 0; |
| 1181 | while( rtpe_list != 0 && rtpe_list->id_set!=my_current_id) |
| 1182 | rtpe_list = rtpe_list->rset_next; |
no test coverage detected