, 28 Dec 2035 06:36:56 GMT ETag: "36c328a7c12bce41256572a90d6ee9f1caa2feaa" /* Copyright (c) 2010-2012 Red Hat, Inc. This file is part of GlusterFS. This file is licensed to you under your choice of the GNU Lesser General Public License, version 3 or any later version (LGPLv3 or later), or the GNU General Public License, version 2 (GPLv2), in all cases as published by the Free Software Foundation. */ #include #include #include #include #include #include "cli.h" #include "cli-cmd.h" #include "cli-mem-types.h" #include "cli1-xdr.h" #include "protocol-common.h" extern struct rpc_clnt *global_rpc; extern rpc_clnt_prog_t *cli_rpc_prog; int cli_cmd_peer_help_cbk (struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); int cli_cmd_peer_probe_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; if (!(wordcount == 3)) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_PROBE]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); if (!dict) goto out; ret = dict_set_str (dict, "hostname", (char *)words[2]); if (ret) goto out; ret = valid_internet_address ((char *) words[2], _gf_false); if (ret == 1) { ret = 0; } else { cli_out ("%s is an invalid address", words[2]); cli_usage_out (word->pattern); parse_error = 1; ret = -1; goto out; } /* if (words[3]) { ret = dict_set_str (dict, "port", (char *)words[3]); if (ret) goto out; } */ CLI_LOCAL_INIT (local, words, frame, dict); if (proc->fn) { ret = proc->fn (frame, THIS, dict); } out: if (ret) { cli_cmd_sent_status_get (&sent); if ((sent == 0) && (parse_error == 0)) cli_out ("Peer probe failed"); } CLI_STACK_DESTROY (frame); #if (USE_EVENTS) if (ret == 0) { gf_event (EVENT_PEER_ATTACH, "host=%s", (char *)words[2]); } #endif return ret; } int cli_cmd_peer_deprobe_cbk (struct cli_state *state, struct cli_cmd_word *word, const char **words, int wordcount) { int ret = -1; rpc_clnt_procedure_t *proc = NULL; call_frame_t *frame = NULL; dict_t *dict = NULL; int flags = 0; int sent = 0; int parse_error = 0; cli_local_t *local = NULL; if ((wordcount < 3) || (wordcount > 4)) { cli_usage_out (word->pattern); parse_error = 1; goto out; } proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEPROBE]; frame = create_frame (THIS, THIS->ctx->pool); if (!frame) goto out; dict = dict_new (); ret = dict_set_str (dict, "hostn