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

Function mi_enable_rtpengine

modules/rtpengine/rtpengine.c:1260–1329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1258}
1259
1260static mi_response_t *mi_enable_rtpengine(const mi_params_t *params,
1261 struct mi_handler *async_hdl)
1262{
1263 str rtpe_url;
1264 int enable, set;
1265 struct rtpe_set * rtpe_list;
1266 struct rtpe_node * crt_rtpe;
1267 int found, disabled, prev_disabled, recheck_ticks;
1268
1269 found = 0;
1270
1271 if(*rtpe_set_list ==NULL)
1272 goto end;
1273
1274 if (get_mi_string_param(params, "url", &rtpe_url.s, &rtpe_url.len) < 0)
1275 return init_mi_param_error();
1276 if(rtpe_url.s == NULL || rtpe_url.len ==0)
1277 return init_mi_error(400, MI_SSTR("Empty url"));
1278
1279 if (get_mi_int_param(params, "enable", &enable) < 0)
1280 return init_mi_param_error();
1281 if (try_get_mi_int_param(params, "setid", &set) < 0)
1282 set = -1;
1283
1284 RTPE_START_READ();
1285 for(rtpe_list = (*rtpe_set_list)->rset_first; rtpe_list != NULL;
1286 rtpe_list = rtpe_list->rset_next){
1287
1288 if (set !=-1 && set != rtpe_list->id_set)
1289 continue;
1290
1291 for(crt_rtpe = rtpe_list->rn_first; crt_rtpe != NULL;
1292 crt_rtpe = crt_rtpe->rn_next){
1293 /*found a matching rtpe*/
1294
1295 if(crt_rtpe->rn_url.len == rtpe_url.len){
1296
1297 if(strncmp(crt_rtpe->rn_url.s, rtpe_url.s, rtpe_url.len) == 0){
1298 /*set the enabled/disabled status*/
1299 found = 1;
1300 prev_disabled = crt_rtpe->rn_disabled;
1301 switch (enable) {
1302 case 0: /* disable */
1303 recheck_ticks = MI_MAX_RECHECK_TICKS;
1304 disabled = 1;
1305 break;
1306 case 2: /* pending */
1307 recheck_ticks = get_ticks() + rtpengine_disable_tout;
1308 disabled = 1;
1309 break;
1310 default: /* enable */
1311 recheck_ticks = MI_MIN_RECHECK_TICKS;
1312 disabled = 0;
1313 break;
1314 }
1315 crt_rtpe->rn_disabled = disabled;
1316 crt_rtpe->rn_recheck_ticks = recheck_ticks;
1317 if (prev_disabled != crt_rtpe->rn_disabled)

Callers

nothing calls this directly

Calls 7

get_mi_string_paramFunction · 0.85
init_mi_param_errorFunction · 0.85
init_mi_errorFunction · 0.85
get_mi_int_paramFunction · 0.85
try_get_mi_int_paramFunction · 0.85
get_ticksFunction · 0.85

Tested by

no test coverage detected