apps/app_verify.c
static char *handle_show_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
#define FORMAT  "%-32s : %s\n"
#define FORMAT2 "%-32s : %f\n"
	struct call_verify *v;
	int which = 0;
	char *ret = NULL;

	switch(cmd) {
	case CLI_INIT:
		e->command = "verify show profile";
		e->usage =
			"Usage: verify show profile <profile name>\n"
			"       Displays information about a verification profile.\n";
		return NULL;
	case CLI_GENERATE:
		if (a->pos != 3) {
			return NULL;
		}
		AST_LIST_TRAVERSE(&verifys, v, entry) {
			if (!strncasecmp(a->word, v->name, strlen(a->word)) && ++which > a->n) {
				ret = ast_strdup(v->name);
				break;
			}
		}

		return ret;
	}

	if (a->argc != 4) {
		return CLI_SHOWUSAGE;
	}

	AST_RWLIST_RDLOCK(&verifys);
	AST_LIST_TRAVERSE(&verifys, v, entry) {
		if (!strcasecmp(a->argv[3], v->name)) {
			ast_cli(a->fd, FORMAT, "Name", v->name);
			ast_cli(a->fd, FORMAT, "Verification Method", v->verifymethod);
			ast_cli(a->fd, FORMAT, "Request Method", v->requestmethod);
			ast_cli(a->fd, FORMAT, "Verification Request", v->verifyrequest);
			ast_cli(a->fd, FORMAT, "Verification Context", v->verifycontext);
			ast_cli(a->fd, FORMAT, "Validate Token Request", v->validatetokenrequest);
			ast_cli(a->fd, FORMAT, "Obtain Token Request", v->obtaintokenrequest);
			ast_cli(a->fd, FORMAT, "Verify Variable Name", v->local_var);
			ast_cli(a->fd, FORMAT, "Via Variable Name", v->via_number);
			ast_cli(a->fd, FORMAT, "Remote Verify Variable Name", v->remote_var);
			ast_cli(a->fd, FORMAT, "Remote Via Variable Name", v->via_remote_var);
			ast_cli(a->fd, FORMAT, "Remote Token Variable Name", v->token_remote_var);
			ast_cli(a->fd, FORMAT, "Incoming Variable Assignments", v->setinvars);
			ast_cli(a->fd, FORMAT, "Outgoing Variable Assignments", v->setoutvars);
			ast_cli(a->fd, FORMAT, "Sanity Checks", AST_CLI_YESNO(v->sanitychecks));
			ast_cli(a->fd, FORMAT, "Allow Extending Trust", AST_CLI_YESNO(v->extendtrust));
			ast_cli(a->fd, FORMAT, "Allow DISA Thru", AST_CLI_YESNO(v->allowdisathru));
			ast_cli(a->fd, FORMAT, "Allow PSTN Thru", AST_CLI_YESNO(v->allowpstnthru));
			ast_cli(a->fd, FORMAT, "Allow Token", AST_CLI_YESNO(v->allowtoken));
			ast_cli(a->fd, FORMAT, "Flag Private IP Addresses", AST_CLI_YESNO(v->flagprivateip));
			ast_cli(a->fd, FORMAT, "Success Regex", v->successregex);
			ast_cli(a->fd, FORMAT, "Outgoing Regex", v->outregex);
			ast_cli(a->fd, FORMAT, "Blacklist Endpoint", v->blacklist_endpoint);
			ast_cli(a->fd, FORMAT2, "Blacklist Threshold", v->blacklist_threshold);
			ast_cli(a->fd, FORMAT, "Blacklist Fail Open", AST_CLI_YESNO(v->blacklist_failopen));
			ast_cli(a->fd, FORMAT, "Exception Context", v->exceptioncontext);
			ast_cli(a->fd, FORMAT, "Failure Action", v->failureaction);
			ast_cli(a->fd, FORMAT, "Failure Playback File", v->failurefile);
			ast_cli(a->fd, FORMAT, "Failure Dialplan Location", v->failurelocation);
			ast_cli(a->fd, FORMAT, "Region Identifier", v->region);
			ast_cli(a->fd, FORMAT, "CLLI", v->clli);
			ast_cli(a->fd, FORMAT, "Fail Group", v->failgroup);
			ast_cli(a->fd, FORMAT, "code_good", v->code_good);
			ast_cli(a->fd, FORMAT, "code_fail", v->code_fail);
			ast_cli(a->fd, FORMAT, "code_requestfail", v->code_requestfail);
			ast_cli(a->fd, FORMAT, "code_spoof", v->code_spoof);
			ast_cli(a->fd, FORMAT, "Log Level", v->loglevel);
			ast_cli(a->fd, FORMAT, "Log Msg Fmt", v->logmsg);
			ast_cli(a->fd, "%s%d of %d%s incoming calls in profile '%s' have successfully passed verification\n",
				ast_term_color(v->insuccess == 0 ? COLOR_RED : COLOR_GREEN, COLOR_BLACK),
				v->insuccess, v->in, ast_term_reset(), v->name);
			ast_cli(a->fd, "%s%d of %d%s outgoing calls in profile '%s' have successfully been out-verified\n",
				ast_term_color(v->outsuccess == 0 ? COLOR_RED : COLOR_GREEN, COLOR_BLACK),
				v->outsuccess, v->out, ast_term_reset(), v->name);
			break;
		}
	}
	AST_RWLIST_UNLOCK(&verifys);
	if (!v) {
		ast_cli(a->fd, "No such verify profile: '%s'\n", a->argv[3]);
	}

	return CLI_SUCCESS;
