diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2008-06-29 15:05:48 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2008-06-29 15:05:48 +0000 |
commit | d9e8eab9a3869d54c2ae26c2d7a757762b0e68f7 (patch) | |
tree | fdc2fe8c67c52dfb722af879837b069cd629bf63 /drivers/dahdi/xpp/init_card_4_30 | |
parent | e4de227a9fcedf1a521bd8a885b8bcd8e180101d (diff) |
Changes in XPP initialization and configuration:
* The configuration for XPP init_card_* scripts is done now
in /etc/dahdi/xpp.conf and uses a simple syntax (example included).
For PRI modules, the 'pri_protocol' setting, determines how
to configure it (E1/T1).
* In Astribank PRI modules, the LED behaviour represent which ports
are *CLOCK MASTER* (red color) and which are *CLOCK SLAVE* (green color).
Usually (but not always), this corresponds to the NT/TE settings in Asterisk.
* dahdi_genconf now replaces zapconf and deprecates genzaptelconf.
Relevant configuration settings were removed from the kernel
package and are implemented and described in the tools package.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@4480 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/xpp/init_card_4_30')
-rwxr-xr-x | drivers/dahdi/xpp/init_card_4_30 | 102 |
1 files changed, 39 insertions, 63 deletions
diff --git a/drivers/dahdi/xpp/init_card_4_30 b/drivers/dahdi/xpp/init_card_4_30 index 0d0ae2b..e79a0dd 100755 --- a/drivers/dahdi/xpp/init_card_4_30 +++ b/drivers/dahdi/xpp/init_card_4_30 @@ -33,6 +33,7 @@ use strict; # 4 - PRI # XBUS_REVISION - xbus revision number # XBUS_CONNECTOR - xbus connector string +# XBUS_LABEL - xbus label string # # Output data format: # - An optional comment start with ';' or '#' until the end of line @@ -59,10 +60,11 @@ use XppConfig $init_dir; my $unit_id; my %opts; $ENV{XPP_BASE} = '/proc/xpp'; -my @pri_specs; getopts('o:', \%opts); +my %settings; + sub logit { print STDERR "$unit_id: @_\n"; } @@ -142,24 +144,12 @@ sub finish_quad() { PRI::gen "0 WD 83 9B"; # PC4 (Port configuration 4): RPD_1.GPI (nConfig1), XPD_1.GPOL (MUX_SEL2) } -sub read_pri_specs() { - # For lab tests - my $labfile = "${0}.setup"; - - # Source default files - $ENV{ZAPTEL_DEFAULTS} = "$labfile" if -r "$labfile"; - my $setup_var = 'XPP_PRI_SETUP'; - my $setup_string; - my ($default_file, %source_defaults) = - XppConfig::source_vars($setup_var); - $setup_string = $source_defaults{$setup_var}; - $setup_string =~ s/^\s+//; # trim - $setup_string =~ s/\s+$//; # trim - $setup_string =~ s/\s+/\n/g; # cannonical spaces - #main::logit "From $default_file: $setup_var=\n$setup_string"; - @pri_specs = split(/\s+/, $setup_string); - push(@pri_specs, 'NUM/*=TE,E1'); # Fall back default (last) - main::logit "pri_specs: @pri_specs"; +sub read_defaults() { + if(XppConfig::read_config(\%settings)) { + main::logit "Defaults from $settings{xppconf}"; + } else { + main::logit "No defaults file, use hard-coded defaults."; + } } package PRI::Port; @@ -168,57 +158,46 @@ sub new { my $pack = shift; my $port = { @_ }; bless $port, $pack; - $port->process_pri_spec; return $port; } -sub write_pri_info { +sub get_pri_protocol { my $port = shift; my $subunit = $port->{PORT_NUM}; - my @pri_setup = @{$port->{PRI_SETUP}}; - my $pri_type = $pri_setup[0] || die "Missing pri_type parameter"; - my $pri_proto = $pri_setup[1] || die "Missing pri_proto parameter"; my $xpd_name = "XPD-$ENV{UNIT_NUMBER}$subunit"; - my $info = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/pri_info"; - - main::logit "$xpd_name: PRI_SETUP $pri_type $pri_proto"; - open(INFO, ">$info") || die "Failed to open '$info': $!\n"; - print INFO "$pri_type $pri_proto\n" || die "Failed writing to '$info': $!\n"; - close INFO || die "Failed during close of '$info': $!\n"; + my $pri_protocol; + my @keys = ( + "pri_protocol/connector:$ENV{XBUS_CONNECTOR}/$xpd_name", + "pri_protocol/label:$ENV{XBUS_LABEL}/$xpd_name", + "pri_protocol/$ENV{XBUS_NAME}/$xpd_name", + "pri_protocol" + ); + foreach my $k (@keys) { + $k = lc($k); # Lowercase + $pri_protocol = $settings{$k}; + if(defined $pri_protocol) { + $port->{pri_protocol} = $pri_protocol; + return $pri_protocol; + } + } + return undef; } -sub process_pri_spec($) { +sub write_pri_info { my $port = shift; my $subunit = $port->{PORT_NUM}; my $xpd_name = "XPD-$ENV{UNIT_NUMBER}$subunit"; - my $match; - my $setup; - my @pri_setup; -SPEC: - for(my $i = 0; $i < @pri_specs; $i++) { - my $spec = $pri_specs[$i]; - ($match, $setup) = split(/=/, $spec); - next unless defined $match and defined $setup; - # Convert "globs" to regex - $match =~ s/\*/.*/g; - $match =~ s/\?/./g; - #logit "match: $match"; - my @patlist = ( - "CONNECTOR/$ENV{XBUS_CONNECTOR}/$xpd_name", - "NUM/$ENV{XBUS_NAME}/$xpd_name" - ); - foreach my $pattern (@patlist) { - #logit "testmatch: $pattern =~ $match"; - if($pattern =~ $match) { - main::logit "$xpd_name: MATCH '$pattern' ~ '$match' setup=$setup"; - last SPEC; - } - } + my $info = "$ENV{XPP_BASE}/$ENV{XBUS_NAME}/$xpd_name/pri_info"; + my $pri_protocol = $port->get_pri_protocol; + + if(defined $pri_protocol) { + main::logit "$xpd_name: pri_protocol $pri_protocol"; + open(INFO, ">$info") || die "Failed to open '$info': $!\n"; + print INFO "$pri_protocol\n" || die "Failed writing '$pri_protocol' to '$info': $!\n"; + close INFO || die "Failed during close of '$info': $!\n"; + } else { + main::logit "$xpd_name: Skip setting pri protocol -- non given"; } - die "No setup matching $ENV{XBUS_NAME}/$xpd_name\n" unless defined $setup; - @pri_setup = split(/,/, $setup); - die "Bad setup string '$setup'\n" unless @pri_setup; - $port->{'PRI_SETUP'} = \@pri_setup; } sub port_setup($) { @@ -349,7 +328,7 @@ package main; logit "Starting '$0'"; -PRI::read_pri_specs; +PRI::read_defaults; sub main() { my @ports; @@ -359,12 +338,9 @@ sub main() { PRI::init_quad; # Must initialize all 4 ports, regardless how much there are for($subunit = 0; $subunit < 4; $subunit++) { - my $is_nt = 0; - - #logit "main(): Initializing subunit $subunit is_nt=$is_nt"; + #logit "main(): Initializing subunit $subunit"; my $p = PRI::Port->new( 'PORT_NUM' => $subunit, - 'PRI_NT' => $is_nt, 'EXIST' => ($subunit < $ENV{UNIT_SUBUNITS}) ); $p->port_setup; |