summaryrefslogtreecommitdiff
path: root/xpp/utils/zconf/Zaptel/Xpp
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/zconf/Zaptel/Xpp')
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Line.pm59
-rw-r--r--xpp/utils/zconf/Zaptel/Xpp/Xpd.pm43
2 files changed, 83 insertions, 19 deletions
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Line.pm b/xpp/utils/zconf/Zaptel/Xpp/Line.pm
new file mode 100644
index 0000000..e3e04f0
--- /dev/null
+++ b/xpp/utils/zconf/Zaptel/Xpp/Line.pm
@@ -0,0 +1,59 @@
+package Zaptel::Xpp::Line;
+#
+# Written by Oron Peled <oron@actcom.co.il>
+# Copyright (C) 2008, Xorcom
+# This program is free software; you can redistribute and/or
+# modify it under the same terms as Perl itself.
+#
+# $Id$
+#
+use strict;
+use Zaptel::Utils;
+
+my $proc_base = "/proc/xpp";
+
+sub new($$$) {
+ my $pack = shift or die "Wasn't called as a class method\n";
+ my $xpd = shift or die;
+ my $index = shift;
+ defined $index or die;
+ my $self = {};
+ bless $self, ref($xpd);
+ $self->{XPD} = $xpd;
+ $self->{INDEX} = $index;
+ return $self;
+}
+
+sub create_all($$) {
+ my $pack = shift or die "Wasn't called as a class method\n";
+ my $xpd = shift || die;
+ my $procdir = shift || die;
+ local $/ = "\n";
+ my @lines;
+ for(my $i = 0; $i < $xpd->{CHANNELS}; $i++) {
+ my $line = Zaptel::Xpp::Line->new($xpd, $i);
+ push(@lines, $line);
+ }
+ $xpd->{LINES} = \@lines;
+ my ($infofile) = glob "$procdir/*_info";
+ die "Failed globbing '$procdir/*_info'" unless defined $infofile;
+ my $type = $xpd->type;
+ open(F, "$infofile") || die "Failed opening '$infofile': $!";
+ while (<F>) {
+ chomp;
+ if($type eq 'FXO') {
+ if(s/^\s*battery\s*:\s*//) {
+ my @batt = split;
+ foreach my $l (@lines) {
+ die unless @batt;
+ $l->{BATTERY} = shift @batt;
+ }
+ die if @batt;
+ }
+ }
+ }
+ close F;
+}
+
+
+1;
diff --git a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
index c05cfdb..326aafd 100644
--- a/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
+++ b/xpp/utils/zconf/Zaptel/Xpp/Xpd.pm
@@ -9,6 +9,8 @@ package Zaptel::Xpp::Xpd;
#
use strict;
use Zaptel::Utils;
+use Zaptel::Xpp;
+use Zaptel::Xpp::Line;
my $proc_base = "/proc/xpp";
@@ -64,21 +66,15 @@ sub zt_registration($$) {
return $result;
}
-#
-# Backward compatibility for old drivers
-# before changeset:5119
-#
-# Newer drivers should directly have $xpd->spanno
-#
-sub spanno_of_xpd($) {
- my $xpd = shift || die;
-
- warn "Running on old driver. Keep going...\n";
- use Zaptel;
- my @spans = Zaptel::spans;
-
- my ($span) = grep { $_->name eq $xpd->fqn } @spans;
- return ($span) ? $span->num : 0;
+sub xpds_by_spanno() {
+ my @xbuses = Zaptel::Xpp::xbuses("SORT_CONNECTOR");
+ my @xpds = map { $_->xpds } @xbuses;
+ @xpds = grep { $_->spanno } @xpds;
+ @xpds = sort { $a->spanno <=> $b->spanno } @xpds;
+ my @spanno = map { $_->spanno } @xpds;
+ my @idx;
+ @idx[@spanno] = @xpds; # The spanno is the index now
+ return @idx;
}
sub new($$) {
@@ -92,8 +88,18 @@ sub new($$) {
local $/ = "\n";
open(F, "$procdir/summary") || die "Missing summary file in $procdir";
my $head = <F>;
- chomp $head;
- # "XPD-00 (BRI_TE ,card present, span 3)"
+ chomp $head; # "XPD-00 (BRI_TE ,card present, span 3)"
+ # The driver does not export the number of channels...
+ # Let's find it indirectly
+ while(<F>) {
+ chomp;
+ if(s/^\s*offhook\s*:\s*//) {
+ my @offhook = split;
+ @offhook || die "No channels in '$procdir/summary'";
+ $self->{CHANNELS} = @offhook;
+ last;
+ }
+ }
close F;
$head =~ s/^(XPD-(\d\d))\s+// || die;
$self->{ID} = $2;
@@ -105,13 +111,12 @@ sub new($$) {
#warn "Garbage in '$procdir/summary': rest='$rest'\n" if $rest;
if($span =~ s/span\s+(\d+)//) { # since changeset:5119
$self->{SPANNO} = $1;
- } else {
- $self->{SPANNO} = $self->spanno_of_xpd;
}
$self->{TYPE} = $type;
$self->{IS_BRI} = ($type =~ /BRI_(NT|TE)/);
$self->{IS_PRI} = ($type =~ /[ETJ]1_(NT|TE)/);
$self->{IS_DIGITAL} = ( $self->{IS_BRI} || $self->{IS_PRI} );
+ Zaptel::Xpp::Line->create_all($self, $procdir);
return $self;
}