static mi_response_t *clusterer_set_status(const mi_params_t *params, struct mi_handler *async_hdl) { int cluster_id; int state; int rc; if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0) return init_mi_param_error(); if (cluster_id < 1) return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'")); if (get_mi_int_param(params, "status", &state) < 0) return init_mi_param_error(); if (state != STATE_DISABLED && state != STATE_ENABLED) return init_mi_error(400, MI_SSTR("Bad value for 'status'")); rc = cl_set_state(cluster_id, state); if (rc == -1) return init_mi_error(404, MI_SSTR("Cluster id not found")); if (rc == 1) return init_mi_error(404, MI_SSTR("Node id not found")); return init_mi_result_ok(); }
static mi_response_t *cluster_send_mi(const mi_params_t *params, struct mi_handler *async_hdl) { int cluster_id, node_id; int rc; str cmd_name; mi_item_t *cmd_params_arr = NULL; int no_params = 0; if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0) return init_mi_param_error(); if (cluster_id < 1) return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'")); if (get_mi_int_param(params, "destination", &node_id) < 0) return init_mi_param_error(); if (node_id < 1) return init_mi_error(400, MI_SSTR("Bad value for 'destination'")); if (node_id == current_id) return init_mi_error(400, MI_SSTR("Local node specified as destination")); if (get_mi_string_param(params, "cmd_name", &cmd_name.s, &cmd_name.len) < 0) return init_mi_param_error(); rc = try_get_mi_array_param(params, "cmd_params", &cmd_params_arr, &no_params); if (rc < 0) { cmd_params_arr = NULL; if (rc == -2) return init_mi_param_error(); } rc = send_mi_cmd(cluster_id, node_id, cmd_name, cmd_params_arr, no_params); switch (rc) { case CLUSTERER_SEND_SUCCES: LM_DBG("MI command <%.*s> sent\n", cmd_name.len, cmd_name.s); return init_mi_result_ok(); case CLUSTERER_CURR_DISABLED: LM_INFO("Local node disabled, MI command <%.*s> not sent\n", cmd_name.len, cmd_name.s); return init_mi_result_string(MI_SSTR("Local node disabled")); case CLUSTERER_DEST_DOWN: LM_ERR("Destination down, MI command <%.*s> not sent\n", cmd_name.len, cmd_name.s); return init_mi_error(400, MI_SSTR("Destination down")); case CLUSTERER_SEND_ERR: LM_ERR("Error sending MI command <%.*s>+\n", cmd_name.len, cmd_name.s); return init_mi_error(400, MI_SSTR("Send error")); default: LM_BUG("Bad send error code\n"); return init_mi_error(400, MI_SSTR("Internal error")); } }
mi_response_t *refreshXcapDoc(const mi_params_t *params, struct mi_handler *async_hdl) { str doc_url; xcap_doc_sel_t doc_sel; char* serv_addr; str stream= {0, 0}; int type; int xcap_port; char* etag= NULL; if (get_mi_string_param(params, "doc_uri", &doc_url.s, &doc_url.len) < 0) return init_mi_param_error(); if(doc_url.s == NULL || doc_url.len== 0) { LM_ERR("empty uri\n"); return init_mi_error(404, MI_SSTR("Empty document URL")); } if (get_mi_int_param(params, "port", &xcap_port) < 0) return init_mi_param_error(); /* send GET HTTP request to the server */ stream.s = send_http_get(doc_url.s, xcap_port, NULL, 0, &etag, &stream.len); if(stream.s== NULL) { LM_ERR("in http get\n"); return 0; } /* call registered functions with document argument */ if(parse_doc_url(doc_url, &serv_addr, &doc_sel)< 0) { LM_ERR("parsing document url\n"); return 0; } type = xcap_doc_type(&doc_sel.auid); if (type < 0) { LM_ERR("incorect auid: %.*s\n", doc_sel.auid.len, doc_sel.auid.s); goto error; } run_xcap_update_cb(type, doc_sel.xid, stream.s); pkg_free(stream.s); return init_mi_result_ok(); error: if(stream.s) pkg_free(stream.s); return 0; }
static mi_response_t *mi_b2b_bridge_f(const mi_params_t *params, struct mi_handler *async_hdl) { int flag; if (get_mi_int_param(params, "flag", &flag) < 0) return init_mi_param_error(); return mi_b2b_bridge(params, flag, NULL); }
static mi_response_t *mi_b2b_bridge_4(const mi_params_t *params, struct mi_handler *async_hdl) { int flag; str prov_media; if (get_mi_int_param(params, "flag", &flag) < 0) return init_mi_param_error(); if (get_mi_string_param(params, "prov_media_uri", &prov_media.s, &prov_media.len) < 0) return init_mi_param_error(); return mi_b2b_bridge(params, flag, &prov_media); }
mi_response_t *mi_set_prob(const mi_params_t *params, struct mi_handler *async_hdl) { int percent; if (get_mi_int_param(params, "prob_proc", &percent) < 0) return init_mi_param_error(); if (percent > 100) { LM_ERR("incorrect probability <%u>\n", percent); return init_mi_error(400, MI_SSTR("Bad parameter value")); } *probability = percent; return init_mi_result_ok(); }
static mi_response_t *cluster_bcast_mi(const mi_params_t *params, struct mi_handler *async_hdl) { int cluster_id; int rc; str cmd_name; mi_item_t *cmd_params_arr = NULL; int no_params = 0; if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0) return init_mi_param_error(); if (cluster_id < 1) return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'")); if (get_mi_string_param(params, "cmd_name", &cmd_name.s, &cmd_name.len) < 0) return init_mi_param_error(); rc = try_get_mi_array_param(params, "cmd_params", &cmd_params_arr, &no_params); if (rc < 0) { cmd_params_arr = NULL; if (rc == -2) return init_mi_param_error(); } rc = send_mi_cmd(cluster_id, 0, cmd_name, cmd_params_arr, no_params); switch (rc) { case CLUSTERER_SEND_SUCCES: LM_DBG("MI command <%.*s> sent\n", cmd_name.len, cmd_name.s); break; case CLUSTERER_CURR_DISABLED: LM_INFO("Local node disabled, MI command <%.*s> not sent\n", cmd_name.len, cmd_name.s); break; case CLUSTERER_DEST_DOWN: LM_ERR("All nodes down, MI command <%.*s> not sent\n", cmd_name.len, cmd_name.s); break; case CLUSTERER_SEND_ERR: LM_ERR("Error sending MI command <%.*s>+\n", cmd_name.len, cmd_name.s); break; } return run_mi_cmd_local(&cmd_name, cmd_params_arr, no_params); }