summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-05-19 16:46:06 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2009-05-19 16:46:06 +0000
commited38d8829eb28229ae6cb0e881f1374d55302221 (patch)
treed830fb98493f4fae8b839c441ec1d68861471ee2
parent096417e3731173f0a70625d413b4d68a449adec1 (diff)
dahdi-perl: make dahdi_genconf default to hardhdlc
dahdi_genconf's 'bri_hardhdlc' parameter changes. Should generally work with no need for manual configuration unless you use a bristuffed driver (zaphfc, qozap). See notes in genconf_parameters. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@6647 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rwxr-xr-xxpp/dahdi_genconf2
-rw-r--r--xpp/genconf_parameters15
-rw-r--r--xpp/perl_modules/Dahdi/Config/Gen/System.pm43
-rw-r--r--xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm1
-rw-r--r--xpp/perl_modules/Dahdi/Config/Params.pm2
-rw-r--r--xpp/perl_modules/Dahdi/Xpp/Xpd.pm20
6 files changed, 67 insertions, 16 deletions
diff --git a/xpp/dahdi_genconf b/xpp/dahdi_genconf
index 8167514..b03c42b 100755
--- a/xpp/dahdi_genconf
+++ b/xpp/dahdi_genconf
@@ -128,7 +128,7 @@ It uses two information sources:
The actual dahdi hardware is automatically detected on the host.
-=item /etc/dahdi/genconf_params
+=item /etc/dahdi/genconf_parameters
A configuration file that supplements the hardware information.
Its location may be overriden via the C<GENCONF_PARAMETERS> environment
diff --git a/xpp/genconf_parameters b/xpp/genconf_parameters
index 1ffc22f..3a4b2fc 100644
--- a/xpp/genconf_parameters
+++ b/xpp/genconf_parameters
@@ -89,10 +89,17 @@
#echo_can oslec
#echo_can none # to avoid echo canceler altogether
-# bri_hardhdlc: If this parameter is set to 'yes', in the entries for
-# BRI cards 'hardhdlc' will be used instead of 'dchan' (an alias for
-# 'fcshdlc').
-#bri_hardhdlc yes
+# bri_hardhdlc:
+# 'yes' - forces BRI cards to use 'hardhdlc' signalling.
+# 'no' - forces BRI cards to use 'dchan' (an alias for 'fcshdlc').
+# It is usefull only for dahdi with the bristuff patch.
+#
+# If it is left out or set to 'auto':
+# * Information supplied by the driver is used to decide:
+# - Currently implemented for Astribanks.
+# - Taken from /sys/bus/xpds/drivers/bri/dchan_hardhdlc.
+# * Without this info, falls back to 'hardhdlc'.
+#bri_hardhdlc auto
# For MFC/R2 Support: 'R2' will make E1 spans CAS and with the
# 'r2_idle_bits' bit in system.conf . It will also make dahdi_genconf default
diff --git a/xpp/perl_modules/Dahdi/Config/Gen/System.pm b/xpp/perl_modules/Dahdi/Config/Gen/System.pm
index 6ec705f..3f9217b 100644
--- a/xpp/perl_modules/Dahdi/Config/Gen/System.pm
+++ b/xpp/perl_modules/Dahdi/Config/Gen/System.pm
@@ -48,11 +48,6 @@ sub gen_digital($$) {
$span_crc4 = '';
$framing = 'cas';
}
- my $dchan_type = 'dchan';
- if ($span->is_bri() && is_true($gconfig->{'bri_hardhdlc'})) {
- $dchan_type = 'hardhdlc';
- }
-
$timing = ($termtype eq 'NT') ? 0 : $bri_te_last_timing++;
printf "span=%d,%d,%d,%s,%s%s%s\n",
$num,
@@ -63,14 +58,42 @@ sub gen_digital($$) {
$span_crc4,
$span_yellow;
printf "# termtype: %s\n", lc($termtype);
- if ($gconfig->{'pri_connection_type'} eq 'PRI') {
+ my $dchan_type;
+ if ($span->is_bri()) {
+ my $use_bristuff = 0;
+ my $cfg_hardhdlc = $gconfig->{'bri_hardhdlc'};
+ my $xpd = $span->xpd();
+ if(!defined($cfg_hardhdlc) || $cfg_hardhdlc =~ /AUTO/i) {
+ # Autodetect
+ if(defined($xpd)) {
+ # Bristuff?
+ if(defined($xpd->dchan_hardhdlc) && !is_true($xpd->dchan_hardhdlc)) {
+ $use_bristuff = 1;
+ }
+ }
+ } elsif(!is_true($cfg_hardhdlc)) {
+ $use_bristuff = 1;
+ }
+ if($use_bristuff) {
+ $dchan_type = 'dchan';
+ } else {
+ $dchan_type = 'hardhdlc';
+ }
printf "bchan=%s\n", Dahdi::Config::Gen::bchan_range($span);
my $dchan = $span->dchan();
printf "$dchan_type=%d\n", $dchan->num();
- } elsif ($gconfig->{'pri_connection_type'} eq 'R2' ) {
- my $idle_bits = $gconfig->{'r2_idle_bits'};
- printf "cas=%s:$idle_bits\n", Dahdi::Config::Gen::bchan_range($span);
- printf "dchan=%d\n", $span->dchan()->num();
+ } elsif($span->is_pri()) {
+ if ($gconfig->{'pri_connection_type'} eq 'PRI') {
+ printf "bchan=%s\n", Dahdi::Config::Gen::bchan_range($span);
+ my $dchan = $span->dchan();
+ printf "dchan=%d\n", $dchan->num();
+ } elsif ($gconfig->{'pri_connection_type'} eq 'R2' ) {
+ my $idle_bits = $gconfig->{'r2_idle_bits'};
+ printf "cas=%s:$idle_bits\n", Dahdi::Config::Gen::bchan_range($span);
+ printf "dchan=%d\n", $span->dchan()->num();
+ }
+ } else {
+ die "Digital span $num is not BRI, nor PRI?";
}
print_echo_can($gconfig, Dahdi::Config::Gen::bchan_range($span));
}
diff --git a/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm b/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm
index 208fcfa..a98f912 100644
--- a/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm
+++ b/xpp/perl_modules/Dahdi/Config/Gen/Xpporder.pm
@@ -2,6 +2,7 @@ package Dahdi::Config::Gen::Xpporder;
use strict;
use Dahdi::Config::Gen qw(is_true);
+use Dahdi::Xpp;
sub new($$$) {
my $pack = shift || die;
diff --git a/xpp/perl_modules/Dahdi/Config/Params.pm b/xpp/perl_modules/Dahdi/Config/Params.pm
index 2ff2a0e..816b5c1 100644
--- a/xpp/perl_modules/Dahdi/Config/Params.pm
+++ b/xpp/perl_modules/Dahdi/Config/Params.pm
@@ -106,7 +106,7 @@ sub item($$) {
brint_overlap => 'no',
bri_sig_style => 'bri_ptmp',
echo_can => 'mg2',
- bri_hardhdlc => 'no',
+ bri_hardhdlc => 'auto',
pri_connection_type => 'PRI',
r2_idle_bits => '1101',
'pri_termtype' => [ 'SPAN/* TE' ],
diff --git a/xpp/perl_modules/Dahdi/Xpp/Xpd.pm b/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
index a1e7eb3..55439fc 100644
--- a/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
+++ b/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
@@ -85,6 +85,25 @@ sub xpd_old_getoffhook($) {
my %attr_missing_warned; # Prevent duplicate warnings
+sub xpd_driver_getattr($$) {
+ my $xpd = shift || die;
+ my $attr = shift || die;
+ $attr = lc($attr);
+ my ($busnum, $unitnum, $subunitnum) = ($xpd->xbus->num, $xpd->unit, $xpd->subunit);
+ my $file = sprintf "$Dahdi::Xpp::sysfs_xpds/%02d:%1d:%1d/driver/$attr",
+ $busnum, $unitnum, $subunitnum;
+ if(!defined($file)) {
+ warn "$0: xpd_driver_getattr($attr) -- Missing attribute.\n" if
+ $attr_missing_warned{$attr};
+ return undef;
+ }
+ open(F, $file) || return undef;
+ my $val = <F>;
+ close F;
+ chomp $val;
+ return $val;
+}
+
sub xpd_getattr($$) {
my $xpd = shift || die;
my $attr = shift || die;
@@ -198,6 +217,7 @@ sub new($$$$$) {
if($type =~ /BRI_(NT|TE)/) {
$self->{IS_BRI} = 1;
$self->{TERMTYPE} = $1;
+ $self->{DCHAN_HARDHDLC} = $self->xpd_driver_getattr('dchan_hardhdlc');
}
$self->{IS_PRI} = ($type =~ /[ETJ]1/);
$self->{IS_DIGITAL} = ( $self->{IS_BRI} || $self->{IS_PRI} );