[asterisk-dev] dahdi_genconf and CAS configuration

Tzafrir Cohen tzafrir.cohen at xorcom.com
Sun Aug 16 12:51:49 CDT 2009


The commit below (dahdi-tools, r7019) includes initial suppor for E1/T1
CAS configuration generation.

This will not be used by default (the default configuration generated
will be for ISDN). However if /etc/dahdi/genconf_parameters has:

pri_connection_type CAS

this code will be used. At the moment it will assume channels are either
fxo_ks or fxs_ks . Furthermore, for the sake of simplicity we assume
that "NT" spans, that is, spans which with timing set to '0' in the span
line in system.conf will be "FXS channels" (and hence fxo_ks signalling,
whereas "TE" spans (spans with a non-zero timing value) will be "FXO
channels" (fxs_ks signalling).


I believe that after reading the above two things should be quite
obvious:

1. The terminology used is poor. Mixing different terminology from
different fields. 

For starters, "pri" is used throughout our code as a name for "E1/J1/T1". 
We just couldn't figure out a better name for it (e.g. consider the name
of the parameter of wct4xxp: "t1e1override" - just sounds bad).

2. We need to better understand what should be written there, and how to
specificy it. I hope that the simple, flat format of genconf_parameters
is good enough.

So, what do you think should be configured? How?

----- Forwarded message from SVN commits to the Digium repositories <svn-commits at lists.digium.com> -----

To: dahdi-commits at lists.digium.com, svn-commits at lists.digium.com
Date: Sun, 16 Aug 2009 17:27:32 -0000
From: SVN commits to the Digium repositories <svn-commits at lists.digium.com>
Subject: [svn-commits] tzafrir: tools/trunk r7019 -
	/tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/

Author: tzafrir
Date: Sun Aug 16 12:27:28 2009
New Revision: 7019

URL: http://svn.asterisk.org/svn-view/dahdi?view=rev&rev=7019
Log:
dahdi-perl: Add basic T1-CAS support for dahdi_genconf
 - Support added in generators of system.conf and of chan_dahdi.conf .
 - Some strange asumptions about being FXS/FXO depending on being timing
   provider/supplier.
 - New gen_cas() method for Chandahdi and System.
 - Now gen_digital() is a bit cleaner.
 - Call gen_cas(), gen_openr2(), gen_digital() according to
   the 'pri_connection_type' config (CAS, R2, PRI/BRI).

xpp rev: 7307

Modified:
    tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm
    tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/System.pm

Modified: tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm
URL: http://svn.asterisk.org/svn-view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm?view=diff&rev=7019&r1=7018&r2=7019
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/Chandahdi.pm Sun Aug 16 12:27:28 2009
@@ -80,6 +80,31 @@
 	reset_chandahdi_values(@to_reset);
 }
 
