summaryrefslogtreecommitdiff
path: root/xpp/dahdi_genconf
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-08-12 12:56:21 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2008-08-12 12:56:21 +0000
commit2fdffda1d2950e14be0563616377c2697a05e3e9 (patch)
tree9b789f5da11303721914af21d84109828e5b82c3 /xpp/dahdi_genconf
parentd5e395dcecb856f067ca3eaa2663e540d974320c (diff)
MFC/R2 configuration generation support
If optional setting 'pri_connection_type' is set to R2, configure E1 spans as CAS and generate a unicall.conf snippet (unicall-channels.conf). git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@4766 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/dahdi_genconf')
-rwxr-xr-xxpp/dahdi_genconf57
1 files changed, 51 insertions, 6 deletions
diff --git a/xpp/dahdi_genconf b/xpp/dahdi_genconf
index ecc9819..f869ade 100755
--- a/xpp/dahdi_genconf
+++ b/xpp/dahdi_genconf
@@ -72,6 +72,8 @@ my $defaultzone = $lc_country;
my $bri_sig_style = 'bri_ptmp';
my $brint_overlap = 'no';
my $pri_termtype = 'SPAN/* TE';
+my $pri_connection_type = 'PRI'; # PRI or R2
+my $r2_idle_bits = '1101';
my $echo_can = 'mg2';
my $bri_hardhdlc= 'no';
@@ -97,6 +99,8 @@ my %dahdi_default_vars = (
bri_sig_style => \$bri_sig_style,
brint_overlap => \$brint_overlap,
pri_termtype => \$pri_termtype,
+ pri_connection_type => \$pri_connection_type,
+ r2_idle_bits => \$r2_idle_bits,
echo_can => \$echo_can,
bri_hardhdlc => \$bri_hardhdlc,
);
@@ -130,11 +134,13 @@ my $dahdiconf_file;
my $chan_dahdi_channels_file;
my $users_file;
my $chan_dahdi_conf_file;
+my $unicall_channels_file;
my %files = (
dahdi => { file => \$dahdiconf_file, func => \&gen_dahdiconf },
chan_dahdi => { file => \$chan_dahdi_channels_file, func => \&gen_chan_dahdi_channelsconf },
users => { file => \$users_file, func => \&gen_usersconf },
+ unicall => { file => \$unicall_channels_file, func => \&gen_unicall_channels },
chan_dahdi_full => { file => \$chan_dahdi_conf_file, func => \&gen_chan_dahdi_conf },
);
@@ -209,7 +215,12 @@ sub gen_dahdi_digital($) {
$span_crc4 = (defined $span_crc4) ? ",$span_crc4" : '';
my $span_yellow = $span->yellow();
$span_yellow = (defined $span_yellow) ? ",$span_yellow" : '';
-
+ # "MFC/R2 does not normally use CRC4"
+ # FIXME: a finer way to override:
+ if ($pri_connection_type eq 'R2') {
+ $span_crc4 = '';
+ $framing = 'cas';
+ }
my $dchan_type = 'dchan';
if ($span->is_bri() && ($bri_hardhdlc eq 'yes')) {
$dchan_type = 'hardhdlc';
@@ -225,12 +236,41 @@ sub gen_dahdi_digital($) {
$span_crc4,
$span_yellow;
printf "# termtype: %s\n", lc($termtype);
- printf "bchan=%s\n", bchan_range($span);
- my $dchan = $span->dchan();
- printf "$dchan_type=%d\n", $dchan->num();
+ if ($pri_connection_type eq 'PRI') {
+ printf "bchan=%s\n", bchan_range($span);
+ my $dchan = $span->dchan();
+ printf "$dchan_type=%d\n", $dchan->num();
+ } elsif ($pri_connection_type eq 'R2' ) {
+ my $idle_bits = $r2_idle_bits;
+ printf "cas=%s:$idle_bits\n", bchan_range($span);
+ printf "dchan=%d\n", $span->dchan()->num();
+ }
print_echo_can(bchan_range($span));
}
+sub gen_unicall_channels($) {
+ my $file = shift || die;
+ die "Only for R2" unless $pri_connection_type eq 'R2';
+ rename "$file", "$file.bak"
+ or $! == 2 # ENOENT (No dependency on Errno.pm)
+ or die "Failed to backup old config: $!\n";
+ open(F, ">$file") || die "$0: Failed to open $file: $!\n";
+ my $old = select F;
+ printf "; Autogenerated by %s on %s -- do not hand edit\n", $0, scalar(localtime);
+ print "; This file should be #included in unicall.conf\n\n";
+ foreach my $span (@spans) {
+ next unless $span->is_digital();
+ printf "; Span %d: %s %s\n", $span->num, $span->name, $span->description;
+ my $idle_bits = $r2_idle_bits;
+ printf "protocolend=%s\n", ($span->termtype() eq 'TE') ? 'cpe' : 'co';
+ printf "channel=%s\n", bchan_range($span);
+ print "\n";
+ }
+ close F;
+ select $old;
+}
+
+
sub gen_dahdiconf($) {
my $file = shift || die;
rename "$file", "$file.bak"
@@ -296,6 +336,10 @@ sub gen_chan_dahdi_digital($) {
my $span = shift || die;
my $num = $span->num() || die;
die "Span #$num is analog" unless $span->is_digital();
+ if($span->is_pri && $pri_connection_type eq 'R2') {
+ printf "; Skipped: $pri_connection_type config generated into $unicall_channels_file\n\n";
+ return;
+ }
my $type = $span->type() || die "$0: Span #$num -- unkown type\n";
my $termtype = $span->termtype() || die "$0: Span #$num -- unkown termtype [NT/TE]\n";
my $group = $default_group{"$type"};
@@ -571,12 +615,12 @@ sub set_defaults {
$dahdiconf_file = $ENV{DAHDI_CONF_FILE} || "/etc/dahdi/system.conf";
$chan_dahdi_channels_file = $ENV{CHAN_DAHDI_CHANNELS_FILE} || "/etc/asterisk/dahdi-channels.conf";
$users_file = $ENV{USERS_FILE} || "/etc/asterisk/users.conf";
+ $unicall_channels_file = $ENV{UNICALL_CHANNELS_FILE} || "/etc/asterisk/unicall-channels.conf";
$chan_dahdi_conf_file = $ENV{CHAN_DAHDI_CONF_FILE} || "/etc/asterisk/chan_dahdi.conf";
}
sub parse_args {
- return if @ARGV == 0;
- @default_files = ();
+ push(@ARGV, 'unicall') if $pri_connection_type eq 'R2';
for my $file (@ARGV) {
die "$0: Unknown file '$file'" unless defined $files{$file};
push @default_files, $file;
@@ -588,6 +632,7 @@ sub generate_files {
&{$files{$file}->{func}}(${$files{$file}->{file}});
}
}
+
set_defaults;
parse_args;
generate_files;