#undef FORMAT
#undef FORMAT2
}
/*! \brief CLI command to dump verification profile */
\brief CLI command to dump verification profile
\ brief CLI command to dump verification profile
static char *handle_show_profile(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
#define FORMAT  "%-32s : %s\n"
#define FORMAT2 "%-32s : %f\n"
	struct call_verify *v;
	int which = 0;
	char *ret = NULL;
	switch(cmd) {
	case CLI_INIT:
		e->command = "verify show profile";
		e->usage =
			"Usage: verify show profile <profile name>\n"
			"       Displays information about a verification profile.\n";
		return NULL;
	case CLI_GENERATE:
		if (a->pos != 3) {
			return NULL;
		}
		AST_LIST_TRAVERSE(&verifys, v, entry) {
			if (!strncasecmp(a->word, v->name, strlen(a->word)) && ++which > a->n) {
				ret = ast_strdup(v->name);
				break;
			}
		}
		return ret;
	}
	if (a->argc != 4) {
		return CLI_SHOWUSAGE;
	}
	AST_RWLIST_RDLOCK(&verifys);
	AST_LIST_TRAVERSE(&verifys, v, entry) {
		if (!strcasecmp(a->argv[3], v->name)) {
			ast_cli(a->fd, FORMAT, "Name", v->name);
			ast_cli(a->fd, FORMAT, "Verification Method", v->verifymethod);
			ast_cli(a->fd, FORMAT, "Request Method", v->requestmethod);
			ast_cli(a->fd, FORMAT, "Verification Request", v->verifyrequest);
			ast_cli(a->fd, FORMAT, "Verification Context", v->verifycontext);
			ast_cli(a->fd, FORMAT, "Validate Token Request", v->validatetokenrequest);
			ast_cli(a->fd, FORMAT, "Obtain Token Request", v->obtaintokenrequest);
			ast_cli(a->fd, FORMAT, "Verify Variable Name", v->local_var);
			ast_cli(a->fd, FORMAT, "Via Variable Name", v->via_number);
			ast_cli(a->fd, FORMAT, "Remote Verify Variable Name", v->remote_var);
			ast_cli(a->fd, FORMAT, "Remote Via Variable Name", v->via_remote_var);
			ast_cli(a->fd, FORMAT, "Remote Token Variable Name", v->token_remote_var);
			ast_cli(a->fd, FORMAT, "Incoming Variable Assignments", v->setinvars);
			ast_cli(a->fd, FORMAT, "Outgoing Variable Assignments", v->setoutvars);
			ast_cli(a->fd, FORMAT, "Sanity Checks", AST_CLI_YESNO(v->sanitychecks));
			ast_cli(a->fd, FORMAT, "Allow Extending Trust", AST_CLI_YESNO(v->extendtrust));
			ast_cli(a->fd, FORMAT, "Allow DISA Thru", AST_CLI_YESNO(v->allowdisathru));
			ast_cli(a->fd, FORMAT, "Allow PSTN Thru", AST_CLI_YESNO(v->allowpstnthru));
			ast_cli(a->fd, FORMAT, "Allow Token", AST_CLI_YESNO(v->allowtoken));
			ast_cli(a->fd, FORMAT, "Flag Private IP Addresses", AST_CLI_YESNO(v->flagprivateip));
			ast_cli(a->fd, FORMAT, "Success Regex", v->successregex);
			ast_cli(a->fd, FORMAT, "Outgoing Regex", v->outregex);
			ast_cli(a->fd, FORMAT, "Blacklist Endpoint", v->blacklist_endpoint);
			ast_cli(a->fd, FORMAT2, "Blacklist Threshold", v->blacklist_threshold);
			ast_cli(a->fd, FORMAT, "Blacklist Fail Open", AST_CLI_YESNO(v->blacklist_failopen));
			ast_cli(a->fd, FORMAT, "Exception Context", v->exceptioncontext);
			ast_cli(a->fd, FORMAT, "Failure Action", v->failureaction);
			ast_cli(a->fd, FORMAT, "Failure Playback File", v->failurefile);
			ast_cli(a->fd, FORMAT, "Failure Dialplan Location", v->failurelocation);
			ast_cli(a->fd, FORMAT, "Region Identifier", v->region);
			ast_cli(a->fd, FORMAT, "CLLI", v->clli);
			ast_cli(a->fd, FORMAT, "Fail Group", v->failgroup);
			ast_cli(a->fd, FORMAT, "code_good", v->code_good);
			ast_cli(a->fd, FORMAT, "code_fail", v->code_fail);
			ast_cli(a->fd, FORMAT, "code_requestfail", v->code_requestfail);
			ast_cli(a->fd, FORMAT, "code_spoof", v->code_spoof);
			ast_cli(a->fd, FORMAT, "Log Level", v->loglevel);
			ast_cli(a->fd, FORMAT, "Log Msg Fmt", v->logmsg);
			ast_cli(a->fd, "%s%d of %d%s incoming calls in profile '%s' have successfully passed verification\n",
				ast_term_color(v->insuccess == 0 ? COLOR_RED : COLOR_GREEN, COLOR_BLACK),
				v->insuccess, v->in, ast_term_reset(), v->name);
			ast_cli(a->fd, "%s%d of %d%s outgoing calls in profile '%s' have successfully been out-verified\n",
				ast_term_color(v->outsuccess == 0 ? COLOR_RED : COLOR_GREEN, COLOR_BLACK),
				v->outsuccess, v->out, ast_term_reset(), v->name);
			break;
		}
	}
	AST_RWLIST_UNLOCK(&verifys);
	if (!v) {
		ast_cli(a->fd, "No such verify profile: '%s'\n", a->argv[3]);
	}
	return CLI_SUCCESS;
#undef FORMAT
#undef FORMAT2
}
static char * handle_show_profile ( struct ast_cli_entry * e , int cmd , struct ast_cli_args * a ) { #define FORMAT   "%-32s : %s\n" #define FORMAT2  "%-32s : %f\n" struct call_verify * v ; int which = 0 ; char * ret = NULL ; switch ( cmd ) { case CLI_INIT : e -> command = " " ; e -> usage = " \n " " \n " ; return NULL ; case CLI_GENERATE : if ( a -> pos != 3 ) { return NULL ; } AST_LIST_TRAVERSE ( & verifys , v , entry ) { if ( ! strncasecmp ( a -> word , v -> name , strlen ( a -> word ) ) && ++ which > a -> n ) { ret = ast_strdup ( v -> name ) ; break ; } } return ret ; } if ( a -> argc != 4 ) { return CLI_SHOWUSAGE ; } AST_RWLIST_RDLOCK ( & verifys ) ; AST_LIST_TRAVERSE ( & verifys , v , entry ) { if ( ! strcasecmp ( a -> argv [ 3 ] , v -> name ) ) { ast_cli ( a -> fd , FORMAT , " " , v -> name ) ; ast_cli ( a -> fd , FORMAT , " " , v -> verifymethod ) ; ast_cli ( a -> fd , FORMAT , " " , v -> requestmethod ) ; ast_cli ( a -> fd , FORMAT , " " , v -> verifyrequest ) ; ast_cli ( a -> fd , FORMAT , " " , v -> verifycontext ) ; ast_cli ( a -> fd , FORMAT , " " , v -> validatetokenrequest ) ; ast_cli ( a -> fd , FORMAT , " " , v -> obtaintokenrequest ) ; ast_cli ( a -> fd , FORMAT , " " , v -> local_var ) ; ast_cli ( a -> fd , FORMAT , " " , v -> via_number ) ; ast_cli ( a -> fd , FORMAT , " " , v -> remote_var ) ; ast_cli ( a -> fd , FORMAT , " " , v -> via_remote_var ) ; ast_cli ( a -> fd , FORMAT , " " , v -> token_remote_var ) ; ast_cli ( a -> fd , FORMAT , " " , v -> setinvars ) ; ast_cli ( a -> fd , FORMAT , " " , v -> setoutvars ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> sanitychecks ) ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> extendtrust ) ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> allowdisathru ) ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> allowpstnthru ) ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> allowtoken ) ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> flagprivateip ) ) ; ast_cli ( a -> fd , FORMAT , " " , v -> successregex ) ; ast_cli ( a -> fd , FORMAT , " " , v -> outregex ) ; ast_cli ( a -> fd , FORMAT , " " , v -> blacklist_endpoint ) ; ast_cli ( a -> fd , FORMAT2 , " " , v -> blacklist_threshold ) ; ast_cli ( a -> fd , FORMAT , " " , AST_CLI_YESNO ( v -> blacklist_failopen ) ) ; ast_cli ( a -> fd , FORMAT , " " , v -> exceptioncontext ) ; ast_cli ( a -> fd , FORMAT , " " , v -> failureaction ) ; ast_cli ( a -> fd , FORMAT , " " , v -> failurefile ) ; ast_cli ( a -> fd , FORMAT , " " , v -> failurelocation ) ; ast_cli ( a -> fd , FORMAT , " " , v -> region ) ; ast_cli ( a -> fd , FORMAT , " " , v -> clli ) ; ast_cli ( a -> fd , FORMAT , " " , v -> failgroup ) ; ast_cli ( a -> fd , FORMAT , " " , v -> code_good ) ; ast_cli ( a -> fd , FORMAT , " " , v -> code_fail ) ; ast_cli ( a -> fd , FORMAT , " " , v -> code_requestfail ) ; ast_cli ( a -> fd , FORMAT , " " , v -> code_spoof ) ; ast_cli ( a -> fd , FORMAT , " " , v -> loglevel ) ; ast_cli ( a -> fd , FORMAT , " " , v -> logmsg ) ; ast_cli ( a -> fd , " \n " , ast_term_color ( v -> insuccess == 0 ? COLOR_RED : COLOR_GREEN , COLOR_BLACK ) , v -> insuccess , v -> in , ast_term_reset ( ) , v -> name ) ; ast_cli ( a -> fd , " \n " , ast_term_color ( v -> outsuccess == 0 ? COLOR_RED : COLOR_GREEN , COLOR_BLACK ) , v -> outsuccess , v -> out , ast_term_reset ( ) , v -> name ) ; break ; } } AST_RWLIST_UNLOCK ( & verifys ) ; if ( ! v ) { ast_cli ( a -> fd , " \n " , a -> argv [ 3 ] ) ; } return CLI_SUCCESS ; #undef  FORMAT #undef  FORMAT2 }
\brief CLI command to dump verification profile
\ brief CLI command to dump verification profile