summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dahdi/xpp/XppConfig.pm84
-rwxr-xr-xdrivers/dahdi/xpp/init_card_1_304
-rwxr-xr-xdrivers/dahdi/xpp/init_card_2_304
-rwxr-xr-xdrivers/dahdi/xpp/init_card_4_304
-rw-r--r--drivers/dahdi/xpp/xpp.conf14
5 files changed, 104 insertions, 6 deletions
diff --git a/drivers/dahdi/xpp/XppConfig.pm b/drivers/dahdi/xpp/XppConfig.pm
new file mode 100644
index 0000000..2ccb6a9
--- /dev/null
+++ b/drivers/dahdi/xpp/XppConfig.pm
@@ -0,0 +1,84 @@
+package XppConf;
+#
+# 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;
+
+my $conf_file = "/etc/dahdi/xpp.conf";
+
+$conf_file = $ENV{XPP_CONFIG} if $ENV{XPP_CONFIG};
+
+sub subst_var($$) {
+ my $lookup = shift;
+ my $string = shift;
+
+ if(defined $lookup->{$string}) {
+ return $lookup->{$string};
+ } else {
+ return $string;
+ }
+}
+
+sub read_config($) {
+ my $input = shift || die;
+ my %xpp_config;
+ my $lookup = \%xpp_config;
+
+ open(F, $input) || die "Failed reading configuration $input: $!\n";
+LINE:
+ while(<F>) {
+ chomp;
+ s/#.*//; # strip comments
+ next unless /\S/;
+ s/^\s*//;
+ if(s/\\$//) {
+ my $next = <F>;
+ $next =~ s/^\s*//;
+ $_ .= " $next";
+ redo LINE;
+ }
+ my ($key, $value) = split(/=/, $_, 2);
+ # Trim whitespace around key/value
+ $key =~ s/^\s*(\S+)\s*$/$1/;
+ $value =~ s/^\s*(\S+)\s*$/$1/;
+ # Variable substitution
+ my $new_value = $value;
+ $new_value =~ s/\$(\w+)/subst_var($lookup,$1)/eg;
+ $xpp_config{$key} = $new_value;
+ }
+ close F;
+ return %xpp_config;
+}
+
+my %x = read_config($conf_file);
+
+sub show_vars {
+ my $assoc = shift;
+ foreach (sort keys %{$assoc}) {
+ print "$_\t$assoc->{$_}\n";
+ }
+}
+
+sub source_vars {
+ my @keys = @_;
+ my %conf = read_config($conf_file);
+ my %result;
+ my $k;
+ my $v;
+
+ foreach (@keys) {
+ if(defined $conf{$_}) {
+ $result{$_} = $conf{$_};
+ }
+ }
+ return ($conf_file, %result);
+}
+
+source_vars(qw(XPP_PRI_SETUP opermode));
+
+1;
diff --git a/drivers/dahdi/xpp/init_card_1_30 b/drivers/dahdi/xpp/init_card_1_30
index 68a6d02..a0623d5 100755
--- a/drivers/dahdi/xpp/init_card_1_30
+++ b/drivers/dahdi/xpp/init_card_1_30
@@ -45,7 +45,7 @@ use Getopt::Std;
my $program = basename("$0");
my $init_dir = dirname("$0");
BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir", "$init_dir/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
my $unit_id;
my %opts;
$ENV{XPP_BASE} = '/proc/xpp';
@@ -380,7 +380,7 @@ sub read_defaults() {
my $var_debug = 'DEBUG_INIT_FXS';
my $var_skip_calib = 'INIT_FXS_SKIP_CALIB';
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($var_debug, $var_skip_calib);
+ XppConfig::source_vars($var_debug, $var_skip_calib);
$debug = $source_defaults{$var_debug};
$skip_calib = $source_defaults{$var_skip_calib};
main::logit "From $default_file: $var_debug=$debug $var_skip_calib=$skip_calib";
diff --git a/drivers/dahdi/xpp/init_card_2_30 b/drivers/dahdi/xpp/init_card_2_30
index c682c19..6cc6804 100755
--- a/drivers/dahdi/xpp/init_card_2_30
+++ b/drivers/dahdi/xpp/init_card_2_30
@@ -45,7 +45,7 @@ use Getopt::Std;
my $program = basename("$0");
my $init_dir = dirname("$0");
BEGIN { $init_dir = dirname($0); unshift(@INC, "$init_dir", "$init_dir/zconf", "$init_dir/utils/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
my $unit_id;
my %opts;
$ENV{XPP_BASE} = '/proc/xpp';
@@ -312,7 +312,7 @@ sub read_defaults() {
my $var_debug = 'DEBUG_INIT_FXO';
my $var_opermode = 'opermode';
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($var_debug, $var_opermode);
+ XppConfig::source_vars($var_debug, $var_opermode);
$debug = $source_defaults{$var_debug};
my $tmp_opermode = $source_defaults{$var_opermode};
if(defined($tmp_opermode) and $tmp_opermode) {
diff --git a/drivers/dahdi/xpp/init_card_4_30 b/drivers/dahdi/xpp/init_card_4_30
index 25e6ec7..c5ff7b8 100755
--- a/drivers/dahdi/xpp/init_card_4_30
+++ b/drivers/dahdi/xpp/init_card_4_30
@@ -149,7 +149,7 @@ sub read_pri_specs() {
my $setup_var = 'XPP_PRI_SETUP';
my $setup_string;
my ($default_file, %source_defaults) =
- Zaptel::Config::Defaults::source_vars($setup_var);
+ XppConfig::source_vars($setup_var);
$setup_string = $source_defaults{$setup_var};
$setup_string =~ s/^\s+//; # trim
$setup_string =~ s/\s+$//; # trim
@@ -345,7 +345,7 @@ sub port_setup($) {
package main;
BEGIN { my $dir = dirname($0); unshift(@INC, "$dir", "$dir/zconf"); }
-use Zaptel::Config::Defaults;
+use XppConfig;
logit "Starting '$0'";
diff --git a/drivers/dahdi/xpp/xpp.conf b/drivers/dahdi/xpp/xpp.conf
new file mode 100644
index 0000000..2629a3c
--- /dev/null
+++ b/drivers/dahdi/xpp/xpp.conf
@@ -0,0 +1,14 @@
+# A local replacement for /etc/default/zaptel
+
+#INIT_FXS_SKIP_CALIB=1
+DEBUG_INIT_FXS=0
+DEBUG_INIT_FXO=0
+
+opermode=ISRAEL
+
+#TYPE=T1
+TYPE = E1
+
+XPP_PRI_SETUP = \
+ NUM/*/XPD-0[02]=TE,$TYPE \
+ NUM/*/XPD-0[13]=NT,$TYPE