dahdi: Filter 'HWEC' from DAHDI_GETVERSION results if hwec is really not present.

Internally in DAHDI there is always a hardware echocan factory registered and
available. Having this factory always registered allows for DAHDI to work in a
backward compatible fashion. Namely, by default DAHDI will always use a hardware
echocan if one is available unless 'hwec_overrides_swec' dahdi module parameter
is set to 0 on load. However, if there were no real hardware echocans available
in the system dahdi would still report "Echo Canceller(s): HWEC" in the
dahdi_cfg -v output since the hwec factory is always there.

After this change dahdi_cfg will no longer report HWEC as one of the available
echocans if there isn't a physical span present that actually has a hardware
echocan.

Internal-Issue-ID: DAHLIN-300
Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@10727 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Shaun Ruffell
2012-10-04 20:24:24 +00:00
committed by Russ Meyerriecks
parent ca710bae94
commit 25ce85e770

View File

@@ -5137,19 +5137,57 @@ static int dahdi_ioctl_sfconfig(unsigned long data)
return res;
}
/* Returns true if there are any hardware echocan on any span. */
static bool dahdi_any_hwec_available(void)
{
int i;
bool hwec_available = false;
struct dahdi_span *s;
mutex_lock(&registration_mutex);
list_for_each_entry(s, &span_list, spans_node) {
for (i = 0; i < s->channels; ++i) {
struct dahdi_chan *const chan = s->chans[i];
if (dahdi_is_hwec_available(chan)) {
hwec_available = true;
break;
}
}
}
mutex_unlock(&registration_mutex);
return hwec_available;
}
static int dahdi_ioctl_get_version(unsigned long data)
{
struct dahdi_versioninfo vi;
struct ecfactory *cur;
size_t space = sizeof(vi.echo_canceller) - 1;
bool have_hwec = dahdi_any_hwec_available();
memset(&vi, 0, sizeof(vi));
strlcpy(vi.version, dahdi_version, sizeof(vi.version));
spin_lock(&ecfactory_list_lock);
list_for_each_entry(cur, &ecfactory_list, list) {
const char * const ec_name = cur->ec->get_name(NULL);
if ((ec_name == hwec_def_name) && !have_hwec) {
/*
* The hardware echocan factory is always registered so
* that hwec can be configured on the channels as if it
* was a software echocan. However, it can be confusing
* to list it as one of the available options in the
* output of dahdi_cfg if there isn't a REAL hardware
* echocanceler attached to any of the spans. In that
* case, do not report the presence of the hardware
* echocan factory to userspace.
*
*/
continue;
}
strncat(vi.echo_canceller + strlen(vi.echo_canceller),
cur->ec->get_name(NULL), space);
space -= strlen(cur->ec->get_name(NULL));
ec_name, space);
space -= strlen(ec_name);
if (space < 1)
break;
if (cur->list.next && (cur->list.next != &ecfactory_list)) {