summaryrefslogtreecommitdiff
path: root/xpp/perl_modules/Dahdi/Span.pm
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-29 16:57:48 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-06-29 16:57:48 +0000
commit0fd300bf14ba0826ec96017886f3d26530c4368e (patch)
tree8cae5d7e1c7eeb5a476a6d1b0bd93a59b0fc5712 /xpp/perl_modules/Dahdi/Span.pm
parent5156247998b357c16e8d634f2f938d218ea4cf12 (diff)
dahdi_genconf configuration separated from the kernel config.
* Using /etc/dahdi/genconf_parameters. * A shiny new format (sample file included). * xpp_fxloader is configured from /etc/dahdi/init.conf (like the init.d script). * Yet some more string cleanups. git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4484 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/perl_modules/Dahdi/Span.pm')
-rw-r--r--xpp/perl_modules/Dahdi/Span.pm61
1 files changed, 55 insertions, 6 deletions
diff --git a/xpp/perl_modules/Dahdi/Span.pm b/xpp/perl_modules/Dahdi/Span.pm
index a196ce2..96a18b4 100644
--- a/xpp/perl_modules/Dahdi/Span.pm
+++ b/xpp/perl_modules/Dahdi/Span.pm
@@ -137,7 +137,7 @@ my @bri_strings = (
);
my @pri_strings = (
- '(E1|T1|J1)_(NT|TE)',
+ '(E1|T1|J1)',
'Tormenta 2 .*Quad (E1|T1)', # tor2.
'Digium Wildcard .100P (T1|E1)/', # wct1xxp
'ISA Tormenta Span 1', # torisa
@@ -166,7 +166,6 @@ sub init_proto($$) {
$self->{DCHAN_IDX} = 23;
$self->{BCHAN_LIST} = [ 0 .. 22 ];
}
- $self->{TYPE} = "${proto}_$self->{TERMTYPE}";
}
sub new($$) {
@@ -207,7 +206,7 @@ sub new($$) {
my ($proto) = grep(/(E1|T1|J1)/, @info);
$proto = 'UNKNOWN' unless defined $proto;
my ($termtype) = grep(/(NT|TE)/, @info);
- $termtype = 'TE' unless defined $termtype;
+ $termtype = 'UNKNOWN' unless defined $termtype;
$self->{IS_DIGITAL} = 1;
$self->{IS_PRI} = 1;
@@ -216,8 +215,6 @@ sub new($$) {
last;
}
}
- die "$0: Unkown TERMTYPE [NT/TE]\n"
- if $self->is_digital and !defined $self->{TERMTYPE};
($self->{NAME}, $self->{DESCRIPTION}) = (split(/\s+/, $head, 4))[2, 3];
$self->{IS_DAHDI_SYNC_MASTER} =
($self->{DESCRIPTION} =~ /\(MASTER\)/) ? 1 : 0;
@@ -286,7 +283,6 @@ sub new($$) {
} else {
die "'$self->{PROTO}' unsupported yet";
}
- $self->{SIGNALLING} = ($self->{TERMTYPE} eq 'NT') ? $DAHDI_PRI_NET : $DAHDI_PRI_CPE ;
}
return $self;
}
@@ -297,4 +293,57 @@ sub bchans($) {
return @{$self->{BCHANS}};
}
+sub set_termtype($$) {
+ my $span = shift || die;
+ my $termtype = shift || die;
+ $span->{TERMTYPE} = $termtype;
+ $span->{SIGNALLING} = ($termtype eq 'NT') ? $DAHDI_PRI_NET : $DAHDI_PRI_CPE ;
+ $span->{TYPE} = $span->proto . "_$termtype";
+}
+
+sub pri_set_fromconfig($$) {
+ my $span = shift || die;
+ my $genconf = shift || die;
+ my $name = $span->name;
+# if(defined $termtype) {
+# die "Termtype for $name already defined as $termtype\n";
+# }
+ my $pri_termtype = $genconf->{pri_termtype};
+ my @pri_specs;
+ if(defined $pri_termtype) {
+ @pri_specs = @{$pri_termtype};
+ }
+ push(@pri_specs , 'SPAN/* TE'); # Default
+ my @patlist = ( "SPAN/" . $span->num );
+ my ($xbus_name, $xpd_name) = ($name =~ m|(XBUS-\d+)/(XPD-\d+)|);
+ if(defined $xbus_name) {
+ push(@patlist, "NUM/$xbus_name/$xpd_name");
+# push(@patlist, "CONNECTOR/$ENV{XBUS_CONNECTOR}/$xpd_name");
+ }
+ #print STDERR "PATLIST=@patlist\n";
+ my $match_termtype;
+SPEC:
+ for(my $i = 0; $i < @pri_specs; $i++) {
+ my $spec = $pri_specs[$i];
+ #print STDERR "spec: $spec\n";
+ my ($match, $termtype) = split(/\s+/, $spec);
+ next unless defined $match and defined $termtype;
+ # Convert "globs" to regex
+ $match =~ s/\*/.*/g;
+ $match =~ s/\?/./g;
+ #print STDERR "match: $match\n";
+ foreach my $pattern (@patlist) {
+ #print STDERR "testmatch: $pattern =~ $match\n";
+ if($pattern =~ $match) {
+ #print STDERR "$xpd_name: MATCH '$pattern' ~ '$match' termtype=$termtype\n";
+ $match_termtype = $termtype;
+ last SPEC;
+ }
+ }
+ }
+ die "Unknown pri_termtype" unless defined $match_termtype;
+ $span->set_termtype($match_termtype);
+}
+
+
1;