mi_response_t *mi_get_hash(const mi_params_t *params, struct mi_handler *async_hdl) { if (!hash_file) { LM_INFO("no hash_file given, disable hash functionality\n"); return init_mi_error(404, MI_SSTR("Functionality disabled")); } else { return init_mi_result_string(config_hash, MD5_LEN); } }
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 *mi_check_hash(const mi_params_t *params, struct mi_handler *async_hdl) { char tmp[MD5_LEN]; memset(tmp, 0, MD5_LEN); if (!hash_file) { LM_INFO("no hash_file given, disable hash functionality\n"); return init_mi_error(404, MI_SSTR("Functionality disabled")); } else { if (MD5File(tmp, hash_file) != 0) { LM_ERR("could not hash the config file"); return init_mi_error(500, MI_SSTR("Internal error")); } if (strncmp(config_hash, tmp, MD5_LEN) == 0) return init_mi_result_string(MI_SSTR("The actual config file hash " "is identical to the stored one.")); else return init_mi_error(400, MI_SSTR("The actual config file hash is not " "identical to the stored one.")); } }