summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-04-29 22:44:32 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-04-29 22:44:32 +0000
commit21263d58b5659eb42d200a38b17da18fce49a881 (patch)
tree205cbb81e5906362c4be4eb11800f028694c620f /xpp/utils/zconf
parent2c5d383ce7ad82476fe1687b9d29aad87a80e6ee (diff)
xpp rev. 3814:
* Protocol no. 2.6: syncing improvements. * Support for 8-port Astribank BRI. * Firmware unloading now works: rmmod xpp_usb; /etc/hotplug/usb/xpp_fxloader reset * Defaults of kernel parameters are now part of parameter description. * World-readable kernel parameters. * No need for extra patch beyond bristuff for Astribank BRI. * Default poll intervals changed: 500 in BRI and FXO. * Allow changing FXS polls interval at run time. * BRI initalization fixed on SUSE (path to logger). * When using the SUSE zaptel rpm package, set modules_var=ZAPTEL_MODULES in /etc/sysconfig/zaptel . * zt_registration not verbose by default. * xpp_sync warns if FXO is sync slave. * Fixed genzaptelconf -z (zapscan output emulation). * PCM fixes. * Solves "multiple ticks" bug. No need for pcm_tasklets workaround. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2478 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils/zconf')
-rw-r--r--xpp/utils/zconf/Zaptel.pm5
-rw-r--r--xpp/utils/zconf/Zaptel/Chans.pm38
-rw-r--r--xpp/utils/zconf/Zaptel/Span.pm58
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp.pm17
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Xbus.pm36
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Xpd.pm31
6 files changed, 176 insertions, 9 deletions
diff --git a/xpp/utils/zconf/Zaptel.pm b/xpp/utils/zconf/Zaptel.pm
index 394aa8e..7642b0e 100644
--- a/xpp/utils/zconf/Zaptel.pm
+++ b/xpp/utils/zconf/Zaptel.pm
@@ -5,7 +5,10 @@ package Zaptel;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
+use Zaptel::Span;
my $proc_base = "/proc/zaptel";
diff --git a/xpp/utils/zconf/Zaptel/Chans.pm b/xpp/utils/zconf/Zaptel/Chans.pm
index 31bc5f7..3364060 100644
--- a/xpp/utils/zconf/Zaptel/Chans.pm
+++ b/xpp/utils/zconf/Zaptel/Chans.pm
@@ -5,9 +5,12 @@ package Zaptel::Chans;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -36,11 +39,42 @@ sub new($$$$$) {
$type = $1; # One of our AB
} elsif(defined $info) {
$type = (split(/\s+/, $info))[0];
+ $type = 'FXS' if $type =~ /^FXS/;
+ $type = 'FXO' if $type =~ /^FXO/;
} else {
- $type = $fqn;
+ $type = undef;
}
$self->type($type);
return $self;
}
+my $ztcfg = $ENV{ZTCFG} || '/sbin/ztcfg';
+sub probe_type($) {
+ my $self = shift;
+ my $fqn = $self->fqn;
+ my $num = $self->num;
+ my $type;
+
+ if($fqn =~ m:WCTDM/|\ WRTDM/|OPVXA1200/:) {
+ my %maybe;
+
+ undef %maybe;
+ foreach my $sig (qw(fxo fxs)) {
+ my $cmd = "echo ${sig}ks=$num | $ztcfg -c /dev/fd/0";
+
+ $maybe{$sig} = system("$cmd >/dev/null 2>&1") == 0;
+ }
+ if($maybe{fxo} and $maybe{fxs}) {
+ $type = 'EMPTY';
+ } elsif($maybe{fxo}) {
+ $type = 'FXS';
+ } elsif($maybe{fxs}) {
+ $type = 'FXO';
+ }
+ } else {
+ $type = $self->type;
+ }
+ return $type;
+}
+
1;
diff --git a/xpp/utils/zconf/Zaptel/Span.pm b/xpp/utils/zconf/Zaptel/Span.pm
index 08ebae2..c020d2f 100644
--- a/xpp/utils/zconf/Zaptel/Span.pm
+++ b/xpp/utils/zconf/Zaptel/Span.pm
@@ -5,7 +5,9 @@ package Zaptel::Span;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
use Zaptel::Chans;
my $proc_base = "/proc/zaptel";
@@ -16,6 +18,7 @@ sub chans($) {
}
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -27,6 +30,25 @@ sub AUTOLOAD {
}
}
+sub by_number($) {
+ my $span_number = shift;
+ die "Missing span number" unless defined $span_number;
+ my @spans = Zaptel::spans();
+
+ my ($span) = grep { $_->num == $span_number } @spans;
+ return $span;
+}
+
+my @bri_strings = (
+ 'BRI_(NT|TE)',
+ '(?:quad|octo)BRI PCI ISDN Card.* \[(NT|TE)\]\ ',
+ 'octoBRI \[(NT|TE)\] ',
+ 'HFC-S PCI A ISDN.* \[(NT|TE)\] '
+ );
+
+our $ZAPBRI_NET = 'bri_net';
+our $ZAPBRI_CPE = 'bri_cpe';
+
sub new($$) {
my $pack = shift or die "Wasn't called as a class method\n";
my $num = shift or die "Missing a span number parameter\n";
@@ -35,6 +57,17 @@ sub new($$) {
open(F, "$proc_base/$num") or die "Failed to open '$proc_base/$num\n";
my $head = <F>;
chomp $head;
+ foreach my $cardtype (@bri_strings) {
+ if($head =~ m/$cardtype/) {
+ $self->{IS_BRI} = 1;
+ $self->{TERMTYPE} = $1;
+ $self->{DCHAN_IDX} = 2;
+ $self->{BCHAN_LIST} = [ 0, 1 ];
+ last;
+ }
+ }
+ die "$0: Unkown TERMTYPE [NT/TE]\n"
+ if $self->is_bri and !defined $self->{TERMTYPE};
($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3];
$self->{CHANS} = [];
while(<F>) {
@@ -47,7 +80,30 @@ sub new($$) {
push(@{$self->{CHANS}}, $c);
}
close F;
+ if($self->is_bri()) {
+ $self->{CODING} = 'ami';
+ $self->{YELLOW} = undef;
+ $self->{DCHAN} = ($self->chans())[$self->{DCHAN_IDX}];
+ $self->{BCHANS} = [ ($self->chans())[@{$self->{BCHAN_LIST}}] ];
+ # Infer some info from channel name:
+ my $first_chan = ($self->chans())[0] || die "$0: No channels in span #$num\n";
+ my $chan_fqn = $first_chan->fqn();
+ if($chan_fqn =~ m(ZTHFC.*/|ztqoz.*/|XPP_BRI_.*/)) { # BRI
+ $self->{FRAMING} = 'ccs';
+ $self->{SWITCHTYPE} = 'euroisdn';
+ $self->{SIGNALLING} = ($self->{TERMTYPE} eq 'NT') ? $ZAPBRI_NET : $ZAPBRI_CPE ;
+ } elsif($chan_fqn =~ m(ztgsm.*/)) { # Junghanns's GSM cards.
+ $self->{FRAMING} = 'ccs';
+ $self->{SIGNALLING} = 'gsm';
+ }
+ }
return $self;
}
+sub bchans($) {
+ my $self = shift || die;
+
+ return @{$self->{BCHANS}};
+}
+
1;
diff --git a/xpp/utils/zconf/Zaptel/Xpp.pm b/xpp/utils/zconf/Zaptel/Xpp.pm
index b627438..dd1f34c 100644
--- a/xpp/utils/zconf/Zaptel/Xpp.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp.pm
@@ -5,7 +5,9 @@ package Zaptel::Xpp;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
use Zaptel::Xpp::Xbus;
my $proc_base = "/proc/xpp";
@@ -33,7 +35,7 @@ sub xbuses {
$name =~ s/://;
$name =~ /XBUS-(\d\d)/ or die "Bad XBUS number: $name";
my $num = $1;
- @attr = map { $_ = uc($_); split(/=/); } @attr;
+ @attr = map { split(/=/); } @attr;
my $xbus = Zaptel::Xpp::Xbus->new(NAME => $name, NUM => $num, @attr);
push(@xbuses, $xbus);
}
@@ -51,6 +53,17 @@ sub xbuses {
return sort $sorter @xbuses;
}
+sub xpd_of_span($) {
+ my $span = shift or die "Missing span parameter";
+ return undef unless defined $span;
+ foreach my $xbus (Zaptel::Xpp::xbuses('SORT_CONNECTOR')) {
+ foreach my $xpd ($xbus->xpds()) {
+ return $xpd if $xpd->fqn eq $span->name;
+ }
+ }
+ return undef;
+}
+
sub sync {
my $newsync = shift;
my $result;
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
index 8d9d340..772e050 100644
--- a/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp/Xbus.pm
@@ -5,12 +5,15 @@ package Zaptel::Xpp::Xbus;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
use Zaptel::Xpp::Xpd;
my $proc_base = "/proc/xpp";
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -27,9 +30,37 @@ sub xpds($) {
return @{$xbus->{XPDS}};
}
+sub by_number($) {
+ my $busnumber = shift;
+ die "Missing xbus number parameter" unless defined $busnumber;
+ my @xbuses = Zaptel::Xpp::xbuses();
+
+ my ($xbus) = grep { $_->num == $busnumber } @xbuses;
+ return $xbus;
+}
+
+sub get_xpd_by_number($$) {
+ my $xbus = shift;
+ my $xpdnum = shift;
+ die "Missing XPD number parameter" unless defined $xpdnum;
+ my @xpds = $xbus->xpds;
+ return $xpds[$xpdnum];
+}
+
sub new($$) {
my $pack = shift or die "Wasn't called as a class method\n";
- my $self = { @_ };
+ my $self = {};
+ while(@_) {
+ my ($k, $v) = @_;
+ shift; shift;
+ # Keys in all caps
+ $k = uc($k);
+ # Some values are in all caps as well
+ if($k =~ /^(STATUS)$/) {
+ $v = uc($v);
+ }
+ $self->{$k} = $v;
+ }
bless $self, $pack;
$self->{NAME} or die "Missing xbus name";
my $prefix = "$proc_base/" . $self->{NAME};
@@ -45,6 +76,7 @@ sub new($$) {
);
push(@{$self->{XPDS}}, $xpd);
}
+ @{$self->{XPDS}} = sort { $a->num <=> $b->num } @{$self->{XPDS}};
return $self;
}
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
index 180b7ea..94176b8 100644
--- a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
@@ -5,11 +5,14 @@ package Zaptel::Xpp::Xpd;
# This program is free software; you can redistribute and/or
# modify it under the same terms as Perl itself.
#
-#use strict;
+# $Id$
+#
+use strict;
my $proc_base = "/proc/xpp";
# Accessors (miniperl does not have Class:Accessor)
+our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $name = uc($AUTOLOAD);
@@ -21,6 +24,32 @@ sub AUTOLOAD {
}
}
+sub blink($$) {
+ my $self = shift;
+ my $on = shift;
+ my $result;
+
+ my $file = "$proc_base/" . $self->fqn . "/blink";
+ die "$file is missing" unless -f $file;
+ # First query
+ open(F, "$file") or die "Failed to open $file for reading: $!";
+ $result = <F>;
+ chomp $result;
+ close F;
+ if(defined($on) and $on ne $result) { # Now change
+ open(F, ">$file") or die "Failed to open $file for writing: $!";
+ print F ($on)?"1":"0";
+ if(!close(F)) {
+ if($! == 17) { # EEXISTS
+ # good
+ } else {
+ undef $result;
+ }
+ }
+ }
+ return $result;
+}
+
sub zt_registration($$) {
my $self = shift;
my $on = shift;