| 1 |
package Dahdi; |
| 2 |
# |
| 3 |
# Written by Oron Peled <[email protected]> |
| 4 |
# Copyright (C) 2007, Xorcom |
| 5 |
# This program is free software; you can redistribute and/or |
| 6 |
# modify it under the same terms as Perl itself. |
| 7 |
# |
| 8 |
# $Id$ |
| 9 |
# |
| 10 |
use strict; |
| 11 |
use Dahdi::Span; |
| 12 |
|
| 13 |
=head1 NAME |
| 14 |
|
| 15 |
Dahdi - Perl interface to Dahdi information |
| 16 |
|
| 17 |
This package allows access from Perl to information about Dahdi |
| 18 |
hardware and loaded Dahdi devices. |
| 19 |
|
| 20 |
=head1 SYNOPSIS |
| 21 |
|
| 22 |
# Listing channels in analog spans: |
| 23 |
use Dahdi; |
| 24 |
# scans system: |
| 25 |
my @spans = Dahdi::spans(); |
| 26 |
for my $span (@spans) { |
| 27 |
next if ($span->is_digital); |
| 28 |
$span->num. " - [". $span->type ."] ". $span->name. "\n"; |
| 29 |
for my $chan ($span->chans) { |
| 30 |
print " - ".$chan->num . " - [". $chan->type. "] ". $chan->fqn". \n"; |
| 31 |
} |
| 32 |
} |
| 33 |
=cut |
| 34 |
|
| 35 |
our $virt_base; |
| 36 |
our $proc_dahdi_base; |
| 37 |
our $proc_usb_base; |
| 38 |
our $sys_base; |
| 39 |
|
| 40 |
=head1 spans() |
| 41 |
|
| 42 |
Returns a list of span objects, ordered by span number. |
| 43 |
|
| 44 |
=cut |
| 45 |
|
| 46 |
sub spans() { |
| 47 |
my @spans; |
| 48 |
|
| 49 |
-d $proc_dahdi_base or return (); |
| 50 |
foreach my $zfile (glob "$proc_dahdi_base/*") { |
| 51 |
next unless ($zfile =~ m{^$proc_dahdi_base/\d+$}); |
| 52 |
my $span = Dahdi::Span->new($zfile); |
| 53 |
push(@spans, $span); |
| 54 |
} |
| 55 |
@spans = sort { $a->num <=> $b->num } @spans; |
| 56 |
return @spans; |
| 57 |
} |
| 58 |
|
| 59 |
=head1 ENVIRONMENT |
| 60 |
|
| 61 |
If C<DAHDI_VIRT_TOP> is set in the environment, it will be considered |
| 62 |
as a path to a directory that holds a dump (copy) of all the required |
| 63 |
files from /proc and /sys . You can generate that directory using the |
| 64 |
script C<build_tools/dump_sys_state> . |
| 65 |
|
| 66 |
=head1 SEE ALSO |
| 67 |
|
| 68 |
Span objects: L<Dahdi::Span>. |
| 69 |
|
| 70 |
Dahdi channels objects: L<Dahdi::Chan>. |
| 71 |
|
| 72 |
Dahdi hardware devices information: L<Dahdi::Hardware>. |
| 73 |
|
| 74 |
Xorcom Astribank -specific information: L<Dahdi::Xpp>. |
| 75 |
|
| 76 |
=cut |
| 77 |
|
| 78 |
1; |