コード例 #1
0
ファイル: cli_commands.c プロジェクト: coreyfarrell/asterisk
static int cli_channel_print_body(void *obj, void *arg, int flags)
{
	const struct ast_channel_snapshot *snapshot = obj;
	struct ast_sip_cli_context *context = arg;
	char *print_name = NULL;
	int print_name_len;
	int indent;
	int flexwidth;
	char *print_time = alloca(32);

	ast_assert(context->output_buffer != NULL);

	print_name_len = strlen(snapshot->name) + strlen(snapshot->appl) + 2;
	print_name = alloca(print_name_len);

	/* Append the application */
	snprintf(print_name, print_name_len, "%s/%s", snapshot->name, snapshot->appl);

	indent = CLI_INDENT_TO_SPACES(context->indent_level);
	flexwidth = CLI_LAST_TABSTOP - indent;

	ast_format_duration_hh_mm_ss(ast_tvnow().tv_sec - snapshot->creationtime.tv_sec, print_time, 32);

	ast_str_append(&context->output_buffer, 0, "%*s: %-*.*s %-12.12s  %-11.11s\n",
		CLI_INDENT_TO_SPACES(context->indent_level), "Channel",
		flexwidth, flexwidth,
		print_name,
		ast_state2str(snapshot->state),
		print_time);

	if (context->recurse) {
		context->indent_level++;
		indent = CLI_INDENT_TO_SPACES(context->indent_level);
		flexwidth = CLI_LAST_TABSTOP - indent - 25;

		ast_str_append(&context->output_buffer, 0,
			"%*s: %-*.*s  CLCID: \"%s\" <%s>\n",
			indent, "Exten",
			flexwidth, flexwidth,
			snapshot->exten,
			snapshot->connected_name,
			snapshot->connected_number
			);
		context->indent_level--;
		if (context->indent_level == 0) {
			ast_str_append(&context->output_buffer, 0, "\n");
		}
	}

	return 0;
}
コード例 #2
0
ファイル: location.c プロジェクト: MakerHe/asterisk
static int cli_aor_print_header(void *obj, void *arg, int flags)
{
	struct ast_sip_cli_context *context = arg;
	RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);

	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
	int filler = CLI_LAST_TABSTOP - indent - 7;

	ast_assert(context->output_buffer != NULL);

	ast_str_append(&context->output_buffer, 0,
		"%*s:  <Aor%*.*s>  <MaxContact>\n",
		indent, "Aor", filler, filler, CLI_HEADER_FILLER);

	if (context->recurse) {
		context->indent_level++;
		formatter_entry = ast_sip_lookup_cli_formatter("contact");
		if (formatter_entry) {
			formatter_entry->print_header(NULL, context, 0);
		}
		context->indent_level--;
	}

	return 0;
}
コード例 #3
0
ファイル: location.c プロジェクト: MakerHe/asterisk
static int cli_contact_print_body(void *obj, void *arg, int flags)
{
	struct ast_sip_contact_wrapper *wrapper = obj;
	struct ast_sip_contact *contact = wrapper->contact;
	struct ast_sip_cli_context *context = arg;
	int indent;
	int flexwidth;
	const char *contact_id = ast_sorcery_object_get_id(contact);
	const char *hash_start = contact_id + strlen(contact->aor) + 2;

	RAII_VAR(struct ast_sip_contact_status *, status,
		ast_sorcery_retrieve_by_id( ast_sip_get_sorcery(), CONTACT_STATUS, contact_id),
		ao2_cleanup);

	ast_assert(contact->uri != NULL);
	ast_assert(context->output_buffer != NULL);

	indent = CLI_INDENT_TO_SPACES(context->indent_level);
	flexwidth = CLI_LAST_TABSTOP - indent - 9 - strlen(contact->aor) + 1;

	ast_str_append(&context->output_buffer, 0, "%*s:  %s/%-*.*s %-10.10s %-7.7s %11.3f\n",
		indent,
		"Contact",
		contact->aor,
		flexwidth, flexwidth,
		contact->uri,
		hash_start,
		ast_sip_get_contact_short_status_label(status ? status->status : UNKNOWN),
		(status && (status->status != UNKNOWN) ? ((long long) status->rtt) / 1000.0 : NAN));

	return 0;
}
コード例 #4
0
ファイル: location.c プロジェクト: lyx2014/Asterisk
static int cli_contact_print_body(void *obj, void *arg, int flags)
{
	struct ast_sip_contact_wrapper *wrapper = obj;
	struct ast_sip_contact *contact = wrapper->contact;
	struct ast_sip_cli_context *context = arg;
	int indent;
	int flexwidth;

	RAII_VAR(struct ast_sip_contact_status *, status,
		ast_sorcery_retrieve_by_id( ast_sip_get_sorcery(), CONTACT_STATUS, ast_sorcery_object_get_id(contact)),
		ao2_cleanup);

	ast_assert(contact->uri != NULL);
	ast_assert(context->output_buffer != NULL);

	indent = CLI_INDENT_TO_SPACES(context->indent_level);
	flexwidth = CLI_LAST_TABSTOP - indent - 2;

	ast_str_append(&context->output_buffer, 0, "%*s:  %-*.*s  %-12.12s  %11.3f\n",
		indent,
		"Contact",
		flexwidth, flexwidth,
		wrapper->contact_id,
		(status ? (status->status == AVAILABLE ? "Avail" : "Unavail") : "Unknown"),
		(status ? ((long long) status->rtt) / 1000.0 : NAN));

	return 0;
}
コード例 #5
0
ファイル: location.c プロジェクト: MakerHe/asterisk
static int cli_contact_print_header(void *obj, void *arg, int flags)
{
	struct ast_sip_cli_context *context = arg;
	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
	int filler = CLI_LAST_TABSTOP - indent - 23;

	ast_assert(context->output_buffer != NULL);

	ast_str_append(&context->output_buffer, 0,
		"%*s:  <Aor/ContactUri%*.*s> <Hash....> <Status> <RTT(ms)..>\n",
		indent, "Contact", filler, filler, CLI_HEADER_FILLER);

	return 0;
}
コード例 #6
0
ファイル: cli_commands.c プロジェクト: coreyfarrell/asterisk
static int cli_channel_print_header(void *obj, void *arg, int flags)
{
	struct ast_sip_cli_context *context = arg;
	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
	int filler = CLI_LAST_TABSTOP - indent - 13;

	ast_assert(context->output_buffer != NULL);

	ast_str_append(&context->output_buffer, 0,
		"%*s:  <ChannelId%*.*s>  <State.....>  <Time.....>\n",
		indent, "Channel", filler, filler, CLI_HEADER_FILLER);
	if (context->recurse) {
		context->indent_level++;
		indent = CLI_INDENT_TO_SPACES(context->indent_level);
		filler = CLI_LAST_TABSTOP - indent - 38;
		ast_str_append(&context->output_buffer, 0,
			"%*s: <DialedExten%*.*s>  CLCID: <ConnectedLineCID.......>\n",
			indent, "Exten", filler, filler, CLI_HEADER_FILLER);
		context->indent_level--;
	}

	return 0;
}
コード例 #7
0
ファイル: config_auth.c プロジェクト: huangjingpei/asterisk
static int cli_print_header(void *obj, void *arg, int flags)
{
	struct ast_sip_cli_context *context = arg;
	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
	int filler = CLI_MAX_WIDTH - indent - 20;

	ast_assert(context->output_buffer != NULL);

	ast_str_append(&context->output_buffer, 0,
		"%*s:  <AuthId/UserName%*.*s>\n", indent, "I/OAuth", filler, filler,
		CLI_HEADER_FILLER);

	return 0;
}
コード例 #8
0
ファイル: pjsip_distributor.c プロジェクト: scudella/asterisk
static int cli_unid_print_header(void *obj, void *arg, int flags)
{
	struct ast_sip_cli_context *context = arg;
	RAII_VAR(struct ast_sip_cli_formatter_entry *, formatter_entry, NULL, ao2_cleanup);

	int indent = CLI_INDENT_TO_SPACES(context->indent_level);
	int filler = CLI_LAST_TABSTOP - indent - 7;

	ast_assert(context->output_buffer != NULL);

	ast_str_append(&context->output_buffer, 0,
		"%*s:  <IP Address%*.*s>  <Count> <Age(sec)>\n",
		indent, "Request", filler, filler, CLI_HEADER_FILLER);

	return 0;
}
コード例 #9
0
ファイル: location.c プロジェクト: litnimax/asterisk
static int cli_aor_print_body(void *obj, void *arg, int flags)
{
	struct ast_sip_aor *aor = obj;
	struct ast_sip_cli_context *context = arg;
	int indent;
	int flexwidth;

	ast_assert(context->output_buffer != NULL);

//	context->current_aor = aor;

	indent = CLI_INDENT_TO_SPACES(context->indent_level);
	flexwidth = CLI_LAST_TABSTOP - indent - 12;

	ast_str_append(&context->output_buffer, 0, "%*s:  %-*.*s %12u\n",
		indent,
		"Aor",
		flexwidth, flexwidth,
		ast_sorcery_object_get_id(aor), aor->max_contacts);

	if (context->recurse) {
		struct ast_sip_cli_formatter_entry *formatter_entry;

		context->indent_level++;

		formatter_entry = ast_sip_lookup_cli_formatter("contact");
		if (formatter_entry) {
			formatter_entry->iterate(aor, formatter_entry->print_body, context);
			ao2_ref(formatter_entry, -1);
		}

		context->indent_level--;

		if (context->indent_level == 0) {
			ast_str_append(&context->output_buffer, 0, "\n");
		}
	}

	if (context->show_details || (context->show_details_only_level_0 && context->indent_level == 0)) {
		ast_str_append(&context->output_buffer, 0, "\n");
		ast_sip_cli_print_sorcery_objectset(aor, context, 0);
	}

	return 0;
}
コード例 #10
0
ファイル: pjsip_distributor.c プロジェクト: scudella/asterisk
static int cli_unid_print_body(void *obj, void *arg, int flags)
{
	struct unidentified_request *unid = obj;
	struct ast_sip_cli_context *context = arg;
	int indent;
	int flexwidth;
	int64_t ms = ast_tvdiff_ms(ast_tvnow(), unid->first_seen);

	ast_assert(context->output_buffer != NULL);

	indent = CLI_INDENT_TO_SPACES(context->indent_level);
	flexwidth = CLI_LAST_TABSTOP - 4;

	ast_str_append(&context->output_buffer, 0, "%*s:  %-*.*s  %7d %10.3f\n",
		indent,
		"Request",
		flexwidth, flexwidth,
		unid->src_name, unid->count,  ms / 1000.0);

	return 0;
}
コード例 #11
0
ファイル: config_auth.c プロジェクト: huangjingpei/asterisk
static int cli_print_body(void *obj, void *arg, int flags)
{
	struct ast_sip_auth *auth = obj;
	struct ast_sip_cli_context *context = arg;
	char title[32];

	ast_assert(context->output_buffer != NULL);

	snprintf(title, 32, "%sAuth", context->auth_direction ? context->auth_direction : "");

	ast_str_append(&context->output_buffer, 0, "%*s:  %s/%s\n",
		CLI_INDENT_TO_SPACES(context->indent_level), title,
		ast_sorcery_object_get_id(auth), auth->auth_user);

	if (context->show_details
		|| (context->show_details_only_level_0 && context->indent_level == 0)) {
		ast_str_append(&context->output_buffer, 0, "\n");
		ast_sip_cli_print_sorcery_objectset(auth, context, 0);
	}

	return 0;
}