Exemplo n.º 1
0
static struct chanspy_ds *next_channel(struct ast_channel *chan,
	const struct ast_channel *last, const char *spec,
	const char *exten, const char *context, struct chanspy_ds *chanspy_ds)
{
	struct ast_channel *next;
	const size_t pseudo_len = strlen("DAHDI/pseudo");

redo:
	if (!ast_strlen_zero(spec))
		next = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));

	else if (!ast_strlen_zero(exten))
		next = ast_walk_channel_by_exten_locked(last, exten, context);
	else
		next = ast_channel_walk_locked(last);

	if (!next)
		return NULL;

	if (!strncmp(next->name, "DAHDI/pseudo", pseudo_len)) {
		last = next;
		ast_channel_unlock(next);
		goto redo;
	} else if (next == chan) {
		last = next;
		ast_channel_unlock(next);
		goto redo;
	}

	return setup_chanspy_ds(next, chanspy_ds);
}
Exemplo n.º 2
0
static struct chanspy_ds *next_channel(struct ast_channel *chan,
	const struct ast_channel *last, const char *spec,
	const char *exten, const char *context, struct chanspy_ds *chanspy_ds)
{
	struct ast_channel *this;
	char channel_name[AST_CHANNEL_NAME];
	static size_t PSEUDO_CHAN_LEN = 0;

	if (!PSEUDO_CHAN_LEN) {
		PSEUDO_CHAN_LEN = *dahdi_chan_name_len + strlen("/pseudo");
	}

redo:
	if (spec)
		this = ast_walk_channel_by_name_prefix_locked(last, spec, strlen(spec));
	else if (exten)
		this = ast_walk_channel_by_exten_locked(last, exten, context);
	else
		this = ast_channel_walk_locked(last);

	if (!this)
		return NULL;

	snprintf(channel_name, AST_CHANNEL_NAME, "%s/pseudo", dahdi_chan_name);
	if (!strncmp(this->name, channel_name, PSEUDO_CHAN_LEN)) {
		last = this;
		ast_channel_unlock(this);
		goto redo;
	} else if (this == chan) {
		last = this;
		ast_channel_unlock(this);
		goto redo;
	}

	return setup_chanspy_ds(this, chanspy_ds);
}