From ef4399ff222f532ef427255e30ec9016b9e25c1e Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 4 Nov 2009 17:52:29 +0000 Subject: CAS DAHD/Asterisk configuration generation support Also support generating (open)R2 config in chan_dahdi.conf, while we're at it. Default configuration remains ISDN as before if no extra settings are given in genconf_parameters. Merged revisions 7016,7018-7019,7224,7257 via svnmerge from http://svn.digium.com/svn/dahdi/tools/trunk ........ r7016 | tzafrir | 2009-08-16 20:04:04 +0300 (Sun, 16 Aug 2009) | 6 lines dahdi-perl: chan_dahdi.conf generator can generate openr2 conf If configured to use R2 ("pri_connection_type R2" in genconf_parameters), the chandahdi generator of dahdi_genconf will now generate configuration for the openr2 support in chan_dahdi. ........ r7018 | tzafrir | 2009-08-16 20:19:26 +0300 (Sun, 16 Aug 2009) | 10 lines xpp: Dahdi::Config::Gen.pm: improvements in preperation for T1-CAS: - New channo_range() method which returns range strings for any list of channel numbers (handle sorting, validation, etc.) - Reimplement bchan_range() as a small wrapper around channo_range(). - Another small wrapper is chan_range() that works on channel objects. - Also a parse_chan_range() does the reverse (from range string to a list of channel numbers). This isn't used at the moment. xpp rev: 7306 ........ r7019 | tzafrir | 2009-08-16 20:27:28 +0300 (Sun, 16 Aug 2009) | 11 lines 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 ........ r7224 | tzafrir | 2009-09-27 17:01:20 +0200 (Sun, 27 Sep 2009) | 6 lines dahdi_perl: improved config generation for T1 CAS A few extra options for a CAS span signalling. xpp rev: 7343, 7346, 7369 ........ r7257 | tzafrir | 2009-09-29 21:28:58 +0200 (Tue, 29 Sep 2009) | 2 lines xpp: more T1-CAS config generation support ........ git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/branches/2.2@7475 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- xpp/perl_modules/Dahdi/Config/Gen/System.pm | 84 +++++++++++++++++++++++++++-- 1 file changed, 81 insertions(+), 3 deletions(-) (limited to 'xpp/perl_modules/Dahdi/Config/Gen/System.pm') diff --git a/xpp/perl_modules/Dahdi/Config/Gen/System.pm b/xpp/perl_modules/Dahdi/Config/Gen/System.pm index 3f9217b..d1dfe40 100644 --- a/xpp/perl_modules/Dahdi/Config/Gen/System.pm +++ b/xpp/perl_modules/Dahdi/Config/Gen/System.pm @@ -28,7 +28,77 @@ sub print_echo_can($$) { print "echocanceller=$echo_can,$chans\n"; } -sub gen_digital($$) { +sub gen_t1_cas($$) { + my $self = shift || die; + my $gconfig = shift || die; + my $parameters = $gconfig->{PARAMETERS} || die; + my $genconf_file = $parameters->{GENCONF_FILE} || die; + my $span = shift || die; + my $num = $span->num() || die; + my $proto = $span->proto || die; + die "Generate configuration for '$proto' is not possible. Maybe you meant R2?" + unless $proto eq 'T1'; + 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 && $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 = $gconfig->{tdm_framing}; + if(!defined $framing) { + $framing = 'esf'; + } elsif($framing ne 'esf' && $framing ne 'd4') { + die "T1-CAS valid framing is only 'esf' or 'd4'. Not '$framing'. Check '$genconf_file'\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 ($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 ($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 ($pri_connection_type eq 'CAS' ) { + my $type = ($termtype eq 'TE') ? 'FXO' : 'FXS'; + my $sig = $gconfig->{'dahdi_signalling'}{$type}; + my $em_signalling = $gconfig->{'em_signalling'}; + if ($em_signalling ne 'none') { + $sig = 'e&m'; + # FIXME: but we don't handle E1 yet + $sig = 'e&me1' if $proto eq 'E1'; + } + 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 +215,16 @@ sub generate($$$) { 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_t1_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) { -- cgit v1.2.3