+sub gen_cas($$$) {
+	my $self = shift || die;
+	my $gconfig = shift || die;
+	my $span = shift || die;
+	my $num = $span->num() || die;
+	my $termtype = $span->termtype() || die "$0: Span #$num -- unkown termtype [NT/TE]\n";
+	my $type = $span->type;
+	my $group = $gconfig->{'group'}{"$type"};
+	die "$0: missing default group (termtype=$termtype)\n" unless defined($group);
+	my $context = $gconfig->{'context'}{"$type"};
+	die "$0: missing default context\n" unless $context;
+	# Fake type for signalling
+	my $faketype = ($termtype eq 'TE') ? 'FXO' : 'FXS';
+	my $sig = $gconfig->{'chan_dahdi_signalling'}{$faketype};
+	my @to_reset = qw/context group/;
+	my $chans = Dahdi::Config::Gen::chan_range($span->chans());
+	$group .= "," . (10 + $num);	# Invent unique group per span
+	printf "group=$group\n";
+	printf "context=$context\n";
+	printf "switchtype = %s\n", $span->switchtype;
+	printf "signalling = %s\n", $sig;
+	printf "channel => %s\n", $chans;
+	reset_chandahdi_values(@to_reset);
+}
+
 sub gen_digital($$$) {
 	my $self = shift || die;
 	my $gconfig = shift || die;
@@ -134,6 +159,7 @@
 
 	return if $type eq 'EMPTY';
 	die "missing default_chan_dahdi_signalling for chan #$num type $type" unless $sig;
+	die "missing context for chan #$num type $type" unless $context;
 	$callerid = ($type eq 'FXO')
 			? 'asreceived'
 			: sprintf "\"Channel %d\" <%04d>", $num, $exten;
@@ -199,6 +225,8 @@
 			if($span->is_pri) {
 				if($gconfig->{'pri_connection_type'} eq 'R2') {
 					$self->gen_openr2($gconfig, $span);
+				} elsif($gconfig->{'pri_connection_type'} eq 'CAS') {
+					$self->gen_cas($gconfig, $span);
 				} else {
 					$self->gen_digital($gconfig, $span);
 				}

Modified: tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/System.pm
URL: http://svn.asterisk.org/svn-view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/System.pm?view=diff&rev=7019&r1=7018&r2=7019
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/System.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Config/Gen/System.pm Sun Aug 16 12:27:28 2009
@@ -28,7 +28,61 @@
 	print "echocanceller=$echo_can,$chans\n";
 }
 
-sub gen_digital($$) {
+sub gen_cas($$) {
+	my $self = shift || die;
+	my $gconfig = shift || die;
+	my $span = shift || die;
+	my $num = $span->num() || die;
+	my $pri_connection_type = $gconfig->{pri_connection_type} || die;
+	die "Span #$num is analog" unless $span->is_digital();
+	die "Span #$num is not CAS" unless $span->is_pri && $gconfig->{pri_connection_type} eq 'CAS';
+	my $termtype = $span->termtype() || die "$0: Span #$num -- unkown termtype [NT/TE]\n";
+	my $timing;
+	my $lbo = 0;
+	my $framing = $span->framing() || die "$0: No framing information for span #$num\n";
+	my $coding =  $span->coding() || die "$0: No coding information for span #$num\n";
+	my $span_crc4 = $span->crc4();
+	$span_crc4 = (defined $span_crc4) ? ",$span_crc4" : '';
+	my $span_yellow = $span->yellow();
+	$span_yellow = (defined $span_yellow) ? ",$span_yellow" : '';
+	$timing = ($termtype eq 'NT') ? 0 : $bri_te_last_timing++;
+	printf "span=%d,%d,%d,%s,%s%s%s\n",
+			$num,
+			$timing,
+			$lbo,
+			$framing,
+			$coding,
+			$span_crc4,
+			$span_yellow;
+	printf "# termtype: %s\n", lc($termtype);
+	my $dchan_type;
+	my $chan_range;
+	if($span->is_pri()) {
+		if ($gconfig->{'pri_connection_type'} eq 'PRI') {
+			$chan_range = Dahdi::Config::Gen::bchan_range($span);
+			printf "bchan=%s\n", $chan_range;
+			my $dchan = $span->dchan();
+			printf "dchan=%d\n", $dchan->num();
+		} elsif ($gconfig->{'pri_connection_type'} eq 'R2' ) {
+			my $idle_bits = $gconfig->{'r2_idle_bits'};
+			$chan_range = Dahdi::Config::Gen::bchan_range($span);
+			printf "cas=%s:$idle_bits\n", $chan_range;
+			printf "dchan=%d\n", $span->dchan()->num();
+		} elsif ($gconfig->{'pri_connection_type'} eq 'CAS' ) {
+			my $type = ($termtype eq 'TE') ? 'FXO' : 'FXS';
+			my $sig = $gconfig->{'dahdi_signalling'}{$type};
+			die "unknown default dahdi signalling for chan $num type $type" unless defined $sig;
+			$chan_range = Dahdi::Config::Gen::chan_range($span->chans());
+			printf "%s=%s\n", $sig, $chan_range;
+		}
+	} else {
+		die "Digital span $num is not PRI";
+	}
+	print_echo_can($gconfig, $chan_range);
+}
+
+sub gen_digital($$$) {
+	my $self = shift || die;
 	my $gconfig = shift || die;
 	my $span = shift || die;
 	my $num = $span->num() || die;
@@ -145,8 +199,16 @@
 HEAD
 	foreach my $span (@spans) {
 		printf "# Span %d: %s %s\n", $span->num, $span->name, $span->description;
-		if($span->is_digital()) {
-			gen_digital($gconfig, $span);
+		if($span->is_digital) {
+			if($span->is_pri) {
+				if($gconfig->{'pri_connection_type'} eq 'CAS') {
+					$self->gen_cas($gconfig, $span);
+				} else {
+					$self->gen_digital($gconfig, $span);
+				}
+			} elsif($span->is_bri) {
+				$self->gen_digital($gconfig, $span);
+			}
 		} else {
 			foreach my $chan ($span->chans()) {
 				if(1 || !defined $chan->type) {


_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

----- End forwarded message -----

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-dev mailing list