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; 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_usage_out (word->pattern); parse_error = 1; goto out; } /* if (words[3]) { ret = dict_set_str (dict, "port", (char *)words[3]); if (ret) goto out; } */ 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"); } if (frame) STACK_DESTROY (frame->root); return ret; }
static int xlator_option_validate_addr_list (xlator_t *xl, const char *key, const char *value, volume_option_t *opt, char **op_errstr) { int ret = -1; char *dup_val = NULL; char *addr_tok = NULL; char *save_ptr = NULL; char errstr[4096] = {0,}; dup_val = gf_strdup (value); if (!dup_val) goto out; addr_tok = strtok_r (dup_val, ",", &save_ptr); if (addr_tok == NULL) goto out; while (addr_tok) { if (!valid_internet_address (addr_tok, _gf_true)) goto out; addr_tok = strtok_r (NULL, ",", &save_ptr); } ret = 0; out: if (ret) { snprintf (errstr, sizeof (errstr), "option %s %s: '%s' is not " "a valid internet-address-list", key, value, value); gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", errstr); if (op_errstr) *op_errstr = gf_strdup (errstr); } GF_FREE (dup_val); return ret; }
static int xlator_option_validate_addr (xlator_t *xl, const char *key, const char *value, volume_option_t *opt, char **op_errstr) { int ret = -1; char errstr[256]; if (!valid_internet_address ((char *)value, _gf_false)) { snprintf (errstr, 256, "option %s %s: '%s' is not a valid internet-address," " it does not conform to standards.", key, value, value); gf_msg (xl->name, GF_LOG_ERROR, 0, LG_MSG_INVALID_ENTRY, "%s", errstr); if (op_errstr) *op_errstr = gf_strdup (errstr); } ret = 0; return ret; }