[dahdi-commits] tzafrir: tools/trunk r4766 - /tools/trunk/xpp/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Tue Aug 12 07:56:22 CDT 2008


Author: tzafrir
Date: Tue Aug 12 07:56:21 2008
New Revision: 4766

URL: http://svn.digium.com/view/dahdi?view=rev&rev=4766
Log:
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).

Modified:
    tools/trunk/xpp/dahdi_genconf
    tools/trunk/xpp/genconf_parameters

Modified: tools/trunk/xpp/dahdi_genconf
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/dahdi_genconf?view=diff&rev=4766&r1=4765&r2=4766
==============================================================================
--- tools/trunk/xpp/dahdi_genconf (original)
+++ tools/trunk/xpp/dahdi_genconf Tue Aug 12 07:56:21 2008
@@ -72,6 +72,8 @@
 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 @@
 		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 $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 @@
 	$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,11 +236,40 @@
 			$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;
@@ -296,6 +336,10 @@
 	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 @@
 	$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 @@
 		&{$files{$file}->{func}}(${$files{$file}->{file}});
 	}
 }
+
 set_defaults;
 parse_args;
 generate_files;

Modified: tools/trunk/xpp/genconf_parameters
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/genconf_parameters?view=diff&rev=4766&r1=4765&r2=4766
==============================================================================
--- tools/trunk/xpp/genconf_parameters (original)
+++ tools/trunk/xpp/genconf_parameters Tue Aug 12 07:56:21 2008
@@ -50,6 +50,10 @@
 #
 #bri_hardhdlc		yes
 
+# For MFC/R2 Support
+#pri_connection_type	R2
+#r2_idle_bits		1101
+
 # pri_types contains a list of settings:
 # Currently the only setting is for TE or NT (the default is TE)
 #




More information about the dahdi-commits mailing list