Imported Upstream version 2.10.2
This commit is contained in:
commit
7c176870b3
|
@ -0,0 +1,51 @@
|
|||
*.o
|
||||
.*.o.d
|
||||
.*.lo.d
|
||||
*.asciidoc
|
||||
*.html
|
||||
build_tools/menuselect-deps
|
||||
autoconfig.h
|
||||
config.log
|
||||
config.status
|
||||
dahdi_cfg
|
||||
dahdi_diag
|
||||
dahdi_maint
|
||||
dahdi_monitor
|
||||
dahdi_scan
|
||||
dahdi_speed
|
||||
dahdi_test
|
||||
dahdi_tool
|
||||
fxotune
|
||||
fxstest
|
||||
genconf_parameters.sample
|
||||
hdlcgen
|
||||
hdlcstress
|
||||
hdlctest
|
||||
hdlcverify
|
||||
libtonezone.a
|
||||
libtonezone.so
|
||||
makeopts
|
||||
patgen
|
||||
patlooptest
|
||||
pattest
|
||||
sethdlc
|
||||
timertest
|
||||
tonezone.lo
|
||||
tonezones.txt
|
||||
version.c
|
||||
xpp/.depend
|
||||
xpp/.octasic.depend
|
||||
xpp/.perlcheck
|
||||
xpp/astribank_allow
|
||||
xpp/astribank_hexload
|
||||
xpp/astribank_is_starting
|
||||
xpp/astribank_tool
|
||||
xpp/dahdi_genconf.8
|
||||
xpp/dahdi_hardware.8
|
||||
xpp/dahdi_registration.8
|
||||
xpp/lsdahdi.8
|
||||
xpp/test_parse
|
||||
xpp/twinstar.8
|
||||
xpp/xpp_blink.8
|
||||
xpp/xpp_sync.8
|
||||
zonedata.lo
|
|
@ -0,0 +1,341 @@
|
|||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
|
@ -0,0 +1,504 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
#
|
||||
# Makefile for DAHDI tools
|
||||
#
|
||||
# Copyright (C) 2001-2010 Digium, Inc.
|
||||
#
|
||||
#
|
||||
|
||||
ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
|
||||
ifneq ($(wildcard makeopts),)
|
||||
include makeopts
|
||||
endif
|
||||
endif
|
||||
|
||||
SUBDIRS_UTILS_ALL:= ppp
|
||||
SUBDIRS_UTILS := xpp
|
||||
|
||||
OPTFLAGS=-O2
|
||||
CFLAGS+=-I. $(OPTFLAGS) -g -fPIC -Wall -DBUILDING_TONEZONE #-DTONEZONE_DRIVER
|
||||
ifneq (,$(findstring ppc,$(UNAME_M)))
|
||||
CFLAGS+=-fsigned-char
|
||||
endif
|
||||
ifneq (,$(findstring x86_64,$(UNAME_M)))
|
||||
CFLAGS+=-m64
|
||||
endif
|
||||
|
||||
ifeq ($(DAHDI_DEVMODE),yes)
|
||||
CFLAGS+=-Werror -Wunused -Wundef $(DAHDI_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
|
||||
endif
|
||||
|
||||
ROOT_PREFIX=
|
||||
|
||||
# extra cflags to build dependencies. Recursively expanded.
|
||||
MAKE_DEPS= -MD -MT $@ -MF .$(subst /,_,$@).d -MP
|
||||
|
||||
CFLAGS+=$(DAHDI_INCLUDE)
|
||||
|
||||
CHKCONFIG := $(wildcard /sbin/chkconfig)
|
||||
UPDATE_RCD := $(wildcard /usr/sbin/update-rc.d)
|
||||
ifeq (,$(DESTDIR))
|
||||
ifneq (,$(CHKCONFIG))
|
||||
ADD_INITD := $(CHKCONFIG) --add dahdi
|
||||
else
|
||||
ifneq (,$(UPDATE_RCD))
|
||||
ADD_INITD := $(UPDATE_RCD) dahdi defaults 15 30
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
INITRD_DIR := $(firstword $(wildcard $(DESTDIR)/etc/rc.d/init.d $(DESTDIR)/etc/init.d))
|
||||
ifneq (,$(INITRD_DIR))
|
||||
INIT_TARGET := $(INITRD_DIR)/dahdi
|
||||
COPY_INITD := install -D dahdi.init $(INIT_TARGET)
|
||||
endif
|
||||
|
||||
RCCONF_FILE = /etc/dahdi/init.conf
|
||||
MODULES_FILE = /etc/dahdi/modules
|
||||
GENCONF_FILE = /etc/dahdi/genconf_parameters
|
||||
MODPROBE_FILE = /etc/modprobe.d/dahdi.conf
|
||||
BLACKLIST_FILE = /etc/modprobe.d/dahdi.blacklist.conf
|
||||
BASH_COMP_DIR = /etc/bash_completion.d
|
||||
BASH_COMP_FILE = $(BASH_COMP_DIR)/dahdi
|
||||
|
||||
NETSCR_DIR := $(firstword $(wildcard $(DESTDIR)/etc/sysconfig/network-scripts ))
|
||||
ifneq (,$(NETSCR_DIR))
|
||||
NETSCR_TARGET := $(NETSCR_DIR)/ifup-hdlc
|
||||
COPY_NETSCR := install -D ifup-hdlc $(NETSCR_TARGET)
|
||||
endif
|
||||
|
||||
TOOLSVERSION=$(shell build_tools/make_version . dahdi/tools)
|
||||
|
||||
LTZ_A:=libtonezone.a
|
||||
LTZ_A_OBJS:=zonedata.o tonezone.o version.o
|
||||
LTZ_SO:=libtonezone.so
|
||||
LTZ_SO_OBJS:=zonedata.lo tonezone.lo version.o
|
||||
LTZ_SO_MAJOR_VER:=2
|
||||
LTZ_SO_MINOR_VER:=0
|
||||
|
||||
# sbindir, libdir, includedir and mandir are defined in makeopts
|
||||
# (from configure).
|
||||
BIN_DIR:=$(sbindir)
|
||||
LIB_DIR:=$(libdir)
|
||||
INC_DIR:=$(includedir)/dahdi
|
||||
MAN_DIR:=$(mandir)/man8
|
||||
DATA_DIR:=${datadir}/dahdi
|
||||
CONFIG_DIR:=$(sysconfdir)/dahdi
|
||||
CONFIG_FILE:=$(CONFIG_DIR)/system.conf
|
||||
UDEVRULES_DIR:=$(sysconfdir)/udev/rules.d
|
||||
|
||||
# Utilities we build with a standard build procedure:
|
||||
UTILS = dahdi_tool dahdi_test dahdi_monitor dahdi_speed sethdlc dahdi_cfg \
|
||||
fxstest fxotune dahdi_diag dahdi_scan
|
||||
|
||||
# some tests:
|
||||
UTILS += patgen pattest patlooptest hdlcstress hdlctest hdlcgen \
|
||||
hdlcverify timertest dahdi_maint
|
||||
|
||||
|
||||
BINS:=fxotune dahdi_cfg dahdi_monitor dahdi_speed dahdi_test dahdi_scan dahdi_maint
|
||||
ifeq (1,$(PBX_NEWT))
|
||||
BINS += dahdi_tool
|
||||
endif
|
||||
ifeq (1,$(PBX_HDLC))
|
||||
BINS += sethdlc
|
||||
endif
|
||||
ASSIGNED_DATA_SCRIPTS:=\
|
||||
dahdi_handle_device \
|
||||
dahdi_span_config \
|
||||
dahdi_auto_assign_compat \
|
||||
span_config.d/10-dahdi-cfg \
|
||||
span_config.d/20-fxotune \
|
||||
span_config.d/50-asterisk \
|
||||
handle_device.d/10-span-types \
|
||||
handle_device.d/20-span-assignments
|
||||
|
||||
ASSIGNED_UTILS:=dahdi_span_assignments dahdi_span_types \
|
||||
dahdi_waitfor_span_assignments
|
||||
ASSIGNED_CONF:=assigned-spans.conf.sample span-types.conf.sample
|
||||
|
||||
MAN_PAGES:= \
|
||||
$(wildcard $(BINS:%=doc/%.8)) \
|
||||
$(wildcard $(ASSIGNED_UTILS:%=doc/%.8))
|
||||
|
||||
TEST_BINS:=patgen pattest patlooptest hdlcstress hdlctest hdlcgen hdlcverify timertest dahdi_maint
|
||||
# All the man pages. Not just installed ones:
|
||||
GROFF_PAGES := $(wildcard doc/*.8 xpp/*.8)
|
||||
GROFF_HTML := $(GROFF_PAGES:%=%.html)
|
||||
|
||||
GENERATED_DOCS := $(GROFF_HTML) README.html README.Astribank.html
|
||||
|
||||
all: prereq programs
|
||||
|
||||
libs: $(LTZ_SO) $(LTZ_A)
|
||||
|
||||
utils-subdirs:
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir; \
|
||||
done
|
||||
|
||||
programs: libs utils
|
||||
|
||||
utils: $(BINS) utils-subdirs
|
||||
|
||||
version.c: FORCE
|
||||
@TOOLSVERSION="${TOOLSVERSION}" build_tools/make_version_c > $@.tmp
|
||||
@if cmp -s $@.tmp $@ ; then :; else \
|
||||
mv $@.tmp $@ ; \
|
||||
fi
|
||||
@rm -f $@.tmp
|
||||
|
||||
tests: $(TEST_BINS)
|
||||
|
||||
$(UTILS): %: %.o
|
||||
|
||||
$(UTILS): version.o
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
%.lo: %.c
|
||||
$(CC) $(CFLAGS) $(MAKE_DEPS) -c -o $@ $<
|
||||
|
||||
%: %.o
|
||||
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
prereq: config.status
|
||||
|
||||
dahdi_tool: CFLAGS+=$(NEWT_INCLUDE)
|
||||
dahdi_tool: LIBS+=$(NEWT_LIB)
|
||||
|
||||
dahdi_speed: CFLAGS+=-O0
|
||||
|
||||
$(LTZ_A): $(LTZ_A_OBJS)
|
||||
ar rcs $@ $^
|
||||
ranlib $@
|
||||
|
||||
$(LTZ_SO): $(LTZ_SO_OBJS)
|
||||
$(CC) $(CFLAGS) -shared -Wl,-soname,$(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) -o $@ $^ -lm
|
||||
|
||||
dahdi_cfg: $(LTZ_A)
|
||||
dahdi_cfg: LIBS+=-lm -lpthread
|
||||
dahdi_pcap:
|
||||
$(CC) $(CFLAGS) dahdi_pcap.c -lpcap -o $@ $<
|
||||
|
||||
|
||||
fxstest: $(LTZ_SO)
|
||||
fxstest: LIBS+=-lm
|
||||
fxotune: LIBS+=-lm
|
||||
|
||||
tonezones.txt: zonedata.c
|
||||
perl -ne 'next unless (/\.(country|description) = *"([^"]*)/); \
|
||||
print (($$1 eq "country")? "* $$2\t":"$$2\n");' $< \
|
||||
>$@
|
||||
|
||||
%.asciidoc: %.sample
|
||||
perl -n -e \
|
||||
'if (/^#($$|\s)(.*)/){ if (!$$in_doc){print "\n"}; $$in_doc=1; print "$$2\n" } else { if ($$in_doc){print "\n"}; $$in_doc=0; print " $$_" }' \
|
||||
$< \
|
||||
| perl -p -e 'if (/^ #?(\w+)=/ && ! exists $$cfgs{$$1}){my $$cfg = $$1; $$cfgs{$$cfg} = 1; s/^/\n[[cfg_$$cfg]]\n/}' >$@
|
||||
|
||||
docs: $(GENERATED_DOCS)
|
||||
|
||||
genconf_parameters.sample: xpp/genconf_parameters
|
||||
cp $< $@
|
||||
|
||||
README.html: README system.conf.asciidoc init.conf.asciidoc tonezones.txt \
|
||||
UPGRADE.txt genconf_parameters.asciidoc assigned-spans.conf.asciidoc \
|
||||
span-types.conf.asciidoc
|
||||
$(ASCIIDOC) -n -a toc -a toclevels=4 $<
|
||||
|
||||
README.Astribank.html: xpp/README.Astribank
|
||||
$(ASCIIDOC) -o $@ -n -a toc -a toclevels=4 $<
|
||||
|
||||
# on Debian: this requires the full groff, not just groff-base.
|
||||
%.8.html: %.8
|
||||
man -Thtml $^ >$@
|
||||
|
||||
htmlman: $(GROFF_HTML)
|
||||
|
||||
install: all install-programs
|
||||
@echo "###################################################"
|
||||
@echo "###"
|
||||
@echo "### DAHDI tools installed successfully."
|
||||
@echo "### If you have not done so before, install init scripts with:"
|
||||
@echo "###"
|
||||
@echo "### make config"
|
||||
@echo "###"
|
||||
@echo "###################################################"
|
||||
|
||||
install-programs: install-utils install-libs
|
||||
|
||||
install-utils: utils install-utils-subdirs
|
||||
ifneq (,$(BINS))
|
||||
install -d $(DESTDIR)$(BIN_DIR)
|
||||
install $(BINS) $(DESTDIR)$(BIN_DIR)/
|
||||
install -d $(DESTDIR)$(MAN_DIR)
|
||||
install -m 644 $(MAN_PAGES) $(DESTDIR)$(MAN_DIR)/
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(CONFIG_FILE)))
|
||||
$(INSTALL) -d $(DESTDIR)$(CONFIG_DIR)
|
||||
$(INSTALL) -m 644 system.conf.sample $(DESTDIR)$(CONFIG_FILE)
|
||||
endif
|
||||
install -d $(DESTDIR)$(DATA_DIR)
|
||||
tar cf - -C hotplug $(ASSIGNED_DATA_SCRIPTS) | tar xf - -C $(DESTDIR)$(DATA_DIR)/
|
||||
install $(ASSIGNED_UTILS) $(DESTDIR)/$(BIN_DIR)/
|
||||
install -m 644 $(ASSIGNED_CONF) $(DESTDIR)/$(CONFIG_DIR)/
|
||||
install -d $(DESTDIR)$(BASH_COMP_DIR)
|
||||
install -m 644 dahdi-bash-completion $(DESTDIR)$(BASH_COMP_FILE)
|
||||
|
||||
install-libs: libs
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)/$(LIB_DIR)
|
||||
$(INSTALL) -m 755 $(LTZ_A) $(DESTDIR)$(LIB_DIR)/
|
||||
$(INSTALL) -m 755 $(LTZ_SO) $(DESTDIR)$(LIB_DIR)/$(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER)
|
||||
ifeq (,$(DESTDIR))
|
||||
if [ `id -u` = 0 ]; then \
|
||||
/sbin/ldconfig || : ;\
|
||||
fi
|
||||
endif
|
||||
rm -f $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).$(LTZ_SO_MAJOR_VER)
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
# Overwrite the 1.0 links out there. dahdi-tools 2.0.0 installed
|
||||
# 1.0 links but dahdi-tools changed them to 2.0 in order to explicitly
|
||||
# break applications linked with zaptel. But, this also meant that
|
||||
# applications linked with libtonezone.so.1.0 broke when dahdi-tools
|
||||
# 2.1.0 was installed.
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).1.0
|
||||
$(LN) -sf $(LTZ_SO).$(LTZ_SO_MAJOR_VER).$(LTZ_SO_MINOR_VER) \
|
||||
$(DESTDIR)$(LIB_DIR)/$(LTZ_SO).1
|
||||
ifneq (no,$(USE_SELINUX))
|
||||
ifeq (,$(DESTDIR))
|
||||
/sbin/restorecon -v $(DESTDIR)$(LIB_DIR)/$(LTZ_SO)
|
||||
endif
|
||||
endif
|
||||
$(INSTALL) -d -m 755 $(DESTDIR)/$(INC_DIR)
|
||||
$(INSTALL) -m 644 tonezone.h $(DESTDIR)$(INC_DIR)/
|
||||
|
||||
install-utils-subdirs:
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir install; \
|
||||
done
|
||||
|
||||
install-tests: tests
|
||||
ifneq (,$(TEST_BINS))
|
||||
install -d $(DESTDIR)$(BIN_DIR)
|
||||
install $(TEST_BINS) $(DESTDIR)$(BIN_DIR)/
|
||||
endif
|
||||
|
||||
config:
|
||||
ifneq (,$(COPY_INITD))
|
||||
$(COPY_INITD)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(RCCONF_FILE)))
|
||||
$(INSTALL) -D -m 644 init.conf.sample $(DESTDIR)$(RCCONF_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(MODULES_FILE)))
|
||||
$(INSTALL) -D -m 644 modules.sample $(DESTDIR)$(MODULES_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(GENCONF_FILE)))
|
||||
$(INSTALL) -D -m 644 xpp/genconf_parameters $(DESTDIR)$(GENCONF_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(MODPROBE_FILE)))
|
||||
$(INSTALL) -D -m 644 modprobe.conf.sample $(DESTDIR)$(MODPROBE_FILE)
|
||||
endif
|
||||
ifeq (,$(wildcard $(DESTDIR)$(BLACKLIST_FILE)))
|
||||
$(INSTALL) -D -m 644 blacklist.sample $(DESTDIR)$(BLACKLIST_FILE)
|
||||
endif
|
||||
$(INSTALL) -d $(DESTDIR)$(UDEVRULES_DIR)
|
||||
$(INSTALL) -D -m 644 dahdi.rules $(DESTDIR)$(UDEVRULES_DIR)/
|
||||
ifneq (,$(COPY_NETSCR))
|
||||
$(COPY_NETSCR)
|
||||
endif
|
||||
ifneq (,$(ADD_INITD))
|
||||
$(ADD_INITD)
|
||||
endif
|
||||
@echo "DAHDI has been configured."
|
||||
@echo ""
|
||||
@echo "List of detected DAHDI devices:"
|
||||
@echo ""
|
||||
@if [ `xpp/dahdi_hardware | tee /dev/stderr | wc -l` -eq 0 ]; then \
|
||||
echo "No hardware found"; \
|
||||
else \
|
||||
echo ""; \
|
||||
echo "run 'dahdi_genconf modules' to load support for only " ;\
|
||||
echo "the DAHDI hardware installed in this system. By "; \
|
||||
echo "default support for all DAHDI hardware is loaded at "; \
|
||||
echo "DAHDI start. "; \
|
||||
fi
|
||||
|
||||
update:
|
||||
@if [ -d .svn ]; then \
|
||||
echo "Updating from Subversion..." ; \
|
||||
svn update | tee update.out; \
|
||||
rm -f .version; \
|
||||
if [ `grep -c ^C update.out` -gt 0 ]; then \
|
||||
echo ; echo "The following files have conflicts:" ; \
|
||||
grep ^C update.out | cut -b4- ; \
|
||||
fi ; \
|
||||
rm -f update.out; \
|
||||
else \
|
||||
echo "Not under version control"; \
|
||||
fi
|
||||
|
||||
dist:
|
||||
@./build_tools/make_dist "dahdi-tools" "$(TOOLSVERSION)"
|
||||
|
||||
clean:
|
||||
rm -f $(BINS) $(TEST_BINS)
|
||||
rm -f *.o dahdi_cfg tzdriver sethdlc
|
||||
rm -f $(LTZ_SO) $(LTZ_A) *.lo
|
||||
@for dir in $(SUBDIRS_UTILS_ALL); do \
|
||||
$(MAKE) -C $$dir clean; \
|
||||
done
|
||||
@for dir in $(SUBDIRS_UTILS); do \
|
||||
$(MAKE) -C $$dir clean; \
|
||||
done
|
||||
rm -f libtonezone*
|
||||
rm -f fxotune
|
||||
rm -f core
|
||||
rm -f dahdi_cfg-shared fxstest
|
||||
rm -rf $(GENERATED_DOCS) *.asciidoc tonezones.txt
|
||||
rm -f dahdi_pcap
|
||||
|
||||
distclean: dist-clean
|
||||
|
||||
dist-clean: clean
|
||||
rm -f makeopts
|
||||
rm -f config.log config.status
|
||||
rm -f .*.d
|
||||
|
||||
config.status: configure
|
||||
@CFLAGS="" ./configure
|
||||
@echo "****"
|
||||
@echo "**** The configure script was just executed, so 'make' needs to be"
|
||||
@echo "**** restarted."
|
||||
@echo "****"
|
||||
@exit 1
|
||||
|
||||
.PHONY: distclean dist-clean clean all install programs tests devel data config update install-programs install-libs install-utils-subdirs utils-subdirs prereq dist
|
||||
|
||||
FORCE:
|
||||
|
||||
ifneq ($(wildcard .*.d),)
|
||||
include .*.d
|
||||
endif
|
|
@ -0,0 +1,371 @@
|
|||
DAHDI Telephony Interface Driver
|
||||
=================================
|
||||
Asterisk Development Team <asteriskteam@digium.com>
|
||||
$Revision$, $Date$
|
||||
|
||||
DAHDI stands for Digium Asterisk Hardware Device Interface. This
|
||||
package contains the user-space tools to configure the kernel modules
|
||||
included in the package dahdi-linux.
|
||||
|
||||
Build Requirements
|
||||
------------------
|
||||
This package needs the headers from dahdi-linux. Thus you should install
|
||||
dahdi-linux before building dahdi-tools.
|
||||
|
||||
Build System
|
||||
~~~~~~~~~~~~
|
||||
GCC and friends. Generally you will need to install the package gcc.
|
||||
There may be cases where you will need a specific version of gcc to build
|
||||
kernel modules.
|
||||
|
||||
|
||||
Extra Libraries
|
||||
~~~~~~~~~~~~~~~
|
||||
Some libraries are needed for extra utilities that are provided with
|
||||
DAHDI.
|
||||
|
||||
- libusb is needed for building fpga_load, needed for firmware loading of
|
||||
the Xorcom Astribank.
|
||||
- libnewt is needed to build the optional but useful utility dahdi_tool.
|
||||
|
||||
|
||||
Installation
|
||||
~~~~~~~~~~~~
|
||||
Note: If using `sudo` to build/install, you may need to add /sbin to your PATH.
|
||||
----------------------------------
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
# To install init scripts and config files:
|
||||
#make config
|
||||
----------------------------------
|
||||
|
||||
|
||||
Build Tweaks
|
||||
~~~~~~~~~~~~
|
||||
Partial Build/Install
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
There are some make targets that are provided to build or install just
|
||||
parts of DAHDI:
|
||||
|
||||
. Build targets:
|
||||
- make: Build DAHDI user-space programs and libraries. partial
|
||||
targets of it:
|
||||
* make 'utilname': builds 'utilname' alone (e.g: `make dahdi_diag`)
|
||||
* make utils: Build just the programs.
|
||||
* make libs: Build libtonezone.
|
||||
* make tests: Build testing binaries.
|
||||
. Install targets:
|
||||
- make install: Install everything. Sub-targets of it:
|
||||
* make install-utils: Installs most things.
|
||||
* make install-libs: Installs libtonezone.
|
||||
- make config: install configuration files (overriding existing ones).
|
||||
- make install-test: Install testing binaries.
|
||||
|
||||
|
||||
Installation to a Subtree
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
The following may be useful when testing the package or when preparing a
|
||||
package for a binary distribution (such as an rpm package) installing
|
||||
onto a subtree rather than on the real system.
|
||||
|
||||
make install DESTDIR=targetdir
|
||||
|
||||
This can be useful for any partial install target from the list above.
|
||||
|
||||
|
||||
Options For ./configure
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
The configure script executes various tests and based on them generates
|
||||
makeopts. You can pass it --with options and variable settings, for
|
||||
instance:
|
||||
|
||||
./configure --without-ncurses CC="gcc-4.10"
|
||||
|
||||
If you just want to recreate the same files without a full detection
|
||||
run, use:
|
||||
|
||||
./config.status
|
||||
|
||||
To re-run ./configure with the same parameters it was run with last
|
||||
time, use:
|
||||
|
||||
./config.status --recheck
|
||||
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
Configuration for DAHDI resides under /etc/dahdi .
|
||||
|
||||
/etc/dahdi/system.conf
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
The main method to configure DAHDI devices is using the utility
|
||||
*dahdi_cfg*. dahdi_cfg reads data from the configuration file
|
||||
/etc/dahdi/system.conf , figures out what configuration to send to
|
||||
channels, and send it to the kernel.
|
||||
|
||||
A sample annotated system.conf is included in this directory and
|
||||
installed by default. Edit it to suit your configuration. Alternatively
|
||||
use the script dahdi_genconf to generate one that should work with your
|
||||
system. Note that while dahdi_genconf will generate a working configuration,
|
||||
it will not automatically detect hardware echo cancellation modules. These
|
||||
will have to be enabled manually in system.conf.
|
||||
|
||||
/etc/dahdi/init.conf
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
The configuration file of the dahdi init.d script is
|
||||
/etc/dahdi/init.conf . That file is used to override defaults that are
|
||||
set at the beginning of the init.d script.
|
||||
|
||||
Reference Configuration
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Sample system.conf
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
include::system.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample init.conf
|
||||
^^^^^^^^^^^^^^^^
|
||||
include::init.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample genconf_parameters
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
FIXME: still not properly formatted.
|
||||
|
||||
include::genconf_parameters.asciidoc[]
|
||||
|
||||
|
||||
Sample assigned-spans.conf
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
include::assigned-spans.conf.asciidoc[]
|
||||
|
||||
|
||||
Sample span-types.conf
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
include::span-types.conf.asciidoc[]
|
||||
|
||||
|
||||
Tonezones
|
||||
~~~~~~~~~
|
||||
The file zonedata.c contains the information about the tone zones used
|
||||
in libtonezone (and hence also in dahdi_cfg). Here is a list of those zones:
|
||||
|
||||
include::tonezones.txt[]
|
||||
|
||||
|
||||
DAHDI PERL modules
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
The directory xpp has, in addition to helper utilities for the
|
||||
Xorcom Astribank, a collection of PERL modules to provide information
|
||||
related to DAHDI. The PERL modules themselves are under xpp/perl_modules/ .
|
||||
In xpp/ there are several utilities that use those modules:
|
||||
- xpp-specific: dahdi_registration, xpp_sync, xpp_blink .
|
||||
- General: lsdahdi, dahdi_genconf, dahdi_hardware, dahdi_drivers
|
||||
|
||||
The DAHDI PERL modules will currently only be automatically installed if you
|
||||
happen to install the xpp directory. Those utilities require the PERL modules
|
||||
to be installed, however they will also look for them in the directory
|
||||
perl_modules, and thus can be run directly from the DAHDI source tree. For
|
||||
example:
|
||||
|
||||
./xpp/dahdi_hardware -v
|
||||
|
||||
To get usage information on a program, you can also use perldoc
|
||||
(sometimes provided in a package separate from perl itself). For
|
||||
instance:
|
||||
|
||||
perldoc ./xpp/lsdahdi
|
||||
|
||||
Some of them are specific for the Xorcom Astribank and described in its
|
||||
documentation. the others are:
|
||||
|
||||
lsdahdi::
|
||||
A somewhat glorified `cat /proc/dahdi/*`.
|
||||
dahdi_genconf::
|
||||
Generates configuration based on the existing DAHDI channels and on
|
||||
/etc/dahdi/genconf_parameters (replaces genzaptelconf as well).
|
||||
dahdi_drivers::
|
||||
A two-liner script (not installed by default) that simply returns the
|
||||
modules that should be modprobe-d on this system.
|
||||
dahdi_hardware::
|
||||
Uses the information from SysFS and its own knowledge to show
|
||||
what PCI/USB DAHDI hardware is connected and if it is currently used
|
||||
by a driver. Shows also some more information for Astribanks from
|
||||
/proc/xpp .
|
||||
|
||||
|
||||
PPP Support
|
||||
~~~~~~~~~~~
|
||||
DAHDI digital cards can provide data channels through PPP as
|
||||
point-to-point connections. This requires a plug-in to the PPP daemon
|
||||
that is included in the ppp/ subdirectory. To install it:
|
||||
|
||||
1. Make sure you have the PPP source / headers installed. On Debian:
|
||||
|
||||
apt-get install ppp-dev
|
||||
|
||||
2. Run 'make' on the ppp subdirectory:
|
||||
|
||||
make -C ppp
|
||||
make -C ppp install
|
||||
|
||||
3. Make sure your kernel has support for both PPP (which is common is
|
||||
distribution kernels and for HDLC (much less common) - CONFIG_PPP and
|
||||
CONFIG_HDLC .
|
||||
|
||||
|
||||
Initialization
|
||||
--------------
|
||||
This section documents the start up sequence of the DAHDI modules.
|
||||
|
||||
There are generally two options: explicit (using an init script) and
|
||||
implicit (run from UDEV hook scripts).
|
||||
|
||||
Explicit
|
||||
~~~~~~~~
|
||||
The dahdi init scripts does the following tasks:
|
||||
|
||||
* Loading the module dahdi and any other module listed in
|
||||
/etc/dahdi/modules.
|
||||
* For xpp (Astribanks) - some specific initializations. See
|
||||
README.Astribank.
|
||||
* Runs link:doc/dahdi_cfg.8.html[dahdi_cfg] after all modules were
|
||||
loaded.
|
||||
* A number of other tools may need to be run:
|
||||
** link:doc/fxotune.8.html[fxotune]
|
||||
** dahdihpec_enable
|
||||
|
||||
Only at this point Asterisk (or any other user of DAHDI) can be run.
|
||||
|
||||
|
||||
Implicit
|
||||
~~~~~~~~
|
||||
(Also known as "hot-plug" or "pinned-spans". This requires:
|
||||
|
||||
* dahdi >= 2.8.0
|
||||
* Setting the module parameter auto_assign_spans of dahdi to 0
|
||||
* (Recommended) Asterisk >= 12 - which supports "dahdi create channels".
|
||||
|
||||
When a device driver of a DAHDI device finishes initialization, it
|
||||
creates a dahdi_device kernel object. A dahdi_device represents a single
|
||||
DAHDI device (such as a PCI card) and may have several spans. If the
|
||||
value of auto_assign_spans is 1 when dahdi_device is created, spans are
|
||||
assigned automatically - each new span gets the first available span
|
||||
number and range of channels. However if it is set to 0, spans will not
|
||||
get assigned, and user space programs need to assign them. The
|
||||
low-level interface for doing so is explained in the section "Span
|
||||
Assignment" in the README of DAHDI-Linux.
|
||||
|
||||
New Devices
|
||||
^^^^^^^^^^^
|
||||
When a kernel object is created or destroyed, the kernel sends an event
|
||||
to user space. Those events are normally handled by udevd. Configurations
|
||||
for udevd ("udev rules") may be placed in /etc/udev/rules.d or
|
||||
/lib/udev/rules.d. This package installs rules that instruct udevd to
|
||||
run the script `/usr/share/dahdi/dahdi_handle_device` on each new
|
||||
device, which runs all the scripts in `/usr/share/dahdi/handle_device.d`.
|
||||
Those scripts will:
|
||||
|
||||
* If `/etc/dahdi/span-types.conf` exists, apply it to the device. It is
|
||||
used for E1/T1/J1 settings. See
|
||||
<<_sample_span_types_conf,sample span-types.conf>>.
|
||||
|
||||
* If `/etc/dahdi/assigned-spans.conf` exists, assign the span according
|
||||
to it (if it is not specified there: don't assign it).
|
||||
used for E1/T1/J1 settings. See
|
||||
<<_sample_assigned_spans_conf,sample assigned-spans.conf>>.
|
||||
|
||||
* But if that file does not exist, assign the span to the first
|
||||
available place.
|
||||
|
||||
This script mainly uses the commands
|
||||
link:doc/dahdi_span_types.8.html[dahdi_span_types] and
|
||||
link:doc/dahdi_span_assignments.8.html[dahdi_span_assignments].
|
||||
|
||||
DAHDI devices are listed under `/sys/bus/dahdi_devices/devices`.
|
||||
|
||||
If you want to disable running this script, add the following line to
|
||||
`/etc/dahdi/init.conf`:
|
||||
.............................
|
||||
DAHDI_UDEV_DISABLE_DEVICES=yes
|
||||
.............................
|
||||
|
||||
|
||||
New Spans
|
||||
^^^^^^^^^
|
||||
Once a span is assigned, a kernel object will appear for it. It will be
|
||||
listed under its device. As a new kernel object was created, an event is
|
||||
sent to udev.
|
||||
|
||||
The standard DAHDI udev rules instruct udevd to run the script
|
||||
`/usr/share/dahdi/dahdi_span_config` which runs all the scripts in
|
||||
`/usr/share/dahdi/span_config.d`. Those script configures the new
|
||||
span:
|
||||
|
||||
* If system.conf does not exist, generates a temporary configuration
|
||||
for the span using link:doc/dahdi_genconf.8.html[dahdi_genconf
|
||||
system].
|
||||
|
||||
* Runs link:doc/dahdi_cfg.8.html[dahdi_cfg] on the new span (using `-S`
|
||||
and -C`).
|
||||
|
||||
* Runs `asterisk -rx 'dahdi create channels'` to add the new channels
|
||||
and spans to Asterisk (if they were configured in advance).
|
||||
|
||||
If you want to disable running this script, add the following line to
|
||||
`/etc/dahdi/init.conf`:
|
||||
.............................
|
||||
DAHDI_UDEV_DISABLE_SPANS=yes
|
||||
.............................
|
||||
|
||||
|
||||
New Channels
|
||||
^^^^^^^^^^^^
|
||||
DAHDI channels have their own representation in the kernel. The standard
|
||||
udev rules that dahdi-tools includes for them, however, don't run a
|
||||
script for each device. Each DAHDI channel creates a block device file
|
||||
at /dev/dahdi/chan/'span'/'rel-chan', where 'span' and 'rel-chan' are
|
||||
each three-digit numbers (e.g: 035). 'span' is the span number and
|
||||
'rel-chan' is the channel number relative to the span.
|
||||
|
||||
The udev rules generate the following extra symlinks under /dev/dahdi:
|
||||
|
||||
* /dev/dahdi/'num' - the channel number. As it was originally (but
|
||||
continues beyond 250).
|
||||
* /dev/dahdi/devices/'hardware_id'/'rel-span'/'rel-chan' - if the DAHDI
|
||||
device has a hardware ID field, provide listing of the device's span
|
||||
and channels.
|
||||
* /dev/dahdi/devices/@'hardware_id'/'rel-span'/'rel-chan' - likewise for
|
||||
the connector field. It has a "@" prefix.
|
||||
|
||||
|
||||
include::UPGRADE.txt[]
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
This package is distributed under the terms of the GNU General Public License
|
||||
Version 2, except for some components which are distributed under the terms of
|
||||
the GNU Lesser General Public License Version 2.1. Both licenses are included
|
||||
in this directory, and each file is clearly marked as to which license applies.
|
||||
|
||||
If you wish to use the DAHDI drivers in an application for which the license
|
||||
terms are not appropriate (e.g. a proprietary embedded system), licenses under
|
||||
more flexible terms can be readily obtained through Digium, Inc. at reasonable
|
||||
cost.
|
||||
|
||||
|
||||
Reporting Bugs
|
||||
--------------
|
||||
Please report bug and patches to the Asterisk bug tracker at
|
||||
http://bugs.digium.com/[] in the "DAHDI" category.
|
||||
|
||||
|
||||
Links
|
||||
-----
|
||||
- http://asterisk.org/[] - The Asterisk PBX
|
||||
- http://voip-info.org/[]
|
||||
- http://voip-info.org/wiki/view/DAHDI[]
|
||||
- http://docs.tzafrir.org.il/dahdi-tools/README.html[Up-to-date HTML version
|
||||
of this file]
|
|
@ -0,0 +1,102 @@
|
|||
Upgrade Notes
|
||||
-------------
|
||||
|
||||
Information for upgrading from Zaptel 1.2 or 1.4 to DAHDI 2.0
|
||||
|
||||
Upgrading from Zaptel to DAHDI is fairly straightforward; install this
|
||||
package using the installation instructions, and then reconfigure and
|
||||
rebuild Asterisk; Asterisk 1.4 releases later than 1.4.21, and all
|
||||
releases of Asterisk 1.6, will automatically use DAHDI in preference
|
||||
to Zaptel, even if Zaptel is still installed on the system.
|
||||
|
||||
Important notes about upgrading:
|
||||
|
||||
The Zaptel package, which included both kernel modules and userspace
|
||||
tools for configuring and managing the modules, has been split into
|
||||
two packages:
|
||||
|
||||
* dahdi-linux: kernel modules
|
||||
* dahdi-tools: userspace tools
|
||||
|
||||
In addition, there is a dahdi-linux-complete package that contains both
|
||||
dahdi-linux and dahdi-tools for simplified installation.
|
||||
|
||||
NOTE: The dahdi-linux and dahdi-tools packages have *separate*
|
||||
version numbers; they will not be released 'in sync', and it is
|
||||
perfectly acceptable to use (for example) dahdi-tools 2.0.6 with
|
||||
dahdi-linux 2.0.11. The dahdi-linux-complete package version number will
|
||||
always include *both* of these version numbers so that you will know
|
||||
what is included in it.
|
||||
|
||||
|
||||
DAHDI-Linux
|
||||
~~~~~~~~~~~
|
||||
Module Names
|
||||
^^^^^^^^^^^^
|
||||
The primary kernel modules have changed names; the new names are:
|
||||
|
||||
zaptel.ko -> dahdi.ko
|
||||
ztd-eth.ko -> dahdi_dynamic_eth.ko
|
||||
ztd-loc.ko -> dahdi_dynamic_loc.ko
|
||||
ztdummy.ko -> dahdi_dummy.ko
|
||||
ztdynamic.ko -> dahdi_dynamic.ko
|
||||
zttranscode.ko -> dahdi_transcode.ko
|
||||
|
||||
* The kernel modules for card drivers have *not* changed names,
|
||||
although the wcusb and torisa drivers are no longer included.
|
||||
|
||||
* This package no longer includes the 'menuselect' utility for
|
||||
choosing which modules to build; all modules that can be built are
|
||||
built automatically.
|
||||
|
||||
|
||||
Echo Canceller Modules
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
It is no longer possible and needed to select a software echo canceler
|
||||
at compile time to build into dahdi.ko; all four included echo
|
||||
cancelers (MG2, KB1, SEC and SEC2) are built as loadable modules.
|
||||
If the Digium HPEC binary object file has been placed into the
|
||||
proper directory the HPEC module will be built as well.
|
||||
|
||||
Any or all of these modules can be loaded at the same time, and the echo
|
||||
canceler to be used on the system's channels can be configured using
|
||||
the dahdi_cfg tool from the dahdi-tools package.
|
||||
|
||||
IMPORTANT: It is *mandatory* to configure an echo canceler for the system's
|
||||
channels using dahdi_cfg. There is *no* default echo canceler with DAHDI, not
|
||||
even hardware echo cancellation modules. See
|
||||
<<_echo_cancellers,section on echo cancellers>> in sample system.conf.
|
||||
|
||||
|
||||
DAHDI-Tools
|
||||
~~~~~~~~~~~
|
||||
Many tool names have changed:
|
||||
|
||||
ztcfg -> dahdi_cfg
|
||||
ztmonitor -> dahdi_monitor
|
||||
ztscan -> dahdi_scan
|
||||
ztspeed -> dahdi_speed
|
||||
zttest -> dahdi_test
|
||||
zttool -> dahdi_tool
|
||||
zapconf -> dahdi_genconf (deprecates genzaptelconf)
|
||||
|
||||
* The system configuration file has moved from /etc/zaptel.conf to
|
||||
<<_sample_system_conf,/etc/dahdi/system.conf>>.
|
||||
|
||||
* The dahdi_cfg tool can now be used to select an echo canceler on a
|
||||
channel-by-channel basis in the system configuration file; see
|
||||
system.conf.sample for examples of how to do this.
|
||||
|
||||
* The configuration for XPP init_card_* scripts is done now
|
||||
in /etc/dahdi/xpp.conf and uses a simple syntax (example included).
|
||||
For PRI modules, the 'pri_protocol' setting, determines how
|
||||
to configure it (E1/T1).
|
||||
|
||||
* In Astribank PRI modules, the LED behaviour represents which ports
|
||||
are *CLOCK MASTER* (red color) and which are *CLOCK SLAVE* (green color).
|
||||
Usually (but not always), this corresponds to the NT/TE settings in Asterisk.
|
||||
|
||||
* The /etc/sysconfig/zaptel (or /etc/default/zaptel file, depending
|
||||
on your distribution) is now split into two separate files:
|
||||
/etc/dahdi/modules control which modules are loaded and module options are
|
||||
set via /etc/modprobe.d/dahdi.
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# /etc/dahdi/assigned-spans.conf:
|
||||
#
|
||||
# This file assigns span and channel numbers to dahdi devices
|
||||
#
|
||||
# Built as a table keyed by <id>:
|
||||
# <id> <spanspec>....
|
||||
#
|
||||
# Where:
|
||||
# * The <id> field may be either:
|
||||
# hardware_id
|
||||
# @location
|
||||
# devpath (in sysfs)
|
||||
# * Shell-style globbing is allowed for the <id> field
|
||||
# * There may one or more of <spanspec>
|
||||
# * Each <spanspec> is composed as:
|
||||
# <local_spanno>:<assigned_spanno>:<base_channo>
|
||||
#
|
||||
# Examples:
|
||||
|
||||
# Astribank with two spans:
|
||||
# FXS * 8 channels + 4 digital inputs 2 digital outputs
|
||||
# FXO * 8 channels
|
||||
#usb:QA-1 1:1:1
|
||||
#usb:QA-1 2:2:15
|
||||
|
||||
# Same Astribank in one-liner
|
||||
#usb:QA-1 1:1:1 2:2:15
|
||||
|
||||
# Astribank with 4*PRI spans and 3*FXS*8 spans
|
||||
# Note that channels are NOT globally contigous
|
||||
# each span get its own 50 numbers. Also, skip
|
||||
# Channel number 250...
|
||||
#usb:INT03165 1:1:1 # E1
|
||||
#usb:INT03165 2:2:51 # E1
|
||||
#usb:INT03165 3:3:151 # E1
|
||||
#usb:INT03165 4:4:201 # E1
|
||||
#usb:INT03165 5:5:301 # FXS * 8 channels
|
||||
#usb:INT03165 6:6:351 # FXS * 8 channels
|
||||
#usb:INT03165 7:7:401 # FXS * 8 channels
|
||||
|
||||
# Alternatively -- all in one-line
|
||||
#usb:INT03165 1:1:1 2:2:51 3:3:151 4:4:201 5:5:301 6:6:351 7:7:401
|
||||
|
||||
# Astribank with 4*BRI without hardware_id :-(
|
||||
# We use the location on the bus (ie: where it is physically
|
||||
# located). Note the '@' prefix that indicate the location key.
|
||||
#@usb-0000:00:1d.7-3 1:1:50
|
||||
#@usb-0000:00:1d.7-3 2:2:100
|
||||
#@usb-0000:00:1d.7-3 3:3:150
|
||||
#@usb-0000:00:1d.7-3 4:4:200
|
||||
|
||||
# Same configuration with globbing:
|
||||
#/sys/*/usb1/1-6/* 1:1:50
|
||||
#/sys/*/usb1/1-6/* 2:2:100
|
||||
#/sys/*/usb1/1-6/* 3:3:150
|
||||
#/sys/*/usb1/1-6/* 4:4:200
|
|
@ -0,0 +1,114 @@
|
|||
/* autoconfig.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define if your system has the DAHDI headers. */
|
||||
#undef HAVE_DAHDI
|
||||
|
||||
/* Define if your system has the DAHDI23 headers. */
|
||||
#undef HAVE_DAHDI23
|
||||
|
||||
/* Define DAHDI23 headers version */
|
||||
#undef HAVE_DAHDI23_VERSION
|
||||
|
||||
/* Define DAHDI headers version */
|
||||
#undef HAVE_DAHDI_VERSION
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <linux/soundcard.h> header file. */
|
||||
#undef HAVE_LINUX_SOUNDCARD_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define this to indicate the ${NEWT_DESCRIP} library */
|
||||
#undef HAVE_NEWT
|
||||
|
||||
/* Define to indicate the ${NEWT_DESCRIP} library version */
|
||||
#undef HAVE_NEWT_VERSION
|
||||
|
||||
/* Define to 1 if you have the `semtimedop' function. */
|
||||
#undef HAVE_SEMTIMEDOP
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/soundcard.h> header file. */
|
||||
#undef HAVE_SYS_SOUNDCARD_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define this to indicate the ${USB_DESCRIP} library */
|
||||
#undef HAVE_USB
|
||||
|
||||
/* Define to indicate the ${USB_DESCRIP} library version */
|
||||
#undef HAVE_USB_VERSION
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Enable extensions on AIX 3, Interix. */
|
||||
#ifndef _ALL_SOURCE
|
||||
# undef _ALL_SOURCE
|
||||
#endif
|
||||
/* Enable GNU extensions on systems that have them. */
|
||||
#ifndef _GNU_SOURCE
|
||||
# undef _GNU_SOURCE
|
||||
#endif
|
||||
/* Enable threading extensions on Solaris. */
|
||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
||||
# undef _POSIX_PTHREAD_SEMANTICS
|
||||
#endif
|
||||
/* Enable extensions on HP NonStop. */
|
||||
#ifndef _TANDEM_SOURCE
|
||||
# undef _TANDEM_SOURCE
|
||||
#endif
|
||||
/* Enable general extensions on Solaris. */
|
||||
#ifndef __EXTENSIONS__
|
||||
# undef __EXTENSIONS__
|
||||
#endif
|
||||
|
||||
|
||||
/* Define to 1 if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
static int bit_next(int prev)
|
||||
{
|
||||
return (prev + 1) % 256;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
# blacklist all the drivers by default in order to ensure that
|
||||
# /etc/init.d/dahdi installs them in the correct order so that the spans are
|
||||
# ordered consistently.
|
||||
|
||||
blacklist wct4xxp
|
||||
blacklist wcte12xp
|
||||
blacklist wcte13xp
|
||||
blacklist wct1xxp
|
||||
blacklist wcte11xp
|
||||
blacklist wctdm24xxp
|
||||
blacklist wcfxo
|
||||
blacklist wctdm
|
||||
blacklist wctc4xxp
|
||||
blacklist wcb4xxp
|
||||
blacklist wcaxx
|
||||
blacklist wcte43x
|
||||
|
||||
# Some mISDN drivers may try to attach to cards supported by DAHDI. If you
|
||||
# have a card which is *not* supported by DAHDI but supported by one of the
|
||||
# below drivers you should feel free to remove it from the blacklist below.
|
||||
blacklist hfcmulti
|
||||
blacklist netjet
|
||||
blacklist hfcpci
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
|
||||
check_for_app() {
|
||||
$1 --version 2>&1 >/dev/null
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
echo "Please install $1 and run bootstrap.sh again!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# On FreeBSD and OpenBSD, multiple autoconf/automake versions have different names.
|
||||
# On linux, envitonment variables tell which one to use.
|
||||
|
||||
uname -s | grep -q BSD
|
||||
if [ $? = 0 ] ; then # BSD case
|
||||
case `uname -sr` in
|
||||
'FreeBSD 4'*) # FreeBSD 4.x has a different naming
|
||||
MY_AC_VER=259
|
||||
MY_AM_VER=19
|
||||
;;
|
||||
*)
|
||||
MY_AC_VER=-2.62
|
||||
MY_AM_VER=-1.9
|
||||
;;
|
||||
esac
|
||||
else # linux case
|
||||
MY_AC_VER=
|
||||
MY_AM_VER=
|
||||
AUTOCONF_VERSION=2.60
|
||||
AUTOMAKE_VERSION=1.9
|
||||
export AUTOCONF_VERSION
|
||||
export AUTOMAKE_VERSION
|
||||
fi
|
||||
|
||||
check_for_app autoconf${MY_AC_VER}
|
||||
check_for_app autoheader${MY_AC_VER}
|
||||
check_for_app automake${MY_AM_VER}
|
||||
check_for_app aclocal${MY_AM_VER}
|
||||
|
||||
echo "Generating the configure script ..."
|
||||
|
||||
aclocal${MY_AM_VER}
|
||||
autoconf${MY_AC_VER}
|
||||
autoheader${MY_AC_VER}
|
||||
automake${MY_AM_VER} --add-missing --copy 2>/dev/null
|
||||
|
||||
exit 0
|
|
@ -0,0 +1,90 @@
|
|||
#!/bin/sh
|
||||
|
||||
# upload_dahdi: upload a dahdi tarball to updates.xorcom.com
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
BRANCH_NAME=1.4
|
||||
REV=HEAD
|
||||
DAHDI_BASE=http://svn.digium.com/svn/dahdi
|
||||
TARBALLS_DIR=$PWD
|
||||
|
||||
me=`basename $0`
|
||||
|
||||
say() {
|
||||
echo "$me: $@"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo >&2 "$0: Generate snapshot from DAHDI SVN"
|
||||
echo >&2 ' ($Id$)'
|
||||
echo >&2 ""
|
||||
echo >&2 "$0 [-r REV] [-2] [-s]"
|
||||
echo >&2 "$0 <-h | --help>: This message"
|
||||
echo >&2 ""
|
||||
echo >&2 "Options:"
|
||||
echo >&2 " -2 --dahdi12: Use Asterisk 1.2. Implies -u."
|
||||
echo >&2 " -r --rev REV: extract xpp-dahdi from this revision ($REV)."
|
||||
echo >&2 " -s --show: Just show versions. Do nothing"
|
||||
|
||||
}
|
||||
|
||||
opt_showonly=no
|
||||
|
||||
options=`getopt -o 2hr:s --long dahdi12,help,rev:,revision:,show -- "$@"`
|
||||
if [ $? != 0 ] ; then echo >&2 "Terminating..." ; exit 1 ; fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "$options"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-2|--dahdi12) BRANCH_NAME=1.2;;
|
||||
-s|--show) opt_showonly=yes ;;
|
||||
-r|--rev|--revision) REV="$2"; shift ;;
|
||||
-h|--help) usage; exit 0;;
|
||||
--) shift ; break ;;
|
||||
esac
|
||||
shift;
|
||||
done
|
||||
|
||||
BRANCH=branches/$BRANCH_NAME
|
||||
DAHDI_URL=$DAHDI_BASE/$BRANCH
|
||||
|
||||
set -e
|
||||
|
||||
# Get the name of the "previous version" for this release.
|
||||
# The idea is to look at the latest tag for that branhch. Tags are
|
||||
# global, and hence we filter tag names by branch name.
|
||||
#
|
||||
# Note: this strips any minor version number.
|
||||
# e.g: if last releast was 1.4.5.1, this will still return 1.4.5 . Here
|
||||
# we rely on the fact that the revision number will be added.
|
||||
dahdi_ver=`svn ls -r $REV $DAHDI_BASE/tags | grep "^$BRANCH_NAME" \
|
||||
| sed -e "s/\($BRANCH_NAME\.[0-9]\+\)[/.-].*/\1/" \
|
||||
| sort -nu -t . -k 3 | tail -n 1`
|
||||
|
||||
real_rev=`svn info -r $REV $DAHDI_URL \
|
||||
| awk '/^Last Changed Rev: /{print $4}'`
|
||||
|
||||
ver_full="$dahdi_ver.9.svn.$real_rev"
|
||||
tar_name="dahdi-$ver_full"
|
||||
tar_ball_full="$TARBALLS_DIR/$tar_name.tar.gz"
|
||||
|
||||
say "Version: $ver_full (ver: $dahdi_ver, rev: $real_rev)"
|
||||
say "Tarball: $tar_ball_full"
|
||||
|
||||
if [ "$opt_showonly" = 'yes' ]; then
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
DAHDI_CHECKOUT_DIR=`mktemp -d dahdi_checkout_dir_XXXXXX`
|
||||
|
||||
# Package a tarball from the subversion, using 'make dist':
|
||||
svn export -q -r $REV $DAHDI_URL $DAHDI_CHECKOUT_DIR/$tar_name
|
||||
echo "$ver_full" >$DAHDI_CHECKOUT_DIR/$tar_name/.version
|
||||
tar cz -C $DAHDI_CHECKOUT_DIR -f $tar_ball_full $tar_name
|
||||
|
||||
rm -rf $DAHDI_CHECKOUT_DIR
|
||||
|
|
@ -0,0 +1,142 @@
|
|||
#! /usr/bin/perl
|
||||
#
|
||||
# Written by Oron Peled <oron@actcom.co.il>
|
||||
# Copyright (C) 2012, Xorcom
|
||||
# This program is free software; you can redistribute and/or
|
||||
# modify it under the same terms as Perl itself.
|
||||
#
|
||||
#dahdi_sysfs_copy: Short perl script to copy dahdi related sysfs trees
|
||||
# into a designated directory.
|
||||
#
|
||||
# $Id: $
|
||||
#
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Path qw(mkpath);
|
||||
use File::Copy;
|
||||
use Cwd qw(realpath);
|
||||
|
||||
my $destdir = shift || die "Usage: $0 <destdir>\n";
|
||||
|
||||
my %symlinks;
|
||||
my %walk_ups;
|
||||
my %inode_cash;
|
||||
|
||||
# Starting points for recursion
|
||||
my @toplevels = qw(
|
||||
/sys/bus/dahdi_devices
|
||||
/sys/bus/astribanks
|
||||
/sys/class/dahdi
|
||||
);
|
||||
|
||||
# Loop prevention (by inode number lookup)
|
||||
sub seen {
|
||||
my $ino = shift || die;
|
||||
my $path = shift || die;
|
||||
if(defined $inode_cash{$ino}) {
|
||||
#print STDERR "DEBUG($ino): $path\n";
|
||||
return 1;
|
||||
}
|
||||
$inode_cash{$ino}++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Walk up a path and copy readable attributes from any
|
||||
# directory level.
|
||||
sub walk_up {
|
||||
my $path = shift || die;
|
||||
my $curr = $path;
|
||||
# Walk up
|
||||
for (my $curr = $path; $curr; $curr =~ s'/?[^/]+$'') {
|
||||
my ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($curr);
|
||||
next if seen($ino, $curr); # Skip visited directories
|
||||
# Scan directory
|
||||
opendir(my $d, $curr) || die "Failed opendir($curr): $!\n";
|
||||
my @entries = readdir $d;
|
||||
foreach my $entry (@entries) {
|
||||
next if $entry =~ /^[.][.]?$/;
|
||||
my $file = "$curr/$entry";
|
||||
my ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($file);
|
||||
# Copy file
|
||||
if (-f _ && ($mode & 0004)) { # The '-r _' is buggy
|
||||
copy($file, "$destdir$file") ||
|
||||
die "Failed to copy '$file': $!\n";
|
||||
}
|
||||
}
|
||||
closedir $d;
|
||||
}
|
||||
}
|
||||
|
||||
# Handle a given path (directory,symlink,regular-file)
|
||||
sub handle_path {
|
||||
my $path = shift || die;
|
||||
my ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($path);
|
||||
# Save attributes before recursion starts
|
||||
my $isdir = -d _;
|
||||
my $islink = -l _;
|
||||
my $isreadable = $mode & 00004; # The '-r _' was buggy
|
||||
return if seen($ino, $path); # Loop prevention
|
||||
my $dest = "$destdir/$path";
|
||||
if ($isdir) {
|
||||
mkpath("$dest");
|
||||
scan_directory($path);
|
||||
} elsif ($islink) {
|
||||
# We follow links (the seen() protect us from loops)
|
||||
my $target = readlink($path) ||
|
||||
die "Failed readlink($path): $!\n";
|
||||
my $follow = $target;
|
||||
if ($target !~ m{^/}) { # fix relative symlinks
|
||||
my $dir = $path;
|
||||
$dir =~ s,/[^/]*$,,;
|
||||
$follow = realpath("$dir/$target");
|
||||
}
|
||||
# Save symlink details, so we create them after all
|
||||
# destination tree (subdirectories, files) is ready
|
||||
die "Duplicate entry '$dest'\n" if exists $symlinks{$dest};
|
||||
$symlinks{$dest} = "$target";
|
||||
# Now follow symlink
|
||||
handle_path($follow);
|
||||
$walk_ups{$follow}++;
|
||||
} elsif ($isreadable) {
|
||||
copy($path, "$dest") ||
|
||||
die "Failed to copy '$path': $!\n";
|
||||
}
|
||||
}
|
||||
|
||||
# Scan a given directory (calling handle_path for recursion)
|
||||
sub scan_directory {
|
||||
my $dir = shift || die;
|
||||
my $entry;
|
||||
opendir(my $d, $dir) || die "Failed opendir($dir): $!\n";
|
||||
my @dirs = readdir $d;
|
||||
foreach my $entry (@dirs) {
|
||||
next if $entry =~ /^[.][.]?$/;
|
||||
handle_path("$dir/$entry");
|
||||
}
|
||||
closedir $d;
|
||||
}
|
||||
|
||||
# Filter out non-existing toplevels
|
||||
my @scan = grep { lstat($_) } @toplevels;
|
||||
|
||||
# Recurse all trees, creating subdirectories and copying files
|
||||
foreach my $path (@scan) {
|
||||
handle_path($path);
|
||||
}
|
||||
|
||||
# Now, that all sub-directories were created, we can
|
||||
# create the wanted symlinks
|
||||
for my $dest (keys %symlinks) {
|
||||
my $link = $symlinks{$dest};
|
||||
die "Missing link for '$dest'\n" unless defined $link;
|
||||
unlink $dest if -l $dest;
|
||||
symlink($link,$dest) ||
|
||||
die "Failed symlink($link,$dest): $!\n";
|
||||
}
|
||||
|
||||
# Walk up directories that were symlink destinations
|
||||
# and fill their attributes
|
||||
foreach my $dir (keys %walk_ups) {
|
||||
walk_up($dir);
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
#!/bin/sh
|
||||
|
||||
# dump_sys_state: dump some /sys and /proc files to a directory.
|
||||
# $Id$
|
||||
#
|
||||
# Written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
# Copyright (C) 2009, Xorcom
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
# 02110-1301, USA
|
||||
|
||||
# The DAHDI-perl modules will use such a dump instead of the files from
|
||||
# the real system if DAHDI_VIRT_TOP is set to the root.
|
||||
#
|
||||
# ./build_tools/dump_sys_state my_sys_state
|
||||
#
|
||||
# # And then later:
|
||||
# DAHDI_VIRT_TOP="$PWD/my_sys_state" dahdi_genconf
|
||||
|
||||
mydir=`dirname $0`
|
||||
dahdi_sysfs_copy="$mydir/dahdi_sysfs_copy"
|
||||
|
||||
# Give usage message on expected texts
|
||||
|
||||
if [ "$#" -ne 0 ]; then
|
||||
echo >&2 "Usage: $0"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
id="sys_dump.`hostname`_`date +%F_%H.%M.%S`"
|
||||
tarball="$id.tar.gz"
|
||||
|
||||
tmpdir=`mktemp -td 'dahdi_dump.XXXXXX'`
|
||||
echo -n >&2 "Creating ... "
|
||||
trap "[ -d '$tmpdir' ] && rm -rf '$tmpdir'" 0 1 2 15
|
||||
|
||||
topdir="$tmpdir/$id"
|
||||
|
||||
if [ -r /proc/bus/usb/devices ]; then
|
||||
mkdir -p "$topdir/proc/bus/usb"
|
||||
cp -a /proc/bus/usb/devices "$topdir/proc/bus/usb/"
|
||||
fi
|
||||
|
||||
if [ -d /proc/dahdi ]; then
|
||||
mkdir -p "$topdir/proc/dahdi"
|
||||
if find /proc/dahdi -type f >/dev/null; then
|
||||
cp -a /proc/dahdi/* "$topdir/proc/dahdi/"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d /proc/xpp ]; then
|
||||
mkdir -p "$topdir/proc/xpp"
|
||||
if find /proc/xpp -type f >/dev/null; then
|
||||
cp -a /proc/xpp/* "$topdir/proc/xpp/"
|
||||
find "$topdir/proc/xpp" -type f -name command -exec rm -f '{}' ';'
|
||||
fi
|
||||
fi
|
||||
|
||||
"$dahdi_sysfs_copy" "$topdir"
|
||||
echo -n >&2 "tarball ... "
|
||||
( cd "$tmpdir" && tar czf - . ) > "$tarball";
|
||||
echo >&2 "ready in '$tarball'"
|
|
@ -0,0 +1,26 @@
|
|||
#! /bin/sh
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo >&2 "Usage: $0 <package> <version>"
|
||||
exit 1
|
||||
fi
|
||||
package="$1"
|
||||
version="$2"
|
||||
tarball_prefix="$package-$version"
|
||||
echo "I: Making dist tarball for $tarball_prefix"
|
||||
tarball_name="$tarball_prefix.tar.gz"
|
||||
|
||||
tmp_work_dir=".tmp"
|
||||
tmp_version_dir="$tmp_work_dir/$tarball_prefix"
|
||||
|
||||
if [ "$DESTDIR" != '' ]; then
|
||||
destdir="$DESTDIR/"
|
||||
fi
|
||||
output="$destdir$tarball_name"
|
||||
|
||||
mkdir -p "$tmp_version_dir"
|
||||
git archive --format tar HEAD | tar xf - -C "$tmp_version_dir"
|
||||
echo "$version" > "$tmp_version_dir/.version"
|
||||
tar czf "$output" -C "$tmp_work_dir" "$tarball_prefix"
|
||||
rm -rf "$tmp_work_dir"
|
||||
echo "I: tarball is ready: '$output'"
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# make an object file from a raw binary firmware file
|
||||
# arguments:
|
||||
# 1 - firmware file
|
||||
# 2 - output file
|
||||
|
||||
bfdname=@BDFNAME@
|
||||
bfdarch=@BDFARCH@
|
||||
|
||||
objcopy -I binary ${1} -B ${bfdarch} -O ${bfdname} ${2} --rename-section .data=.rodata,alloc,load,data,contents,readonly
|
|
@ -0,0 +1,122 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -f ${1}/.version ]; then
|
||||
cat ${1}/.version
|
||||
elif [ -f ${1}/.svnrevision ]; then
|
||||
echo SVN-`cat ${1}/.svnbranch`-r`cat ${1}/.svnrevision`
|
||||
elif [ -d ${1}/.svn ]; then
|
||||
PARTS=`LANG=C svn info ${1} | grep URL | awk '{print $2;}' | sed -e s:^.*/svn/${2}/:: | sed -e 's:/: :g'`
|
||||
BRANCH=0
|
||||
TEAM=0
|
||||
|
||||
REV=`svnversion -c ${1} | cut -d: -f2`
|
||||
|
||||
if [ "${PARTS}" = "trunk" ]
|
||||
then
|
||||
echo SVN-'trunk'-r${REV}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for PART in $PARTS
|
||||
do
|
||||
if [ ${BRANCH} != 0 ]
|
||||
then
|
||||
RESULT="${RESULT}-${PART}"
|
||||
break
|
||||
fi
|
||||
|
||||
if [ ${TEAM} != 0 ]
|
||||
then
|
||||
RESULT="${RESULT}-${PART}"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "branches" ]
|
||||
then
|
||||
BRANCH=1
|
||||
RESULT="branch"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "tags" ]
|
||||
then
|
||||
BRANCH=1
|
||||
RESULT="tag"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "team" ]
|
||||
then
|
||||
TEAM=1
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
echo SVN-${RESULT##-}-r${REV}
|
||||
elif [ -d ${1}/.git ]; then
|
||||
# If the first log commit messages indicates that this is checked into
|
||||
# subversion, we'll just use the SVN- form of the revision.
|
||||
MODIFIED=""
|
||||
SVN_REV=`git log --pretty=full -1 | grep -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
|
||||
if [ -z "$SVN_REV" ]; then
|
||||
VERSION=`git describe --tags --dirty=M 2> /dev/null | sed -e "s/^v\([0-9]\)/\1/"`
|
||||
if [ $? -ne 0 ]; then
|
||||
if [ "`git ls-files -m | wc -l`" != "0" ]; then
|
||||
MODIFIED="M"
|
||||
fi
|
||||
# Some older versions of git do not support all the above
|
||||
# options.
|
||||
VERSION=GIT-`git rev-parse --short --verify HEAD`${MODIFIED}
|
||||
fi
|
||||
echo ${VERSION}
|
||||
else
|
||||
PARTS=`LANG=C git log --pretty=full | grep -F "git-svn-id:" | head -1 | awk '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
|
||||
BRANCH=0
|
||||
TEAM=0
|
||||
|
||||
if [ "`git ls-files -m | wc -l`" != "0" ]; then
|
||||
MODIFIED="M"
|
||||
fi
|
||||
|
||||
if [ "${PARTS}" = "trunk" ]; then
|
||||
echo SVN-'trunk'-r${SVN_REV}${MODIFIED}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for PART in $PARTS
|
||||
do
|
||||
if [ ${BRANCH} != 0 ]; then
|
||||
RESULT="${RESULT}-${PART}"
|
||||
break
|
||||
fi
|
||||
|
||||
if [ ${TEAM} != 0 ]; then
|
||||
RESULT="${RESULT}-${PART}"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "branches" ]; then
|
||||
BRANCH=1
|
||||
RESULT="branch"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "tags" ]; then
|
||||
BRANCH=1
|
||||
RESULT="tag"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${PART}" = "team" ]; then
|
||||
TEAM=1
|
||||
continue
|
||||
fi
|
||||
done
|
||||
|
||||
echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED}
|
||||
fi
|
||||
else
|
||||
# Use the directory information in the absence of any other version
|
||||
# information
|
||||
pwd -P
|
||||
fi
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
cat << END
|
||||
/*
|
||||
* version.c
|
||||
* Automatically generated
|
||||
*/
|
||||
|
||||
const char dahdi_tools_version[] = "DAHDI Tools Version - ${TOOLSVERSION}";
|
||||
|
||||
END
|
|
@ -0,0 +1,80 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
GIT_URL=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
|
||||
CONF_FILE=build_tools/git_test.conf
|
||||
|
||||
usage() {
|
||||
me=`basename $0`
|
||||
echo "$me: test building Zaptel vs. kernel from git"
|
||||
echo "Usage:"
|
||||
echo " $me checkout <kerneldir> Pull a kernel version into <kerneldir>"
|
||||
echo " $me update Update (pull) the kernel tree."
|
||||
echo " $me setver <kernel_ver> Set the kernel version"
|
||||
echo " $me test Test-build"
|
||||
echo ""
|
||||
echo " $me versions [pattern] List available versions."
|
||||
}
|
||||
|
||||
# Set a variable in $CONF_FILE
|
||||
# The format of CONF_FILE is assumed to be:
|
||||
# VAR=value
|
||||
# in shell syntax. "value" may be quoted.
|
||||
# "value should not contain a '|' character.
|
||||
set_var() {
|
||||
var="$1"
|
||||
val="$2"
|
||||
if grep -q "^$var=" $CONF_FILE 2>/dev/null; then
|
||||
sed -i -e "s|^$var=.*|$var=\"$val\"|" $CONF_FILE
|
||||
else
|
||||
echo "$var=\"$val\"" >>$CONF_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -r "$CONF_FILE" ]; then . "$CONF_FILE"; fi
|
||||
|
||||
if echo "$CONF_FILE" | grep -qv '^/'; then
|
||||
# make CONF_FILE an absolute path:
|
||||
CONF_FILE="$PWD/$CONF_FILE"
|
||||
fi
|
||||
|
||||
command="$1"
|
||||
|
||||
case "$command" in
|
||||
checkout)
|
||||
kernel_dir="$2"
|
||||
cd "$kernel_dir"
|
||||
git clone $GIT_URL
|
||||
set_var kernel_dir "$kernel_dir/linux-2.6"
|
||||
;;
|
||||
update)
|
||||
cd "$kernel_dir"
|
||||
git pull
|
||||
;;
|
||||
versions)
|
||||
cd "$kernel_dir"
|
||||
git tag -l $2 | cut -c2-
|
||||
;;
|
||||
setver)
|
||||
kernel_ver="$2"
|
||||
tag="v$kernel_ver"
|
||||
cd "$kernel_dir"
|
||||
git-reset --hard "$tag"
|
||||
make defconfig prepare
|
||||
set_var kernel_ver "$kernel_ver"
|
||||
;;
|
||||
test)
|
||||
# you can pass extra parameters to the make command in
|
||||
# two ways:
|
||||
# 1. Set th value of MAKE_PARAMS in git_test.conf .
|
||||
# 2. Any extra command-line parameter.
|
||||
shift
|
||||
make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS "$@"
|
||||
;;
|
||||
*)
|
||||
echo "$0: no such command $command. Aborting."
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
# uninstall-modules
|
||||
#
|
||||
# Remove all the modules passed in on the command line from the modules
|
||||
# directory. This script is called by the makefile.
|
||||
|
||||
KERNEL_MODULES_DIR=$1
|
||||
shift
|
||||
MODULES="$*"
|
||||
|
||||
usage() {
|
||||
echo "$0: Used to delete kernel modules from the modules directory."
|
||||
echo ""
|
||||
echo "Usage:"
|
||||
echo " $0 MODULES_BASE_DIR mod1 [mod2 [...]]"
|
||||
echo ""
|
||||
echo " MODULES_BASE_DIR - typically /lib/modules/KVERS"
|
||||
echo " modN - (optionally partial) module name to remove."
|
||||
}
|
||||
|
||||
if [ -z "$KERNEL_MODULES_DIR" ]; then
|
||||
echo "Missing kernel module directory."
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if [ -z "$MODULES" ]; then
|
||||
echo "Missing one or more modules to delete."
|
||||
usage
|
||||
exit 1;
|
||||
fi
|
||||
for mod in $MODULES; do
|
||||
BASE=`basename $mod`
|
||||
for file in `cat $KERNEL_MODULES_DIR/modules.dep | cut -d : -f 1 | grep "$BASE$"`; do
|
||||
if [ -e "$file" ]; then
|
||||
#echo "Deleting $file."
|
||||
rm -f $file
|
||||
fi
|
||||
done
|
||||
done
|
||||
exit 0
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,217 @@
|
|||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
m4_define([TOOLSVERSION],
|
||||
m4_bpatsubst(m4_esyscmd([build_tools/make_version . dahdi/tools]),
|
||||
[\([0-9.]*\)\(\w\|\W\)*],
|
||||
[\1]))
|
||||
AC_INIT(dahdi, TOOLSVERSION, www.asterisk.org)
|
||||
|
||||
# check existence of the package
|
||||
AC_CONFIG_SRCDIR([dahdi_cfg.c])
|
||||
|
||||
AC_COPYRIGHT("dahdi-tools")
|
||||
AC_REVISION($Revision$)
|
||||
|
||||
ac_default_prefix=/usr
|
||||
if test ${sysconfdir} = '${prefix}/etc'; then
|
||||
sysconfdir=/etc
|
||||
fi
|
||||
if test ${mandir} = '${prefix}/man'; then
|
||||
mandir=/usr/share/man
|
||||
fi
|
||||
|
||||
if test ${localstatedir} = '${prefix}/var'; then
|
||||
localstatedir=/var
|
||||
fi
|
||||
|
||||
# specify output header file
|
||||
AC_CONFIG_HEADER(autoconfig.h)
|
||||
|
||||
# This needs to be before any macros that use the C compiler
|
||||
AC_GNU_SOURCE
|
||||
|
||||
AC_CHECK_HEADERS([sys/soundcard.h linux/soundcard.h])
|
||||
|
||||
AC_CHECK_TOOL([LD], [ld])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AST_CHECK_GNU_MAKE
|
||||
|
||||
test_obj=conftest.o
|
||||
AC_COMPILE_IFELSE(AC_LANG_SOURCE(),[
|
||||
BDFNAME=`LANG=C objdump -f $test_obj | grep -e "$test_obj:" | sed "s/.*file format \(.*\)/\1/"`
|
||||
BDFARCH=`LANG=C objdump -f $test_obj | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`
|
||||
],[])
|
||||
AC_SUBST(BDFNAME)
|
||||
AC_SUBST(BDFARCH)
|
||||
|
||||
# Set the default value of HOSTCC from CC if --host was not provided:
|
||||
HOSTCC=${HOSTCC:=${CC}}
|
||||
AC_SUBST(HOSTCC)
|
||||
|
||||
AC_PATH_PROG([GREP], [grep], :)
|
||||
AC_PATH_PROG([SHELL], [sh], :)
|
||||
AC_PATH_PROG([LN], [ln], :)
|
||||
|
||||
AC_PATH_PROG([WGET], [wget], :)
|
||||
if test "${WGET}" != ":" ; then
|
||||
DOWNLOAD=${WGET}
|
||||
else
|
||||
AC_PATH_PROG([FETCH], [fetch], [:])
|
||||
DOWNLOAD=${FETCH}
|
||||
fi
|
||||
AC_SUBST(DOWNLOAD)
|
||||
|
||||
AC_LANG(C)
|
||||
|
||||
AC_ARG_ENABLE(dev-mode,
|
||||
[ --enable-dev-mode Turn on developer mode],
|
||||
[case "${enableval}" in
|
||||
y|ye|yes) DAHDI_DEVMODE=yes ;;
|
||||
n|no) DAHDI_DEVMODE=no ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-dev-mode) ;;
|
||||
esac])
|
||||
AC_SUBST(DAHDI_DEVMODE)
|
||||
|
||||
AC_MSG_CHECKING(for -Wdeclaration-after-statement support)
|
||||
if $(${CC} -Wdeclaration-after-statement -S -o /dev/null -xc /dev/null > /dev/null 2>&1); then
|
||||
AC_MSG_RESULT(yes)
|
||||
DAHDI_DECLARATION_AFTER_STATEMENT=-Wdeclaration-after-statement
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
DAHDI_DECLARATION_AFTER_STATEMENT=
|
||||
fi
|
||||
AC_SUBST(DAHDI_DECLARATION_AFTER_STATEMENT)
|
||||
|
||||
AST_EXT_LIB_SETUP([DAHDI], [DAHDI], [dahdi])
|
||||
AST_EXT_LIB_SETUP([NEWT], [newt], [newt])
|
||||
AST_EXT_LIB_SETUP([USB], [usb], [usb])
|
||||
|
||||
AST_C_DEFINE_CHECK([DAHDI], [DAHDI_CODE], [dahdi/user.h])
|
||||
DAHDI23_DIR="${DAHDI_DIR}"
|
||||
AST_C_DEFINE_CHECK([DAHDI23], [DAHDI_CONFIG_NTTE], [dahdi/user.h])
|
||||
AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
|
||||
AST_EXT_LIB_CHECK([USB], [usb], [usb_init], [usb.h])
|
||||
|
||||
AC_CHECK_FUNCS([semtimedop])
|
||||
|
||||
PBX_HDLC=0
|
||||
AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc.h])
|
||||
AC_COMPILE_IFELSE(
|
||||
[ AC_LANG_PROGRAM( [#include <linux/hdlc.h>],
|
||||
[#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
|
||||
int foo = 0;
|
||||
#else
|
||||
int foo = bar;
|
||||
#endif
|
||||
0])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
PBX_HDLC=1],
|
||||
[AC_MSG_RESULT(no)]
|
||||
)
|
||||
if test $PBX_HDLC = 0; then
|
||||
AC_MSG_CHECKING([for GENERIC_HDLC_VERSION version 4 in linux/hdlc/ioctl.h])
|
||||
AC_COMPILE_IFELSE(
|
||||
[ AC_LANG_PROGRAM( [
|
||||
#include <sys/socket.h>
|
||||
#include <linux/if.h>],
|
||||
[#if defined(GENERIC_HDLC_VERSION) && GENERIC_HDLC_VERSION >= 4
|
||||
int foo = 0;
|
||||
#else
|
||||
int foo = bar;
|
||||
#endif
|
||||
0])],
|
||||
[AC_MSG_RESULT(yes)
|
||||
PBX_HDLC=1],
|
||||
[AC_MSG_RESULT(no)]
|
||||
)
|
||||
fi
|
||||
|
||||
if test "x${PBX_HDLC}" != "x1"; then
|
||||
AC_MSG_NOTICE([GENERIC_HDLC_VERSION (version 4) not found, disabling sethdlc.])
|
||||
fi
|
||||
|
||||
AC_SUBST(PBX_HDLC)
|
||||
|
||||
AC_ARG_WITH(selinux,
|
||||
[AS_HELP_STRING([--with-selinux],
|
||||
[enable (with) / disable (without) SELinux])],
|
||||
[USE_SELINUX=$withval],
|
||||
[ if test ! -x /usr/sbin/sestatus; then
|
||||
USE_SELINUX=no;
|
||||
elif /usr/sbin/sestatus | grep "SELinux status:" | grep -q "enabled"; then
|
||||
USE_SELINUX=yes
|
||||
fi
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
AC_SUBST(USE_SELINUX)
|
||||
|
||||
# for asciidoc before ver. 7, the backend must be stated explicitly:
|
||||
ASCIIDOC='asciidoc'
|
||||
asciidoc_ver=`asciidoc --version 2>&1 | awk '/^asciidoc /{print $2}' | cut -d. -f 1 | head -n 1`
|
||||
if test "$asciidoc_ver" != '' && test $asciidoc_ver -lt 7; then
|
||||
ASCIIDOC="asciidoc -b xhtml"
|
||||
fi
|
||||
AC_SUBST(ASCIIDOC)
|
||||
|
||||
AC_ARG_WITH(ppp,
|
||||
[AS_HELP_STRING([--with-ppp=PATH],[Use PPP support from PATH])],
|
||||
[],
|
||||
[with_ppp=check]
|
||||
)
|
||||
# somebody will fix that
|
||||
default_ppp_path=/usr
|
||||
|
||||
case "$with_ppp" in
|
||||
yes|check) ppp_path="$default_ppp_path";;
|
||||
no) ppp_path='' ;;
|
||||
*) ppp_path="$with_ppp" ;;
|
||||
esac
|
||||
|
||||
level_file="$ppp_path/include/pppd/patchlevel.h"
|
||||
PPP_VERSION=
|
||||
if test "$ppp_path" != '' && test -r "$level_file"; then
|
||||
PPPD_VERSION=`awk -F '"' '/VERSION/ { print $$2; }' $level_file`
|
||||
fi
|
||||
|
||||
case "$with_ppp" in
|
||||
check|no) :;;
|
||||
*)
|
||||
# If we asked explicitly for ppp support
|
||||
if test "$PPPD_VERSION" = ''; then
|
||||
# but have not detected it
|
||||
AC_MSG_ERROR(failed to find pppd/patchlevel.h: no ppp support.)
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if test "x${PBX_DAHDI}" != "x1"; then
|
||||
AC_MSG_NOTICE([***])
|
||||
AC_MSG_NOTICE([*** Building this package requires DAHDI support. *** ])
|
||||
AC_MSG_NOTICE([*** Please install the dahdi-linux package. ***])
|
||||
AC_MSG_NOTICE([***])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test "x${PBX_DAHDI23}" != "x1"; then
|
||||
AC_MSG_NOTICE([***])
|
||||
AC_MSG_NOTICE([*** Building this package requires DAHDI support (>= 2.3) *** ])
|
||||
AC_MSG_NOTICE([*** Please install a recent dahdi-linux package. ***])
|
||||
AC_MSG_NOTICE([***])
|
||||
exit 1
|
||||
fi
|
||||
|
||||
AC_SUBST(PPPD_VERSION)
|
||||
|
||||
AC_CONFIG_FILES([makeopts])
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_NOTICE(*** dahdi-tools build successfully configured ***)
|
|
@ -0,0 +1,133 @@
|
|||
# Check for bash
|
||||
[ -z "$BASH_VERSION" ] && return
|
||||
|
||||
__dahdi_span_assignments() {
|
||||
local cur prev has_cmd i
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
has_cmd=0
|
||||
for (( i=0; i < COMP_CWORD; i++)); do
|
||||
case "${COMP_WORDS[$i]}" in
|
||||
add | auto | dumpconfig | list | remove)
|
||||
has_cmd=1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "$prev" in
|
||||
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-h -k -n -v --help --key --dry-run --verbose' -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
if [ "$has_cmd" = 1 ]; then
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(shopt -s nullglob; \
|
||||
echo /sys/bus/dahdi_devices/devices/* ) )
|
||||
else
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'add auto dumpconfig list remove' -- $cur) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_span_assignments dahdi_span_assignments
|
||||
|
||||
__dahdi_span_types() {
|
||||
local cur prev has_cmd i
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
has_cmd=0
|
||||
for (( i=0; i < COMP_CWORD; i++)); do
|
||||
case "${COMP_WORDS[$i]}" in
|
||||
dumpconfig | list | set)
|
||||
has_cmd=1
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
case "$prev" in
|
||||
-k | --key) COMPREPLY=( $(compgen -W 'devpath hwid location' -- $cur) ) ;;
|
||||
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-h -k -n -v --help --key --dry-run --line-type --verbose' -- $cur ) )
|
||||
;;
|
||||
*)
|
||||
if [ "$has_cmd" = 1 ]; then
|
||||
# FIXME: check if devices are settable?
|
||||
COMPREPLY=( ${COMPREPLY[@]} $( \
|
||||
grep -l '[EJT]1' /sys/devices/pci0000:00/0000:00:10.4/usb1/1-1/xbus-00/*/spantype 2>/dev/null | sed -e 's|/spantype||') )
|
||||
else
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'dumpconfig list set' -- $cur) )
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_span_types dahdi_span_types
|
||||
|
||||
|
||||
__dahdi_genconf() {
|
||||
local cur
|
||||
COMPREPLY=()
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
|
||||
case "$prev" in
|
||||
--line-type) COMPREPLY=( $(compgen -W 'E1 J1 T1' -- $cur) ) ;;
|
||||
*)
|
||||
case "$cur" in
|
||||
-*) COMPREPLY+=( $(compgen -W '-F -v -V --freepbx --version --verbose --line-type' -- $cur ) ) ;;
|
||||
*)
|
||||
COMPREPLY+=( $(compgen -W "$( perl -e 'my $file = "\u$ARGV[0]";
|
||||
# Complete module name. Translate the case of the
|
||||
# first letter
|
||||
my @pats = map {"$_/Dahdi/Config/Gen/$file*.pm"} @INC;
|
||||
foreach (@pats) {
|
||||
foreach(glob) {
|
||||
s|.*/||;
|
||||
s|.pm$||;
|
||||
s|^(.)|lc($1)|e;
|
||||
print "$_ "
|
||||
}
|
||||
}')" -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F __dahdi_genconf dahdi_genconf
|
||||
|
||||
__dahdi_cfg() {
|
||||
local cur prev
|
||||
COMPREPLY=()
|
||||
cur=${COMP_WORDS[COMP_CWORD]}
|
||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||
|
||||
case "$prev" in
|
||||
-c) COMPREPLY=( $(compgen -f -- $cur) ) ;;
|
||||
-S) COMPREPLY=( $(ls -d /sys/bus/dahdi_spans/devices/* 2>/dev/null | sed -e 's/.*-//') ) ;;
|
||||
# FIXME: A similar completion for -C (<chan1>-<chan2>)
|
||||
*)
|
||||
COMPREPLY=( ${COMPREPLY[@]} $(compgen -W \
|
||||
'-c -C -f -h -s -S -t -v ' -- $cur ) )
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Disable until -c works properly
|
||||
#complete -F __dahdi_cfg dahdi_cfg
|
|
@ -0,0 +1,343 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# dahdi This shell script takes care of loading and unloading \
|
||||
# DAHDI Telephony interfaces
|
||||
# chkconfig: 2345 9 92
|
||||
# description: The DAHDI drivers allow you to use your linux \
|
||||
# computer to accept incoming data and voice interfaces
|
||||
#
|
||||
# config: /etc/dahdi/init.conf
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: dahdi
|
||||
# Required-Start: $local_fs $remote_fs
|
||||
# Required-Stop: $local_fs $remote_fs
|
||||
# Should-Start: $network $syslog
|
||||
# Should-Stop: $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: DAHDI kernel modules
|
||||
# Description: dahdi - load and configure DAHDI modules
|
||||
### END INIT INFO
|
||||
|
||||
initdir=/etc/init.d
|
||||
|
||||
# Don't edit the following values. Edit /etc/dahdi/init.conf instead.
|
||||
|
||||
DAHDI_CFG=/usr/sbin/dahdi_cfg
|
||||
DAHDI_CFG_CMD=${DAHDI_CFG_CMD:-"$DAHDI_CFG"} # e.g: for a custom system.conf location
|
||||
|
||||
FXOTUNE=/usr/sbin/fxotune
|
||||
|
||||
# The default syncer Astribank. Usually set automatically to a sane
|
||||
# value by xpp_sync(1) if you have an Astribank. You can set this to an
|
||||
# explicit Astribank (e.g: 01).
|
||||
XPP_SYNC=auto
|
||||
|
||||
# The maximal timeout (seconds) to wait for udevd to finish generating
|
||||
# device nodes after the modules have loaded and before running dahdi_cfg.
|
||||
DAHDI_DEV_TIMEOUT=20
|
||||
|
||||
# A list of modules to unload when stopping.
|
||||
# All of their dependencies will be unloaded as well.
|
||||
DAHDI_UNLOAD_MODULES="dahdi"
|
||||
|
||||
#
|
||||
# Determine which kind of configuration we're using
|
||||
#
|
||||
system=redhat # assume redhat
|
||||
if [ -f /etc/debian_version ]; then
|
||||
system=debian
|
||||
fi
|
||||
|
||||
if [ -f /etc/gentoo-release ]; then
|
||||
system=debian
|
||||
fi
|
||||
|
||||
if [ -f /etc/SuSE-release -o -f /etc/novell-release ]
|
||||
then
|
||||
system=debian
|
||||
fi
|
||||
|
||||
# Source function library.
|
||||
if [ $system = redhat ]; then
|
||||
. $initdir/functions || exit 0
|
||||
fi
|
||||
|
||||
DAHDI_MODULES_FILE="/etc/dahdi/modules"
|
||||
|
||||
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
|
||||
|
||||
if [ $system = redhat ]; then
|
||||
LOCKFILE=/var/lock/subsys/dahdi
|
||||
fi
|
||||
|
||||
# recursively unload a module and its dependencies, if possible.
|
||||
# where's modprobe -r when you need it?
|
||||
# inputs: module to unload.
|
||||
# returns: the result from
|
||||
unload_module() {
|
||||
module="$1"
|
||||
line=`lsmod 2>/dev/null | grep "^$1 "`
|
||||
if [ "$line" = '' ]; then return; fi # module was not loaded
|
||||
|
||||
set -- $line
|
||||
# $1: the original module, $2: size, $3: refcount, $4: deps list
|
||||
mods=`echo $4 | tr , ' '`
|
||||
ec_modules=""
|
||||
# xpp_usb keeps the xpds below busy if an xpp hardware is
|
||||
# connected. Hence must be removed before them:
|
||||
case "$module" in xpd_*) mods="xpp_usb $mods";; esac
|
||||
|
||||
for mod in $mods; do
|
||||
case "$mod" in
|
||||
dahdi_echocan_*)
|
||||
ec_modules="$mod $ec_modules"
|
||||
;;
|
||||
*)
|
||||
# run in a subshell, so it won't step over our vars:
|
||||
(unload_module $mod)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# Now that all the other dependencies are unloaded, we can unload the
|
||||
# dahdi_echocan modules. The drivers that register spans may keep
|
||||
# references on the echocan modules before they are unloaded.
|
||||
for mod in $ec_modules; do
|
||||
(unload_module $mod)
|
||||
done
|
||||
rmmod $module
|
||||
}
|
||||
|
||||
unload_modules() {
|
||||
for module in $DAHDI_UNLOAD_MODULES; do
|
||||
unload_module $module
|
||||
done
|
||||
}
|
||||
|
||||
# In (xpp) hotplug mode, the init script is also executed from the
|
||||
# hotplug hook. In that case it should not attempt to loade modules.
|
||||
#
|
||||
# This function only retunrs false (1) if we're in hotplug mode and
|
||||
# coming from the hotplug hook script.
|
||||
hotplug_should_load_modules() {
|
||||
if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" != '' ]
|
||||
then
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# In (xpp) hotplug mode: quit after we loaded modules.
|
||||
#
|
||||
# In hotplug mode, the main run should end here, whereas the rest of the
|
||||
# script should be finished by the instance running from the hook.
|
||||
# Note that we only get here if there are actually Astribanks on the
|
||||
# system (otherwise noone will trigger the run of the hotplug hook
|
||||
# script).
|
||||
hotplug_exit_after_load() {
|
||||
if [ "$XPP_HOTPLUG_DAHDI" = yes -a "$CALLED_FROM_ATRIBANK_HOOK" = '' ]
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
|
||||
xpp_startup() {
|
||||
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||
aas=`cat "$aas_param" 2>/dev/null`
|
||||
if [ "$aas" = 0 ]; then
|
||||
echo 1>&2 "Don't wait for Astribanks (use Asterisk hotplug-support)"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
# do nothing if there are no astribank devices:
|
||||
if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
|
||||
|
||||
hotplug_exit_after_load
|
||||
}
|
||||
|
||||
|
||||
hpec_start() {
|
||||
# HPEC license found
|
||||
if ! echo /var/lib/digium/licenses/HPEC-*.lic | grep -v '\*' | grep -q .; then
|
||||
return
|
||||
fi
|
||||
|
||||
# dahdihpec_enable not installed in /usr/sbin
|
||||
if [ ! -f /usr/sbin/dahdihpec_enable ]; then
|
||||
echo -n "Running dahdihpec_enable: Failed"
|
||||
echo -n "."
|
||||
echo " The dahdihpec_enable binary is not installed in /usr/sbin."
|
||||
return
|
||||
fi
|
||||
|
||||
# dahdihpec_enable not set executable
|
||||
if [ ! -x /usr/sbin/dahdihpec_enable ]; then
|
||||
echo -n "Running dahdihpec_enable: Failed"
|
||||
echo -n "."
|
||||
echo " /usr/sbin/dahdihpec_enable is not set as executable."
|
||||
return
|
||||
fi
|
||||
|
||||
# dahdihpec_enable properly installed
|
||||
if [ $system = debian ]; then
|
||||
echo -n "Running dahdihpec_enable: "
|
||||
/usr/sbin/dahdihpec_enable 2> /dev/null
|
||||
elif [ $system = redhat ]; then
|
||||
action "Running dahdihpec_enable: " /usr/sbin/dahdihpec_enable
|
||||
fi
|
||||
if [ $? = 0 ]; then
|
||||
echo -n "done"
|
||||
echo "."
|
||||
else
|
||||
echo -n "Failed"
|
||||
echo -n "."
|
||||
echo " This can be caused if you had already run dahdihpec_enable, or if your HPEC license is no longer valid."
|
||||
fi
|
||||
}
|
||||
|
||||
shutdown_dynamic() {
|
||||
if ! grep -q ' DYN/' /proc/dahdi/* 2>/dev/null; then return; fi
|
||||
|
||||
# we should only get here if we have dynamic spans. Right?
|
||||
$DAHDI_CFG_CMD -s
|
||||
}
|
||||
|
||||
load_modules() {
|
||||
# Some systems, e.g. Debian Lenny, add here -b, which will break
|
||||
# loading of modules blacklisted in modprobe.d/*
|
||||
unset MODPROBE_OPTIONS
|
||||
modules=`sed -e 's/#.*$//' $DAHDI_MODULES_FILE 2>/dev/null`
|
||||
#if [ "$modules" = '' ]; then
|
||||
# what?
|
||||
#fi
|
||||
echo "Loading DAHDI hardware modules:"
|
||||
modprobe dahdi
|
||||
for line in $modules; do
|
||||
if [ $system = debian ]; then
|
||||
echo -n " ${line}: "
|
||||
if modprobe $line 2> /dev/null; then
|
||||
echo -n "done"
|
||||
else
|
||||
echo -n "error"
|
||||
fi
|
||||
elif [ $system = redhat ]; then
|
||||
action " ${line}: " modprobe $line
|
||||
fi
|
||||
done
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Make sure that either dahdi is loaded or modprobe-able
|
||||
dahdi_modules_loadable() {
|
||||
modinfo dahdi >/dev/null 2>&1 || lsmod | grep -q -w ^dahdi
|
||||
}
|
||||
|
||||
if [ ! -x "$DAHDI_CFG" ]; then
|
||||
echo "dahdi_cfg not executable"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
RETVAL=0
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
if ! dahdi_modules_loadable; then
|
||||
echo "No DAHDI modules on the system. Not starting"
|
||||
exit 0
|
||||
fi
|
||||
if hotplug_should_load_modules; then
|
||||
load_modules
|
||||
fi
|
||||
|
||||
TMOUT=$DAHDI_DEV_TIMEOUT # max secs to wait
|
||||
|
||||
while [ ! -d /dev/dahdi ] ; do
|
||||
sleep 1
|
||||
TMOUT=`expr $TMOUT - 1`
|
||||
if [ $TMOUT -eq 0 ] ; then
|
||||
echo "Error: missing /dev/dahdi!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
xpp_startup
|
||||
|
||||
# Assign all spans that weren't handled via udev + /etc/dahdi/assigned-spans.conf
|
||||
/usr/share/dahdi/dahdi_auto_assign_compat
|
||||
|
||||
if [ $system = debian ]; then
|
||||
echo -n "Running dahdi_cfg: "
|
||||
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
|
||||
echo "."
|
||||
elif [ $system = redhat ]; then
|
||||
action "Running dahdi_cfg: " $DAHDI_CFG_CMD
|
||||
fi
|
||||
RETVAL=$?
|
||||
|
||||
if [ "$LOCKFILE" != '' ]; then
|
||||
[ $RETVAL -eq 0 ] && touch $LOCKFILE
|
||||
fi
|
||||
|
||||
if [ -x "$FXOTUNE" ] && [ -r /etc/fxotune.conf ]; then
|
||||
# Allowed to fail if e.g. Asterisk already uses channels:
|
||||
$FXOTUNE -s || :
|
||||
fi
|
||||
|
||||
# Do not try to call xpp_sync if there are no Astribank devices
|
||||
# installed.
|
||||
if test -e /sys/bus/astribanks; then
|
||||
# Set the right Astribanks ticker:
|
||||
LC_ALL=C xpp_sync "$XPP_SYNC"
|
||||
fi
|
||||
|
||||
hpec_start
|
||||
;;
|
||||
stop)
|
||||
# Unload drivers
|
||||
#shutdown_dynamic # FIXME: needs test from someone with dynamic spans
|
||||
echo -n "Unloading DAHDI hardware modules: "
|
||||
if unload_modules; then
|
||||
echo "done"
|
||||
else
|
||||
echo "error"
|
||||
fi
|
||||
if [ "$LOCKFILE" != '' ]; then
|
||||
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE
|
||||
fi
|
||||
;;
|
||||
unload)
|
||||
unload_modules
|
||||
;;
|
||||
restart|force-reload)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
reload)
|
||||
if [ $system = debian ]; then
|
||||
echo -n "Rerunning dahdi_cfg: "
|
||||
$DAHDI_CFG_CMD 2> /dev/null && echo -n "done"
|
||||
echo "."
|
||||
elif [ $system = redhat ]; then
|
||||
action "Rerunning dahdi_cfg: " $DAHDI_CFG_CMD
|
||||
fi
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
if [ -d /proc/dahdi ]; then
|
||||
/usr/sbin/lsdahdi
|
||||
RETVAL=0
|
||||
else
|
||||
RETVAL=3
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: dahdi {start|stop|restart|status|reload|unload}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
ACTION!="add", GOTO="dahdi_add_end"
|
||||
|
||||
# DAHDI devices with ownership/permissions for running as non-root
|
||||
SUBSYSTEM=="dahdi", OWNER="asterisk", GROUP="asterisk", MODE="0660"
|
||||
|
||||
# Backward compat names: /dev/dahdi/<channo>
|
||||
SUBSYSTEM=="dahdi_channels", SYMLINK+="dahdi/%m"
|
||||
|
||||
# Add persistant names as well
|
||||
SUBSYSTEM=="dahdi_channels", ATTRS{hardware_id}!="", SYMLINK+="dahdi/devices/%s{hardware_id}/%s{local_spanno}/%n"
|
||||
SUBSYSTEM=="dahdi_channels", ATTRS{location}!="", SYMLINK+="dahdi/devices/@%s{location}/%s{local_spanno}/%n"
|
||||
|
||||
LABEL="dahdi_add_end"
|
||||
|
||||
# hotplug scripts
|
||||
SUBSYSTEM=="dahdi_devices", RUN+="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_handle_device"
|
||||
SUBSYSTEM=="dahdi_spans", RUN+="%E{DAHDI_TOOLS_ROOTDIR}/usr/share/dahdi/dahdi_span_config"
|
|
@ -0,0 +1,26 @@
|
|||
<category name="MENUSELECT_UTILS" displayname="Utilities">
|
||||
<member name="fxotune" remove_on_change="fxotune fxotune.o">
|
||||
</member>
|
||||
<member name="fxstest" remove_on_change="fxstest fxstest.o">
|
||||
<defaultenabled>no</defaultenabled>
|
||||
</member>
|
||||
<member name="sethdlc" remove_on_change="sethdlc sethdlc.o">
|
||||
<depend>hdlc</depend>
|
||||
</member>
|
||||
<member name="dahdi_cfg" remove_on_change="dahdi_cfg dahdi_cfg.o">
|
||||
</member>
|
||||
<member name="dahdi_diag" remove_on_change="dahdi_diag dahdi_diag.o">
|
||||
<defaultenabled>no</defaultenabled>
|
||||
</member>
|
||||
<member name="dahdi_monitor" remove_on_change="dahdi_monitor dahdi_monitor.o">
|
||||
</member>
|
||||
<member name="dahdi_scan" remove_on_change="dahdi_scan dahdi_scan.o">
|
||||
</member>
|
||||
<member name="dahdi_speed" remove_on_change="dahdi_speed dahdi_speed.o">
|
||||
</member>
|
||||
<member name="dahdi_test" remove_on_change="dahdi_test dahdi_test.o">
|
||||
</member>
|
||||
<member name="dahdi_tool" remove_on_change="dahdi_tool dahdi_tool.o">
|
||||
<depend>libnewt</depend>
|
||||
</member>
|
||||
</category>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int chan;
|
||||
if ((argc < 2) || (sscanf(argv[1], "%d", &chan) != 1)) {
|
||||
fprintf(stderr, "Usage: dahdi_diag <channel>\n");
|
||||
exit(1);
|
||||
}
|
||||
fd = open("/dev/dahdi/ctl", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror("open(/dev/dahdi/ctl");
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DAHDI_CHANDIAG, &chan)) {
|
||||
perror("ioctl(DAHDI_CHANDIAG)");
|
||||
exit(1);
|
||||
}
|
||||
exit(0);
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
* Performance and Maintenance utility
|
||||
*
|
||||
* Written by Russ Meyerriecks <rmeyerriecks@digium.com>
|
||||
*
|
||||
* Copyright (C) 2009-2010 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define DAHDI_CTL "/dev/dahdi/ctl"
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
void display_help(char *argv0, int exitcode)
|
||||
{
|
||||
char *c;
|
||||
c = strrchr(argv0, '/');
|
||||
if (!c)
|
||||
c = argv0;
|
||||
else
|
||||
c++;
|
||||
fprintf(stderr, "%s\n\n", dahdi_tools_version);
|
||||
fprintf(stderr, "Usage: %s -s <span num> <options>\n", c);
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -h, --help display help\n");
|
||||
fprintf(stderr, " -s, --span <span num> specify the span\n");
|
||||
fprintf(stderr, " -l, --loopback <localhost|networkline|"\
|
||||
"networkpayload|loopup|"\
|
||||
"loopdown|off>\n"\
|
||||
"\t\tlocalhost - loop back towards host\n"\
|
||||
"\t\tnetworkline - network line loopback\n"\
|
||||
"\t\tnetworkpayload - network payload loopback\n"\
|
||||
"\t\tloopup - transmit loopup signal\n"\
|
||||
"\t\tloopdown - transmit loopdown signal\n"\
|
||||
"\t\toff - end loopback mode\n");
|
||||
fprintf(stderr, " -i, --insert <fas|multi|crc|cas|prbs|bipolar>"\
|
||||
"\n\t\tinsert an error of a specific type\n");
|
||||
fprintf(stderr, " -r, --reset "\
|
||||
"reset the error counters\n\n");
|
||||
fprintf(stderr, "Examples: \n");
|
||||
fprintf(stderr, "Enable network line loopback\n");
|
||||
fprintf(stderr, " dahdi_maint -s 1 --loopback networkline\n");
|
||||
fprintf(stderr, "Disable network line loopback\n");
|
||||
fprintf(stderr, " dahdi_maint -s 1 --loopback off\n\n");
|
||||
|
||||
exit(exitcode);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
static int ctl = -1;
|
||||
int res;
|
||||
|
||||
int doloopback = 0;
|
||||
char *larg = NULL;
|
||||
int span = 1;
|
||||
int iflag = 0;
|
||||
char *iarg = NULL;
|
||||
int gflag = 0;
|
||||
int c;
|
||||
int rflag = 0;
|
||||
|
||||
struct dahdi_maintinfo m;
|
||||
struct dahdi_spaninfo s;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"loopback", required_argument, 0, 'l'},
|
||||
{"span", required_argument, 0, 's'},
|
||||
{"insert", required_argument, 0, 'i'},
|
||||
{"reset", no_argument, 0, 'r'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
int option_index = 0;
|
||||
|
||||
if (argc < 2) { /* no options */
|
||||
display_help(argv[0], 1);
|
||||
}
|
||||
|
||||
while ((c = getopt_long(argc, argv, "hj:l:p:s:i:g:r",
|
||||
long_options, &option_index)) != -1) {
|
||||
switch (c) {
|
||||
case 'h':
|
||||
display_help(argv[0], 0);
|
||||
break;
|
||||
case 'l': /* loopback */
|
||||
larg = optarg;
|
||||
doloopback = 1;
|
||||
break;
|
||||
case 's': /* specify a span */
|
||||
span = atoi(optarg);
|
||||
break;
|
||||
case 'i': /* insert an error */
|
||||
iarg = optarg;
|
||||
iflag = 1;
|
||||
break;
|
||||
case 'g': /* generate psuedo random sequence */
|
||||
gflag = 1;
|
||||
break;
|
||||
case 'r': /* reset the error counters */
|
||||
rflag = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ctl = open(DAHDI_CTL, O_RDWR);
|
||||
if (ctl < 0) {
|
||||
fprintf(stderr, "Unable to open %s\n", DAHDI_CTL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(doloopback || iflag || gflag || rflag)) {
|
||||
s.spanno = span;
|
||||
res = ioctl(ctl, DAHDI_SPANSTAT, &s);
|
||||
if (res || ((__u32)-1 == s.fecount))
|
||||
printf("Error counters not supported by the driver"\
|
||||
" for this span\n");
|
||||
printf("Span %d:\n", span);
|
||||
printf(">Framing Errors : %d:\n", s.fecount);
|
||||
printf(">CRC Errors : %d:\n", s.crc4count);
|
||||
printf(">Code Violations : %d:\n", s.cvcount);
|
||||
printf(">E-bit Count : %d:\n", s.ebitcount);
|
||||
printf(">General Errored Seconds : %d:\n", s.errsec);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
m.spanno = span;
|
||||
|
||||
if (doloopback) {
|
||||
if (!strcasecmp(larg, "localhost")) {
|
||||
printf("Span %d: local host loopback ON\n", span);
|
||||
m.command = DAHDI_MAINT_LOCALLOOP;
|
||||
} else if (!strcasecmp(larg, "networkline")) {
|
||||
printf("Span %d: network line loopback ON\n", span);
|
||||
m.command = DAHDI_MAINT_NETWORKLINELOOP;
|
||||
} else if (!strcasecmp(larg, "networkpayload")) {
|
||||
printf("Span %d: network payload loopback ON\n", span);
|
||||
m.command = DAHDI_MAINT_NETWORKPAYLOADLOOP;
|
||||
} else if (!strcasecmp(larg, "loopup")) {
|
||||
printf("Span %d: transmitting loopup signal\n", span);
|
||||
m.command = DAHDI_MAINT_LOOPUP;
|
||||
} else if (!strcasecmp(larg, "loopdown")) {
|
||||
printf("Span %d: transmitting loopdown signal\n", span);
|
||||
m.command = DAHDI_MAINT_LOOPDOWN;
|
||||
} else if (!strcasecmp(larg, "off")) {
|
||||
printf("Span %d: loopback OFF\n", span);
|
||||
m.command = DAHDI_MAINT_NONE;
|
||||
} else {
|
||||
display_help(argv[0], 1);
|
||||
}
|
||||
|
||||
res = ioctl(ctl, DAHDI_MAINT, &m);
|
||||
if (res) {
|
||||
printf("This type of looping not supported by the"\
|
||||
" driver for this span\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Leave the loopup/loopdown signal on the line for
|
||||
* five seconds according to AT&T TR 54016
|
||||
*/
|
||||
if ((m.command == DAHDI_MAINT_LOOPUP) ||
|
||||
(m.command == DAHDI_MAINT_LOOPDOWN)) {
|
||||
sleep(5);
|
||||
m.command = DAHDI_MAINT_NONE;
|
||||
ioctl(ctl, DAHDI_MAINT, &m);
|
||||
}
|
||||
}
|
||||
|
||||
if (iflag) {
|
||||
if (!strcasecmp(iarg, "fas")) {
|
||||
m.command = DAHDI_MAINT_FAS_DEFECT;
|
||||
printf("Inserting a single FAS defect\n");
|
||||
} else if (!strcasecmp(iarg, "multi")) {
|
||||
m.command = DAHDI_MAINT_MULTI_DEFECT;
|
||||
printf("Inserting a single multiframe defect\n");
|
||||
} else if (!strcasecmp(iarg, "crc")) {
|
||||
m.command = DAHDI_MAINT_CRC_DEFECT;
|
||||
printf("Inserting a single CRC defect\n");
|
||||
} else if (!strcasecmp(iarg, "cas")) {
|
||||
m.command = DAHDI_MAINT_CAS_DEFECT;
|
||||
printf("Inserting a single CAS defect\n");
|
||||
} else if (!strcasecmp(iarg, "prbs")) {
|
||||
m.command = DAHDI_MAINT_PRBS_DEFECT;
|
||||
printf("Inserting a single PRBS defect\n");
|
||||
} else if (!strcasecmp(iarg, "bipolar")) {
|
||||
m.command = DAHDI_MAINT_BIPOLAR_DEFECT;
|
||||
printf("Inserting a single bipolar defect\n");
|
||||
#ifdef DAHDI_MAINT_ALARM_SIM
|
||||
} else if (!strcasecmp(iarg, "sim")) {
|
||||
m.command = DAHDI_MAINT_ALARM_SIM;
|
||||
printf("Incrementing alarm simulator\n");
|
||||
#endif
|
||||
} else {
|
||||
display_help(argv[0], 1);
|
||||
}
|
||||
res = ioctl(ctl, DAHDI_MAINT, &m);
|
||||
if (res)
|
||||
printf("This type of error injection is not supported"\
|
||||
" by the driver for this span\n");
|
||||
}
|
||||
|
||||
if (gflag) {
|
||||
printf("Enabled the Pseudo-Random Binary Sequence Generation"\
|
||||
" and Monitor\n");
|
||||
m.command = DAHDI_MAINT_PRBS;
|
||||
res = ioctl(ctl, DAHDI_MAINT, &m);
|
||||
if (res) {
|
||||
printf("Pseudo-random binary sequence generation is"\
|
||||
" not supported by the driver for this span\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (rflag) {
|
||||
printf("Resetting error counters for span %d\n", span);
|
||||
m.command = DAHDI_RESET_COUNTERS;
|
||||
res = ioctl(ctl, DAHDI_MAINT, &m);
|
||||
if (res) {
|
||||
printf("Resetting error counters is not supported by"\
|
||||
" the driver for this span\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,785 @@
|
|||
/*
|
||||
* Monitor a DAHDI Channel
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
#include "wavformat.h"
|
||||
#include "autoconfig.h"
|
||||
|
||||
#ifdef HAVE_SYS_SOUNDCARD_H
|
||||
# include <sys/soundcard.h>
|
||||
#else
|
||||
# ifdef HAVE_LINUX_SOUNDCARD_H
|
||||
# include <linux/soundcard.h>
|
||||
# else
|
||||
# error "Your installation appears to be missing soundcard.h which is needed to continue."
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* defines for file handle numbers
|
||||
*/
|
||||
#define MON_BRX 0 /*!< both channels if multichannel==1 or receive otherwise */
|
||||
#define MON_TX 1 /*!< transmit channel */
|
||||
#define MON_PRE_BRX 2 /*!< same as MON_BRX but before echo cancellation */
|
||||
#define MON_PRE_TX 3 /*!< same as MON_TX but before echo cancellation */
|
||||
#define MON_STEREO 4 /*!< stereo mix of rx/tx streams */
|
||||
#define MON_PRE_STEREO 5 /*!< stereo mix of rx/tx before echo can. This is exactly what is fed into the echo can */
|
||||
|
||||
#define BLOCK_SIZE 240
|
||||
|
||||
#define BUFFERS 4
|
||||
|
||||
#define FRAG_SIZE 8
|
||||
|
||||
#define MAX_OFH 6
|
||||
|
||||
/* Put the ofh (output file handles) outside the main loop in case we ever add a
|
||||
* signal handler.
|
||||
*/
|
||||
static FILE *ofh[MAX_OFH];
|
||||
static int run = 1;
|
||||
|
||||
static int stereo;
|
||||
static int verbose;
|
||||
|
||||
/* handler to catch ctrl-c */
|
||||
void cleanup_and_exit(int signal)
|
||||
{
|
||||
fprintf(stderr, "cntrl-c pressed\n");
|
||||
run = 0; /* stop reading */
|
||||
}
|
||||
|
||||
int filename_is_wav(char *filename)
|
||||
{
|
||||
if (NULL != strstr(filename, ".wav"))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill the wav header with default info
|
||||
* num_chans - 0 = mono; 1 = stereo
|
||||
*/
|
||||
void wavheader_init(struct wavheader *wavheader, int num_chans)
|
||||
{
|
||||
memset(wavheader, 0, sizeof(struct wavheader));
|
||||
|
||||
memcpy(&wavheader->riff_chunk_id, "RIFF", 4);
|
||||
memcpy(&wavheader->riff_type, "WAVE", 4);
|
||||
|
||||
memcpy(&wavheader->fmt_chunk_id, "fmt ", 4);
|
||||
wavheader->fmt_data_size = 16;
|
||||
wavheader->fmt_compression_code = 1;
|
||||
wavheader->fmt_num_channels = num_chans;
|
||||
wavheader->fmt_sample_rate = 8000;
|
||||
wavheader->fmt_avg_bytes_per_sec = 16000;
|
||||
wavheader->fmt_block_align = 2;
|
||||
wavheader->fmt_significant_bps = 16;
|
||||
|
||||
memcpy(&wavheader->data_chunk_id, "data", 4);
|
||||
}
|
||||
|
||||
int audio_open(void)
|
||||
{
|
||||
int fd;
|
||||
int speed = 8000;
|
||||
int fmt = AFMT_S16_LE;
|
||||
int fragsize = (BUFFERS << 16) | (FRAG_SIZE);
|
||||
struct audio_buf_info ispace, ospace;
|
||||
fd = open("/dev/dsp", O_WRONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open /dev/dsp: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
/* Step 1: Signed linear */
|
||||
if (ioctl(fd, SNDCTL_DSP_SETFMT, &fmt) < 0) {
|
||||
fprintf(stderr, "ioctl(SETFMT) failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
/* Step 2: Make non-stereo */
|
||||
if (ioctl(fd, SNDCTL_DSP_STEREO, &stereo) < 0) {
|
||||
fprintf(stderr, "ioctl(STEREO) failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
if (stereo != 0) {
|
||||
fprintf(stderr, "Can't turn stereo off :(\n");
|
||||
}
|
||||
/* Step 3: Make 8000 Hz */
|
||||
if (ioctl(fd, SNDCTL_DSP_SPEED, &speed) < 0) {
|
||||
fprintf(stderr, "ioctl(SPEED) failed: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
if (speed != 8000) {
|
||||
fprintf(stderr, "Warning: Requested 8000 Hz, got %d\n", speed);
|
||||
}
|
||||
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &fragsize)) {
|
||||
fprintf(stderr, "Sound card won't let me set fragment size to %u %u-byte buffers (%x)\n"
|
||||
"so sound may be choppy: %s.\n", BUFFERS, (1 << FRAG_SIZE), fragsize, strerror(errno));
|
||||
}
|
||||
bzero(&ispace, sizeof(ispace));
|
||||
bzero(&ospace, sizeof(ospace));
|
||||
|
||||
if (ioctl(fd, SNDCTL_DSP_GETISPACE, &ispace)) {
|
||||
/* They don't support block size stuff, so just return but notify the user */
|
||||
fprintf(stderr, "Sound card won't let me know the input buffering...\n");
|
||||
}
|
||||
if (ioctl(fd, SNDCTL_DSP_GETOSPACE, &ospace)) {
|
||||
/* They don't support block size stuff, so just return but notify the user */
|
||||
fprintf(stderr, "Sound card won't let me know the output buffering...\n");
|
||||
}
|
||||
fprintf(stderr, "New input space: %d of %d %d byte fragments (%d bytes left)\n",
|
||||
ispace.fragments, ispace.fragstotal, ispace.fragsize, ispace.bytes);
|
||||
fprintf(stderr, "New output space: %d of %d %d byte fragments (%d bytes left)\n",
|
||||
ospace.fragments, ospace.fragstotal, ospace.fragsize, ospace.bytes);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int pseudo_open(void)
|
||||
{
|
||||
int fd;
|
||||
int x = 1;
|
||||
fd = open("/dev/dahdi/pseudo", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open pseudo channel: %s\n", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SETLINEAR, &x)) {
|
||||
fprintf(stderr, "Unable to set linear mode: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
x = BLOCK_SIZE;
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &x)) {
|
||||
fprintf(stderr, "unable to set sane block size: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
#define barlen 35
|
||||
#define baroptimal 3250
|
||||
//define barlevel 200
|
||||
#define barlevel ((baroptimal/barlen)*2)
|
||||
#define maxlevel (barlen*barlevel)
|
||||
|
||||
void draw_barheader()
|
||||
{
|
||||
char bar[barlen + 4];
|
||||
|
||||
memset(bar, '-', sizeof(bar));
|
||||
memset(bar, '<', 1);
|
||||
memset(bar + barlen + 2, '>', 1);
|
||||
memset(bar + barlen + 3, '\0', 1);
|
||||
|
||||
memcpy(bar + (barlen / 2), "(RX)", 4);
|
||||
printf("%s", bar);
|
||||
|
||||
memcpy(bar + (barlen / 2), "(TX)", 4);
|
||||
printf(" %s\n", bar);
|
||||
}
|
||||
|
||||
void draw_bar(int avg, int max)
|
||||
{
|
||||
char bar[barlen+5];
|
||||
|
||||
memset(bar, ' ', sizeof(bar));
|
||||
|
||||
max /= barlevel;
|
||||
avg /= barlevel;
|
||||
if (avg > barlen)
|
||||
avg = barlen;
|
||||
if (max > barlen)
|
||||
max = barlen;
|
||||
|
||||
if (avg > 0)
|
||||
memset(bar, '#', avg);
|
||||
if (max > 0)
|
||||
memset(bar + max, '*', 1);
|
||||
|
||||
bar[barlen+1] = '\0';
|
||||
printf("%s", bar);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void visualize(short *tx, short *rx, int cnt)
|
||||
{
|
||||
int x;
|
||||
float txavg = 0;
|
||||
float rxavg = 0;
|
||||
static int txmax = 0;
|
||||
static int rxmax = 0;
|
||||
static int sametxmax = 0;
|
||||
static int samerxmax = 0;
|
||||
static int txbest = 0;
|
||||
static int rxbest = 0;
|
||||
float ms;
|
||||
static struct timeval last;
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
ms = (tv.tv_sec - last.tv_sec) * 1000.0 + (tv.tv_usec - last.tv_usec) / 1000.0;
|
||||
for (x = 0; x < cnt; x++) {
|
||||
txavg += abs(tx[x]);
|
||||
rxavg += abs(rx[x]);
|
||||
}
|
||||
txavg = abs(txavg / cnt);
|
||||
rxavg = abs(rxavg / cnt);
|
||||
|
||||
if (txavg > txbest)
|
||||
txbest = txavg;
|
||||
if (rxavg > rxbest)
|
||||
rxbest = rxavg;
|
||||
|
||||
/* Update no more than 10 times a second */
|
||||
if (ms < 100)
|
||||
return;
|
||||
|
||||
/* Save as max levels, if greater */
|
||||
if (txbest > txmax) {
|
||||
txmax = txbest;
|
||||
sametxmax = 0;
|
||||
}
|
||||
if (rxbest > rxmax) {
|
||||
rxmax = rxbest;
|
||||
samerxmax = 0;
|
||||
}
|
||||
|
||||
memcpy(&last, &tv, sizeof(last));
|
||||
|
||||
/* Clear screen */
|
||||
printf("\r ");
|
||||
draw_bar(rxbest, rxmax);
|
||||
printf(" ");
|
||||
draw_bar(txbest, txmax);
|
||||
if (verbose)
|
||||
printf(" Rx: %5d (%5d) Tx: %5d (%5d)", rxbest, rxmax, txbest, txmax);
|
||||
txbest = 0;
|
||||
rxbest = 0;
|
||||
|
||||
/* If we have had the same max hits for x times, clear the values */
|
||||
sametxmax++;
|
||||
samerxmax++;
|
||||
if (sametxmax > 6) {
|
||||
txmax = 0;
|
||||
sametxmax = 0;
|
||||
}
|
||||
if (samerxmax > 6) {
|
||||
rxmax = 0;
|
||||
samerxmax = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int afd = -1;
|
||||
int pfd[4] = {-1, -1, -1, -1};
|
||||
short buf_brx[BLOCK_SIZE * 2];
|
||||
short buf_tx[BLOCK_SIZE * 4];
|
||||
short stereobuf[BLOCK_SIZE * 4];
|
||||
int res_brx, res_tx;
|
||||
int visual = 0;
|
||||
int multichannel = 0;
|
||||
int ossoutput = 0;
|
||||
int preecho = 0;
|
||||
int savefile = 0;
|
||||
int stereo_output = 0;
|
||||
int limit = 0;
|
||||
int readcount = 0;
|
||||
int x, chan;
|
||||
struct dahdi_confinfo zc;
|
||||
int opt;
|
||||
extern char *optarg;
|
||||
struct wavheader wavheaders[MAX_OFH]; /* we have one for each potential filehandle */
|
||||
unsigned int bytes_written[MAX_OFH] = {0};
|
||||
int file_is_wav[MAX_OFH] = {0};
|
||||
int i;
|
||||
|
||||
if ((argc < 2) || (atoi(argv[1]) < 1)) {
|
||||
fprintf(stderr, "Usage: dahdi_monitor <channel num> [-v[v]] [-m] [-o] [-l limit] [-f FILE | -s FILE | -r FILE1 -t FILE2] [-F FILE | -S FILE | -R FILE1 -T FILE2]\n");
|
||||
fprintf(stderr, "Options:\n");
|
||||
fprintf(stderr, " -v: Visual mode. Implies -m.\n");
|
||||
fprintf(stderr, " -vv: Visual/Verbose mode. Implies -m.\n");
|
||||
fprintf(stderr, " -l LIMIT: Stop after reading LIMIT bytes\n");
|
||||
fprintf(stderr, " -m: Separate rx/tx streams.\n");
|
||||
fprintf(stderr, " -o: Output audio via OSS. Note: Only 'normal' combined rx/tx streams are output via OSS.\n");
|
||||
fprintf(stderr, " -f FILE: Save combined rx/tx stream to mono FILE. Cannot be used with -m.\n");
|
||||
fprintf(stderr, " -r FILE: Save rx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, " -t FILE: Save tx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, " -s FILE: Save stereo rx/tx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, " -F FILE: Save combined pre-echocanceled rx/tx stream to FILE. Cannot be used with -m.\n");
|
||||
fprintf(stderr, " -R FILE: Save pre-echocanceled rx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, " -T FILE: Save pre-echocanceled tx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, " -S FILE: Save pre-echocanceled stereo rx/tx stream to FILE. Implies -m.\n");
|
||||
fprintf(stderr, "Examples:\n");
|
||||
fprintf(stderr, "Save a stream to a file\n");
|
||||
fprintf(stderr, " dahdi_monitor 1 -f stream.raw\n");
|
||||
fprintf(stderr, "Visualize an rx/tx stream and save them to separate files.\n");
|
||||
fprintf(stderr, " dahdi_monitor 1 -v -r streamrx.raw -t streamtx.raw\n");
|
||||
fprintf(stderr, "Play a combined rx/tx stream via OSS and save it to a file\n");
|
||||
fprintf(stderr, " dahdi_monitor 1 -o -f stream.raw\n");
|
||||
fprintf(stderr, "Save a combined normal rx/tx stream and a combined 'preecho' rx/tx stream to files\n");
|
||||
fprintf(stderr, " dahdi_monitor 1 -f stream.raw -F streampreecho.raw\n");
|
||||
fprintf(stderr, "Save a normal rx/tx stream and a 'preecho' rx/tx stream to separate files\n");
|
||||
fprintf(stderr, " dahdi_monitor 1 -m -r streamrx.raw -t streamtx.raw -R streampreechorx.raw -T streampreechotx.raw\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
chan = atoi(argv[1]);
|
||||
|
||||
while ((opt = getopt(argc, argv, "vmol:f:r:t:s:F:R:T:S:")) != -1) {
|
||||
switch (opt) {
|
||||
case '?':
|
||||
exit(EXIT_FAILURE);
|
||||
case 'v':
|
||||
if (visual)
|
||||
verbose = 1;
|
||||
visual = 1;
|
||||
multichannel = 1;
|
||||
break;
|
||||
case 'm':
|
||||
multichannel = 1;
|
||||
break;
|
||||
case 'o':
|
||||
ossoutput = 1;
|
||||
break;
|
||||
case 'l':
|
||||
if (sscanf(optarg, "%d", &limit) != 1 || limit < 0)
|
||||
limit = 0;
|
||||
fprintf(stderr, "Will stop reading after %d bytes\n", limit);
|
||||
break;
|
||||
case 'f':
|
||||
if (multichannel) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when multichannel mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_BRX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_BRX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing combined stream to %s\n", optarg);
|
||||
file_is_wav[MON_BRX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_BRX]) {
|
||||
wavheader_init(&wavheaders[MON_BRX], 1);
|
||||
if (fwrite(&wavheaders[MON_BRX], 1, sizeof(struct wavheader), ofh[MON_BRX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
savefile = 1;
|
||||
break;
|
||||
case 'F':
|
||||
if (multichannel) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when multichannel mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_PRE_BRX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing pre-echo combined stream to %s\n", optarg);
|
||||
file_is_wav[MON_PRE_BRX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_PRE_BRX]) {
|
||||
wavheader_init(&wavheaders[MON_PRE_BRX], 1);
|
||||
if (fwrite(&wavheaders[MON_PRE_BRX], 1, sizeof(struct wavheader), ofh[MON_PRE_BRX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
preecho = 1;
|
||||
savefile = 1;
|
||||
break;
|
||||
case 'r':
|
||||
if (!multichannel && ofh[MON_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_BRX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_BRX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing receive stream to %s\n", optarg);
|
||||
file_is_wav[MON_BRX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_BRX]) {
|
||||
wavheader_init(&wavheaders[MON_BRX], 1);
|
||||
if (fwrite(&wavheaders[MON_BRX], 1, sizeof(struct wavheader), ofh[MON_BRX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
break;
|
||||
case 'R':
|
||||
if (!multichannel && ofh[MON_PRE_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_PRE_BRX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_PRE_BRX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing pre-echo receive stream to %s\n", optarg);
|
||||
file_is_wav[MON_PRE_BRX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_PRE_BRX]) {
|
||||
wavheader_init(&wavheaders[MON_PRE_BRX], 1);
|
||||
if (fwrite(&wavheaders[MON_PRE_BRX], 1, sizeof(struct wavheader), ofh[MON_PRE_BRX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
preecho = 1;
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
break;
|
||||
case 't':
|
||||
if (!multichannel && ofh[MON_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_TX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_TX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing transmit stream to %s\n", optarg);
|
||||
file_is_wav[MON_TX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_TX]) {
|
||||
wavheader_init(&wavheaders[MON_TX], 1);
|
||||
if (fwrite(&wavheaders[MON_TX], 1, sizeof(struct wavheader), ofh[MON_TX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
break;
|
||||
case 'T':
|
||||
if (!multichannel && ofh[MON_PRE_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_PRE_TX]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_PRE_TX] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing pre-echo transmit stream to %s\n", optarg);
|
||||
file_is_wav[MON_PRE_TX] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_PRE_TX]) {
|
||||
wavheader_init(&wavheaders[MON_PRE_TX], 1);
|
||||
if (fwrite(&wavheaders[MON_PRE_TX], 1, sizeof(struct wavheader), ofh[MON_PRE_TX]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
preecho = 1;
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
break;
|
||||
case 's':
|
||||
if (!multichannel && ofh[MON_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_STEREO]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_STEREO] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing stereo stream to %s\n", optarg);
|
||||
file_is_wav[MON_STEREO] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_STEREO]) {
|
||||
wavheader_init(&wavheaders[MON_STEREO], 2);
|
||||
if (fwrite(&wavheaders[MON_STEREO], 1, sizeof(struct wavheader), ofh[MON_STEREO]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
stereo_output = 1;
|
||||
break;
|
||||
case 'S':
|
||||
if (!multichannel && ofh[MON_PRE_BRX]) {
|
||||
fprintf(stderr, "'%c' mode cannot be used when combined mode is enabled.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (ofh[MON_PRE_STEREO]) {
|
||||
fprintf(stderr, "Cannot specify option '%c' more than once.\n", opt);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if ((ofh[MON_PRE_STEREO] = fopen(optarg, "w")) == NULL) {
|
||||
fprintf(stderr, "Could not open %s for writing: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
fprintf(stderr, "Writing pre-echo stereo stream to %s\n", optarg);
|
||||
file_is_wav[MON_PRE_STEREO] = filename_is_wav(optarg);
|
||||
if (file_is_wav[MON_PRE_STEREO]) {
|
||||
wavheader_init(&wavheaders[MON_PRE_STEREO], 2);
|
||||
if (fwrite(&wavheaders[MON_PRE_STEREO], 1, sizeof(struct wavheader), ofh[MON_PRE_STEREO]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Could not write wav header to %s: %s\n", optarg, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
preecho = 1;
|
||||
multichannel = 1;
|
||||
savefile = 1;
|
||||
stereo_output = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ossoutput) {
|
||||
if (multichannel) {
|
||||
printf("Multi-channel audio is enabled. OSS output will be disabled.\n");
|
||||
ossoutput = 0;
|
||||
} else {
|
||||
/* Open audio */
|
||||
if ((afd = audio_open()) < 0) {
|
||||
printf("Cannot open audio ...\n");
|
||||
ossoutput = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ossoutput && !multichannel && !savefile) {
|
||||
fprintf(stderr, "Nothing to do with the stream(s) ...\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Open Pseudo device */
|
||||
if ((pfd[MON_BRX] = pseudo_open()) < 0)
|
||||
exit(1);
|
||||
if (multichannel && ((pfd[MON_TX] = pseudo_open()) < 0))
|
||||
exit(1);
|
||||
if (preecho) {
|
||||
if ((pfd[MON_PRE_BRX] = pseudo_open()) < 0)
|
||||
exit(1);
|
||||
if (multichannel && ((pfd[MON_PRE_TX] = pseudo_open()) < 0))
|
||||
exit(1);
|
||||
}
|
||||
/* Conference them */
|
||||
if (multichannel) {
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
/* Two pseudo's, one for tx, one for rx */
|
||||
zc.confmode = DAHDI_CONF_MONITOR;
|
||||
if (ioctl(pfd[MON_BRX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
zc.confmode = DAHDI_CONF_MONITORTX;
|
||||
if (ioctl(pfd[MON_TX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (preecho) {
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
/* Two pseudo's, one for tx, one for rx */
|
||||
zc.confmode = DAHDI_CONF_MONITOR_RX_PREECHO;
|
||||
if (ioctl(pfd[MON_PRE_BRX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
zc.confmode = DAHDI_CONF_MONITOR_TX_PREECHO;
|
||||
if (ioctl(pfd[MON_PRE_TX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
zc.confmode = DAHDI_CONF_MONITORBOTH;
|
||||
if (ioctl(pfd[MON_BRX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (preecho) {
|
||||
memset(&zc, 0, sizeof(zc));
|
||||
zc.chan = 0;
|
||||
zc.confno = chan;
|
||||
zc.confmode = DAHDI_CONF_MONITORBOTH_PREECHO;
|
||||
if (ioctl(pfd[MON_PRE_BRX], DAHDI_SETCONF, &zc) < 0) {
|
||||
fprintf(stderr, "Unable to monitor: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (signal(SIGINT, cleanup_and_exit) == SIG_ERR) {
|
||||
fprintf(stderr, "Error registering signal handler: %s\n", strerror(errno));
|
||||
}
|
||||
if (visual) {
|
||||
printf("\nVisual Audio Levels.\n");
|
||||
printf("--------------------\n");
|
||||
printf(" Use chan_dahdi.conf file to adjust the gains if needed.\n\n");
|
||||
printf("( # = Audio Level * = Max Audio Hit )\n");
|
||||
draw_barheader();
|
||||
}
|
||||
/* Now, copy from pseudo to audio */
|
||||
while (run) {
|
||||
res_brx = read(pfd[MON_BRX], buf_brx, sizeof(buf_brx));
|
||||
if (res_brx < 1)
|
||||
break;
|
||||
readcount += res_brx;
|
||||
if (ofh[MON_BRX])
|
||||
bytes_written[MON_BRX] += fwrite(buf_brx, 1, res_brx, ofh[MON_BRX]);
|
||||
|
||||
if (multichannel) {
|
||||
res_tx = read(pfd[MON_TX], buf_tx, res_brx);
|
||||
if (res_tx < 1)
|
||||
break;
|
||||
if (ofh[MON_TX])
|
||||
bytes_written[MON_TX] += fwrite(buf_tx, 1, res_tx, ofh[MON_TX]);
|
||||
|
||||
if (stereo_output && ofh[MON_STEREO]) {
|
||||
for (x = 0; x < res_tx; x++) {
|
||||
stereobuf[x*2] = buf_brx[x];
|
||||
stereobuf[x*2+1] = buf_tx[x];
|
||||
}
|
||||
bytes_written[MON_STEREO] += fwrite(stereobuf, 1, res_tx*2, ofh[MON_STEREO]);
|
||||
}
|
||||
|
||||
if (visual) {
|
||||
if (res_brx == res_tx)
|
||||
visualize((short *)buf_tx, (short *)buf_brx, res_brx/2);
|
||||
else
|
||||
printf("Huh? res_tx = %d, res_brx = %d?\n", res_tx, res_brx);
|
||||
}
|
||||
}
|
||||
|
||||
if (preecho) {
|
||||
res_brx = read(pfd[MON_PRE_BRX], buf_brx, sizeof(buf_brx));
|
||||
if (res_brx < 1)
|
||||
break;
|
||||
if (ofh[MON_PRE_BRX])
|
||||
bytes_written[MON_PRE_BRX] += fwrite(buf_brx, 1, res_brx, ofh[MON_PRE_BRX]);
|
||||
|
||||
if (multichannel) {
|
||||
res_tx = read(pfd[MON_PRE_TX], buf_tx, res_brx);
|
||||
if (res_tx < 1)
|
||||
break;
|
||||
if (ofh[MON_PRE_TX])
|
||||
bytes_written[MON_PRE_TX] += fwrite(buf_tx, 1, res_tx, ofh[MON_PRE_TX]);
|
||||
|
||||
if (stereo_output && ofh[MON_PRE_STEREO]) {
|
||||
for (x = 0; x < res_brx; x++) {
|
||||
stereobuf[x*2] = buf_brx[x];
|
||||
stereobuf[x*2+1] = buf_tx[x];
|
||||
}
|
||||
bytes_written[MON_PRE_STEREO] += fwrite(stereobuf, 1, res_brx * 2, ofh[MON_PRE_STEREO]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ossoutput && afd) {
|
||||
if (stereo) {
|
||||
for (x = 0; x < res_brx; x++) {
|
||||
buf_tx[x << 1] = buf_tx[(x << 1) + 1] = buf_brx[x];
|
||||
}
|
||||
x = write(afd, buf_tx, res_brx << 1);
|
||||
} else {
|
||||
x = write(afd, buf_brx, res_brx);
|
||||
}
|
||||
}
|
||||
|
||||
if (limit && readcount >= limit) {
|
||||
/* bail if we've read too much */
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* write filesize info */
|
||||
for (i = 0; i < MAX_OFH; i++) {
|
||||
if (NULL == ofh[i])
|
||||
continue;
|
||||
if (!(file_is_wav[i]))
|
||||
continue;
|
||||
|
||||
wavheaders[i].riff_chunk_size = (bytes_written[i]) + sizeof(struct wavheader) - 8; /* filesize - 8 */
|
||||
wavheaders[i].data_data_size = bytes_written[i];
|
||||
|
||||
rewind(ofh[i]);
|
||||
if (fwrite(&wavheaders[i], 1, sizeof(struct wavheader), ofh[i]) != sizeof(struct wavheader)) {
|
||||
fprintf(stderr, "Failed to write out a full wav header.\n");
|
||||
}
|
||||
fclose(ofh[i]);
|
||||
}
|
||||
printf("done cleaning up ... exiting.\n");
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,332 @@
|
|||
/*
|
||||
* Capturing a pcap from the DAHDI interface
|
||||
*
|
||||
* Copyright (C) 2011 Torrey Searle
|
||||
*
|
||||
* ISDN support added by Horacio Peña
|
||||
* Command line cleanups by Sverker Abrahamsson
|
||||
*
|
||||
* Requirements:
|
||||
* - pcap development library
|
||||
* - DAHDI_MIRROR ioctl which isn't enabled by default in dahdi-linux
|
||||
* To enable this unsupported feature, #define CONFIG_DAHDI_MIRROR
|
||||
* in dahdi-linux
|
||||
* - To build this program call the 'make dahdi_pcap' target
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <dahdi/user.h>
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <pcap.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
#define MAX_CHAN 16
|
||||
//char ETH_P_LAPD[2] = {0x00, 0x30};
|
||||
|
||||
struct mtp2_phdr {
|
||||
u_int8_t sent;
|
||||
u_int8_t annex_a_used;
|
||||
u_int16_t link_number;
|
||||
};
|
||||
|
||||
|
||||
struct lapd_sll_hdr {
|
||||
u_int16_t sll_pkttype; /* packet type */
|
||||
u_int16_t sll_hatype;
|
||||
u_int16_t sll_halen;
|
||||
u_int8_t sll_addr[8];
|
||||
u_int8_t sll_protocol[2]; /* protocol, should be ETH_P_LAPD */
|
||||
};
|
||||
|
||||
|
||||
struct chan_fds {
|
||||
int rfd;
|
||||
int tfd;
|
||||
int chan_id;
|
||||
int proto;
|
||||
char tx_buf[BLOCK_SIZE * 4];
|
||||
int tx_len;
|
||||
char rx_buf[BLOCK_SIZE * 4];
|
||||
int rx_len;
|
||||
};
|
||||
|
||||
int make_mirror(long type, int chan)
|
||||
{
|
||||
int res = 0;
|
||||
int fd = 0;
|
||||
struct dahdi_bufferinfo bi;
|
||||
fd = open("/dev/dahdi/pseudo", O_RDONLY);
|
||||
|
||||
memset(&bi, 0, sizeof(bi));
|
||||
bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.numbufs = 32;
|
||||
bi.bufsize = BLOCK_SIZE;
|
||||
|
||||
ioctl(fd, DAHDI_SET_BUFINFO, &bi);
|
||||
|
||||
res = ioctl(fd, type, &chan);
|
||||
|
||||
if(res)
|
||||
{
|
||||
printf("error setting channel err=%d!\n", res);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int log_packet(struct chan_fds * fd, char is_read, pcap_dumper_t * dump)
|
||||
{
|
||||
unsigned char buf[BLOCK_SIZE * 4];
|
||||
int res = 0;
|
||||
|
||||
struct pcap_pkthdr hdr;
|
||||
struct mtp2_phdr * mtp2 = (struct mtp2_phdr *)buf;
|
||||
struct lapd_sll_hdr * lapd = (struct lapd_sll_hdr *)buf;
|
||||
|
||||
unsigned char *dataptr = buf;
|
||||
int datasize = sizeof(buf);
|
||||
|
||||
if(fd->proto == DLT_LINUX_LAPD)
|
||||
{
|
||||
dataptr += sizeof(struct lapd_sll_hdr);
|
||||
datasize -= sizeof(struct lapd_sll_hdr);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataptr += sizeof(struct mtp2_phdr);
|
||||
datasize -= sizeof(struct mtp2_phdr);
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if(is_read)
|
||||
{
|
||||
res = read(fd->rfd, dataptr, datasize);
|
||||
if(fd->rx_len > 0 && res == fd->rx_len && !memcmp(fd->rx_buf, dataptr, res) )
|
||||
{
|
||||
//skipping dup
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(fd->rx_buf, dataptr, res);
|
||||
fd->rx_len = res;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = read(fd->tfd, dataptr, datasize);
|
||||
if(fd->tx_len > 0 && res == fd->tx_len && !memcmp(fd->tx_buf, dataptr, res) )
|
||||
{
|
||||
//skipping dup
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(fd->tx_buf, dataptr, res);
|
||||
fd->tx_len = res;
|
||||
}
|
||||
|
||||
gettimeofday(&hdr.ts, NULL);
|
||||
|
||||
|
||||
|
||||
|
||||
if(res > 0)
|
||||
{
|
||||
if(fd->proto == DLT_LINUX_LAPD)
|
||||
{
|
||||
hdr.caplen = res+sizeof(struct lapd_sll_hdr)-2;
|
||||
hdr.len = res+sizeof(struct lapd_sll_hdr)-2;
|
||||
|
||||
lapd->sll_pkttype = 3;
|
||||
lapd->sll_hatype = 0;
|
||||
lapd->sll_halen = res;
|
||||
// lapd->sll_addr = ???
|
||||
lapd->sll_protocol[0] = 0x00;
|
||||
lapd->sll_protocol[1] = 0x30;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
hdr.caplen = res+sizeof(struct mtp2_phdr);
|
||||
hdr.len = res+sizeof(struct mtp2_phdr);
|
||||
|
||||
if(is_read)
|
||||
{
|
||||
mtp2->sent = 0;
|
||||
mtp2->annex_a_used = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtp2->sent = 1;
|
||||
mtp2->annex_a_used = 0;
|
||||
}
|
||||
mtp2->link_number = htons(fd->chan_id);
|
||||
}
|
||||
pcap_dump((u_char*)dump, &hdr, buf);
|
||||
pcap_dump_flush(dump);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
printf("Usage: dahdi_pcap [OPTIONS]\n");
|
||||
printf("Capture packets from DAHDI channels to pcap file\n\n");
|
||||
printf("Options:\n");
|
||||
printf(" -p, --proto=[mtp2|lapd] The protocol to capture, default mtp2\n");
|
||||
printf(" -c, --chan=<channels> Comma separated list of channels to capture from, max %d. Mandatory\n", MAX_CHAN);
|
||||
printf(" -f, --file=<filename> The pcap file to capture to. Mandatory\n");
|
||||
printf(" -h, --help Display this text\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct chan_fds chans[MAX_CHAN];
|
||||
char *filename = NULL;
|
||||
int num_chans = 0;
|
||||
int max_fd = 0;
|
||||
int proto = DLT_MTP2_WITH_PHDR;
|
||||
|
||||
int i;
|
||||
int packetcount;
|
||||
int c;
|
||||
|
||||
while (1) {
|
||||
int option_index = 0;
|
||||
static struct option long_options[] = {
|
||||
{"proto", required_argument, 0, 'p'},
|
||||
{"chan", required_argument, 0, 'c'},
|
||||
{"file", required_argument, 0, 'f'},
|
||||
{"help", 0, 0, 'h'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "p:c:f:?",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'p':
|
||||
// Protocol
|
||||
if(strcasecmp("LAPD", optarg)==0)
|
||||
{
|
||||
proto = DLT_LINUX_LAPD;
|
||||
}
|
||||
else if(argc > 0 && strcasecmp("MTP2", argv[1])==0)
|
||||
{
|
||||
proto = DLT_MTP2_WITH_PHDR;
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
// TODO Should it be possible to override protocol per channel?
|
||||
// Channels, comma separated list
|
||||
while(optarg != NULL && num_chans < MAX_CHAN)
|
||||
{
|
||||
int chan = atoi(strsep(&optarg, ","));
|
||||
|
||||
|
||||
chans[num_chans].tfd = make_mirror(DAHDI_TXMIRROR, chan);
|
||||
chans[num_chans].rfd = make_mirror(DAHDI_RXMIRROR, chan);
|
||||
chans[num_chans].chan_id = chan;
|
||||
chans[num_chans].proto = proto;
|
||||
|
||||
if(chans[num_chans].tfd > max_fd)
|
||||
{
|
||||
max_fd = chans[num_chans].tfd;
|
||||
}
|
||||
if(chans[num_chans].rfd > max_fd)
|
||||
{
|
||||
max_fd = chans[num_chans].rfd;
|
||||
}
|
||||
|
||||
num_chans++;
|
||||
}
|
||||
max_fd++;
|
||||
break;
|
||||
case 'f':
|
||||
// File to capture to
|
||||
filename=optarg;
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
// Usage
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
if((num_chans == 0) || (filename == NULL)) {
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Capturing protocol %s on channels ", (proto == DLT_MTP2_WITH_PHDR ? "mtp2":"lapd"));
|
||||
for(i = 0; i < num_chans; i++)
|
||||
{
|
||||
printf("%d", chans[i].chan_id);
|
||||
if(i<num_chans-1)
|
||||
{
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
printf(" to file %s\n", filename);
|
||||
}
|
||||
|
||||
pcap_t * pcap = pcap_open_dead(chans[0].proto, BLOCK_SIZE*4);
|
||||
pcap_dumper_t * dump = pcap_dump_open(pcap, filename);
|
||||
|
||||
packetcount=0;
|
||||
while(1)
|
||||
{
|
||||
fd_set rd_set;
|
||||
FD_ZERO(&rd_set);
|
||||
for(i = 0; i < num_chans; i++)
|
||||
{
|
||||
FD_SET(chans[i].tfd, &rd_set);
|
||||
FD_SET(chans[i].rfd, &rd_set);
|
||||
}
|
||||
|
||||
select(max_fd, &rd_set, NULL, NULL, NULL);
|
||||
|
||||
for(i = 0; i < num_chans; i++)
|
||||
{
|
||||
if(FD_ISSET(chans[i].rfd, &rd_set))
|
||||
{
|
||||
packetcount += log_packet(&chans[i], 1, dump);
|
||||
}
|
||||
if(FD_ISSET(chans[i].tfd, &rd_set))
|
||||
{
|
||||
packetcount += log_packet(&chans[i], 0, dump);
|
||||
}
|
||||
}
|
||||
printf("Packets captured: %d\r", packetcount);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* Scan and output information about DAHDI spans and ports.
|
||||
*
|
||||
* Written by Brandon Kruse <bkruse@digium.com>
|
||||
* and Kevin P. Fleming <kpfleming@digium.com>
|
||||
* Copyright (C) 2007 Digium, Inc.
|
||||
*
|
||||
* Based on zttool written by Mark Spencer <markster@digium.com>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
static inline int is_digital_span(struct dahdi_spaninfo *s)
|
||||
{
|
||||
return (s->linecompat > 0);
|
||||
}
|
||||
|
||||
static int get_basechan(unsigned int spanno)
|
||||
{
|
||||
int res;
|
||||
int basechan;
|
||||
char filename[256];
|
||||
FILE *fp;
|
||||
|
||||
snprintf(filename, sizeof(filename),
|
||||
"/sys/bus/dahdi_spans/devices/span-%u/basechan", spanno);
|
||||
fp = fopen(filename, "r");
|
||||
if (NULL == fp) {
|
||||
return -1;
|
||||
}
|
||||
res = fscanf(fp, "%d", &basechan);
|
||||
fclose(fp);
|
||||
if (EOF == res) {
|
||||
return -1;
|
||||
}
|
||||
return basechan;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ctl;
|
||||
int x, y, z;
|
||||
struct dahdi_params params;
|
||||
unsigned int basechan = 1;
|
||||
int direct_basechan;
|
||||
struct dahdi_spaninfo s;
|
||||
char buf[100];
|
||||
char alarms[50];
|
||||
int filter_count = 0;
|
||||
int span_filter[DAHDI_MAX_SPANS];
|
||||
|
||||
if ((ctl = open("/dev/dahdi/ctl", O_RDWR)) < 0) {
|
||||
fprintf(stderr, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (x = 1; x < argc && filter_count < DAHDI_MAX_SPANS; x++) {
|
||||
int s = atoi(argv[x]);
|
||||
if (s > 0) {
|
||||
span_filter[filter_count++] = s;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 1; x < DAHDI_MAX_SPANS; x++) {
|
||||
|
||||
memset(&s, 0, sizeof(s));
|
||||
s.spanno = x;
|
||||
if (ioctl(ctl, DAHDI_SPANSTAT, &s))
|
||||
continue;
|
||||
|
||||
if (filter_count > 0) {
|
||||
int match = 0;
|
||||
for (z = 0; z < filter_count; z++) {
|
||||
if (x == span_filter[z]) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
basechan += s.totalchans;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* DAHDI-Linux 2.5.x exposes the base channel in sysfs. Let's
|
||||
* try to look for it there in case there are holes in the span
|
||||
* numbering. */
|
||||
direct_basechan = get_basechan(x);
|
||||
if (-1 != direct_basechan) {
|
||||
basechan = direct_basechan;
|
||||
}
|
||||
|
||||
alarms[0] = '\0';
|
||||
if (s.alarms) {
|
||||
if (s.alarms & DAHDI_ALARM_BLUE)
|
||||
strcat(alarms,"BLU/");
|
||||
if (s.alarms & DAHDI_ALARM_YELLOW)
|
||||
strcat(alarms, "YEL/");
|
||||
if (s.alarms & DAHDI_ALARM_RED) {
|
||||
strcat(alarms, "RED/");
|
||||
|
||||
/* Extended alarm feature test. Allows compilation with
|
||||
* versions of dahdi-linux prior to 2.4
|
||||
*/
|
||||
#ifdef DAHDI_ALARM_LFA
|
||||
if (s.alarms & DAHDI_ALARM_LFA)
|
||||
strcat(alarms, "LFA/");
|
||||
#endif /* ifdef DAHDI_ALARM_LFA */
|
||||
}
|
||||
if (s.alarms & DAHDI_ALARM_LOOPBACK)
|
||||
strcat(alarms,"LB/");
|
||||
if (s.alarms & DAHDI_ALARM_RECOVER)
|
||||
strcat(alarms,"REC/");
|
||||
if (s.alarms & DAHDI_ALARM_NOTOPEN)
|
||||
strcat(alarms, "NOP/");
|
||||
if (!strlen(alarms))
|
||||
strcat(alarms, "UUU/");
|
||||
if (strlen(alarms)) {
|
||||
/* Strip trailing / */
|
||||
alarms[strlen(alarms)-1]='\0';
|
||||
}
|
||||
} else {
|
||||
if (s.numchans) {
|
||||
#ifdef DAHDI_ALARM_LFA
|
||||
/* If we continuously receive framing errors
|
||||
* but our span is still in service, and we
|
||||
* are configured for E1 & crc4. We've lost
|
||||
* crc4-multiframe alignment
|
||||
*/
|
||||
if ((s.linecompat & DAHDI_CONFIG_CRC4) &&
|
||||
(s.fecount > 0)) {
|
||||
struct dahdi_spaninfo t;
|
||||
memset(&t, 0, sizeof(t));
|
||||
t.spanno = x;
|
||||
sleep(1);
|
||||
if (ioctl(ctl, DAHDI_SPANSTAT, &t))
|
||||
continue;
|
||||
|
||||
/* Test fecount at two separate time
|
||||
* intervals, if they differ, throw LMFA
|
||||
*/
|
||||
if ((t.fecount > s.fecount) &&
|
||||
!t.alarms) {
|
||||
strcat(alarms, "LMFA/");
|
||||
}
|
||||
}
|
||||
#endif /* ifdef DAHDI_ALARM_LFA */
|
||||
strcat(alarms, "OK");
|
||||
} else {
|
||||
strcpy(alarms, "UNCONFIGURED");
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stdout, "[%d]\n", x);
|
||||
fprintf(stdout, "active=yes\n");
|
||||
fprintf(stdout, "alarms=%s\n", alarms);
|
||||
fprintf(stdout, "description=%s\n", s.desc);
|
||||
fprintf(stdout, "name=%s\n", s.name);
|
||||
fprintf(stdout, "manufacturer=%s\n", s.manufacturer);
|
||||
fprintf(stdout, "devicetype=%s\n", s.devicetype);
|
||||
fprintf(stdout, "location=%s\n", s.location);
|
||||
fprintf(stdout, "basechan=%d\n", basechan);
|
||||
fprintf(stdout, "totchans=%d\n", s.totalchans);
|
||||
fprintf(stdout, "irq=%d\n", s.irq);
|
||||
y = basechan;
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.channo = y;
|
||||
if (ioctl(ctl, DAHDI_GET_PARAMS, ¶ms)) {
|
||||
basechan += s.totalchans;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_digital_span(&s)) {
|
||||
/* this is a digital span */
|
||||
fprintf(stdout, "type=digital-%s\n", s.spantype);
|
||||
fprintf(stdout, "syncsrc=%d\n", s.syncsrc);
|
||||
fprintf(stdout, "lbo=%s\n", s.lboname);
|
||||
fprintf(stdout, "coding_opts=");
|
||||
buf[0] = '\0';
|
||||
if (s.linecompat & DAHDI_CONFIG_B8ZS) strcat(buf, "B8ZS,");
|
||||
if (s.linecompat & DAHDI_CONFIG_AMI) strcat(buf, "AMI,");
|
||||
if (s.linecompat & DAHDI_CONFIG_HDB3) strcat(buf, "HDB3,");
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
fprintf(stdout, "%s\n", buf);
|
||||
fprintf(stdout, "framing_opts=");
|
||||
buf[0] = '\0';
|
||||
if (s.linecompat & DAHDI_CONFIG_ESF) strcat(buf, "ESF,");
|
||||
if (s.linecompat & DAHDI_CONFIG_D4) strcat(buf, "D4,");
|
||||
if (s.linecompat & DAHDI_CONFIG_CCS) strcat(buf, "CCS,");
|
||||
if (s.linecompat & DAHDI_CONFIG_CRC4) strcat(buf, "CRC4,");
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
fprintf(stdout, "%s\n", buf);
|
||||
fprintf(stdout, "coding=");
|
||||
if (s.lineconfig & DAHDI_CONFIG_B8ZS) fprintf(stdout, "B8ZS");
|
||||
else if (s.lineconfig & DAHDI_CONFIG_AMI) fprintf(stdout, "AMI");
|
||||
else if (s.lineconfig & DAHDI_CONFIG_HDB3) fprintf(stdout, "HDB3");
|
||||
fprintf(stdout, "\n");
|
||||
fprintf(stdout, "framing=");
|
||||
if (s.lineconfig & DAHDI_CONFIG_ESF) fprintf(stdout, "ESF");
|
||||
else if (s.lineconfig & DAHDI_CONFIG_D4) fprintf(stdout, "D4");
|
||||
else if (s.lineconfig & DAHDI_CONFIG_CCS) fprintf(stdout, "CCS");
|
||||
else fprintf(stdout, "CAS");
|
||||
if (s.lineconfig & DAHDI_CONFIG_CRC4) fprintf(stdout, "/CRC4");
|
||||
fprintf(stdout, "\n");
|
||||
} else {
|
||||
/* this is an analog span */
|
||||
fprintf(stdout, "type=analog\n");
|
||||
for (y = basechan; y < (basechan + s.totalchans); y++) {
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
params.channo = y;
|
||||
if (ioctl(ctl, DAHDI_GET_PARAMS, ¶ms)) {
|
||||
fprintf(stdout, "port=%d,unknown\n", y);
|
||||
continue;
|
||||
};
|
||||
fprintf(stdout, "port=%d,", y);
|
||||
switch (params.sigcap & (__DAHDI_SIG_FXO | __DAHDI_SIG_FXS)) {
|
||||
case __DAHDI_SIG_FXO:
|
||||
fprintf(stdout, "FXS");
|
||||
break;
|
||||
case __DAHDI_SIG_FXS:
|
||||
fprintf(stdout, "FXO");
|
||||
break;
|
||||
default:
|
||||
fprintf(stdout, "none");
|
||||
}
|
||||
if (params.sigcap & DAHDI_SIG_BROKEN)
|
||||
fprintf(stdout, " FAILED");
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
basechan += s.totalchans;
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
|
@ -0,0 +1,333 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# /usr/sbin/dahdi_span_assignments:
|
||||
#
|
||||
# this script can be used both from udev and
|
||||
# from the command line to assign/unassign and list
|
||||
# current span assignments.
|
||||
#
|
||||
# It uses a configuration file: $DAHDICONFDIR/assigned-spans.conf
|
||||
# (default DAHDICONFDIR=/etc/dahdi)
|
||||
#
|
||||
# The first argument is an action:
|
||||
# "auto" - trigger driver auto_assign attribute for given devices
|
||||
# (no configuration file is used)
|
||||
# "add" - assign (spans which are not already assigned), according
|
||||
# to /etc/dahdi/assigned-spans.conf configuration file
|
||||
# "remove" - unassign spans which are not already unassigned
|
||||
# "list" - human-readable list of all spans (with/without assignments)
|
||||
# "dumpconfig" - dump current assignments in a /etc/dahdi/assigned-spans.conf
|
||||
# compatible format
|
||||
#
|
||||
# Without further arguments, it operates on all existing spans
|
||||
# With one or more sysfs dahdi_devices it is limited to those.
|
||||
#
|
||||
# We may use alternative "keys" for device matching:
|
||||
# * Available keys:
|
||||
# - "hwid" - Hardware id attribute from sysfs
|
||||
# - "@location" - Location attribute from sysfs (embeded inside '<>')
|
||||
# - "/devpath" - The sysfs absolute devpath
|
||||
#
|
||||
# * During "dumpconfig", for each device we take the first available key:
|
||||
# - The preference is: "hwid" or else "@location" or else "/devpath"
|
||||
# - This can be overriden via the SPAN_ASSIGNMENTS_KEY environment variable
|
||||
# or the '{-k|--key} key' command line option.
|
||||
#
|
||||
# * During "add":
|
||||
# - Any key match is valid (hwid/location/devpath)
|
||||
# - Shell globs (wildcards: '*', '?', '[...]') may be optionally used.
|
||||
#
|
||||
# Command line options:
|
||||
# - The '-h|--help' show a usage message.
|
||||
# - The '-n|--dry-run' affects the "add" and "remove" operations.
|
||||
# - The '-v|--verbose' currently shows device matches during "add" operation.
|
||||
# - The '-k <key>|--key <key>' overrides the SPAN_ASSIGNMENTS_KEY environment
|
||||
# variable.
|
||||
#
|
||||
# Examples:
|
||||
# dahdi_span_assignments list
|
||||
# dahdi_span_assignments add # all unassigned devices
|
||||
# dahdi_span_assignments add /sys/bus/dahdi_devices/devices/astribanks:xbus-00
|
||||
# dahdi_span_assignments remove # all assigned devices
|
||||
# dahdi_span_assignments -k location dumpconfig
|
||||
#
|
||||
|
||||
devbase='/sys/bus/dahdi_devices/devices'
|
||||
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
|
||||
DAHDISASSIGNEDSPANSCONF="${DAHDIASSIGNEDSPANSCONF:-"${DAHDICONFDIR}/assigned-spans.conf"}"
|
||||
SPAN_ASSIGNMENTS_KEY=${SPAN_ASSIGNMENTS_KEY:-hwid}
|
||||
dry_run=
|
||||
verbose=
|
||||
|
||||
usage() {
|
||||
echo >&2 "Usage: $0 [options] action [devpath ...]"
|
||||
echo >&2 " action:"
|
||||
echo >&2 " auto - trigger driver auto_assign attribute for given devices"
|
||||
echo >&2 " add - assign spans, according to /etc/dahdi/assigned-spans.conf"
|
||||
echo >&2 " remove - unassign spans"
|
||||
echo >&2 " list - human-readable list of all spans"
|
||||
echo >&2 " dumpconfig - dump current state as new configuration"
|
||||
echo >&2 ""
|
||||
echo >&2 " options:"
|
||||
echo >&2 " -h|--help - Show this help"
|
||||
echo >&2 " -n|--dry-run - For 'add/remove' actions"
|
||||
echo >&2 " -v|--versbose - Show matches during 'add' action"
|
||||
echo >&2 " -k|--key <k> - Override prefered key during dumpconfig action"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse command line options
|
||||
TEMP=`getopt -o hnvk: --long help,dry-run,verbose,key: -n "$0" -- "$@"`
|
||||
if [ $? != 0 ]; then
|
||||
echo >&2 "Bad options"
|
||||
usage
|
||||
fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "$TEMP"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-n|--dry-run)
|
||||
dry_run='true'
|
||||
shift
|
||||
;;
|
||||
-v|--verbose)
|
||||
verbose='true'
|
||||
shift
|
||||
;;
|
||||
-k|--key)
|
||||
SPAN_ASSIGNMENTS_KEY="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Internal error!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo >&2 "Missing action argument"
|
||||
usage
|
||||
fi
|
||||
action="$1"
|
||||
shift
|
||||
|
||||
# Validate SPAN_ASSIGNMENTS_KEY
|
||||
case "$SPAN_ASSIGNMENTS_KEY" in
|
||||
hwid|location|devpath)
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad SPAN_ASSIGNMENTS_KEY='$SPAN_ASSIGNMENTS_KEY' (should be: hwid|location|devpath)"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -d "$devbase" ]; then
|
||||
echo >&2 "$0: Missing '$devbase' (DAHDI driver unloaded?)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use given devices or otherwise, all existing devices
|
||||
if [ "$#" -gt 0 ]; then
|
||||
DEVICES="$@"
|
||||
else
|
||||
DEVICES=`ls -d $devbase/* 2>/dev/null`
|
||||
fi
|
||||
|
||||
# Beware of special characters in attributes
|
||||
attr_clean() {
|
||||
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
|
||||
}
|
||||
|
||||
show_devices() {
|
||||
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
for local_spanno in `cut -d: -f1 "$device/spantype"`
|
||||
do
|
||||
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
|
||||
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
|
||||
if [ "$span" != '' ]; then
|
||||
spanno=`echo $span | sed 's/^.*-//'`
|
||||
name=`cat 2>/dev/null "$device/$span/name"`
|
||||
basechan=`cat 2>/dev/null "$device/$span/basechan"`
|
||||
else
|
||||
spanno='-'
|
||||
basechan='-'
|
||||
fi
|
||||
printf "%-8s %-14s %s %s\n" "$local_spanno:$spanno:$basechan" "[$hardware_id]" "$location" "$devpath"
|
||||
done | sort -n
|
||||
done
|
||||
}
|
||||
|
||||
dump_config() {
|
||||
echo '#'
|
||||
echo "# Autogenerated by $0 on `date`"
|
||||
echo "# Map devices + local spans to span + base channel number"
|
||||
echo ''
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location=`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
if [ "$SPAN_ASSIGNMENTS_KEY" = 'hwid' -a "$hardware_id" != '' ]; then
|
||||
id="$hardware_id"
|
||||
elif [ "$SPAN_ASSIGNMENTS_KEY" = 'location' -a "$location" != '' ]; then
|
||||
id="@$location"
|
||||
else
|
||||
id="$devpath"
|
||||
fi
|
||||
echo "# Device: [$hardware_id] @$location $devpath"
|
||||
for local_spanno in `cut -d: -f1 "$device/spantype"`
|
||||
do
|
||||
span=`grep 2>/dev/null -Hw "$local_spanno" "$device/span-"*"/local_spanno" | \
|
||||
sed -e 's,/local_spanno:.*,,' -e 's,.*/,,'`
|
||||
if [ "$span" != '' ]; then
|
||||
spanno=`echo $span | sed 's/^.*-//'`
|
||||
name=`cat 2>/dev/null "$device/$span/name"`
|
||||
basechan=`cat 2>/dev/null "$device/$span/basechan"`
|
||||
printf "%-30s %s\n" "$id" "$local_spanno:$spanno:$basechan"
|
||||
else
|
||||
echo "# Skipped unassigned local span $local_spanno"
|
||||
fi
|
||||
done | sort
|
||||
echo ''
|
||||
done
|
||||
}
|
||||
|
||||
unassign_all_spans() {
|
||||
for device in $DEVICES
|
||||
do
|
||||
find "$device" -follow -maxdepth 1 -name 'span-*' -type d | \
|
||||
sort | while read spandir; do
|
||||
local_spanno=`cat "$spandir/local_spanno"`
|
||||
if [ "$dry_run" = true ]; then
|
||||
echo "(dry-run) unassign $device $local_spanno"
|
||||
continue
|
||||
fi
|
||||
echo "unassign $device $local_spanno"
|
||||
if ! echo "$local_spanno" > "$device/unassign_span"; then
|
||||
echo >&2 "$0: failed unassigning '$local_spanno' in '$device'"
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Allow comments and empty lines in config file
|
||||
filter_conf() {
|
||||
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$DAHDISASSIGNEDSPANSCONF"
|
||||
}
|
||||
|
||||
assign_device_spans() {
|
||||
device="$1"
|
||||
for s in $spanspecs
|
||||
do
|
||||
local_spanno=`echo "$s" | cut -d: -f1`
|
||||
spanno=`echo "$s" | cut -d: -f2`
|
||||
span="$device/span-$spanno"
|
||||
if [ "$dry_run" = true ]; then
|
||||
echo "(dry-run) assign $device: $s"
|
||||
continue
|
||||
fi
|
||||
if [ -d "$span" ]; then
|
||||
span_local_spanno=`cat "$span/local_spanno"`
|
||||
if [ "$span_local_spanno" != "$local_spanno" ]; then
|
||||
echo "WARNING: $span_local_spanno != $local_spanno"
|
||||
fi
|
||||
echo "$device [$local_spanno] already assigned to span $spanno. Skipping..."
|
||||
continue
|
||||
fi
|
||||
echo "assign $device: $s"
|
||||
if ! echo "$s" > "$device/assign_span"; then
|
||||
echo >&2 "$0: failed assigning '$s' to '$device'"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
match_device() {
|
||||
device="$1"
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
filter_conf | while read id spanspecs
|
||||
do
|
||||
# We use case to enable shell-style globbing in configuration
|
||||
case "$hardware_id" in
|
||||
$id)
|
||||
[ "$verbose" = true ] && echo "match by hwid ($id ~ $hardware_id): $spanspecs"
|
||||
assign_device_spans "$device"
|
||||
;;
|
||||
esac
|
||||
# We use case to enable shell-style globbing in configuration
|
||||
case "$location" in
|
||||
$id)
|
||||
[ "$verbose" = true ] && echo "match by location ($id ~ $location): $spanspecs"
|
||||
assign_device_spans "$device"
|
||||
;;
|
||||
esac
|
||||
# We use case to enable shell-style globbing in configuration
|
||||
case "$devpath" in
|
||||
$id)
|
||||
[ "$verbose" = true ] && echo "match by devpath ($id ~ $devpath): $spanspecs"
|
||||
assign_device_spans "$device"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
assign_devices() {
|
||||
if [ ! -f "$DAHDISASSIGNEDSPANSCONF" ]; then
|
||||
echo >&2 "$0: Missing '$DAHDISASSIGNEDSPANSCONF'"
|
||||
exit 1
|
||||
fi
|
||||
echo "using '$DAHDISASSIGNEDSPANSCONF'"
|
||||
for device in $DEVICES
|
||||
do
|
||||
match_device "$device"
|
||||
done
|
||||
}
|
||||
|
||||
auto_assign_devices() {
|
||||
for device in $DEVICES
|
||||
do
|
||||
echo "auto-assign $device"
|
||||
if [ "$dry_run" != true ]; then
|
||||
echo 1 > "$device/auto_assign"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
case "$action" in
|
||||
auto)
|
||||
auto_assign_devices
|
||||
;;
|
||||
add)
|
||||
assign_devices
|
||||
;;
|
||||
remove)
|
||||
unassign_all_spans
|
||||
;;
|
||||
list)
|
||||
show_devices
|
||||
;;
|
||||
dumpconfig)
|
||||
dump_config
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad action='$action'"
|
||||
usage
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,366 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# /usr/sbin/dahdi_span_types
|
||||
#
|
||||
# This script can be used both from udev and
|
||||
# from the command line to manage PRI spans
|
||||
# type (E1/T1/J1).
|
||||
#
|
||||
# Span types can be set only *BEFORE* span are assigned.
|
||||
#
|
||||
# It uses a configuration file: $DAHDICONFDIR/span-types.conf
|
||||
# (default DAHDICONFDIR=/etc/dahdi)
|
||||
# (the format is documented inside that file)
|
||||
#
|
||||
# The first argument is an action:
|
||||
# "set" - actually write the setting to the driver
|
||||
# "list" - human-readable list of E1/T1/J1 types
|
||||
# "dumpconfig" - dump current assignments in a /etc/dahdi/span-types.conf
|
||||
# compatible format
|
||||
#
|
||||
# Without further arguments, it operates on all existing spans
|
||||
# With one or more sysfs dahdi_devices it is limited to those.
|
||||
#
|
||||
# We may use alternative "keys" for device matching:
|
||||
# * Available keys:
|
||||
# - "hwid" - Hardware id attribute from sysfs
|
||||
# - "@location" - Location attribute from sysfs (embeded inside '<>')
|
||||
# - "/devpath" - The sysfs absolute devpath
|
||||
#
|
||||
# * Wildcard are allowed in the configuration file:
|
||||
# - In the device specifiers (keys)
|
||||
# - In the span numbers
|
||||
# - Example for "match-all": * *:T1
|
||||
#
|
||||
# * During "set":
|
||||
# - If there are multiple matches, for a span, all are applied
|
||||
# - They are always applied in their order in the configuration file
|
||||
# - This means the last match wins
|
||||
# - Example:
|
||||
# * *:T1 # All span on all devices are T1
|
||||
# usb:X1234567 [34]:E1 # Except spans 3,4 on specific device
|
||||
#
|
||||
# * During "dumpconfig", for each device we take the first available key:
|
||||
# - The preference is: "hwid" or else "@location" or else "/devpath"
|
||||
# - This can be overriden via the SPAN_ASSIGNMENTS_KEY environment variable
|
||||
# or the '{-k|--key} key' command line option.
|
||||
#
|
||||
# Command line options:
|
||||
# - The '-h|--help' show a usage message.
|
||||
# - The '-v|--verbose' show debugging messages (on stderr)
|
||||
# - The '-n|--dry-run' During "set", only show what would be done
|
||||
# - The '-k <key>|--key <key>' overrides the SPAN_ASSIGNMENTS_KEY environment
|
||||
# variable.
|
||||
#
|
||||
# Examples:
|
||||
# dahdi_span_types list
|
||||
# dahdi_span_types set # all devices
|
||||
# dahdi_span_types set /sys/bus/dahdi_devices/devices/astribanks:xbus-00
|
||||
# dahdi_span_types -k location dumpconfig
|
||||
#
|
||||
|
||||
|
||||
devbase='/sys/bus/dahdi_devices/devices'
|
||||
DAHDICONFDIR="${DAHDICONFDIR:-/etc/dahdi}"
|
||||
DAHDISPANTYPESCONF="${DAHDISPANTYPESCONF:-"${DAHDICONFDIR}/span-types.conf"}"
|
||||
SPAN_ASSIGNMENTS_KEY=${SPAN_ASSIGNMENTS_KEY:-hwid}
|
||||
|
||||
usage() {
|
||||
echo >&2 "Usage: $0 [options] action [devpath ...]"
|
||||
echo >&2 " action:"
|
||||
echo >&2 " set - set spans to E1/T1 according to /etc/dahdi/span-types.conf"
|
||||
echo >&2 " list - human-readable list of all spans"
|
||||
echo >&2 " dumpconfig - dump current state in /etc/dahdi/span-types.conf format"
|
||||
echo >&2 ""
|
||||
echo >&2 " options:"
|
||||
echo >&2 " -h|--help - Show this help"
|
||||
echo >&2 " -v|--verbose' - Show debugging messages (on stderr)"
|
||||
echo >&2 " -n|--dry-run' - During 'set', only show what would be done"
|
||||
echo >&2 " -k|--key <k> - Override prefered key during dumpconfig action"
|
||||
echo >&2 " --line-mode <m> - Set default line mode to <m> (E1/T1/J1)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Parse command line options
|
||||
TEMP=`getopt -o hnvk: --long help,dry-run,verbose,key:,line-mode: -n "$0" -- "$@"`
|
||||
if [ $? != 0 ]; then
|
||||
echo >&2 "Bad options"
|
||||
usage
|
||||
fi
|
||||
|
||||
# Note the quotes around `$TEMP': they are essential!
|
||||
eval set -- "$TEMP"
|
||||
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
;;
|
||||
-n|--dry-run)
|
||||
shift
|
||||
dry_run=true
|
||||
;;
|
||||
-v|--verbose)
|
||||
shift
|
||||
verbose=true
|
||||
;;
|
||||
-k|--key)
|
||||
SPAN_ASSIGNMENTS_KEY="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--line-mode)
|
||||
DEFAULT_LINE_MODE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Internal error!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo >&2 "Missing action argument"
|
||||
usage
|
||||
fi
|
||||
action="$1"
|
||||
shift
|
||||
|
||||
# Validate SPAN_ASSIGNMENTS_KEY
|
||||
case "$SPAN_ASSIGNMENTS_KEY" in
|
||||
hwid|location|devpath)
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad --key='$SPAN_ASSIGNMENTS_KEY' (should be: hwid|location|devpath)"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
# Validate DEFAULT_LINE_MODE
|
||||
case "$DEFAULT_LINE_MODE" in
|
||||
E1|T1|J1|'')
|
||||
;;
|
||||
*)
|
||||
echo >&2 "Bad --line-mode='$DEFAULT_LINE_MODE' (should be: E1|T1|J1)"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -d "$devbase" ]; then
|
||||
echo >&2 "$0: Missing '$devbase' (DAHDI driver unloaded?)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use given devices or otherwise, all existing devices
|
||||
if [ "$#" -gt 0 ]; then
|
||||
DEVICES="$@"
|
||||
else
|
||||
DEVICES=`ls -d $devbase/* 2>/dev/null`
|
||||
fi
|
||||
|
||||
# Beware of special characters in attributes
|
||||
attr_clean() {
|
||||
cat "$1" 2>/dev/null | tr -d '\n' | tr '!' '/' | tr -c 'a-zA-Z0-9/:.-' '_'
|
||||
}
|
||||
|
||||
show_spantypes() {
|
||||
echo "# PRI span types (E1/T1/J1)"
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
printf "%-10s %-20s %-30s %s\n" \
|
||||
"$st" "[$hardware_id]" "$location" \
|
||||
"$devpath"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
list_pri_spantypes() {
|
||||
find $DEVICES -follow -maxdepth 1 -name spantype | \
|
||||
xargs cat | \
|
||||
sed -n '/:[ETJ]1$/s/^.*://p' | \
|
||||
sort -u | \
|
||||
tr '\n' ' ' | \
|
||||
sed -e 's/^ *//' -e 's/ *$//'
|
||||
}
|
||||
|
||||
dump_config() {
|
||||
pri_spantypes=`list_pri_spantypes`
|
||||
num_spantypes=`echo "$pri_spantypes" | wc -w`
|
||||
gen_default=''
|
||||
echo '#'
|
||||
echo "# Autogenerated by $0 on `date`"
|
||||
echo "# Map PRI DAHDI devices to span types for E1/T1/J1"
|
||||
echo "#"
|
||||
|
||||
echo "# Summary:"
|
||||
if [ "$DEFAULT_LINE_MODE" != '' ]; then
|
||||
gen_default="$DEFAULT_LINE_MODE"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Was run with '--line-mode=$DEFAULT_LINE_MODE'"
|
||||
elif [ "$num_spantypes" -eq 1 ]; then
|
||||
gen_default="$pri_spantypes"
|
||||
echo "# * Generating wildcard match of $gen_default."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
else
|
||||
echo "# * Not generating wildcard match."
|
||||
echo "# - Was run without '--line-mode' option and span were of mixed types [$pri_spantypes]"
|
||||
fi
|
||||
echo "#"
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
echo "# * Generating a list of commented out configurations for spans."
|
||||
echo "# - Spans were $pri_spantypes"
|
||||
echo "# - Uncomment for specific overrides"
|
||||
else
|
||||
echo "# * Generating a list of specific span configurations."
|
||||
echo "# - Spans were of mixed types: $pri_spantypes"
|
||||
fi
|
||||
echo "#"
|
||||
echo ''
|
||||
|
||||
fmt="%-65s %s"
|
||||
printf "$fmt\n" '# @location/hardware_id' 'span_type'
|
||||
|
||||
if [ "$gen_default" != '' ]; then
|
||||
printf "$fmt\t\t# Wildcard line-mode" "*" "*:$gen_default"
|
||||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
for device in $DEVICES
|
||||
do
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
location=`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
if [ "$SPAN_ASSIGNMENTS_KEY" = 'hwid' -a "$hardware_id" != '' ]; then
|
||||
id="$hardware_id"
|
||||
elif [ "$SPAN_ASSIGNMENTS_KEY" = 'location' -a "$location" != '' ]; then
|
||||
id="@$location"
|
||||
else
|
||||
id="$devpath"
|
||||
fi
|
||||
echo "# Device: [$hardware_id] @$location $devpath"
|
||||
cat "$device/spantype" | while read st; do
|
||||
case "$st" in
|
||||
*:[ETJ]1)
|
||||
if [ "$num_spantypes" -eq 1 ]; then
|
||||
printf "#$fmt\n" "$id" "$st"
|
||||
else
|
||||
printf "$fmt\n" "$id" "$st"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
#echo "# Skipped local span `echo $st | sed 's/:/ -- /'`"
|
||||
;;
|
||||
esac
|
||||
done | sort -n
|
||||
echo ''
|
||||
done
|
||||
}
|
||||
|
||||
# Allow comments and empty lines in config file
|
||||
filter_conf() {
|
||||
sed -e 's/#.*//' -e '/^[ \t]*$/d' "$DAHDISPANTYPESCONF"
|
||||
}
|
||||
|
||||
handle_span() {
|
||||
device="$1"
|
||||
spantype="$2"
|
||||
attr_file="$device/spantype"
|
||||
devpath=`cd "$device" && pwd -P`
|
||||
devname=`echo "$device" | sed "s,$devbase/,,"`
|
||||
location='@'`attr_clean "$device/location"`
|
||||
hardware_id=`attr_clean "$device/hardware_id"`
|
||||
spanno=`echo "$spantype" | cut -d: -f1`
|
||||
#echo >&2 "DEBUG: $device $spanno ($spantype)"
|
||||
filter_conf | while read id span_spec; do
|
||||
sn=`echo "$span_spec" | cut -d: -f1`
|
||||
val=`echo "$span_spec" | cut -d: -f2`
|
||||
case "$spanno" in
|
||||
$sn)
|
||||
;;
|
||||
*)
|
||||
#echo >&2 "no-match($device $spanno): $sn"
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
found=no
|
||||
# GLOBBING
|
||||
case "$location" in
|
||||
$id)
|
||||
#echo >&2 "match($id): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
case "$hardware_id" in
|
||||
$id)
|
||||
#echo >&2 "match([$id]): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
case "$devpath" in
|
||||
$id)
|
||||
#echo >&2 "match([$id]): $span_spec"
|
||||
found=yes
|
||||
;;
|
||||
esac
|
||||
if [ "$found" = 'yes' ]; then
|
||||
if [ "$dry_run" = 'true' -o "$verbose" = 'true' ]; then
|
||||
echo >&2 "Set $devname span $spanno = $val"
|
||||
fi
|
||||
if [ "$dry_run" != 'true' ]; then
|
||||
echo "$spanno:$val" > "$attr_file"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
set_all_devices() {
|
||||
if [ ! -f "$DAHDISPANTYPESCONF" ]; then
|
||||
echo >&2 "$0: Missing configuration '$DAHDISPANTYPESCONF'"
|
||||
exit 1
|
||||
fi
|
||||
for device in $DEVICES
|
||||
do
|
||||
devname=`echo "$device" | sed "s,$devbase/,,"`
|
||||
cat "$device/spantype" | while read spantype; do
|
||||
case "$spantype" in
|
||||
*:[ETJ]1)
|
||||
handle_span "$device" "$spantype"
|
||||
;;
|
||||
*)
|
||||
if [ "$dry_run" = 'true' -o "$verbose" = 'true' ]; then
|
||||
echo >&2 "Skipping non-E1/T1/J1 span ($devname -- $spantype)"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
case "$action" in
|
||||
list)
|
||||
show_spantypes
|
||||
;;
|
||||
dumpconfig)
|
||||
dump_config
|
||||
;;
|
||||
set)
|
||||
set_all_devices
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Generic speed test -- Run an infinite loop and
|
||||
* see how high we can count (in 5 seconds). You
|
||||
* can use this to measure how much CPU DAHDI REALLY
|
||||
* is taking.
|
||||
*
|
||||
* MUST BE COMPILED WITHOUT OPTIMIZATION
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/signal.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
static long count=0;
|
||||
|
||||
static void alm(int sig)
|
||||
{
|
||||
printf("Count: %ld\n", count);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int a=0,b=0,c;
|
||||
signal(SIGALRM, alm);
|
||||
alarm(5);
|
||||
for (;;) {
|
||||
for (c=0;c<1000;c++)
|
||||
a = a * b;
|
||||
count++;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/signal.h>
|
||||
#include <math.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define SIZE 8000
|
||||
|
||||
static int verbose;
|
||||
static int pass = 0;
|
||||
static float best = 0.0;
|
||||
static float worst = 100.0;
|
||||
static double total = 0.0;
|
||||
static double total_time = 0.0;
|
||||
static double total_count = 0.0;
|
||||
|
||||
static inline float _fmin(float a, float b)
|
||||
{
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
static double calculate_accuracy(double count, double ms)
|
||||
{
|
||||
return ((count - _fmin(count, fabs(count - ms))) / count) * 100.0;
|
||||
}
|
||||
|
||||
void hup_handler(int sig)
|
||||
{
|
||||
double accuracy = calculate_accuracy(total_count, total_time);
|
||||
printf("\n--- Results after %d passes ---\n", pass);
|
||||
printf("Best: %.3f%% -- Worst: %.3f%% -- Average: %f%%\n",
|
||||
best, worst, pass ? total/pass : 100.00);
|
||||
printf("Cummulative Accuracy (not per pass): %0.3f\n",
|
||||
pass ? accuracy : 0.0);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static void usage(char *argv0)
|
||||
{
|
||||
char *c;
|
||||
c = strrchr(argv0, '/');
|
||||
if (!c)
|
||||
c = argv0;
|
||||
else
|
||||
c++;
|
||||
fprintf(stderr,
|
||||
"Usage: %s [-c COUNT] [-v]\n"
|
||||
" Valid options are:\n"
|
||||
" -c COUNT Run just COUNT cycles (otherwise: forever).\n"
|
||||
" -v More verbose output.\n"
|
||||
" -h This help text.\n"
|
||||
, c);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res;
|
||||
int c;
|
||||
int count = 0;
|
||||
int seconds = 0;
|
||||
int curarg = 1;
|
||||
char buf[8192];
|
||||
float ms;
|
||||
struct timeval start, now;
|
||||
fd = open("/dev/dahdi/pseudo", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open dahdi interface: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while ((c = getopt(argc, argv, "c:hv")) != -1) {
|
||||
switch(c) {
|
||||
case 'c':
|
||||
seconds = atoi(optarg);
|
||||
break;
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
break;
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (curarg < argc) {
|
||||
if (!strcasecmp(argv[curarg], "-v"))
|
||||
verbose++;
|
||||
if (!strcasecmp(argv[curarg], "-c") && argc > curarg)
|
||||
seconds = atoi(argv[curarg + 1]);
|
||||
curarg++;
|
||||
}
|
||||
printf("Opened pseudo dahdi interface, measuring accuracy...\n");
|
||||
signal(SIGHUP, hup_handler);
|
||||
signal(SIGINT, hup_handler);
|
||||
signal(SIGALRM, hup_handler);
|
||||
/* Flush input buffer */
|
||||
for (count = 0; count < 4; count++)
|
||||
res = read(fd, buf, sizeof(buf));
|
||||
count = 0;
|
||||
ms = 0; /* Makes the compiler happy */
|
||||
if (seconds > 0)
|
||||
alarm(seconds + 1); /* This will give 'seconds' cycles */
|
||||
for (;;) {
|
||||
if (count == 0)
|
||||
ms = 0;
|
||||
gettimeofday(&start, NULL);
|
||||
res = read(fd, buf, sizeof(buf));
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Failed to read from pseudo interface: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
count += res;
|
||||
gettimeofday(&now, NULL);
|
||||
ms += (now.tv_sec - start.tv_sec) * 8000;
|
||||
ms += (now.tv_usec - start.tv_usec) / 125.0;
|
||||
if (count >= SIZE) {
|
||||
const double percent = calculate_accuracy(count, ms);
|
||||
if (verbose) {
|
||||
printf("\n%d samples in %0.3f system clock sample intervals (%.3f%%)",
|
||||
count, ms, percent);
|
||||
} else if (pass > 0 && (pass % 8) == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
if (percent > best)
|
||||
best = percent;
|
||||
if (percent < worst)
|
||||
worst = percent;
|
||||
if (!verbose)
|
||||
printf("%.3f%% ", percent);
|
||||
total += percent;
|
||||
fflush(stdout);
|
||||
total_count += count;
|
||||
total_time += ms;
|
||||
count = 0;
|
||||
pass++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,541 @@
|
|||
/*
|
||||
* Configuration program for Zapata Telephony Interface
|
||||
*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2010 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
/*** MODULEINFO
|
||||
<depend>newt</depend>
|
||||
***/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <newt.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
static int ctl = -1;
|
||||
static int span_max_chan_pos;
|
||||
|
||||
static struct dahdi_spaninfo s[DAHDI_MAX_SPANS];
|
||||
|
||||
static char *dahdi_txlevelnames[] = {
|
||||
"0 db (CSU)/0-133 feet (DSX-1)",
|
||||
"133-266 feet (DSX-1)",
|
||||
"266-399 feet (DSX-1)",
|
||||
"399-533 feet (DSX-1)",
|
||||
"533-655 feet (DSX-1)",
|
||||
"-7.5db (CSU)",
|
||||
"-15db (CSU)",
|
||||
"-22.5db (CSU)"
|
||||
} ;
|
||||
|
||||
static char *alarmstr(int span)
|
||||
{
|
||||
static char alarms[80];
|
||||
strcpy(alarms, "");
|
||||
if (s[span].alarms > 0) {
|
||||
if (s[span].alarms & DAHDI_ALARM_BLUE)
|
||||
strcat(alarms,"Blue Alarm/");
|
||||
if (s[span].alarms & DAHDI_ALARM_YELLOW)
|
||||
strcat(alarms, "Yellow Alarm/");
|
||||
if (s[span].alarms & DAHDI_ALARM_RED)
|
||||
strcat(alarms, "Red Alarm/");
|
||||
if (s[span].alarms & DAHDI_ALARM_LOOPBACK)
|
||||
strcat(alarms,"Loopback/");
|
||||
if (s[span].alarms & DAHDI_ALARM_RECOVER)
|
||||
strcat(alarms,"Recovering/");
|
||||
if (s[span].alarms & DAHDI_ALARM_NOTOPEN)
|
||||
strcat(alarms, "Not Open/");
|
||||
if (!strlen(alarms))
|
||||
strcat(alarms, "<unknown>/");
|
||||
if (strlen(alarms)) {
|
||||
/* Strip trailing / */
|
||||
alarms[strlen(alarms)-1]='\0';
|
||||
}
|
||||
} else
|
||||
strcpy(alarms, "No alarms.");
|
||||
return alarms;
|
||||
}
|
||||
|
||||
static char *getalarms(int span, int err)
|
||||
{
|
||||
int res;
|
||||
static char tmp[256];
|
||||
char alarms[50];
|
||||
s[span].spanno = span;
|
||||
res = ioctl(ctl, DAHDI_SPANSTAT, &s[span]);
|
||||
if (res) {
|
||||
if (err)
|
||||
fprintf(stderr, "Unable to get span info on span %d: %s\n", span, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
strcpy(alarms, "");
|
||||
if (s[span].alarms > 0) {
|
||||
if (s[span].alarms & DAHDI_ALARM_BLUE)
|
||||
strcat(alarms,"BLU/");
|
||||
if (s[span].alarms & DAHDI_ALARM_YELLOW)
|
||||
strcat(alarms, "YEL/");
|
||||
if (s[span].alarms & DAHDI_ALARM_RED)
|
||||
strcat(alarms, "RED/");
|
||||
if (s[span].alarms & DAHDI_ALARM_LOOPBACK)
|
||||
strcat(alarms,"LB/");
|
||||
if (s[span].alarms & DAHDI_ALARM_RECOVER)
|
||||
strcat(alarms,"REC/");
|
||||
if (s[span].alarms & DAHDI_ALARM_NOTOPEN)
|
||||
strcat(alarms, "NOP/");
|
||||
if (!strlen(alarms))
|
||||
strcat(alarms, "UUU/");
|
||||
if (strlen(alarms)) {
|
||||
/* Strip trailing / */
|
||||
alarms[strlen(alarms)-1]='\0';
|
||||
}
|
||||
} else {
|
||||
if (s[span].numchans)
|
||||
strcpy(alarms, "OK");
|
||||
else
|
||||
strcpy(alarms, "UNCONFIGURED");
|
||||
}
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "%-15s %s", alarms, s[span].desc);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void add_cards(newtComponent spans)
|
||||
{
|
||||
int x;
|
||||
char *s;
|
||||
void *prev=NULL;
|
||||
|
||||
if (spans)
|
||||
prev = newtListboxGetCurrent(spans);
|
||||
newtListboxClear(spans);
|
||||
for (x=0;x<DAHDI_MAX_SPANS;x++) {
|
||||
s = getalarms(x, 0);
|
||||
if (s && spans) {
|
||||
/* Found one! */
|
||||
newtListboxAppendEntry(spans, s, (void *)(long)x);
|
||||
}
|
||||
}
|
||||
if (spans)
|
||||
newtListboxSetCurrentByKey(spans, prev);
|
||||
|
||||
}
|
||||
|
||||
static void sel_callback(newtComponent c, void *cbdata)
|
||||
{
|
||||
int span;
|
||||
char info[256];
|
||||
char info2[256];
|
||||
cbdata = newtListboxGetCurrent(c);
|
||||
if (cbdata) {
|
||||
span = (long)(cbdata);
|
||||
snprintf(info, sizeof (info), "Span %d: %d total channels, %d configured", span, s[span].totalchans, s[span].numchans);
|
||||
snprintf(info2, sizeof(info2), "%-59s F1=Details F10=Quit", info);
|
||||
} else {
|
||||
span = -1;
|
||||
strcpy(info, "There are no DAHDI spans on this system.");
|
||||
snprintf(info2, sizeof(info2), "%-59s F10=Quit", info);
|
||||
}
|
||||
newtPopHelpLine();
|
||||
newtPushHelpLine(info2);
|
||||
}
|
||||
|
||||
static void show_bits(int span, newtComponent bitbox, newtComponent inuse, newtComponent levels, newtComponent bpvcount,
|
||||
newtComponent alarms, newtComponent syncsrc, newtComponent irqmisses)
|
||||
{
|
||||
struct dahdi_params zp;
|
||||
int x;
|
||||
int res;
|
||||
char c;
|
||||
char tabits[80];
|
||||
char tbbits[80];
|
||||
char tcbits[80];
|
||||
char tdbits[80];
|
||||
char rabits[80];
|
||||
char rbbits[80];
|
||||
char rcbits[80];
|
||||
char rdbits[80];
|
||||
char tmp[1024];
|
||||
|
||||
int use = 0;
|
||||
|
||||
memset(tabits,0, sizeof(tabits));
|
||||
memset(tbbits,0, sizeof(tbbits));
|
||||
memset(rabits,0, sizeof(rabits));
|
||||
memset(rbbits,0, sizeof(rbbits));
|
||||
memset(tcbits,0, sizeof(tcbits));
|
||||
memset(tdbits,0, sizeof(tdbits));
|
||||
memset(rcbits,0, sizeof(rcbits));
|
||||
memset(rdbits,0, sizeof(rdbits));
|
||||
memset(tabits,32, span_max_chan_pos);
|
||||
memset(tbbits,32, span_max_chan_pos);
|
||||
memset(rabits,32, span_max_chan_pos);
|
||||
memset(rbbits,32, span_max_chan_pos);
|
||||
memset(tcbits,32, span_max_chan_pos);
|
||||
memset(tdbits,32, span_max_chan_pos);
|
||||
memset(rcbits,32, span_max_chan_pos);
|
||||
memset(rdbits,32, span_max_chan_pos);
|
||||
|
||||
for (x=0;x<DAHDI_MAX_CHANNELS;x++) {
|
||||
memset(&zp, 0, sizeof(zp));
|
||||
zp.channo = x;
|
||||
res = ioctl(ctl, DAHDI_GET_PARAMS, &zp);
|
||||
if (!res) {
|
||||
if (zp.spanno == span) {
|
||||
if (zp.sigtype && (zp.rxbits > -1)) {
|
||||
if (zp.rxbits & DAHDI_ABIT)
|
||||
rabits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
rabits[zp.chanpos - 1] = '0';
|
||||
if (zp.rxbits & DAHDI_BBIT)
|
||||
rbbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
rbbits[zp.chanpos - 1] = '0';
|
||||
|
||||
if (zp.rxbits & DAHDI_CBIT)
|
||||
rcbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
rcbits[zp.chanpos - 1] = '0';
|
||||
if (zp.rxbits & DAHDI_DBIT)
|
||||
rdbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
rdbits[zp.chanpos - 1] = '0';
|
||||
|
||||
if (zp.txbits & DAHDI_ABIT)
|
||||
tabits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
tabits[zp.chanpos - 1] = '0';
|
||||
if (zp.txbits & DAHDI_BBIT)
|
||||
tbbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
tbbits[zp.chanpos - 1] = '0';
|
||||
if (zp.txbits & DAHDI_CBIT)
|
||||
tcbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
tcbits[zp.chanpos - 1] = '0';
|
||||
if (zp.txbits & DAHDI_DBIT)
|
||||
tdbits[zp.chanpos - 1] = '1';
|
||||
else
|
||||
tdbits[zp.chanpos - 1] = '0';
|
||||
} else {
|
||||
c = '-';
|
||||
if (!zp.sigtype)
|
||||
c = ' ';
|
||||
tabits[zp.chanpos - 1] = c;
|
||||
tbbits[zp.chanpos - 1] = c;
|
||||
tcbits[zp.chanpos - 1] = c;
|
||||
tdbits[zp.chanpos - 1] = c;
|
||||
rabits[zp.chanpos - 1] = c;
|
||||
rbbits[zp.chanpos - 1] = c;
|
||||
rcbits[zp.chanpos - 1] = c;
|
||||
rdbits[zp.chanpos - 1] = c;
|
||||
}
|
||||
if (zp.rxisoffhook)
|
||||
use++;
|
||||
}
|
||||
}
|
||||
}
|
||||
snprintf(tmp, sizeof(tmp), "%s\n%s\n%s\n%s\n\n%s\n%s\n%s\n%s", tabits, tbbits,tcbits,tdbits,rabits,rbbits,rcbits,rdbits);
|
||||
newtTextboxSetText(bitbox, tmp);
|
||||
sprintf(tmp, "%3d/%3d/%3d", s[span].totalchans, s[span].numchans, use);
|
||||
newtTextboxSetText(inuse, tmp);
|
||||
sprintf(tmp, "%s/", dahdi_txlevelnames[s[span].txlevel]);
|
||||
strcat(tmp, dahdi_txlevelnames[s[span].rxlevel]);
|
||||
sprintf(tmp, "%3d/%3d", s[span].txlevel, s[span].rxlevel);
|
||||
newtTextboxSetText(levels, tmp);
|
||||
sprintf(tmp, "%7d", s[span].bpvcount);
|
||||
newtTextboxSetText(bpvcount, tmp);
|
||||
sprintf(tmp, "%7d", s[span].irqmisses);
|
||||
newtTextboxSetText(irqmisses, tmp);
|
||||
newtTextboxSetText(alarms, alarmstr(span));
|
||||
if (s[span].syncsrc > 0)
|
||||
strcpy(tmp, s[s[span].syncsrc].desc);
|
||||
else
|
||||
strcpy(tmp, "Internally clocked");
|
||||
newtTextboxSetText(syncsrc, tmp);
|
||||
|
||||
|
||||
}
|
||||
|
||||
static newtComponent spans;
|
||||
static void show_span(int span)
|
||||
{
|
||||
newtComponent form;
|
||||
newtComponent back;
|
||||
newtComponent label;
|
||||
newtComponent bitbox;
|
||||
newtComponent inuse;
|
||||
newtComponent levels;
|
||||
newtComponent bpvcount;
|
||||
newtComponent alarms;
|
||||
newtComponent syncsrc;
|
||||
newtComponent irqmisses;
|
||||
|
||||
char s1[] = " 1111111111222222222233";
|
||||
char s2[] = "1234567890123456789012345678901";
|
||||
int x;
|
||||
struct newtExitStruct es;
|
||||
|
||||
void *ss;
|
||||
char info2[256];
|
||||
|
||||
if (span < 0) {
|
||||
/* Display info on a span */
|
||||
ss = newtListboxGetCurrent(spans);
|
||||
if (ss) {
|
||||
span = (long)(ss);
|
||||
}
|
||||
}
|
||||
|
||||
snprintf(info2, sizeof(info2), "%-59s F10=Back", s[span].desc);
|
||||
newtCenteredWindow(60,20, s[span].desc);
|
||||
newtPushHelpLine(info2);
|
||||
|
||||
back = newtButton(48,8,"Back");
|
||||
form = newtForm(NULL, NULL, 0);
|
||||
|
||||
newtFormAddComponents(form, back, NULL);
|
||||
|
||||
span_max_chan_pos = s[span].totalchans;
|
||||
for (x=0;x<DAHDI_MAX_CHANNELS;x++) {
|
||||
struct dahdi_params zp;
|
||||
int res;
|
||||
memset(&zp, 0, sizeof(zp));
|
||||
zp.channo = x;
|
||||
res = ioctl(ctl, DAHDI_GET_PARAMS, &zp);
|
||||
if (!res && zp.spanno == span && zp.chanpos > span_max_chan_pos )
|
||||
span_max_chan_pos = zp.chanpos;
|
||||
}
|
||||
|
||||
if (span_max_chan_pos > 32)
|
||||
span_max_chan_pos = 32;
|
||||
|
||||
s1[span_max_chan_pos] = '\0';
|
||||
s2[span_max_chan_pos] = '\0';
|
||||
|
||||
bitbox = newtTextbox(8,10,span_max_chan_pos,9,0);
|
||||
newtFormAddComponent(form, bitbox);
|
||||
|
||||
label = newtLabel(8,8,s1);
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(8,9,s2);
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
newtFormAddHotKey(form, NEWT_KEY_F10);
|
||||
newtFormSetTimer(form, 200);
|
||||
|
||||
label = newtLabel(4,10,"TxA");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,11,"TxB");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,12,"TxC");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,13,"TxD");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,15,"RxA");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,16,"RxB");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,17,"RxC");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
label = newtLabel(4,18,"RxD");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
|
||||
label = newtLabel(4,7,"Total/Conf/Act: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
inuse = newtTextbox(24,7,12,1,0);
|
||||
newtFormAddComponent(form, inuse);
|
||||
|
||||
label = newtLabel(4,6,"Tx/Rx Levels: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
levels = newtTextbox(24,6,30,1,0);
|
||||
newtFormAddComponent(form, levels);
|
||||
|
||||
label = newtLabel(4,5,"Bipolar Viol: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
bpvcount = newtTextbox(24,5,30,1,0);
|
||||
newtFormAddComponent(form, bpvcount);
|
||||
|
||||
label = newtLabel(4,4,"IRQ Misses: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
irqmisses = newtTextbox(24,4,30,1,0);
|
||||
newtFormAddComponent(form, irqmisses);
|
||||
|
||||
label = newtLabel(4,3,"Sync Source: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
syncsrc = newtTextbox(24,3,30,1,0);
|
||||
newtFormAddComponent(form, syncsrc);
|
||||
|
||||
label = newtLabel(4,2,"Current Alarms: ");
|
||||
newtFormAddComponent(form, label);
|
||||
|
||||
alarms = newtTextbox(24,2,30,1,0);
|
||||
newtFormAddComponent(form, alarms);
|
||||
|
||||
for(;;) {
|
||||
/* Wait for user to select something */
|
||||
do {
|
||||
add_cards(NULL);
|
||||
show_bits(span, bitbox, inuse, levels, bpvcount, alarms, syncsrc, irqmisses);
|
||||
newtFormRun(form, &es);
|
||||
} while(es.reason == NEWT_EXIT_TIMER);
|
||||
switch(es.reason) {
|
||||
case NEWT_EXIT_COMPONENT:
|
||||
if (es.u.co == back) {
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
case NEWT_EXIT_HOTKEY:
|
||||
switch(es.u.key) {
|
||||
#if 0
|
||||
case NEWT_KEY_F1:
|
||||
show_span(-1);
|
||||
break;
|
||||
#endif
|
||||
case NEWT_KEY_F10:
|
||||
goto out;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
newtFormDestroy(form);
|
||||
newtPopWindow();
|
||||
newtPopHelpLine();
|
||||
span_max_chan_pos = 0;
|
||||
}
|
||||
|
||||
static void show_spans(void)
|
||||
{
|
||||
newtComponent form;
|
||||
newtComponent quit;
|
||||
newtComponent label;
|
||||
newtComponent sel;
|
||||
|
||||
|
||||
struct newtExitStruct es;
|
||||
|
||||
|
||||
quit = newtButton(50,14,"Quit");
|
||||
sel = newtButton(10,14,"Select");
|
||||
|
||||
spans = newtListbox(5, 2, 10, NEWT_FLAG_SCROLL);
|
||||
newtListboxSetWidth(spans, 65);
|
||||
|
||||
label = newtLabel(5,1,"Alarms Span");
|
||||
|
||||
newtCenteredWindow(72,18, "DAHDI Telephony Interfaces");
|
||||
form = newtForm(NULL, NULL, 0);
|
||||
|
||||
newtFormSetTimer(form, 200);
|
||||
|
||||
newtFormAddComponents(form, spans, sel, quit, label, NULL);
|
||||
|
||||
newtComponentAddCallback(spans, sel_callback, NULL);
|
||||
|
||||
newtFormAddHotKey(form, NEWT_KEY_F1);
|
||||
newtFormAddHotKey(form, NEWT_KEY_F10);
|
||||
|
||||
for(;;) {
|
||||
/* Wait for user to select something */
|
||||
do {
|
||||
add_cards(spans);
|
||||
newtFormRun(form, &es);
|
||||
} while(es.reason == NEWT_EXIT_TIMER);
|
||||
|
||||
switch(es.reason) {
|
||||
case NEWT_EXIT_COMPONENT:
|
||||
if (es.u.co == quit) {
|
||||
/* Quit if appropriate */
|
||||
newtFormDestroy(form);
|
||||
return;
|
||||
} else if (es.u.co == sel) {
|
||||
show_span(-1);
|
||||
}
|
||||
break;
|
||||
case NEWT_EXIT_HOTKEY:
|
||||
switch(es.u.key) {
|
||||
case NEWT_KEY_F1:
|
||||
show_span(-1);
|
||||
break;
|
||||
case NEWT_KEY_F10:
|
||||
newtFormDestroy(form);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
newtPopWindow();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
ctl = open("/dev/dahdi/ctl", O_RDWR);
|
||||
if (ctl < 0) {
|
||||
fprintf(stderr, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
newtInit();
|
||||
newtCls();
|
||||
|
||||
newtDrawRootText(0,0,"DAHDI Tool (C)2002-2008 Digium, Inc.");
|
||||
newtPushHelpLine("Welcome to the DAHDI Tool!");
|
||||
show_spans();
|
||||
cleanup();
|
||||
newtFinished();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright (C) 2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
extern const char dahdi_tools_version[];
|
|
@ -0,0 +1,73 @@
|
|||
#! /bin/sh
|
||||
|
||||
usage() {
|
||||
echo >&2 "Usage: $0 {assigned|unassigned}"
|
||||
echo >&2 "# wait until all spans known are assigned/unassigned"
|
||||
exit 1
|
||||
}
|
||||
|
||||
TIMEOUT=5 # How much time to wait for spans
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
wanted_event="$1"
|
||||
shift
|
||||
|
||||
case "$wanted_event" in
|
||||
assigned)
|
||||
;;
|
||||
unassigned)
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
devbase='/sys/bus/dahdi_devices/devices'
|
||||
|
||||
spans_of() {
|
||||
dev="$1"
|
||||
wc -l < "$dev/spantype"
|
||||
}
|
||||
|
||||
assigned_spans_of() {
|
||||
dev="$1"
|
||||
ls -d "$dev/span-"* 2>/dev/null | wc -l
|
||||
}
|
||||
|
||||
|
||||
waitfor_span_assignments() {
|
||||
wanted_state="$1"
|
||||
device_list=`ls -d "$devbase/"* 2> /dev/null`
|
||||
finished=''
|
||||
count="$TIMEOUT"
|
||||
echo -n "Waiting for spans to become $wanted_state: "
|
||||
while [ "$count" -gt 0 ]; do
|
||||
finished='yes'
|
||||
for dev in $device_list
|
||||
do
|
||||
spans=`spans_of "$dev"`
|
||||
assigned_spans=`assigned_spans_of "$dev"`
|
||||
if [ "$wanted_state" = 'assigned' -a "$assigned_spans" -ne "$spans" ]; then
|
||||
finished='no'
|
||||
elif [ "$wanted_state" = 'unassigned' -a "$assigned_spans" -ne 0 ]; then
|
||||
finished='no'
|
||||
fi
|
||||
done
|
||||
if [ "$finished" = 'yes' ]; then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
echo -n "."
|
||||
fi
|
||||
count=`expr "$count" - 1`
|
||||
done
|
||||
if [ "$finished" = 'yes' ]; then
|
||||
echo "done"
|
||||
else
|
||||
echo "timeout"
|
||||
fi
|
||||
}
|
||||
|
||||
waitfor_span_assignments "$wanted_event"
|
|
@ -0,0 +1,86 @@
|
|||
.TH "DAHDI_CFG" "8" "16 Jun 2008" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_cfg \- configures DAHDI kernel modules from /etc/dahdi/system.conf
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_cfg [\-c \fICFG_FILE\fB] [\-S\fINUM\fB [\-S\fICHANS\fB]] [\-s] [\-f] [\-t] [\-v [\-v ... ] ]
|
||||
|
||||
.B dahdi_cfg \-h
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dahdi_cfg
|
||||
configures DAHDI interface cards from a config file.
|
||||
|
||||
You generally need to run it with a valid configurations
|
||||
in order for DAHDI modules to work properly.
|
||||
|
||||
It must be run to configure every DAHDI span. Normally it is run from
|
||||
the DAHDI init script.
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B \-c \fICFG_FILE
|
||||
.RS
|
||||
Use an alternative configuration file instead of
|
||||
.I /etc/dahdi/system.conf
|
||||
|
||||
If \fICFG_FILE\fR is '\fB\-\fR', it is read from stdin.
|
||||
.RE
|
||||
|
||||
.B \-C \fICHANNELS
|
||||
.RS
|
||||
Only apply changes to channels in the specified range. Only
|
||||
applicable when \-S is in use.
|
||||
.RE
|
||||
|
||||
.B \-s
|
||||
.RS
|
||||
Only shutdown spans.
|
||||
.RE
|
||||
|
||||
.B \-S \fISPAN
|
||||
.RS
|
||||
Only apply changes to span no. \fISPAN\fR. For a digital span (with
|
||||
a 'span=' line in the configuration file) this will do. For an analog
|
||||
span you'll have to explicitly tell dahdi_cfg the range of channels,
|
||||
using \-C .
|
||||
.RE
|
||||
|
||||
.B \-f
|
||||
.RS
|
||||
Always configure every channel, even if it appears not to have changed.
|
||||
.RE
|
||||
|
||||
.B \-t
|
||||
.RS
|
||||
Test mode. Don't do anything, just report what you wanted to do.
|
||||
.RE
|
||||
|
||||
.B \-v
|
||||
.RS
|
||||
Be more verbose. Add extra v-s for extra verbosity.
|
||||
.RE
|
||||
|
||||
.B \-h
|
||||
.RS
|
||||
Display a brief help message.
|
||||
.RE
|
||||
|
||||
.SH FILES
|
||||
|
||||
.I /etc/dahdi/system.conf
|
||||
.RS
|
||||
The default location for the configuration file.
|
||||
.RE
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_tool(8), dahdi_monitor(8), asterisk(8).
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Santiago Ruano Rinc\['o]n
|
||||
<santiago@unicauca.edu.co> for
|
||||
the Debian system (but may be used by others). Permission is
|
||||
granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
|
@ -0,0 +1,52 @@
|
|||
.TH dahdi_diag 8 "2008-01-07"
|
||||
.SH NAME
|
||||
dahdi_diag \(em Dump DAHDI channel parameters
|
||||
.SH SYNOPSIS
|
||||
.B dahdi_diag
|
||||
.I channel
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dahdi_diag
|
||||
asks the kernel to dump parameters for DAHDI channel no.
|
||||
.I channel
|
||||
to the kernel logs. You will be able to see them using, e.g. dmesg(1).
|
||||
|
||||
|
||||
.SH OPTIONS
|
||||
.I channel
|
||||
.RS
|
||||
The number of the DAHDI channel whose parammeters should be dumped.
|
||||
May be any DAHDI channel (even if it is open).
|
||||
.RE
|
||||
|
||||
.SH EXAMPLE
|
||||
|
||||
# /tmp/dahdi_diag 5
|
||||
# dmesg | tail \-n 15
|
||||
Dump of DAHDI Channel 5 (XPP_BRI_TE/00/01/1,5,2):
|
||||
|
||||
flags: 501 hex, writechunk: c5190948, readchunk: c5190954
|
||||
rxgain: ccad2e80, txgain: ccad2e80, gainalloc: 0
|
||||
span: c48a900c, sig: 80 hex, sigcap: 80 hex
|
||||
inreadbuf: \-1, outreadbuf: 0, inwritebuf: 0, outwritebuf: \-1
|
||||
blocksize: 160, numbufs: 4, txbufpolicy: 0, txbufpolicy: 0
|
||||
txdisable: 0, rxdisable: 0, iomask: 0
|
||||
curzone: c78e7000, tonezone: 0, curtone: 00000000, tonep: 0
|
||||
digitmode: 0, txdialbuf: , dialing: 0, aftdialtimer: 0, cadpos. 0
|
||||
confna: 0, confn: 0, confmode: 0, confmute: 0
|
||||
ec: 00000000, echocancel: 0, deflaw: 0, xlaw: ccab5e80
|
||||
echostate: 00, echotimer: 0, echolastupdate: 0
|
||||
itimer: 0, otimer: 0, ringdebtimer: 0
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_cfg(8), asterisk(8), dmesg(1).
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,62 @@
|
|||
.TH "DAHDI_MAINT" "8" "9 Sep 2011" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_maint \- Sets Dahdi spans into maintenance mode, e.g.: loopback
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_maint \-s \fInum\fB [options]
|
||||
.B dahdi_maint <\-h|\-\-help>
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
dahdi_maint uses the DAHDI_MAINT interface to set a Dahdi span (port
|
||||
of a Dahdi adapter card) into loopback mode or similar maintenance mode.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-s \-\-span \fInum\fR
|
||||
.RS
|
||||
The span number. Required.
|
||||
.RE
|
||||
|
||||
.B \-l \-\-loopback <localhost|networkline|networkpayload|loopup|loopdown|off>
|
||||
.RS
|
||||
Loopback type. One of:
|
||||
.IP localhost 4
|
||||
loop back towards host
|
||||
.IP networkline 4
|
||||
network line loopback
|
||||
.IP networkpayload 4
|
||||
network payload loopback
|
||||
.IP loopup 4
|
||||
transmit loopup signal
|
||||
.IP loopdown 4
|
||||
transmit loopdown signal
|
||||
.IP off 4
|
||||
end loopback mode
|
||||
.RE
|
||||
|
||||
.B \-i \-\-insert <fas|multi|crc|cas|prbs|bipolar>
|
||||
.RS
|
||||
Insert an error of a specific type
|
||||
.RE
|
||||
|
||||
.SH EXAMPLES
|
||||
Enable network line loopback on span 1:
|
||||
|
||||
dahdi_maint \-s 1 \-\-loopback networkline
|
||||
|
||||
Disable network line loopback on span 1:
|
||||
|
||||
dahdi_maint \-s 1 \-\-loopback off
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
dahdi_tool(8), dahdi_cfg(8), asterisk(8).
|
||||
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU General Public License, Version 2 any later
|
||||
version published by the Free Software Foundation.
|
|
@ -0,0 +1,145 @@
|
|||
.TH "DAHDI_MONITOR" "8" "9 Sep 2011" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_monitor \- checks the Rx/Tx levels of a DAHDI channels
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_monitor \fInum\fB [\-v[v]]
|
||||
.B dahdi_monitor \fInum\fB [\-o] [<\-f|\-F> \fIFILE\fB]
|
||||
.B dahdi_monitor \fInum\fB [[<\-r|\-R> \fIFILE\fB]] [[<\-t|\-T> \fIFILE\fB]]
|
||||
|
||||
.SH DESCRIPTION
|
||||
|
||||
dahdi_monitor monitors a Dahdi channel. It can record the output to a
|
||||
file, play it to the speaker, or visualize the audio levels on the
|
||||
terminal.
|
||||
|
||||
Recorded audio files are by default raw signed linear PCM. If the file
|
||||
name ends with ".wav", the recorded file will be a WAV file.
|
||||
|
||||
The visual display shows the current audio level at both the Rx
|
||||
(audio Received by Asterisk) and
|
||||
Tx (audio Transmitted by Asterisk)
|
||||
|
||||
To exit the program, press Ctrl-C.
|
||||
|
||||
.SH OPTIONS
|
||||
The first (mandatory) parameter is the number of the channel
|
||||
to monitor.
|
||||
|
||||
.B \-m
|
||||
.RS
|
||||
Multiple channels. Don't multiplex both Rx and Tx in a single channel.
|
||||
Normally there's a different option that you need that implies it.
|
||||
.RE
|
||||
|
||||
.B \-o
|
||||
.RS
|
||||
Plays the output to OSS (/dev/dsp). Requires \-m not to be used.
|
||||
.RE
|
||||
|
||||
.B \-v
|
||||
.RS
|
||||
Display Visual audio levels. With two v-s, Verbose mode is enabled, that
|
||||
shows the actual levels as numbers. Note that this requires a terminal
|
||||
wider than 80 columns to be properly displayed.
|
||||
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-f \fIFILE
|
||||
.RS
|
||||
Record the content of the channel (Tx + Rx) to a file.
|
||||
.RE
|
||||
|
||||
.B \-F \fIFILE
|
||||
.RS
|
||||
Record the content of the channel (Tx + Rx) before the echo canceler
|
||||
to a file.
|
||||
.RE
|
||||
|
||||
.B \-r \fIFILE
|
||||
.RS
|
||||
Record the content of the Rx channel to a file.
|
||||
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-R \fIFILE
|
||||
.RS
|
||||
Record the content of the R channel before the echo canceler to a file.
|
||||
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-s \fIFILE
|
||||
.RS
|
||||
Record the content of the Tx and Rx of the channel to a file.
|
||||
.RE
|
||||
|
||||
.B \-S \fIFILE
|
||||
.RS
|
||||
Records a stereo of both Tx and Rx of the channel before the echo
|
||||
canceler to a file.
|
||||
.RE
|
||||
|
||||
.B \-t \fIFILE
|
||||
.RS
|
||||
Record the content of the Tx channel to a file.
|
||||
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.B \-T \fIFILE
|
||||
.RS
|
||||
Record the content of the Tx channel before the echo canceler to a file.
|
||||
|
||||
Implies \-m.
|
||||
.RE
|
||||
|
||||
.SH EXAMPLES
|
||||
|
||||
Visualize audio levels on DAHDI channel 2:
|
||||
|
||||
dahdi_monitor 2 \-v
|
||||
|
||||
|
||||
Record channel 3 to a file:
|
||||
|
||||
dahdi_monitor 3 \-f output.raw
|
||||
|
||||
This will create a raw PCM file (signed-linear, 8kHz, mono, 16 bits per
|
||||
sample). Both the Tx and Rx will be multiplexed in a single channel.
|
||||
It can be converted to a WAV file using e.g.:
|
||||
|
||||
sox \-s \-c1 \-2 \-r8000 output.raw output.wav
|
||||
|
||||
|
||||
Record Tx and Rx of channel 5 to separate files. This time directly to
|
||||
WAV files:
|
||||
|
||||
dahdi_monitor 5 \-r output_rx.wav \-t output_tx.wav
|
||||
|
||||
|
||||
Record channel 8 to a stereo file (Tx and Rx on its two channels):
|
||||
|
||||
dahdi_monitor 8 \-s output.raw
|
||||
|
||||
Converting it to a WAV file:
|
||||
|
||||
sox \-s \-c2 \-2 \-r8000 output.raw output.wav
|
||||
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
.PP
|
||||
dahdi_tool(8), dahdi_cfg(8).
|
||||
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
This manual page was written by Santiago Ruano Rinc\['o]n
|
||||
<santiago@unicauca.edu.co> for
|
||||
the Debian system (but may be used by others). Permission is
|
||||
granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
|
@ -0,0 +1,101 @@
|
|||
.TH dahdi_scan 8 "2008-03-18"
|
||||
.SH NAME
|
||||
dahdi_scan \(em Print Configuration of DAHDI Spans
|
||||
.SH SYNOPSIS
|
||||
.B dahdi_scan
|
||||
.I [spans]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dahdi_scan
|
||||
prints information about DAHDI spans in the system. For analog spans it
|
||||
also provides a list of channels.
|
||||
|
||||
By default it prints information about all the spans in the system.
|
||||
However if parameters are provided, they will be considered to be a list
|
||||
of span numbers and information will be printed for them.
|
||||
|
||||
Output is printed to the standard output. The format is that of an
|
||||
Asterisk configuration file (similar to a "ini" configuration file),
|
||||
where the name of the section is the number of the span. Note that the
|
||||
specifically for analog spans some keys may appear more than once, and
|
||||
hence you can not use a parser for an "ini" format and assume you have a
|
||||
dictionary.
|
||||
|
||||
.SH EXAMPLES
|
||||
Printing information for spans 1, 2 and 4:
|
||||
|
||||
dahdi_scan 1 2 4
|
||||
|
||||
And to print all the spans:
|
||||
|
||||
dahdi_scan
|
||||
|
||||
Information about a certain analog span:
|
||||
|
||||
[5]
|
||||
active=yes
|
||||
alarms=OK
|
||||
description=Xorcom XPD #00/10: FXS
|
||||
name=XBUS\-00/XPD\-10
|
||||
manufacturer=Xorcom Inc.
|
||||
devicetype=Astribank: Unit 1 Subunit 0: FXS
|
||||
location=usb\-0000:00:03.3\-4
|
||||
basechan=125
|
||||
totchans=8
|
||||
irq=0
|
||||
type=analog
|
||||
port=125,FXS
|
||||
port=126,FXS
|
||||
port=127,FXS
|
||||
port=128,FXS
|
||||
port=129,FXS
|
||||
port=130,FXS
|
||||
port=131,FXS
|
||||
port=132,FXS
|
||||
|
||||
And an example of a digital span:
|
||||
|
||||
[1]
|
||||
active=yes
|
||||
alarms=RED
|
||||
description=T2XXP (PCI) Card 0 Span 1
|
||||
name=TE2/0/1
|
||||
manufacturer=Digium
|
||||
devicetype=Wildcard TE205P (4th Gen)
|
||||
location=Board ID Switch 0
|
||||
basechan=1
|
||||
totchans=24
|
||||
irq=193
|
||||
type=digital\-T1
|
||||
syncsrc=0
|
||||
lbo=0 db (CSU)/0\-133 feet (DSX\-1)
|
||||
coding_opts=B8ZS,AMI
|
||||
framing_opts=ESF,D4
|
||||
coding=B8ZS
|
||||
framing=ESF
|
||||
|
||||
The "type" field may contain: "analog", "digital\-T1", "digital\-E1",
|
||||
"digital\-J1" or "digital\-BRI".
|
||||
|
||||
.SH FILES
|
||||
Requires read access to /dev/dahdi/ctl .
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_cfg(8), asterisk(8).
|
||||
|
||||
.SH BUGS
|
||||
The program still does not do everything described in the man page.
|
||||
|
||||
It also assumes that spans don't skip channel numbers, and that their
|
||||
channel numbers are "running". This is anyway almost always the case.
|
||||
And always the case in a normal boot process.
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,251 @@
|
|||
.TH "DAHDI_SPAN_ASSIGNMENTS" "8" "23 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_span_assignments \- handle DAHDI spans assignments
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-n|\-\-dry\-run] <add|remove|auto> \fB[\fIdevpath\fB...]
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] list \fB[\fIdevpath\fB...]
|
||||
|
||||
.B dahdi_span_assignments [\-v|\-\-verbose] [\-k|\-\-key \fIkey\fB] dumpconfig
|
||||
|
||||
.B dahdi_span_assignments \-h|\-\-help
|
||||
|
||||
.SH DESCRIPTION
|
||||
Channels in DAHDI devices (such as DAHDI PCI cards) are groups to logical
|
||||
units called "spans" (for example: a port in a digital card is a span).
|
||||
When the kernel module parameter \fBdahdi.auto_assign_span\fR is unset,
|
||||
DAHDI devices that register with DAHDI don't cause their spans to be
|
||||
automatically assigned.
|
||||
|
||||
This allows user-space to order DAHDI to assign them to specific span
|
||||
and channel numbers. That way, specific spans on specific DAHDI devices
|
||||
may be assigned with specific span and channel numbers \fBregardless\fR
|
||||
of the registration order of the hardware (or if all hardware is present
|
||||
at all).
|
||||
|
||||
.B dahdi_span_assignments
|
||||
is used to assign those spans or to help creating the configuration
|
||||
file used in their assignment:
|
||||
.B /etc/dahdi/assigned\-spans.conf .
|
||||
|
||||
.SH SUB-COMMANDS
|
||||
|
||||
There are several sub-commands.
|
||||
|
||||
All sub-commands take an optional list of paths to SysFS nodes of
|
||||
devices. If given, the command will only operate on those DAHDI
|
||||
devices. The default is to operate on all devices (which would normally
|
||||
be the sane case when running from the command-line).
|
||||
|
||||
.B add \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with unassigned
|
||||
spans.
|
||||
|
||||
The command will assign spans with DAHDI according to
|
||||
configuration in \fBassigned\-spans.conf\fR.
|
||||
|
||||
If no line matches the span, or if the assignment for it fails (it is
|
||||
not available) it will remain unassigned.
|
||||
|
||||
If any of the span settings fails (the span number or range of channels
|
||||
is already in use), the program will print a message, but continue
|
||||
applying the others. In such a case you should fix assigned\-spans.conf
|
||||
and re-run \fBadd\fR (or run \fBauto\fR to give those channels the
|
||||
first available range and regenerate the file with 'dahdi_genconf
|
||||
assignedspans').
|
||||
.RE
|
||||
|
||||
.B remove \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with assigned
|
||||
spans.
|
||||
|
||||
The command will un-assign them.
|
||||
.RE
|
||||
|
||||
.B auto \fB[\fIdevpath \fB...]
|
||||
.RS
|
||||
Applies to all devices or to those listed on the command line.
|
||||
Parameters are paths (in SysFS) to DAHDI devices with unassigned
|
||||
spans.
|
||||
|
||||
Each span is assigned to first available span number and channel
|
||||
numbers, as if \fBdahdi.auto_assign_span\fR was set. The configuration
|
||||
file doesn't affect these assignments.
|
||||
.RE
|
||||
|
||||
.B list
|
||||
.RS
|
||||
List all spans in the system.
|
||||
.RE
|
||||
|
||||
.B dumpconfig
|
||||
.RS
|
||||
List all assigned spans in the system in a format fit to be used in
|
||||
\fBassigned\-spans.conf\fR. Use this to generate a configuration file after
|
||||
you have (automatically or manually) assigned all existing spans.
|
||||
|
||||
.B dahdi_genconf assignedspans
|
||||
uses this command internally.
|
||||
.RE
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B \-v \-\-verbose
|
||||
.RS
|
||||
Verbose output.
|
||||
.RE
|
||||
|
||||
.B \-n \-\-dry\-run
|
||||
.RS
|
||||
Don't assign / un-assign spans. Only print commands used to do so.
|
||||
.RE
|
||||
|
||||
.B \-k \fIkey
|
||||
.RS
|
||||
For \fBdumpconfig\fR \- The key by which to identify the hardware in the
|
||||
generated configuration. Legal values:
|
||||
|
||||
.B hwid
|
||||
.RS
|
||||
Hardware identifier (e.g.: software-readable serial number). This is the
|
||||
default. If the device has no hwid, devpath is used.
|
||||
.RE
|
||||
|
||||
.B location
|
||||
.RS
|
||||
The location field (file) in the SysFS device node (directory) for the
|
||||
DAHDI device. If not available (typically: DAHDI version <= 2.7.x),
|
||||
devpath is used.
|
||||
.RE
|
||||
|
||||
.B devpath
|
||||
.RS
|
||||
Path in SysFS to the device node.
|
||||
.RE
|
||||
.RE
|
||||
|
||||
.SH CONFIGURATION
|
||||
.B /etc/dahdi/assigned\-spans.conf
|
||||
is a file with lines specifying assignment of spans.
|
||||
|
||||
Empty lines or lines beginning with '#' are ignored.
|
||||
|
||||
Each line is in the format of:
|
||||
|
||||
.I ID spanspec ...
|
||||
|
||||
The \fIID\fR field specifies the DAHDI device and the \fIspanspecs\fR
|
||||
define how to assign its spans. A line may have multiple
|
||||
\fIspanspecs\fR in a single line (though dumpconfig generates a
|
||||
configuration with one per line).
|
||||
|
||||
.SS Span Identifier
|
||||
A DAHDI device may be specified either by a hardware identifier (a
|
||||
software readable serial number or whatever) or the location in which
|
||||
it is installed on the system. The former makes it simpler to change
|
||||
connector / slot whereas the latter makes it simpler to replace a unit.
|
||||
|
||||
The value in this field is matched (when the commands \fBadd\fR and
|
||||
\fBremove\fR) are used) to the following values:
|
||||
|
||||
\fIhwid\fR
|
||||
\fB@\fIlocation\fR
|
||||
\fIdevpath\fR
|
||||
|
||||
See above for their descriptions. The value may include shell wildcards:
|
||||
*, ? and [], which are used in the match. The values to be matched are
|
||||
first cleaned up: '!' is replaced with '/' and any character beyond
|
||||
"a\-zA\-Z0\-9/:.\-" is removed.
|
||||
|
||||
.SS Span Specification
|
||||
|
||||
Each line should have one or more span specifications: this is the value
|
||||
used to assign a span with DAHDI in the SysFS interface. A
|
||||
specification has three colon-separated numbers:
|
||||
|
||||
.I rel_span_no:span_no:first_chan
|
||||
|
||||
for instance, the following are four span specifications for a quad-E1
|
||||
device: 1:6:53 2:7:84 3:8:115 4:9:146 occupying spans 6-9 and channels
|
||||
53-176.
|
||||
|
||||
.B rel_span_no
|
||||
.RS
|
||||
The relative number of the span in the device. E.g.: port number.
|
||||
.RE
|
||||
|
||||
.B span_no
|
||||
.RS
|
||||
The desired DAHDI span number. Must be available.
|
||||
.RE
|
||||
|
||||
.B first_chan
|
||||
.RS
|
||||
The desired DAHDI channel number for the first DAHDI channel in the span.
|
||||
All channels of the span will be assigned following it and hence that
|
||||
space must be available.
|
||||
.RE
|
||||
|
||||
|
||||
.SH ENVIRONMENT
|
||||
|
||||
.B DAHDICONFDIR
|
||||
.RS
|
||||
The directory in which assigned\-spans.conf resides. /etc/dahdi if not
|
||||
overridden from the environment.
|
||||
.RE
|
||||
|
||||
.B DAHDISASSIGNEDSPANSCONF
|
||||
.RS
|
||||
The path to assigned-spans.conf resides. /etc/dahdi/assigned\-spans.conf if
|
||||
not overridden from the environment.
|
||||
.RE
|
||||
|
||||
.B SPAN_ASSIGNMENTS_KEY
|
||||
.RS
|
||||
The default value for \-k . Defaults to "hwid" if not overridden from the
|
||||
environment.
|
||||
.RE
|
||||
|
||||
|
||||
.SH FILES
|
||||
|
||||
.B /etc/dahdi/assigned\-spans.conf
|
||||
.RS
|
||||
The default location for the configuration file.
|
||||
.RE
|
||||
|
||||
.B /sys/bus/dahdi_devices/devices/\fIdevice\fR
|
||||
.RS
|
||||
SysFS node for the device. In this directory reside the following
|
||||
files, among others:
|
||||
|
||||
.B location
|
||||
.RS
|
||||
The value of the device's location field.
|
||||
.RE
|
||||
|
||||
.B assign_span, unassign_span, auto_assign
|
||||
.RS
|
||||
Write only files for the operations. Used by \fBadd\fR, \fBremove\fR and
|
||||
\fBauto\fR, respectively.
|
||||
.RE
|
||||
|
||||
.RE
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_span_types(8), dahdi_genconf(8), dahdi_cfg(8)
|
||||
|
||||
.SH AUTHOR
|
||||
dahdi_span_assignments was written by Oron Peled. This manual page was
|
||||
written by Tzafrir Cohen. Permission is granted to copy, distribute
|
||||
and/or modify this document under the terms of the GNU General Public
|
||||
License, Version 2 any later version published by the Free Software
|
||||
Foundation.
|
||||
|
|
@ -0,0 +1,197 @@
|
|||
.TH "DAHDI_SPAN_TYPES" "8" "23 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_span_types \- set line modes of DAHDI spans before assignment
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_types [\fIoptions\fB] <list|dumpconfig|set> \fB[\fIdevpath \fB...]
|
||||
|
||||
.SH DESCRIPTION
|
||||
The span type (the line mode: E1/T1/J1) must be set to a span before
|
||||
DAHDI assigns it a span number, as E1 spans use more channels.
|
||||
\fBdahdi_span_types\fR applies the span type configuration to an
|
||||
un-assigned span.
|
||||
|
||||
Using it only makes sense when the kernel module parameter
|
||||
\fBdahdi.auto_assign_span\fR is unset, otherwise DAHDI automatically
|
||||
assign span numbers during device registration.
|
||||
|
||||
.B dahdi_span_types
|
||||
takes a command and an optional list of devices. If no device is given,
|
||||
the command is applied to all devices.
|
||||
|
||||
The device is marked as a path in the SysFS tree.
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.B \-h|\-\-help
|
||||
.RS
|
||||
Output usage message and exit
|
||||
.RE
|
||||
|
||||
.B \-n|\-\-dry\-run
|
||||
.RS
|
||||
During \fB"set"\fR operation, only show what would be done, without actually
|
||||
changing anything.
|
||||
.RE
|
||||
|
||||
.B \-v|\-\-verbose
|
||||
.RS
|
||||
During \fB"set"\fR operation, show the actions that are being performed.
|
||||
.RE
|
||||
|
||||
.BI \-\-line\-mode= <E1|T1|J1>
|
||||
.RS
|
||||
During \fB"dumpconfig"\fR operation, force special generation mode:
|
||||
.IP \(bu 3
|
||||
First, generates a "wildcard" entry with the fiven \fBline\-mode\fR.
|
||||
.IP \(bu 3
|
||||
Comment out all span entries. Each of them may be manually un-commented
|
||||
to override the "wildcard".
|
||||
.RE
|
||||
|
||||
.SH SUB-COMMANDS
|
||||
.B set
|
||||
.RS
|
||||
Reads settings from \fBspan\-types.conf\fR and applies them to the
|
||||
device(s) specified in the command line (or all devices, if none
|
||||
specified).
|
||||
.RE
|
||||
|
||||
.B list
|
||||
.RS
|
||||
List line modes for all spans in the system which may be set with
|
||||
dahdi_span_types (E1/T1/J1 spans).
|
||||
.RE
|
||||
|
||||
.B dumpconfig
|
||||
.RS
|
||||
List types for the spans in a format fit to be used in
|
||||
\fBspan\-types.conf\fR. Use this to generate a configuration file after
|
||||
you have (perhaps manually) set all existing spans.
|
||||
|
||||
.B dahdi_genconf spantypes
|
||||
uses this command internally.
|
||||
.RE
|
||||
|
||||
.SH CONFIGURATION
|
||||
.SS General structure
|
||||
.B span\-types.conf
|
||||
is a file with lines specifying line modes of spans.
|
||||
|
||||
Empty lines or lines beginning with '#' are ignored.
|
||||
|
||||
Each line is in the format of:
|
||||
|
||||
.I ID spanspec ...
|
||||
|
||||
The \fIID\fR field specifies the DAHDI device and the \fIspanspecs\fR
|
||||
define the line modes of its spans. A line may have multiple
|
||||
\fIspanspecs\fR in a single line (though dumpconfig generates a
|
||||
configuration with one per line).
|
||||
|
||||
.SS Span Identifier
|
||||
A DAHDI device may be specified either by a hardware identifier (a
|
||||
software readable serial number or whatever) or the location in which
|
||||
it is installed on the system. The former makes it simpler to change
|
||||
connector / slot whereas the latter makes it simpler to replace a unit.
|
||||
|
||||
The value in this field is matched (when the command \fBset\fR is
|
||||
used) to the following values:
|
||||
|
||||
\fIhwid\fR
|
||||
\fB@\fIlocation\fR
|
||||
\fIdevpath\fR
|
||||
|
||||
See above for their descriptions. The value may include shell wildcards:
|
||||
*, ? and [], which are used in the match. The values to be matched are
|
||||
first cleaned up: '!' is replaced with '/' and any character not in
|
||||
"a\-zA\-Z0\-9/:.\-" is replaced by "_".
|
||||
|
||||
Note that while span\-types.conf allows an arbitrarily-complex
|
||||
combination of E1, J1 and T1 ports, it would normally have just a single
|
||||
wildcard line setting the line mode (the first line in the example below).
|
||||
|
||||
.SS Span Specification
|
||||
|
||||
Each line should have one or more span specifications: this is the value
|
||||
used to set span type with DAHDI in the SysFS interface. A
|
||||
specification has two colon-separated fields:
|
||||
|
||||
.I rel_span_no:span_type
|
||||
|
||||
for instance, the following are four span specifications specify ports 1
|
||||
and 2 as E1 and ports 3 and 4 as T1: [12]:E1 [34]:T1 .
|
||||
|
||||
.B rel_span_no
|
||||
.RS
|
||||
The relative number of the span in the device. E.g.: port number.
|
||||
This field may contain shell wildcards (*, ? and [])
|
||||
.RE
|
||||
|
||||
.B span_type
|
||||
.RS
|
||||
E1/T1/J1
|
||||
.RE
|
||||
|
||||
.SS Multiple matches
|
||||
During \fBset\fR operation, the \fBdahdi_span_types\fR applies all
|
||||
matching settings to a span. This is done in the order of lines in the
|
||||
configuration files.
|
||||
|
||||
Thus, if there are multiple matches to a span -- the last match
|
||||
will \fIwin\fR (all will be applied to the kernel in order. The last
|
||||
one in the file will be applied last).
|
||||
|
||||
Example:
|
||||
.EX
|
||||
* *:T1 # All spans on all devices will be T1
|
||||
usb:X1234567 [34]:E1 # Except spans 3,4 on the device which will be E1
|
||||
.EE
|
||||
|
||||
|
||||
.SH ENVIRONMENT
|
||||
|
||||
.B DAHDICONFDIR
|
||||
.RS
|
||||
The directory in which span\-types.conf resides. /etc/dahdi if not
|
||||
overridden from the environment.
|
||||
.RE
|
||||
|
||||
.B DAHDISPANTYPESCONF
|
||||
.RS
|
||||
The path to span\-types.conf resides. /etc/dahdi/span\-types.conf if
|
||||
not overridden from the environment.
|
||||
.RE
|
||||
|
||||
|
||||
.SH FILES
|
||||
|
||||
.B /etc/dahdi/span\-types.conf
|
||||
.RS
|
||||
The default location for the configuration file.
|
||||
.RE
|
||||
|
||||
.B /sys/bus/dahdi_devices/devices/\fIdevice\fR
|
||||
.RS
|
||||
SysFS node for the device. In this directory reside the following
|
||||
files, among others:
|
||||
|
||||
.B spantype
|
||||
.RS
|
||||
read/write file. Reading from it returns current configuration for spans
|
||||
of the device. Span-specifications can be written to it to change line
|
||||
modes (but only for a span that is not assigned yet).
|
||||
.RE
|
||||
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_span_assignments(8), dahdi_genconf(8), dahdi_cfg(8)
|
||||
|
||||
.SH AUTHOR
|
||||
dahdi_span_types was written by Oron Peled. This manual page was
|
||||
written by Tzafrir Cohen. Permission is granted to copy, distribute
|
||||
and/or modify this document under the terms of the GNU General Public
|
||||
License, Version 2 any later version published by the Free Software
|
||||
Foundation.
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
.TH dahdi_test 8 "2005-06-25"
|
||||
.SH "NAME"
|
||||
dahdi_test \(em Test if the DAHDI timer provides timely response
|
||||
.SH "SYNOPSIS"
|
||||
.B dahdi_test
|
||||
.I [ \-v ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B dahdi_test
|
||||
dahdi_test runs a timing test in a loop and prints the result of each loop.
|
||||
The test is as follows:
|
||||
|
||||
It reads 8192 bytes from the DAHDI timer device (\fI/dev/dahdi/pseudo\fR).
|
||||
This should take exactly 8000 ms . It uses calls to
|
||||
.I gettimeofday(2)
|
||||
before and after that read to check that indeed exactly 8000ms have passed.
|
||||
|
||||
Values of 100% and 99.99% Are normally considered a definite
|
||||
.I pass.
|
||||
Values of 99.98% and 99.97% are probably OK as well.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-v
|
||||
.RS
|
||||
Be more verbose: print one line per test.
|
||||
.RE
|
||||
|
||||
.B \-c
|
||||
.I count
|
||||
.RS
|
||||
Run for
|
||||
.I count
|
||||
times instead of running forever.
|
||||
.RE
|
||||
|
||||
.SH FILES
|
||||
.B /dev/dahdi/pseudo
|
||||
.RS
|
||||
.RE
|
||||
The device file used to access the DAHDI timer.
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_tool(8), dahdi_cfg(8), asterisk(8). gettimeofday(2)
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
|
@ -0,0 +1,25 @@
|
|||
.TH "DAHDI_TOOL" "8" "16 June 2008" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_tool \- Shows status of DAHDI interfaces
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_tool
|
||||
|
||||
.SH DESCRIPTION
|
||||
dahdi_tool shows the current status the DAHDI inteface cards plugged
|
||||
to the computer.
|
||||
|
||||
It displays values like Current Alarms, SyncSource, Tx/Rx
|
||||
Levels for each DAHDI interface.
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_monitor(8), asterisk (8).
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Santiago Ruano Rinc\['o]n
|
||||
<santiago@unicauca.edu.co> for
|
||||
the Debian system (but may be used by others). Permission is
|
||||
granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
|
@ -0,0 +1,49 @@
|
|||
.TH "DAHDI_WAITFOR_SPAN_ASSIGNMENTS" "8" "22 Jan 2014" "" ""
|
||||
|
||||
.SH NAME
|
||||
dahdi_waitfor_span_assignments \- wait for DAHDI spans to get (un)assigned
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B dahdi_span_assignments assigned
|
||||
|
||||
.B dahdi_span_assignments unassigned
|
||||
|
||||
.SH DESCRIPTION
|
||||
DAHDI spans get assigned / unassigned asynchronously.
|
||||
|
||||
.B dahdi_span_assignments
|
||||
is a helper script that allows running commands after all the spans have
|
||||
been assigned or unassigned.
|
||||
|
||||
It takes a single command: \fBassigned\fR or \fBunassigned\fR and waits
|
||||
(up until a timeout of 5 seconds) for all the DAHDI spans in the system
|
||||
to do so.
|
||||
|
||||
Note that if the system has a span that will not get assigned
|
||||
automatically (e.g.: it's not in assigned\-spans.conf), this program
|
||||
does not know and will wait until a timeout.
|
||||
|
||||
.SH EXAMPLES
|
||||
|
||||
modprobe wctdm24xxp
|
||||
dahdi_waitfor_span_assignments assigned
|
||||
do_something
|
||||
|
||||
dahdi_span_assignments add
|
||||
dahdi_waitfor_span_assignments assigned
|
||||
do_something_else
|
||||
|
||||
dahdi_span_assignments remove
|
||||
dahdi_span_assignments unassigned
|
||||
do_something_completely_different
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_span_assignments(8)
|
||||
|
||||
.SH AUTHOR
|
||||
dahdi_waitfor_span_assignments was written by Oron Peled. This manual
|
||||
page was written by Tzafrir Cohen. Permission is granted to copy,
|
||||
distribute and/or modify this document under the terms of the GNU
|
||||
General Public License, Version 2 any later version published by the
|
||||
Free Software Foundation.
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
.TH FXOTUNE "8" "9 June 2007" "asterisk" "System Manager's Manuals: Asterisk"
|
||||
.SH NAME
|
||||
fxotune \- automatically tune DAHDI FXO channels
|
||||
.SH SYNOPSIS
|
||||
.B fxotune \-i
|
||||
.I [options]
|
||||
\- detect mode
|
||||
|
||||
.B fxotune \-d
|
||||
.I [ options ]
|
||||
\- dump mode
|
||||
|
||||
.B fxotune \-s
|
||||
.I [ options ]
|
||||
\- Startup mode
|
||||
.SH
|
||||
.SH DESCRIPTION
|
||||
.B fxotune
|
||||
is a script that fine-tune parameters of the FXO modules of the
|
||||
card. It has three modes of operation:
|
||||
|
||||
.I Detect mode (\-i):
|
||||
it detects and tunes all the available FXO channels.
|
||||
It writes settings to a configuration file (/etc/fxotune.conf)
|
||||
from which it can be loaded (e.g: at startup) using \-s .
|
||||
|
||||
.I Dump mode (\-d):
|
||||
Runs detection on a single DAHDI channel, and just dumps waveforms to
|
||||
.B fxotune_dump.vals
|
||||
is generated in the current directory.
|
||||
|
||||
.I Startup mode (\-s):
|
||||
fxotune just reads the settings from fxotune.conf into the FXO modules.
|
||||
|
||||
You are advised to run fxotune on all FXO ports you have that support
|
||||
it and that are connected. Note that the tunning is affected by e.g.
|
||||
the physical parameters of the connection, and thus if it has been
|
||||
radically changed, you may need to re-run fxotune.
|
||||
|
||||
This program only works for the Digium TDM400P/800P/2400P cards and
|
||||
compatible and the Xorcom Astribank devices. Other cards (notably X100P
|
||||
cards and clones) do not have the hardware to support such tuning.
|
||||
|
||||
The tuning process needs a clear line to do the tuning. In order to do
|
||||
that, it runs in cycles of the following: sets the line off-hook, dials
|
||||
a dial string (which should set the PSTN provider waiting for the next
|
||||
digit), and then starts tuning. It has a limited ammount of time for
|
||||
tuning before the PSTN gives up and gives a busy tone. So after a while
|
||||
it hangs up and starts a new cycle.
|
||||
|
||||
.B fxotune
|
||||
has two operation modes: tune (\-i) and set (\-s). In the tune mode it
|
||||
generates /etc/fxotune.conf, and in the set mode it merely applies the
|
||||
parameters from fxotune.conf to device's ports.
|
||||
|
||||
.SH OPTIONS
|
||||
The following options below except \-v (verbose) affect only the
|
||||
detection process and hence apply only to the
|
||||
.I detect
|
||||
and
|
||||
.I dump
|
||||
modes.
|
||||
|
||||
In addition, to maintain compatibility with older versions of fxotune,
|
||||
if in detect or dump mode there is a parameter with option before it, it
|
||||
is considered to be the
|
||||
.I dialstring
|
||||
parameter (\-n).
|
||||
|
||||
.B \-b
|
||||
.I startdev
|
||||
.RS
|
||||
Start tuning from dahdi channel num. \fI startdev\fR: skip all previous
|
||||
channels. By default starting from channel 1.
|
||||
|
||||
In dump mode (\-d) this is the single channel that will be tested.
|
||||
.RE
|
||||
|
||||
.B \-e
|
||||
.I stopdev
|
||||
.RS
|
||||
Tune only up to dahdi channel num. \fI stopdev\fR: skip all previous
|
||||
channels. By default stopping at channel 252.
|
||||
|
||||
In dump mode (\-d) this parameter is ignored.
|
||||
.RE
|
||||
|
||||
.B \-l
|
||||
.I delay-to-silence
|
||||
.RS
|
||||
Time in seconds to wait after dialing the dial-string to get a clear line.
|
||||
The default is 0.
|
||||
before
|
||||
.RE
|
||||
|
||||
.B \-m
|
||||
.I silence-good-for
|
||||
.RS
|
||||
Time in seconds which states how long the PSTN will wait after we dialed
|
||||
the dial-string until it starts giving a busy tone. You can test this by
|
||||
connecting an analog phone to the line and dialing.
|
||||
|
||||
The default is 18 (18 seconds).
|
||||
.RE
|
||||
|
||||
.B \-n
|
||||
.I dial-string
|
||||
.RS
|
||||
Digits to dial to the PSTN in order to get it stop its dialtone and
|
||||
waiting for the next digit.
|
||||
|
||||
The default is "4" (sending just the digit 4). It should work in most
|
||||
cases. Again, this can be tested by connecting a phone to the PSTN line
|
||||
and dialing the dial-string.
|
||||
.RE
|
||||
|
||||
.B \-t
|
||||
.I detect-type
|
||||
.RS
|
||||
This option allows using the older detection method used by fxotune of
|
||||
Zaptel 1.2. use
|
||||
.B \-t 1
|
||||
for that older method. whereas
|
||||
.B \-t 2
|
||||
(the default) uses the current method.
|
||||
|
||||
This option only applies to detect mode (\-i).
|
||||
.RE
|
||||
|
||||
.B \-v[vvvv]
|
||||
.RS
|
||||
Sets debugging on. The more v-s, the higher debug level.
|
||||
|
||||
Note that: \-vv \-v will actually set debug level to 1 instead of 3.
|
||||
.RE
|
||||
|
||||
.B \-w
|
||||
.I wave-form
|
||||
.RS
|
||||
The default: \-1, for multitone waveform. Alternatively: a frequency of a
|
||||
single tone.
|
||||
|
||||
This option only applies to dump mode (\-d).
|
||||
.RE
|
||||
|
||||
|
||||
.SH EXAMPLES
|
||||
.RS
|
||||
fxotune \-i 9
|
||||
.RE
|
||||
if you need to dial 9 for an external line. If you always get a line, you
|
||||
can simply use any digit.
|
||||
.RE
|
||||
|
||||
.B \-s
|
||||
.RS
|
||||
Load settings from the last test. Used at startup.
|
||||
.RE
|
||||
|
||||
.SH FILES
|
||||
.I /etc/fxotune.conf
|
||||
.RS
|
||||
The configuration file generated by fxotune in detect mode and from which
|
||||
configuration is loaded when
|
||||
.B \-s
|
||||
is used.
|
||||
|
||||
.SH NOTES
|
||||
Running fxotune takes approximately a minute per port. If you wish to only
|
||||
run fxotune for several ports, you can use the options \-b and \-e to set a
|
||||
specific range of ports. Another useful trick is to actually keep asterisk
|
||||
running, and only "destroy" the dahdi channels you wish to tune (dahdi
|
||||
destroy channel NNN): other channels will be used by Asterisk, and hence
|
||||
skipped. This can be useful if you have many FXO ports that are not connected.
|
||||
|
||||
.B fxotune
|
||||
writes immediately to
|
||||
.B /etc/fxotune.conf
|
||||
so if you stop it half-way, you may get a half-configured system. If you
|
||||
have already tuned your FXO channels and wish to test-run fxotune again,
|
||||
you are advised to backup /etc/fxotune.conf .
|
||||
|
||||
The default for \-m is 18 seconds. This asusmes that you get a clear line
|
||||
for at least 18 seconds. It is advised that you test that timeout earlier
|
||||
by connecting a phone to the FXO line, dialing 4 (or whatever dial string
|
||||
you put with \-n) and see how much time of silence you have.
|
||||
|
||||
If you connect your device to a PSTN provider that is not in the US, there
|
||||
is a similar operation you should apply before even getting to fxotune:
|
||||
setting the opermode. The opermode sets a number of country-specific
|
||||
parameters. For the Digium analog cards this is set through the kernel module
|
||||
parameter 'opermode' . For the Xorcom Astribank this is set through the
|
||||
variable 'opermode' in /etc/dahdi/xpp.conf .
|
||||
For valid values of this parameter, see
|
||||
/usr/share/asterisk/init_fxo_modes (FIXME: this has changed and will
|
||||
change. Tzafrir).
|
||||
|
||||
.SH SEE ALSO
|
||||
dahdi_cfg(8), dahdi_tool(8), dahdi_monitor(8), asterisk(8).
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,60 @@
|
|||
.TH "FXSTEST" "8" "9 June 2007" "asterisk" "System Manager's Manuals: Asterisk"
|
||||
|
||||
.SH NAME
|
||||
fxstest \- Simple tests for DAHDI FXS adapters
|
||||
.SH SYNOPSIS
|
||||
|
||||
.B fxstest /dev/dahdi/\fIN comand\fR
|
||||
|
||||
.SH DESCRIPTION
|
||||
fxstest can be used to issue one of a number simple tests to FXS
|
||||
adapters (analog adapters intended to connect phones).
|
||||
|
||||
.SH OPTIONS
|
||||
All of those tests operate on a single dahdi channel which has to be an
|
||||
FXS port, and must not be in use by Asterisk or any other program.
|
||||
|
||||
The command has two mandatory parameters.
|
||||
The first parameter is the device file to operate on. It is typically
|
||||
/dev/dahdi/NN , a device file under /dev/dahdi .
|
||||
|
||||
The second parameter is the name of the command to run on that channel:
|
||||
|
||||
.I stats
|
||||
.RS
|
||||
Reports voltages
|
||||
.RE
|
||||
|
||||
.I regdump
|
||||
.RS
|
||||
Dumps ProSLIC registers
|
||||
.RE
|
||||
|
||||
.I tones
|
||||
.RS
|
||||
Plays a series of tones
|
||||
.RE
|
||||
|
||||
.I polarity
|
||||
.RS
|
||||
Requests channel to reverse polarity.
|
||||
.RE
|
||||
|
||||
.I ring
|
||||
.RS
|
||||
Rings phone
|
||||
.RE
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.PP
|
||||
dahdi_tool(8), dahdi_cfg(8), dahdi_monitor(8), asterisk(8).
|
||||
.SH BUGS
|
||||
Does not allow testing channels beyond 249. Should support opening
|
||||
channels through /dev/dahdi/channel .
|
||||
.SH AUTHOR
|
||||
.PP
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> .
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
.PP
|
|
@ -0,0 +1,44 @@
|
|||
.TH patgen 8 "2 Dec 2009"
|
||||
.SH NAME
|
||||
patgen \(em Generates a Pattern for a DAHDI Clear Channel Test
|
||||
.SH SYNOPSIS
|
||||
.B patgen
|
||||
.I dahdi-device
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B patgen
|
||||
Sends test data to a DAHDI channel. The channel should be of CLEAR
|
||||
signalling (e.g: B channel of a PRI line). pattest(8) is used to test
|
||||
the data at the other side. See its manual for more information.
|
||||
|
||||
.B patgen
|
||||
Must be able to write to the channel. Hence this cannot be used for a
|
||||
channel used by Asterisk.
|
||||
|
||||
.SH OPTIONS
|
||||
.I dahdi-device
|
||||
.RS
|
||||
A DAHDI device. Can be either a device number or an explicit device file
|
||||
name
|
||||
.RE
|
||||
|
||||
.SH EXAMPLE
|
||||
patgen /dev/dahdi/5
|
||||
|
||||
patgen 305
|
||||
|
||||
.SH BUGS
|
||||
Waiting for you to report them at <http://issues.asterisk.org> .
|
||||
|
||||
.SH SEE ALSO
|
||||
pattest(8), dahdi_cfg(8), asterisk(8).
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,49 @@
|
|||
.TH pattest 8 "2 Dec 2009"
|
||||
.SH NAME
|
||||
pattest \(em Tests a Pattern for a DAHDI Clear Channel Test
|
||||
.SH SYNOPSIS
|
||||
.B pattest
|
||||
.I dahdi-device
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B pattest
|
||||
Receives test data from a DAHDI channel and checks if it matches the
|
||||
test pattern. The channel should be of CLEAR signalling (e.g: B channel
|
||||
of a PRI line). patgen(8) is used to generate the data at the other side.
|
||||
|
||||
.B pattest
|
||||
Must be able to read from the channel. Hence this cannot be used for a
|
||||
channel used by Asterisk.
|
||||
|
||||
The pattern is a simple series of values from 0 to 255. Hence it takes
|
||||
at most one sample to get in sync with the other side. If there is no
|
||||
output, all is well. Output is an error message.
|
||||
|
||||
.SH OPTIONS
|
||||
.I dahdi-device
|
||||
.RS
|
||||
A DAHDI device. Can be either a device number or an explicit device file
|
||||
name
|
||||
.RE
|
||||
|
||||
.SH EXAMPLE
|
||||
pattest /dev/dahdi/5
|
||||
|
||||
pattest 305
|
||||
.RE
|
||||
|
||||
.SH BUGS
|
||||
Gives way too many errors when does not get any input.
|
||||
|
||||
.SH SEE ALSO
|
||||
patgen(8), dahdi_cfg(8), asterisk(8).
|
||||
|
||||
.SH AUTHOR
|
||||
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com>
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* fxotune.h -- data structures and associated definitions for fxotune.c
|
||||
*
|
||||
* By Matthew Fredrickson <creslin@digium.com>
|
||||
*
|
||||
* Echo coefficients and acim register values taken from AN84 from Silicon
|
||||
* Laboratories app note AN84 for setting echo cancellation coefficients
|
||||
*
|
||||
* (C) 2005 Digium, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
struct wctdm_echo_coefs echo_trys [] =
|
||||
{
|
||||
/* 600 ohm echo settings */
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 10, 0, 6, 1, 254, 2, 255, 0, 0},
|
||||
{ 3, 255, 255, 0, 1, 0, 0, 0, 0},
|
||||
{ 3, 1, 253, 253, 2, 255, 0, 0, 0},
|
||||
{ 9, 254, 251, 255, 2, 0, 1, 0, 0},
|
||||
{ 5, 3, 251, 250, 2, 254, 0, 0, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 900 ohm echo settings */
|
||||
{ 1, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 10, 252, 255, 1, 255, 0, 0, 0, 0},
|
||||
{ 7, 255, 251, 251, 2, 255, 255, 1, 255},
|
||||
{ 3, 1, 251, 250, 1, 254, 255, 0, 255},
|
||||
{ 5, 252, 250, 0, 0, 255, 1, 0, 0},
|
||||
{ 5, 3, 251, 250, 1, 253, 0, 0, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 270 ohm + (750 ohm || 150 nF) (CTR21) */
|
||||
{ 2, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 7, 0, 0, 255, 254, 0, 0, 0, 0},
|
||||
{ 9, 0, 253, 254, 2, 255, 0, 0, 0},
|
||||
{ 5, 1, 249, 254, 4, 253, 1, 0, 0},
|
||||
{ 5, 252, 250, 1, 1, 254, 0, 255, 0},
|
||||
{ 5, 3, 251, 250, 2, 253, 255, 255, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 220 ohm + (820 ohm || 120 nF) (Australia/NewZealand) and 220 ohm + (820 ohm
|
||||
* || 115nF) (Slovakia/SAfrica/Germany/Austria/Bulgaria)
|
||||
*/
|
||||
{ 3, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 7, 0, 255, 254, 255, 0, 255, 0, 0},
|
||||
{ 9, 0, 253, 253, 1, 255, 0, 0, 0},
|
||||
{ 5, 1, 249, 254, 3, 253, 1, 0, 0},
|
||||
{ 5, 252, 250, 1, 1, 254, 0, 255, 0},
|
||||
{ 5, 3, 251, 251, 2, 253, 255, 255, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 370 ohm + (620ohm || 310nF) (New Zealand #2/India) CO Termination */
|
||||
{ 4, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 9, 255, 1, 4, 0, 0, 1, 255, 0},
|
||||
{ 9, 0, 253, 0, 3, 254, 0, 0, 255},
|
||||
{ 9, 2, 250, 253, 5, 253, 1, 0 ,255},
|
||||
{ 5, 252, 250, 1, 2, 255, 0 ,255, 0},
|
||||
{ 5, 3, 251, 250, 3, 254, 255, 255, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 320 ohm + (1050ohm || 230 nF) (England) CO Termination */
|
||||
{ 5, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 9, 0 ,255, 1, 255, 255, 0, 255, 0},
|
||||
{ 5, 255, 252, 0, 2, 254, 0, 255, 255},
|
||||
{ 9, 2, 250, 253, 4, 252, 0, 255, 255},
|
||||
{ 5, 252, 250, 1, 1, 254, 0 ,255, 255},
|
||||
{ 5, 3, 251, 250, 2, 253, 255, 255, 254},
|
||||
{ 3, 1, 1, 242, 2, 9, 245, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 370 ohm + (820 ohm || 110 nF) CO Termination */
|
||||
{ 6, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 6, 1, 254, 253, 0, 255, 0, 0, 0},
|
||||
{ 9, 0, 251, 252, 2, 255, 0, 0, 0},
|
||||
{ 5, 1, 248, 252, 4, 253, 1, 0, 0},
|
||||
{ 5, 252, 250, 0, 0, 254, 0 , 255, 0},
|
||||
{ 5, 3, 251, 250, 2, 253, 255, 255, 254},
|
||||
{ 3, 1, 1, 242, 2, 9, 245, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* 275 ohm + (780 ohm || 115 nF) CO Termination */
|
||||
{ 7, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 7, 255, 255, 255, 255, 0, 0, 0, 0},
|
||||
{ 9, 0, 253, 254, 2, 255, 0, 0, 0},
|
||||
{ 5, 1, 249, 254, 4, 253, 1, 0, 0},
|
||||
{ 5, 252, 250, 1, 1, 254, 0, 255, 0},
|
||||
{ 5, 3, 251, 250, 2, 253, 255, 255, 255},
|
||||
{ 8, 253, 2, 244, 255, 10, 244, 3, 253},
|
||||
{ 10, 249, 244, 8, 12, 245, 252, 0, 1},
|
||||
|
||||
/* Make sure we include the rest of the impedances */
|
||||
{ 8, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 9, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 10, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 11, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 12, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 13, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 14, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{ 15, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
};
|
||||
|
|
@ -0,0 +1,373 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dahdi/user.h>
|
||||
#include <dahdi/wctdm_user.h>
|
||||
|
||||
#include "tonezone.h"
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
static int tones[] = {
|
||||
DAHDI_TONE_DIALTONE,
|
||||
DAHDI_TONE_BUSY,
|
||||
DAHDI_TONE_RINGTONE,
|
||||
DAHDI_TONE_CONGESTION,
|
||||
DAHDI_TONE_DIALRECALL,
|
||||
};
|
||||
|
||||
struct dahdi_vmwi_info mwisend_setting; /*!< Which VMWI methods to use */
|
||||
|
||||
/* Use to translate a DTMF character to the value required by the dahdi call */
|
||||
static int digit_to_dtmfindex(char digit)
|
||||
{
|
||||
if (isdigit(digit))
|
||||
return DAHDI_TONE_DTMF_BASE + (digit - '0');
|
||||
else if (digit >= 'A' && digit <= 'D')
|
||||
return DAHDI_TONE_DTMF_A + (digit - 'A');
|
||||
else if (digit >= 'a' && digit <= 'd')
|
||||
return DAHDI_TONE_DTMF_A + (digit - 'a');
|
||||
else if (digit == '*')
|
||||
return DAHDI_TONE_DTMF_s;
|
||||
else if (digit == '#')
|
||||
return DAHDI_TONE_DTMF_p;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Place a channel into ringing mode */
|
||||
static int dahdi_ring_phone(int fd)
|
||||
{
|
||||
int x;
|
||||
int res;
|
||||
/* Make sure our transmit state is on hook */
|
||||
x = 0;
|
||||
x = DAHDI_ONHOOK;
|
||||
res = ioctl(fd, DAHDI_HOOK, &x);
|
||||
do {
|
||||
x = DAHDI_RING;
|
||||
res = ioctl(fd, DAHDI_HOOK, &x);
|
||||
if (res) {
|
||||
switch (errno) {
|
||||
case EBUSY:
|
||||
case EINTR:
|
||||
/* Wait just in case */
|
||||
fprintf(stderr, "Ring phone is busy:%s\n", strerror(errno));
|
||||
usleep(10000);
|
||||
continue;
|
||||
case EINPROGRESS:
|
||||
fprintf(stderr, "Ring In Progress:%s\n", strerror(errno));
|
||||
res = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Couldn't ring the phone: %s\n", strerror(errno));
|
||||
res = 0;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Phone is ringing\n");
|
||||
}
|
||||
} while (res);
|
||||
return res;
|
||||
}
|
||||
|
||||
int channel_open(const char *name)
|
||||
{
|
||||
int channo, fd;
|
||||
struct stat filestat;
|
||||
const char *DEVICE = "/dev/dahdi/channel";
|
||||
|
||||
/* stat file, if character device, open it */
|
||||
channo = strtoul(name, NULL, 10);
|
||||
fd = stat(name, &filestat);
|
||||
if (!fd && S_ISCHR(filestat.st_mode)) {
|
||||
fd = open(name, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return -1;
|
||||
}
|
||||
/* try out the dahdi_specify interface */
|
||||
} else if (channo > 0) {
|
||||
fd = open(DEVICE, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(DEVICE);
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
|
||||
perror("DAHDI_SPECIFY ioctl failed");
|
||||
return -1;
|
||||
}
|
||||
/* die */
|
||||
} else {
|
||||
fprintf(stderr, "Specified channel is not a valid character "
|
||||
"device or channel number");
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res;
|
||||
int x;
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Usage: fxstest <dahdi device> <cmd>\n"
|
||||
" where cmd is one of:\n"
|
||||
" stats - reports voltages\n"
|
||||
" regdump - dumps ProSLIC registers\n"
|
||||
" tones - plays a series of tones\n"
|
||||
" polarity - tests polarity reversal\n"
|
||||
" ring - rings phone\n"
|
||||
" vmwi - toggles VMWI LED lamp\n"
|
||||
" hvdc - toggles VMWI HV lamp\n"
|
||||
" neon - toggles VMWI NEON lamp\n"
|
||||
" dtmf <sequence> [<duration>]- Send a sequence of dtmf tones (\"-\" denotes no tone)\n"
|
||||
" dtmfcid - create a dtmf cid spill without polarity reversal\n");
|
||||
exit(1);
|
||||
}
|
||||
fd = channel_open(argv[1]);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ( !strcasecmp(argv[2], "neon") || !strcasecmp(argv[2], "vmwi") || !strcasecmp(argv[2], "hvdc")) {
|
||||
fprintf(stderr, "Twiddling %s ...\n", argv[2]);
|
||||
|
||||
if ( !strcasecmp(argv[2], "vmwi") ) {
|
||||
mwisend_setting.vmwi_type = DAHDI_VMWI_LREV;
|
||||
} else if ( !strcasecmp(argv[2], "neon") ) {
|
||||
mwisend_setting.vmwi_type = DAHDI_VMWI_HVAC;
|
||||
} else if ( !strcasecmp(argv[2], "hvdc") ) {
|
||||
mwisend_setting.vmwi_type = DAHDI_VMWI_HVDC;
|
||||
}
|
||||
res = ioctl(fd, DAHDI_VMWI_CONFIG, &mwisend_setting);
|
||||
|
||||
x = 1;
|
||||
res = ioctl(fd, DAHDI_VMWI, &x);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to set %s ...\n", argv[2]);
|
||||
} else {
|
||||
fprintf(stderr, "Set 1 Voice Message...\n");
|
||||
|
||||
sleep(5);
|
||||
x = 2;
|
||||
ioctl(fd, DAHDI_VMWI, &x);
|
||||
fprintf(stderr, "Set 2 Voice Messages...\n");
|
||||
|
||||
sleep(5);
|
||||
x = 0;
|
||||
ioctl(fd, DAHDI_VMWI, &x);
|
||||
fprintf(stderr, "Set No Voice messages...\n");
|
||||
sleep(2);
|
||||
mwisend_setting.vmwi_type = 0;
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "ring")) {
|
||||
fprintf(stderr, "Ringing phone...\n");
|
||||
x = DAHDI_RING;
|
||||
res = ioctl(fd, DAHDI_HOOK, &x);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to ring phone...\n");
|
||||
} else {
|
||||
fprintf(stderr, "Phone is ringing...\n");
|
||||
sleep(2);
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "polarity")) {
|
||||
fprintf(stderr, "Twiddling polarity...\n");
|
||||
/* Insure that the channel is in active mode */
|
||||
x = DAHDI_RING;
|
||||
res = ioctl(fd, DAHDI_HOOK, &x);
|
||||
usleep(100000);
|
||||
x = 0;
|
||||
res = ioctl(fd, DAHDI_HOOK, &x);
|
||||
|
||||
x = 0;
|
||||
res = ioctl(fd, DAHDI_SETPOLARITY, &x);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to polarity...\n");
|
||||
} else {
|
||||
fprintf(stderr, "Polarity is forward...\n");
|
||||
sleep(2);
|
||||
x = 1;
|
||||
ioctl(fd, DAHDI_SETPOLARITY, &x);
|
||||
fprintf(stderr, "Polarity is reversed...\n");
|
||||
sleep(5);
|
||||
x = 0;
|
||||
ioctl(fd, DAHDI_SETPOLARITY, &x);
|
||||
fprintf(stderr, "Polarity is forward...\n");
|
||||
sleep(2);
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "tones")) {
|
||||
int x = 0;
|
||||
for (;;) {
|
||||
res = tone_zone_play_tone(fd, tones[x]);
|
||||
if (res)
|
||||
fprintf(stderr, "Unable to play tone %d\n", tones[x]);
|
||||
sleep(3);
|
||||
x=(x+1) % (sizeof(tones) / sizeof(tones[0]));
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "stats")) {
|
||||
struct wctdm_stats stats;
|
||||
res = ioctl(fd, WCTDM_GET_STATS, &stats);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to get stats on channel %s\n", argv[1]);
|
||||
} else {
|
||||
printf("TIP: %7.4f Volts\n", (float)stats.tipvolt / 1000.0);
|
||||
printf("RING: %7.4f Volts\n", (float)stats.ringvolt / 1000.0);
|
||||
printf("VBAT: %7.4f Volts\n", (float)stats.batvolt / 1000.0);
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "regdump")) {
|
||||
struct wctdm_regs regs;
|
||||
int numregs = NUM_REGS;
|
||||
memset(®s, 0, sizeof(regs));
|
||||
res = ioctl(fd, WCTDM_GET_REGS, ®s);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to get registers on channel %s\n", argv[1]);
|
||||
} else {
|
||||
for (x=60;x<NUM_REGS;x++) {
|
||||
if (regs.direct[x])
|
||||
break;
|
||||
}
|
||||
if (x == NUM_REGS)
|
||||
numregs = 60;
|
||||
printf("Direct registers: \n");
|
||||
for (x=0;x<numregs;x++) {
|
||||
printf("%3d. %02x ", x, regs.direct[x]);
|
||||
if ((x % 8) == 7)
|
||||
printf("\n");
|
||||
}
|
||||
if (numregs == NUM_REGS) {
|
||||
printf("\n\nIndirect registers: \n");
|
||||
for (x=0;x<NUM_INDIRECT_REGS;x++) {
|
||||
printf("%3d. %04x ", x, regs.indirect[x]);
|
||||
if ((x % 6) == 5)
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "setdirect") ||
|
||||
!strcasecmp(argv[2], "setindirect")) {
|
||||
struct wctdm_regop regop;
|
||||
int val;
|
||||
int reg;
|
||||
if ((argc < 5) || (sscanf(argv[3], "%i", ®) != 1) ||
|
||||
(sscanf(argv[4], "%i", &val) != 1)) {
|
||||
fprintf(stderr, "Need a register and value...\n");
|
||||
} else {
|
||||
regop.reg = reg;
|
||||
regop.val = val;
|
||||
if (!strcasecmp(argv[2], "setindirect")) {
|
||||
regop.indirect = 1;
|
||||
} else {
|
||||
regop.indirect = 0;
|
||||
}
|
||||
res = ioctl(fd, WCTDM_SET_REG, ®op);
|
||||
if (res)
|
||||
fprintf(stderr, "Unable to get registers on channel %s\n", argv[1]);
|
||||
else
|
||||
printf("Success.\n");
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "dtmf")) {
|
||||
int duration = 50; /* default to 50 mS duration */
|
||||
char * outstring = "";
|
||||
int dtmftone;
|
||||
|
||||
if(argc < 4) { /* user supplied string */
|
||||
fprintf(stderr, "You must specify a string of dtmf characters to send\n");
|
||||
} else {
|
||||
outstring = argv[3];
|
||||
if(argc >= 5) {
|
||||
sscanf(argv[4], "%30i", &duration);
|
||||
}
|
||||
printf("Going to send a set of DTMF tones >%s<\n", outstring);
|
||||
printf("Using a duration of %d mS per tone\n", duration);
|
||||
/* Flush any left remaining characs in the buffer and place the channel into on-hook transfer mode */
|
||||
x = DAHDI_FLUSH_BOTH;
|
||||
res = ioctl(fd, DAHDI_FLUSH, &x);
|
||||
x = 500 + strlen(outstring) * duration;
|
||||
ioctl(fd, DAHDI_ONHOOKTRANSFER, &x);
|
||||
|
||||
for (x = 0; '\0' != outstring[x]; x++) {
|
||||
dtmftone = digit_to_dtmfindex(outstring[x]);
|
||||
if (0 > dtmftone) {
|
||||
dtmftone = -1;
|
||||
}
|
||||
res = tone_zone_play_tone(fd, dtmftone);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to play DTMF tone %d (0x%x)\n", dtmftone, dtmftone);
|
||||
}
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(argv[2], "dtmfcid")) {
|
||||
char * outstring = "A5551212C"; /* Default string using A and C tones to bracket the number */
|
||||
int dtmftone;
|
||||
|
||||
if(argc >= 4) { /* Use user supplied string */
|
||||
outstring = argv[3];
|
||||
}
|
||||
printf("Going to send a set of DTMF tones >%s<\n", outstring);
|
||||
/* Flush any left remaining characs in the buffer and place the channel into on-hook transfer mode */
|
||||
x = DAHDI_FLUSH_BOTH;
|
||||
res = ioctl(fd, DAHDI_FLUSH, &x);
|
||||
x = 500 + strlen(outstring) * 100;
|
||||
ioctl(fd, DAHDI_ONHOOKTRANSFER, &x);
|
||||
|
||||
/* Play the DTMF tones at a 50 mS on and 50 mS off rate which is standard for DTMF CID spills */
|
||||
for (x = 0; '\0' != outstring[x]; x++) {
|
||||
|
||||
dtmftone = digit_to_dtmfindex(outstring[x]);
|
||||
if (0 > dtmftone) {
|
||||
dtmftone = -1;
|
||||
}
|
||||
res = tone_zone_play_tone(fd, dtmftone);
|
||||
if (res) {
|
||||
fprintf(stderr, "Unable to play DTMF tone %d (0x%x)\n", dtmftone, dtmftone);
|
||||
}
|
||||
usleep(50000);
|
||||
tone_zone_play_tone(fd, -1);
|
||||
usleep(50000);
|
||||
}
|
||||
/* Wait for 150 mS from end of last tone to initiating the ring */
|
||||
usleep(100000);
|
||||
dahdi_ring_phone(fd);
|
||||
sleep(10);
|
||||
printf("Ringing Done\n");
|
||||
} else
|
||||
fprintf(stderr, "Invalid command\n");
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FAST_HDLC_NEED_TABLES
|
||||
#include <dahdi/fasthdlc.h>
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define RANDOM "/dev/urandom" /* Not genuinely random */
|
||||
/* #define RANDOM "/dev/random" */ /* Quite genuinely random */
|
||||
|
||||
int myread(int fd, char *buf, int len)
|
||||
{
|
||||
int sofar;
|
||||
int res;
|
||||
sofar = 0;
|
||||
while(sofar < len) {
|
||||
res = read(fd, buf + sofar, len - sofar);
|
||||
if (res < 0)
|
||||
return res;
|
||||
sofar += res;
|
||||
}
|
||||
return sofar;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char buf[1024];
|
||||
unsigned char outbuf[2048];
|
||||
int res;
|
||||
int randin;
|
||||
int randout;
|
||||
int hdlcout;
|
||||
int cnt;
|
||||
int hdlccnt;
|
||||
int x;
|
||||
int flags;
|
||||
struct fasthdlc_state transmitter;
|
||||
|
||||
fasthdlc_precalc();
|
||||
|
||||
fasthdlc_init(&transmitter, FASTHDLC_MODE_64);
|
||||
|
||||
randin = open(RANDOM, O_RDONLY);
|
||||
if (randin < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", RANDOM, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
randout = open("random.raw", O_WRONLY|O_TRUNC|O_CREAT, 0666);
|
||||
if (randout < 0) {
|
||||
fprintf(stderr, "Unable to open random.raw: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
hdlcout = open("random.hdlc", O_WRONLY|O_TRUNC|O_CREAT, 0666);
|
||||
if (hdlcout < 0) {
|
||||
fprintf(stderr, "Unable to open random.hdlc: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
for (;;) {
|
||||
cnt = (rand() % 256) + 4; /* Read a pseudo-random amount of stuff */
|
||||
res = myread(randin, buf, cnt);
|
||||
if (res != cnt) {
|
||||
fprintf(stderr, "Tried to read %d bytes, but read %d instead\n", cnt, res);
|
||||
exit(1);
|
||||
}
|
||||
res = write(randout, buf, cnt);
|
||||
if (res != cnt) {
|
||||
fprintf(stderr, "Tried to write %d bytes, but wrote %d instead\n", cnt, res);
|
||||
exit(1);
|
||||
}
|
||||
/* HDLC encode */
|
||||
hdlccnt = 0;
|
||||
/* Start with a flag */
|
||||
fasthdlc_tx_frame(&transmitter);
|
||||
if (transmitter.bits >= 8)
|
||||
outbuf[hdlccnt++] = fasthdlc_tx_run(&transmitter);
|
||||
for (x=0;x<cnt;x++) {
|
||||
res = fasthdlc_tx_load(&transmitter, buf[x]);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Unable to load byte :(\n");
|
||||
exit(1);
|
||||
}
|
||||
while(transmitter.bits >= 8) {
|
||||
outbuf[hdlccnt++] = fasthdlc_tx_run(&transmitter);
|
||||
}
|
||||
}
|
||||
flags = (rand() % 4);
|
||||
for (x=0;x<flags;x++) {
|
||||
if (transmitter.bits < 8)
|
||||
fasthdlc_tx_frame(&transmitter);
|
||||
else
|
||||
fprintf(stderr, "Huh? Don't need a frame?\n");
|
||||
outbuf[hdlccnt++] = fasthdlc_tx_run(&transmitter);
|
||||
}
|
||||
if (argc > 1)
|
||||
printf("Encoded %d byte message with %d bytes of HDLC and %d extra flags\n", cnt, hdlccnt, flags);
|
||||
res = write(hdlcout, outbuf, hdlccnt);
|
||||
if (res != hdlccnt) {
|
||||
fprintf(stderr, "Tried to write %d HDLC bytes, but wrote %d instead\n", cnt, res);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ppp_defs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <dahdi/user.h>
|
||||
|
||||
#define FAST_HDLC_NEED_TABLES
|
||||
#include <dahdi/fasthdlc.h>
|
||||
|
||||
#include "bittest.h"
|
||||
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
/* #define BLOCK_SIZE 2048 */
|
||||
#define BLOCK_SIZE 2041
|
||||
|
||||
static int hdlcmode = 0;
|
||||
static int bri_delay = 0;
|
||||
|
||||
|
||||
static unsigned short fcstab[256] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||
|
||||
void print_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int x;
|
||||
printf("{ ");
|
||||
for (x=0;x<len;x++)
|
||||
printf("%02x ",buf[x]);
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
static int fd;
|
||||
static struct fasthdlc_state fs;
|
||||
|
||||
void send_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int res;
|
||||
int x;
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
int pos=0;
|
||||
unsigned int fcs = PPP_INITFCS;
|
||||
if (hdlcmode)
|
||||
res = write(fd, buf, len + 2);
|
||||
else {
|
||||
for (x=0;x<len;x++) {
|
||||
if (fasthdlc_tx_load(&fs, buf[x]))
|
||||
printf("Load error\n");
|
||||
fcs = PPP_FCS(fcs, buf[x]);
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fs.bits > 7)
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
}
|
||||
fcs ^= 0xffff;
|
||||
if (fasthdlc_tx_load(&fs, (fcs & 0xff)))
|
||||
fprintf(stderr, "Load error (fcs1)\n");
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fs.bits > 7)
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fasthdlc_tx_load(&fs, ((fcs >> 8) & 0xff)))
|
||||
fprintf(stderr, "Load error (fcs2)\n");
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fs.bits > 7)
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fasthdlc_tx_frame(&fs))
|
||||
fprintf(stderr, "Frame error\n");
|
||||
if (fs.bits > 7)
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
if (fs.bits > 7)
|
||||
outbuf[pos++] = fasthdlc_tx_run(&fs);
|
||||
write(fd, outbuf, pos);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int res, ch, x;
|
||||
struct dahdi_params tp;
|
||||
struct dahdi_bufferinfo bi;
|
||||
int bs = BLOCK_SIZE;
|
||||
unsigned char c=0;
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
|
||||
while((ch = getopt(argc, argv, "b")) != -1) {
|
||||
switch(ch) {
|
||||
case 'b': bri_delay = 300000; break;
|
||||
case '?': exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind != 1) {
|
||||
fprintf(stderr, "Usage: %s [-b] <DAHDI device>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
fd = open(argv[optind], O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", argv[optind], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs)) {
|
||||
fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
|
||||
fprintf(stderr, "Unable to get channel parameters\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((tp.sigtype & DAHDI_SIG_HDLCRAW) == DAHDI_SIG_HDLCRAW) {
|
||||
printf("In HDLC mode\n");
|
||||
hdlcmode = 1;
|
||||
} else if ((tp.sigtype & DAHDI_SIG_CLEAR) == DAHDI_SIG_CLEAR) {
|
||||
printf("In CLEAR mode\n");
|
||||
hdlcmode = 0;
|
||||
} else {
|
||||
fprintf(stderr, "Not in a reasonable mode\n");
|
||||
exit(1);
|
||||
}
|
||||
res = ioctl(fd, DAHDI_GET_BUFINFO, &bi);
|
||||
if (!res) {
|
||||
bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.numbufs = 4;
|
||||
res = ioctl(fd, DAHDI_SET_BUFINFO, &bi);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Unable to set buf info: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Unable to get buf info: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
ioctl(fd, DAHDI_GETEVENT);
|
||||
fasthdlc_precalc();
|
||||
fasthdlc_init(&fs, FASTHDLC_MODE_64);
|
||||
#if 0
|
||||
print_packet(outbuf, res);
|
||||
printf("FCS is %x, PPP_GOODFCS is %x\n",
|
||||
fcs,PPP_GOODFCS);
|
||||
#endif
|
||||
for(;;) {
|
||||
if (c < 1)
|
||||
c = 1;
|
||||
for (x=0;x<50;x++) {
|
||||
outbuf[x] = c;
|
||||
}
|
||||
send_packet(outbuf, 50);
|
||||
#if 0
|
||||
printf("Wrote %d of %d bytes\n", res, c);
|
||||
#endif
|
||||
/* The HFC chip can't be bombarded too much. If a write has
|
||||
failed, let it recover */
|
||||
if (bri_delay)
|
||||
usleep(bri_delay);
|
||||
|
||||
c = bit_next(c);
|
||||
#if 0
|
||||
printf("(%d) Wrote %d bytes\n", packets++, res);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ppp_defs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <dahdi/user.h>
|
||||
|
||||
#define FAST_HDLC_NEED_TABLES
|
||||
#include <dahdi/fasthdlc.h>
|
||||
|
||||
#include "bittest.h"
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define BLOCK_SIZE 2039
|
||||
|
||||
static unsigned short fcstab[256] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||
|
||||
void print_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int x;
|
||||
printf("{ ");
|
||||
for (x = 0; x < len; x++) {
|
||||
printf("%02x ", buf[x]);
|
||||
}
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
static int bytes;
|
||||
static int errors;
|
||||
static int c;
|
||||
|
||||
void dump_bits(unsigned char *outbuf, int len)
|
||||
{
|
||||
int x, i;
|
||||
for (x = 0; x < len; x++) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (outbuf[x] & (1 << (7 - i))) {
|
||||
printf("1");
|
||||
} else {
|
||||
printf("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void dump_bitslong(unsigned int outbuf, int bits)
|
||||
{
|
||||
int i;
|
||||
printf("Dumping %d bits from %04x\n", bits, outbuf);
|
||||
for (i = 0; i < bits; i++) {
|
||||
if (outbuf & (1 << (31 - i))) {
|
||||
printf("1");
|
||||
} else {
|
||||
printf("0");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int check_frame(unsigned char *outbuf, int res)
|
||||
{
|
||||
static int setup = 0;
|
||||
int x;
|
||||
unsigned short fcs = PPP_INITFCS;
|
||||
if (c < 1) {
|
||||
c = 1;
|
||||
}
|
||||
if (!setup) {
|
||||
c = outbuf[0];
|
||||
setup++;
|
||||
}
|
||||
for (x = 0; x < res; x++) {
|
||||
if (outbuf[x] != c && (x < res - 2)) {
|
||||
printf("(Error %d): Unexpected result, %d != %d, position %d %d bytes since last error.\n",
|
||||
++errors, outbuf[x], c, x, bytes);
|
||||
if (!x) {
|
||||
c = outbuf[0];
|
||||
}
|
||||
bytes = 0;
|
||||
} else {
|
||||
bytes++;
|
||||
}
|
||||
fcs = PPP_FCS(fcs, outbuf[x]);
|
||||
}
|
||||
if (fcs != PPP_GOODFCS) {
|
||||
printf("FCS Check failed :( (%04x != %04x)\n", fcs, PPP_GOODFCS);
|
||||
}
|
||||
#if 0
|
||||
if (res != c) {
|
||||
printf("Res is %d, expected %d\n", res, c+2);
|
||||
}
|
||||
#endif
|
||||
c = bit_next(c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res, x;
|
||||
struct dahdi_params tp;
|
||||
struct dahdi_bufferinfo bi;
|
||||
int bs = BLOCK_SIZE;
|
||||
int pos = 0;
|
||||
unsigned char inbuf[BLOCK_SIZE];
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
int bytes = 0;
|
||||
int out;
|
||||
unsigned int olddata1;
|
||||
int oldones1;
|
||||
int oldbits1;
|
||||
unsigned int olddata = 0;
|
||||
int oldones = 0;
|
||||
int oldbits = 0;
|
||||
int hdlcmode = 0;
|
||||
struct fasthdlc_state fs;
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s <DAHDI device>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
fd = open(argv[1], O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs)) {
|
||||
fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
|
||||
fprintf(stderr, "Unable to get channel parameters\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((tp.sigtype & DAHDI_SIG_HDLCRAW) == DAHDI_SIG_HDLCRAW) {
|
||||
printf("In HDLC mode\n");
|
||||
hdlcmode = 1;
|
||||
} else if ((tp.sigtype & DAHDI_SIG_CLEAR) == DAHDI_SIG_CLEAR) {
|
||||
printf("In CLEAR mode\n");
|
||||
hdlcmode = 0;
|
||||
} else {
|
||||
fprintf(stderr, "Not in a reasonable mode\n");
|
||||
exit(1);
|
||||
}
|
||||
res = ioctl(fd, DAHDI_GET_BUFINFO, &bi);
|
||||
if (!res) {
|
||||
bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
|
||||
bi.numbufs = 4;
|
||||
res = ioctl(fd, DAHDI_SET_BUFINFO, &bi);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Unable to set buf info: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Unable to get buf info: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
ioctl(fd, DAHDI_GETEVENT);
|
||||
fasthdlc_precalc();
|
||||
fasthdlc_init(&fs, FASTHDLC_MODE_64);
|
||||
for (;;) {
|
||||
res = read(fd, outbuf, sizeof(outbuf));
|
||||
if (hdlcmode) {
|
||||
if (res < 0) {
|
||||
if (errno == ELAST) {
|
||||
if (ioctl(fd, DAHDI_GETEVENT, &x) < 0) {
|
||||
fprintf(stderr, "Unaable to get event: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
fprintf(stderr, "Event: %d (%d bytes since last error)\n", x, bytes);
|
||||
bytes = 0;
|
||||
continue;
|
||||
} else {
|
||||
fprintf(stderr, "Error: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
printf("Res is %d, buf0 is %d, buf1 is %d\n", res, outbuf[0], outbuf[1]);
|
||||
#endif
|
||||
if (res < 2) {
|
||||
fprintf(stderr, "Too small? Only got %d bytes\n", res);
|
||||
}
|
||||
check_frame(outbuf, res);
|
||||
} else {
|
||||
for (x = 0; x < res; x++) {
|
||||
oldones1 = oldones;
|
||||
oldbits1 = oldbits;
|
||||
olddata1 = olddata;
|
||||
oldones = fs.ones;
|
||||
oldbits = fs.bits;
|
||||
olddata = fs.data;
|
||||
fasthdlc_rx_load(&fs, outbuf[x]);
|
||||
out = fasthdlc_rx_run(&fs);
|
||||
if (out & RETURN_EMPTY_FLAG) {
|
||||
/* Empty */
|
||||
} else if (out & RETURN_COMPLETE_FLAG) {
|
||||
if (pos && (pos < 2)) {
|
||||
printf("Too short? (%d)\n", pos);
|
||||
} else if (pos) {
|
||||
check_frame(inbuf, pos);
|
||||
}
|
||||
pos = 0;
|
||||
} else if (out & RETURN_DISCARD_FLAG) {
|
||||
printf("Discard (search = %d, len = %d, buf = %d, x=%d, res=%d, oldones: %d, oldbits: %d)\n",
|
||||
c, pos, inbuf[0], x, res, oldones, oldbits);
|
||||
dump_bitslong(olddata, oldbits);
|
||||
printf("Discard oldones: %d, oldbits: %d)\n",
|
||||
oldones1, oldbits1);
|
||||
dump_bitslong(olddata1, oldbits1);
|
||||
if (x > 64) {
|
||||
dump_bits(outbuf + x - 64, 64);
|
||||
dump_bits(outbuf + x, 64);
|
||||
}
|
||||
pos = 0;
|
||||
} else {
|
||||
if ((out != c) && (pos < c) && !pos) {
|
||||
printf("Warning: Expecting %d at pos %d, got %d (x =%d)\n", c, pos, out, x);
|
||||
if (x > 64) {
|
||||
dump_bits(outbuf + x - 64, 64);
|
||||
dump_bits(outbuf + x, 64);
|
||||
}
|
||||
}
|
||||
inbuf[pos++] = out;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define FAST_HDLC_NEED_TABLES
|
||||
#include <dahdi/fasthdlc.h>
|
||||
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
int myread(int fd, unsigned char *buf, int len)
|
||||
{
|
||||
int sofar;
|
||||
int res;
|
||||
sofar = 0;
|
||||
while(sofar < len) {
|
||||
res = read(fd, buf + sofar, len - sofar);
|
||||
if (res < 0)
|
||||
return res;
|
||||
sofar += res;
|
||||
}
|
||||
return sofar;
|
||||
}
|
||||
|
||||
static inline unsigned char nextchar(int fd)
|
||||
{
|
||||
static unsigned char inbuf[2048];
|
||||
static int bytes = 0;
|
||||
static int pos = 0;
|
||||
if (pos >= bytes) {
|
||||
pos = 0;
|
||||
bytes = read(fd, inbuf, sizeof(inbuf));
|
||||
if (bytes < 0) {
|
||||
fprintf(stderr, "Unable to read more data: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
if (bytes == 0) {
|
||||
fprintf(stderr, "-- END OF DATA --\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
return inbuf[pos++];
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned char decbuf[1024];
|
||||
unsigned char actual[1024];
|
||||
int res;
|
||||
int datain;
|
||||
int hdlcin;
|
||||
int hdlccnt;
|
||||
int x;
|
||||
struct fasthdlc_state receiver;
|
||||
|
||||
fasthdlc_precalc();
|
||||
|
||||
fasthdlc_init(&receiver, FASTHDLC_MODE_64);
|
||||
|
||||
hdlcin = open("random.hdlc", O_RDONLY);
|
||||
if (hdlcin < 0) {
|
||||
fprintf(stderr, "Unable to open %s: %s\n", "random.hdlc", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
datain = open("random.raw", O_RDONLY);
|
||||
if (datain < 0) {
|
||||
fprintf(stderr, "Unable to open random.raw: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
hdlccnt = 0;
|
||||
for (;;) {
|
||||
/* Feed in some input */
|
||||
if (fasthdlc_rx_load(&receiver, nextchar(hdlcin))) {
|
||||
fprintf(stderr, "Unable to feed receiver :(\n");
|
||||
exit(1);
|
||||
}
|
||||
res = fasthdlc_rx_run(&receiver);
|
||||
if (res & RETURN_EMPTY_FLAG)
|
||||
continue;
|
||||
if (res & RETURN_COMPLETE_FLAG) {
|
||||
if (hdlccnt) {
|
||||
if (argc > 1)
|
||||
printf("Got message of length %d\n", hdlccnt);
|
||||
res = myread(datain, actual, hdlccnt);
|
||||
if (res != hdlccnt) {
|
||||
fprintf(stderr, "Tried to read %d bytes, but read %d instead\n", hdlccnt, res);
|
||||
exit(1);
|
||||
}
|
||||
for (x=0;x<hdlccnt;x++) {
|
||||
if (actual[x] != decbuf[x]) {
|
||||
fprintf(stderr, "Found discrepancy at offset %d\n", x);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
/* Reset message receiver */
|
||||
hdlccnt = 0;
|
||||
}
|
||||
} else if (res & RETURN_DISCARD_FLAG) {
|
||||
if (1 || hdlccnt) {
|
||||
fprintf(stderr, "Detected abort :(\n");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
decbuf[hdlccnt++] = res;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
#! /bin/sh
|
||||
|
||||
devdir='/sys/bus/dahdi_devices/devices'
|
||||
|
||||
# DAHDI is loaded?
|
||||
if [ ! -d "$devdir" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
devices_by_registration_time() {
|
||||
grep -H '' $devdir/*/registration_time 2>/dev/null | \
|
||||
sed 's,/registration_time:,\t,' | \
|
||||
sort -k 2,2
|
||||
}
|
||||
|
||||
# First assign non-Astribank devices
|
||||
devices_by_registration_time | \
|
||||
grep -v '/astribanks:' | \
|
||||
while read devpath time; do
|
||||
echo >&2 "D: auto '$devpath'"
|
||||
dahdi_span_assignments auto "$devpath"
|
||||
done
|
||||
|
||||
# Now handle Astribanks
|
||||
LC_ALL=C dahdi_registration -Rv on
|
|
@ -0,0 +1,87 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# /usr/share/dahdi/dahdi_handle_device
|
||||
#
|
||||
# Called by UDEV when a dahdi device is added/removed
|
||||
#
|
||||
|
||||
me=`basename $0`
|
||||
dir=`dirname $0`
|
||||
LOGGER="logger -i -t '$me'"
|
||||
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
|
||||
|
||||
# Always redirect stderr somewhere, otherwise the shell script will die
|
||||
# when it tries to do I/O related stuff on closed file descriptor.
|
||||
# Our default is to throw it down the bit-bucket.
|
||||
exec 2> /dev/null
|
||||
# If you wish to trace this script:
|
||||
#exec 2> "/tmp/${me}.$NAME" 1>&2
|
||||
#exec 2> /dev/console
|
||||
|
||||
# Our directory in the beginning, so we can use local lab setup
|
||||
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
export PATH
|
||||
|
||||
set -e
|
||||
|
||||
#echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
|
||||
|
||||
# Do we have a configuration?
|
||||
if [ -f /etc/dahdi/init.conf ]; then
|
||||
. /etc/dahdi/init.conf
|
||||
fi
|
||||
|
||||
if [ "$DAHDI_UDEV_DISABLE_DEVICES" = 'yes' ]; then
|
||||
echo "DAHDI_UDEV_DISABLE_DEVICES=yes. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Can we pass a different value so we can use
|
||||
# alternate (testing) configuration?
|
||||
# Meanwhile, make it hard-coded.
|
||||
DAHDICONFDIR='/etc/dahdi'
|
||||
export DAHDICONFDIR
|
||||
|
||||
run_parts() {
|
||||
# Have our internal "run-parts" (adapted from Fedora),
|
||||
# as implementations differ
|
||||
for i in `LC_ALL=C; ls -d $dir/handle_device.d/*[!~,] 2>/dev/null` ; do
|
||||
[ -d "$i" ] && continue
|
||||
[ ! -x "$i" ] && continue
|
||||
# Don't run *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} files
|
||||
case "$i" in
|
||||
*.cfsaved|*.rpmsave|*.rpmorig|*.rpmnew|*.swp|*,v)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
echo "D: Running '$i'"
|
||||
"$i"
|
||||
done
|
||||
}
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
|
||||
# Check if we can safely do our job
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
echo "Old driver (no auto_assign_spans parameter). Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
if [ `cat /sys/module/dahdi/parameters/auto_assign_spans` -ne 0 ]; then
|
||||
echo "auto_assign_spans=1. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
remove)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
*)
|
||||
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
|
||||
;;
|
||||
esac
|
|
@ -0,0 +1,97 @@
|
|||
#! /bin/sh
|
||||
#
|
||||
# /usr/share/dahdi/dahdi_span_config
|
||||
#
|
||||
# Called by UDEV when a dahdi span is added/removed
|
||||
#
|
||||
|
||||
me=`basename $0`
|
||||
dir=`dirname $0`
|
||||
LOGGER="logger -i -t '$me'"
|
||||
NAME=`basename "$DEVPATH" | tr -c 'A-Za-z0-9-' '_'`
|
||||
|
||||
exec 2> /dev/null
|
||||
# Always redirect stderr somewhere, otherwise the shell script will die
|
||||
# when it tries to do I/O related stuff on closed file descriptor.
|
||||
# Our default is to throw it down the bit-bucket.
|
||||
#exec 2> /dev/console
|
||||
## If you wish to trace this script:
|
||||
#exec 2> "/tmp/${me}.$NAME" 1>&2
|
||||
|
||||
# Our directory in the beginning, so we can use local lab setup
|
||||
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
export PATH
|
||||
|
||||
set -e
|
||||
|
||||
#echo >&2 "$0($ACTION): DEBUG($# args): '$*'"
|
||||
|
||||
# Do we have a configuration?
|
||||
if [ -f /etc/dahdi/init.conf ]; then
|
||||
. /etc/dahdi/init.conf
|
||||
fi
|
||||
|
||||
if [ "$DAHDI_UDEV_DISABLE_SPANS" = 'yes' ]; then
|
||||
echo "DAHDI_UDEV_DISABLE_SPANS=yes. Skip $DEVPATH" | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Can we pass a different value so we can use
|
||||
# alternate (testing) configuration?
|
||||
# Meanwhile, make it hard-coded.
|
||||
DAHDICONFDIR='/etc/dahdi'
|
||||
export DAHDICONFDIR
|
||||
|
||||
run_parts() {
|
||||
# Have our internal "run-parts" (adapted from Fedora),
|
||||
# as implementations differ
|
||||
for i in `LC_ALL=C; ls -d $dir/span_config.d/*[!~,] 2>/dev/null` ; do
|
||||
[ -d "$i" ] && continue
|
||||
[ ! -x "$i" ] && continue
|
||||
# Don't run *.{rpmsave,rpmorig,rpmnew,swp,cfsaved} files
|
||||
case "$i" in
|
||||
*.cfsaved|*.rpmsave|*.rpmorig|*.rpmnew|*.swp|*,v)
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
#echo "D: Running '$i'"
|
||||
"$i"
|
||||
done
|
||||
}
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
|
||||
# Old driver. These scripts probably won't work anyway.
|
||||
if [ ! -f /sys/module/dahdi/parameters/auto_assign_spans ]; then
|
||||
if [ -f /sys/module/dahdi ]; then
|
||||
$LOGGER "Old driver (no auto_assign_spans parameter). Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $(cat /sys/module/dahdi/parameters/auto_assign_spans) -ne 0 ]; then
|
||||
$LOGGER "auto_assign_spans=1. Skip $DEVPATH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set variables
|
||||
span_devpath="/sys$DEVPATH"
|
||||
SPANNO=`echo "$span_devpath" | sed 's,.*/span-,,'`
|
||||
BASECHAN=`cat "$span_devpath/basechan"`
|
||||
CHANNELS=`cat "$span_devpath/channels"`
|
||||
ENDCHAN=`expr "$BASECHAN" + "$CHANNELS" - 1`
|
||||
export SPANNO BASECHAN CHANNELS ENDCHAN
|
||||
# Background run -- don't block udev
|
||||
run_parts 2>&1 < /dev/null | $LOGGER &
|
||||
;;
|
||||
remove|online|offline)
|
||||
# Nothing to do yet...
|
||||
echo "$ACTION: $DEVPATH" | $LOGGER
|
||||
;;
|
||||
*)
|
||||
echo "UNHANDLED: $ACTION: $DEVPATH" | $LOGGER
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
if [ -r "$DAHDICONFDIR/span-types.conf" ]; then
|
||||
dahdi_span_types set "/sys$DEVPATH"
|
||||
fi
|
|
@ -0,0 +1,15 @@
|
|||
#! /bin/sh
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
*)
|
||||
exit 0
|
||||
esac
|
||||
|
||||
# For now, handle only spans in assigned-spans.conf
|
||||
# We leave other cases to /etc/init.d/dahdi, so
|
||||
# legacy ordering can be preserved.
|
||||
if [ -r "$DAHDICONFDIR/assigned-spans.conf" ]; then
|
||||
dahdi_span_assignments add "/sys$DEVPATH"
|
||||
fi
|
|
@ -0,0 +1,28 @@
|
|||
#! /bin/sh
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Sanity check
|
||||
checkit=`"dahdi_cfg" --help 2>&1 | grep -- '-S' | wc -l`
|
||||
if [ "$checkit" != 1 ]; then
|
||||
echo "Bad dahdi_cfg (no -S support). Skipping"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_dahdi_cfg() {
|
||||
echo "dahdi_cfg: span $SPANNO <$BASECHAN-$ENDCHAN> ($DEVPATH)"
|
||||
dahdi_cfg -c "$cfg_file" -S "$SPANNO" -C "$BASECHAN-$ENDCHAN"
|
||||
}
|
||||
|
||||
# Configure DAHDI
|
||||
cfg_file="$DAHDICONFDIR/system.conf"
|
||||
if [ -r "$cfg_file" ]; then
|
||||
run_dahdi_cfg
|
||||
else
|
||||
echo "Using auto-generated config for dahdi_cfg"
|
||||
cfg_file='-'
|
||||
DAHDI_CONF_FILE="$cfg_file" dahdi_genconf system | run_dahdi_cfg
|
||||
fi
|
|
@ -0,0 +1,12 @@
|
|||
#! /bin/sh
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
fxotune_cfg='/etc/fxotune.conf'
|
||||
if [ -r "$fxotune_cfg" ]; then
|
||||
echo "fxotune: span $SPANNO <$BASECHAN-$ENDCHAN> ($DEVPATH)"
|
||||
fxotune -s -b "$BASECHAN" -e "$ENDCHAN"
|
||||
fi
|
|
@ -0,0 +1,14 @@
|
|||
#! /bin/sh
|
||||
|
||||
# This file, if installed under /usr/share/dahdi/span_config.d/ , will
|
||||
# attempt to add a newly-generated span to a running copy of Asterisk.
|
||||
# Asterisk has to be running (if not: it will pick the span on its
|
||||
# startup), and has to have the channels already configured.
|
||||
|
||||
if [ "$ACTION" != 'add' ]; then
|
||||
# Nothing to do here
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Add to asterisk
|
||||
asterisk -rx "dahdi create channels $BASECHAN $ENDCHAN"
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
PATH=/sbin:/usr/sbin:/bin:/usr/bin
|
||||
|
||||
cd /etc/sysconfig/network-scripts
|
||||
. network-functions
|
||||
|
||||
CONFIG=$1
|
||||
source_config
|
||||
|
||||
if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ -z "${MODE}" ]; then
|
||||
echo "No mode specified!"
|
||||
exit
|
||||
fi
|
||||
|
||||
sethdlc ${DEVICE} mode ${MODE}
|
||||
ifconfig ${DEVICE} ${IPADDR} pointopoint ${REMIP}
|
||||
route add -net ${NETWORK} netmask ${NETMASK} ${DEVICE}
|
||||
|
||||
# this is broken! it's only here to keep compatibility with old RH sytstems
|
||||
if [ "${GATEWAY}" != "" -a "${GATEWAY}" != "none" ]
|
||||
then
|
||||
route add default gw ${GATEWAY} metric 1 ${DEVICE}
|
||||
fi
|
||||
|
||||
. /etc/sysconfig/network
|
||||
|
||||
if [ "${GATEWAY}" != "" ]; then
|
||||
if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then
|
||||
# set up default gateway
|
||||
route add default gw ${GATEWAY}
|
||||
fi
|
||||
fi
|
||||
|
||||
/etc/sysconfig/network-scripts/ifup-post $1
|
|
@ -0,0 +1,24 @@
|
|||
#
|
||||
# Shell settings for Dahdi initialization scripts.
|
||||
# This replaces the old/per-platform files (/etc/sysconfig/zaptel,
|
||||
# /etc/defaults/zaptel)
|
||||
#
|
||||
|
||||
# The maximal timeout (seconds) to wait for udevd to finish generating
|
||||
# device nodes after the modules have loaded and before running dahdi_cfg.
|
||||
#DAHDI_DEV_TIMEOUT=40
|
||||
|
||||
# A list of modules to unload when stopping.
|
||||
# All of their dependencies will be unloaded as well.
|
||||
#DAHDI_UNLOAD_MODULES="" # Disable module unloading
|
||||
#DAHDI_UNLOAD_MODULES="dahdi echo" # If you use OSLEC
|
||||
|
||||
# Override settings for xpp_fxloader
|
||||
#XPP_FIRMWARE_DIR=/usr/share/dahdi
|
||||
#XPP_HOTPLUG_DISABLED=yes
|
||||
#XPP_HOTPLUG_DAHDI=yes
|
||||
#ASTERISK_SUPPORTS_DAHDI_HOTPLUG=yes
|
||||
|
||||
# Disable udev handling:
|
||||
#DAHDI_UDEV_DISABLE_DEVICES=yes
|
||||
#DAHDI_UDEV_DISABLE_SPANS=yes
|
|
@ -0,0 +1,323 @@
|
|||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2005-05-14.22
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=
|
||||
chgrpcmd=
|
||||
stripcmd=
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dstarg=
|
||||
no_target_directory=
|
||||
|
||||
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
-c (ignored)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test -n "$1"; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t) dstarg=$2
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-T) no_target_directory=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
*) # When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
test -n "$dir_arg$dstarg" && break
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$1"; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src ;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
src=
|
||||
|
||||
if test -d "$dst"; then
|
||||
mkdircmd=:
|
||||
chmodcmd=
|
||||
else
|
||||
mkdircmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dstarg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dstarg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst ;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dstarg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst/`basename "$src"`
|
||||
fi
|
||||
fi
|
||||
|
||||
# This sed command emulates the dirname command.
|
||||
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if test ! -d "$dstdir"; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
shift
|
||||
IFS=$oIFS
|
||||
|
||||
pathcomp=
|
||||
|
||||
while test $# -ne 0 ; do
|
||||
pathcomp=$pathcomp$1
|
||||
shift
|
||||
if test ! -d "$pathcomp"; then
|
||||
$mkdirprog "$pathcomp"
|
||||
# mkdir can fail with a `File exist' error in case several
|
||||
# install-sh are creating the directory concurrently. This
|
||||
# is OK.
|
||||
test -d "$pathcomp" || exit
|
||||
fi
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
$doit $mkdircmd "$dst" \
|
||||
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
|
||||
|
||||
else
|
||||
dstfile=`basename "$dst"`
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
$doit $cpprog "$src" "$dsttmp" &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| {
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
if test -f "$dstdir/$dstfile"; then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|
||||
|| {
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
}
|
||||
}
|
||||
fi || { (exit 1); exit 1; }
|
||||
done
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
{
|
||||
(exit 0); exit 0
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
|
@ -0,0 +1,49 @@
|
|||
CC=@CC@
|
||||
LD=@LD@
|
||||
HOSTCC=@HOSTCC@
|
||||
CFLAGS=@CFLAGS@
|
||||
LDFLAGS=@LDFLAGS@
|
||||
|
||||
INSTALL=@INSTALL@
|
||||
GREP=@GREP@
|
||||
SHELL=@SHELL@
|
||||
LN=@LN@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
|
||||
DOWNLOAD=@DOWNLOAD@
|
||||
|
||||
DAHDI_DEVMODE=@DAHDI_DEVMODE@
|
||||
DAHDI_DECLARATION_AFTER_STATEMENT=@DAHDI_DECLARATION_AFTER_STATEMENT@
|
||||
|
||||
PBX_NEWT=@PBX_NEWT@
|
||||
NEWT_LIB=@NEWT_LIB@
|
||||
NEWT_INCLUDE=@NEWT_INCLUDE@
|
||||
|
||||
PBX_USB=@PBX_USB@
|
||||
USB_LIB=@USB_LIB@
|
||||
USB_INCLUDE=@USB_INCLUDE@
|
||||
|
||||
PBX_HDLC=@PBX_HDLC@
|
||||
|
||||
DAHDI_INCLUDE=@DAHDI_INCLUDE@
|
||||
|
||||
USE_SELINUX=@USE_SELINUX@
|
||||
|
||||
PPPD_VERSION=@PPPD_VERSION@
|
||||
|
||||
ASCIIDOC=@ASCIIDOC@
|
|
@ -0,0 +1,4 @@
|
|||
# You should place any module parameters for your DAHDI modules here
|
||||
# Example:
|
||||
#
|
||||
# options wctdm24xxp latency=6
|
|
@ -0,0 +1,63 @@
|
|||
# Contains the list of modules to be loaded / unloaded by /etc/init.d/dahdi.
|
||||
#
|
||||
# NOTE: Please add/edit /etc/modprobe.d/dahdi or /etc/modprobe.conf if you
|
||||
# would like to add any module parameters.
|
||||
#
|
||||
# Format of this file: list of modules, each in its own line.
|
||||
# Anything after a '#' is ignore, likewise trailing and leading
|
||||
# whitespaces and empty lines.
|
||||
|
||||
# Digium TE205P/TE207P/TE210P/TE212P: PCI dual-port T1/E1/J1
|
||||
# Digium TE405P/TE407P/TE410P/TE412P: PCI quad-port T1/E1/J1
|
||||
# Digium TE220: PCI-Express dual-port T1/E1/J1
|
||||
# Digium TE420: PCI-Express quad-port T1/E1/J1
|
||||
wct4xxp
|
||||
|
||||
# Digium TE435
|
||||
# Digium TE235
|
||||
# Digium TE436
|
||||
# Digium TE236
|
||||
wcte43x
|
||||
|
||||
# Digium TE120P: PCI single-port T1/E1/J1
|
||||
# Digium TE121: PCI-Express single-port T1/E1/J1
|
||||
# Digium TE122: PCI single-port T1/E1/J1
|
||||
wcte12xp
|
||||
|
||||
# Digium TE131: PCI-Express single-port T1/E1/J1
|
||||
# Digium TE132: PCI single-port T1/E1/J1
|
||||
# Digium TE133: PCI-Express single-port T1/E1/J1 with hardware echocan
|
||||
# Digium TE134: PCI single-port T1/E1/J1 with hardware echocan
|
||||
wcte13xp
|
||||
|
||||
# Digium T100P: PCI single-port T1
|
||||
# Digium E100P: PCI single-port E1
|
||||
wct1xxp
|
||||
|
||||
# Digium TE110P: PCI single-port T1/E1/J1
|
||||
wcte11xp
|
||||
|
||||
# Digium TDM2400P/AEX2400: up to 24 analog ports
|
||||
# Digium TDM800P/AEX800: up to 8 analog ports
|
||||
# Digium TDM410P/AEX410: up to 4 analog ports
|
||||
wctdm24xxp
|
||||
|
||||
# Digium A4A/A4B/A8A/A8B
|
||||
wcaxx
|
||||
|
||||
# X100P - Single port FXO interface
|
||||
# X101P - Single port FXO interface
|
||||
wcfxo
|
||||
|
||||
# Digium TDM400P: up to 4 analog ports
|
||||
wctdm
|
||||
|
||||
# Digium B410P: 4 NT/TE BRI ports
|
||||
wcb4xxp
|
||||
|
||||
# Digium TC400B: G729 / G723 Transcoding Engine
|
||||
wctc4xxp
|
||||
|
||||
# Xorcom Astribank Devices
|
||||
xpp_usb
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ppp_defs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "bittest.h"
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
/* #define BLOCK_SIZE 2048 */
|
||||
#define BLOCK_SIZE 2041
|
||||
#define DEVICE "/dev/dahdi/channel"
|
||||
|
||||
static const char rcsid[] = "$Id$";
|
||||
char *prog_name;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <dahdi_chan>\n", prog_name);
|
||||
fprintf(stderr, " e.g.: %s /dev/dahdi/55\n", prog_name);
|
||||
fprintf(stderr, " %s 455\n", prog_name);
|
||||
fprintf(stderr, "%s version %s\n", prog_name, rcsid);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void print_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int x;
|
||||
printf("{ ");
|
||||
for (x=0;x<len;x++)
|
||||
printf("%02x ",buf[x]);
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
int channel_open(const char *name, int *bs)
|
||||
{
|
||||
int channo, fd;
|
||||
struct dahdi_params tp;
|
||||
struct stat filestat;
|
||||
|
||||
/* stat file, if character device, open it */
|
||||
channo = strtoul(name, NULL, 10);
|
||||
fd = stat(name, &filestat);
|
||||
if (!fd && S_ISCHR(filestat.st_mode)) {
|
||||
fd = open(name, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return -1;
|
||||
}
|
||||
/* try out the dahdi_specify interface */
|
||||
} else if (channo > 0) {
|
||||
fd = open(DEVICE, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(DEVICE);
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
|
||||
perror("DAHDI_SPECIFY ioctl failed");
|
||||
return -1;
|
||||
}
|
||||
/* die */
|
||||
} else {
|
||||
fprintf(stderr, "Specified channel is not a valid character "
|
||||
"device or channel number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, bs) < 0) {
|
||||
perror("SET_BLOCKSIZE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
|
||||
fprintf(stderr, "Unable to get channel parameters\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res, res1, x;
|
||||
int bs = BLOCK_SIZE;
|
||||
unsigned char c=0;
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
|
||||
prog_name = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
fd = channel_open(argv[1], &bs);
|
||||
if (fd < 0)
|
||||
exit(1);
|
||||
|
||||
ioctl(fd, DAHDI_GETEVENT);
|
||||
#if 0
|
||||
print_packet(outbuf, res);
|
||||
printf("FCS is %x, PPP_GOODFCS is %x\n",
|
||||
fcs,PPP_GOODFCS);
|
||||
#endif
|
||||
for(;;) {
|
||||
res = bs;
|
||||
for (x=0;x<bs;x++) {
|
||||
outbuf[x] = c;
|
||||
c = bit_next(c);
|
||||
}
|
||||
res1 = write(fd, outbuf, res);
|
||||
if (res1 < res) {
|
||||
int e;
|
||||
struct dahdi_spaninfo zi;
|
||||
res = ioctl(fd,DAHDI_GETEVENT,&e);
|
||||
if (res == -1)
|
||||
{
|
||||
perror("DAHDI_GETEVENT");
|
||||
exit(1);
|
||||
}
|
||||
if (e == DAHDI_EVENT_NOALARM)
|
||||
printf("ALARMS CLEARED\n");
|
||||
if (e == DAHDI_EVENT_ALARM)
|
||||
{
|
||||
zi.spanno = 0;
|
||||
res = ioctl(fd,DAHDI_SPANSTAT,&zi);
|
||||
if (res == -1)
|
||||
{
|
||||
perror("DAHDI_SPANSTAT");
|
||||
exit(1);
|
||||
}
|
||||
printf("Alarm mask %x hex\n",zi.alarms);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#if 0
|
||||
printf("(%d) Wrote %d bytes\n", packets++, res);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,345 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This test sends a set of incrementing byte values out the specified
|
||||
* dadhi device. The device is then read back and the read back characters
|
||||
* are verified that they increment as well.
|
||||
* If there is a break in the incrementing pattern, an error is flagged
|
||||
* and the comparison starts at the last value read.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define BLOCK_SIZE 2039
|
||||
#define DEVICE "/dev/dahdi/channel"
|
||||
|
||||
#define CONTEXT_SIZE 7
|
||||
/* Prints a set of bytes in hex format */
|
||||
static void print_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int x;
|
||||
printf("{ ");
|
||||
for (x=0;x<len;x++)
|
||||
printf("%02x ",buf[x]);
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
/* Shows data immediately before and after the specified byte to provide context for an error */
|
||||
static void show_error_context(unsigned char *buf, int offset, int bufsize)
|
||||
{
|
||||
int low;
|
||||
int total = CONTEXT_SIZE;
|
||||
|
||||
if (offset >= bufsize || 0 >= bufsize || 0 > offset ) {
|
||||
return;
|
||||
}
|
||||
|
||||
low = offset - (CONTEXT_SIZE-1)/2;
|
||||
if (0 > low) {
|
||||
total += low;
|
||||
low = 0;
|
||||
}
|
||||
if (low + total > bufsize) {
|
||||
total = bufsize - low;
|
||||
}
|
||||
buf += low;
|
||||
printf("Offset %d ", low);
|
||||
print_packet(buf, total);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Shows how the program can be invoked */
|
||||
static void usage(const char * progname)
|
||||
{
|
||||
printf("%s: Pattern loop test\n", progname);
|
||||
printf("Usage: %s <dahdi device> [-t <secs>] [-r <count>] [-b <count>] [-vh?] \n", progname);
|
||||
printf("\t-? - Print this usage summary\n");
|
||||
printf("\t-t <secs> - # of seconds for the test to run\n");
|
||||
printf("\t-r <count> - # of test loops to run before a summary is printed\n");
|
||||
printf("\t-s <count> - # of writes to skip before testing for results\n");
|
||||
printf("\t-v - Verbosity (repetitive v's add to the verbosity level e.g. -vvvv)\n");
|
||||
printf("\t-b <# buffer bytes> - # of bytes to display from buffers on each pass\n");
|
||||
printf("\n\t Also accepts old style usage:\n\t %s <device name> [<timeout in secs>]\n", progname);
|
||||
}
|
||||
|
||||
int channel_open(const char *name, int *bs)
|
||||
{
|
||||
int channo, fd;
|
||||
struct dahdi_params tp;
|
||||
struct stat filestat;
|
||||
|
||||
/* stat file, if character device, open it */
|
||||
channo = strtoul(name, NULL, 10);
|
||||
fd = stat(name, &filestat);
|
||||
if (!fd && S_ISCHR(filestat.st_mode)) {
|
||||
fd = open(name, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return -1;
|
||||
}
|
||||
/* try out the dahdi_specify interface */
|
||||
} else if (channo > 0) {
|
||||
fd = open(DEVICE, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(DEVICE);
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
|
||||
perror("DAHDI_SPECIFY ioctl failed");
|
||||
return -1;
|
||||
}
|
||||
/* die */
|
||||
} else {
|
||||
fprintf(stderr, "Specified channel is not a valid character "
|
||||
"device or channel number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, bs) < 0) {
|
||||
perror("SET_BLOCKSIZE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
|
||||
fprintf(stderr, "Unable to get channel parameters\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res, x;
|
||||
int i;
|
||||
int bs = BLOCK_SIZE;
|
||||
int skipcount = 10;
|
||||
unsigned char c=0,c1=0;
|
||||
unsigned char inbuf[BLOCK_SIZE];
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
int setup=0;
|
||||
unsigned long bytes=0;
|
||||
int timeout=0;
|
||||
int loop_errorcount;
|
||||
int reportloops = 0;
|
||||
int buff_disp = 0;
|
||||
unsigned long currentloop = 0;
|
||||
unsigned long total_errorcount = 0;
|
||||
int verbose = 0;
|
||||
char * device;
|
||||
int opt;
|
||||
int oldstyle_cmdline = 1;
|
||||
unsigned int event_count = 0;
|
||||
|
||||
/* Parse the command line arguments */
|
||||
while((opt = getopt(argc, argv, "b:s:t:r:v?h")) != -1) {
|
||||
switch(opt) {
|
||||
case 'h':
|
||||
case '?':
|
||||
usage(argv[0]);
|
||||
exit(1);
|
||||
break;
|
||||
case 'b':
|
||||
buff_disp = strtoul(optarg, NULL, 10);
|
||||
if (BLOCK_SIZE < buff_disp) {
|
||||
buff_disp = BLOCK_SIZE;
|
||||
}
|
||||
oldstyle_cmdline = 0;
|
||||
break;
|
||||
case 'r':
|
||||
reportloops = strtoul(optarg, NULL, 10);
|
||||
oldstyle_cmdline = 0;
|
||||
break;
|
||||
case 's':
|
||||
skipcount = strtoul(optarg, NULL, 10);
|
||||
oldstyle_cmdline = 0;
|
||||
break;
|
||||
case 't':
|
||||
timeout = strtoul(optarg, NULL, 10);
|
||||
oldstyle_cmdline = 0;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
oldstyle_cmdline = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* If no device was specified */
|
||||
if(NULL == argv[optind]) {
|
||||
printf("You need to supply a dahdi device to test\n");
|
||||
usage(argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Get the dahdi device name */
|
||||
if (argv[optind])
|
||||
device = argv[optind];
|
||||
|
||||
/* To maintain backward compatibility with previous versions process old style command line */
|
||||
if (oldstyle_cmdline && argc > optind +1) {
|
||||
timeout = strtoul(argv[optind+1], NULL, 10);
|
||||
}
|
||||
|
||||
time_t start_time = 0;
|
||||
|
||||
fd = channel_open(device, &bs);
|
||||
if (fd < 0)
|
||||
exit(1);
|
||||
ioctl(fd, DAHDI_GETEVENT);
|
||||
|
||||
i = DAHDI_FLUSH_ALL;
|
||||
if (ioctl(fd,DAHDI_FLUSH,&i) == -1) {
|
||||
perror("DAHDI_FLUSH");
|
||||
exit(255);
|
||||
}
|
||||
|
||||
/* Mark time if program has a specified timeout */
|
||||
if(0 < timeout){
|
||||
start_time = time(NULL);
|
||||
printf("Using Timeout of %d Seconds\n",timeout);
|
||||
}
|
||||
|
||||
/* ********* MAIN TESTING LOOP ************ */
|
||||
for(;;) {
|
||||
/* Prep the data and write it out to dahdi device */
|
||||
res = bs;
|
||||
for (x = 0; x < bs; x++) {
|
||||
outbuf[x] = c1++;
|
||||
}
|
||||
|
||||
write_again:
|
||||
res = write(fd,outbuf,bs);
|
||||
if (res != bs) {
|
||||
if (ELAST == errno) {
|
||||
ioctl(fd, DAHDI_GETEVENT, &x);
|
||||
if (event_count > 0)
|
||||
printf("Event: %d\n", x);
|
||||
++event_count;
|
||||
} else {
|
||||
printf("W: Res is %d: %s\n", res, strerror(errno));
|
||||
}
|
||||
goto write_again;
|
||||
}
|
||||
|
||||
/* If this is the start of the test then skip a number of packets before test results */
|
||||
if (skipcount) {
|
||||
if (skipcount > 1) {
|
||||
res = read(fd,inbuf,bs);
|
||||
}
|
||||
skipcount--;
|
||||
if (!skipcount) {
|
||||
printf("Going for it...\n");
|
||||
}
|
||||
i = 1;
|
||||
ioctl(fd,DAHDI_BUFFER_EVENTS, &i);
|
||||
continue;
|
||||
}
|
||||
|
||||
read_again:
|
||||
res = read(fd, inbuf, bs);
|
||||
if (res < bs) {
|
||||
printf("R: Res is %d\n", res);
|
||||
ioctl(fd, DAHDI_GETEVENT, &x);
|
||||
printf("Event: %d\n", x);
|
||||
goto read_again;
|
||||
}
|
||||
/* If first time through, set byte that is used to test further bytes */
|
||||
if (!setup) {
|
||||
c = inbuf[0];
|
||||
setup++;
|
||||
}
|
||||
/* Test the packet read back for data pattern */
|
||||
loop_errorcount = 0;
|
||||
for (x = 0; x < bs; x++) {
|
||||
/* if error */
|
||||
if (inbuf[x] != c) {
|
||||
total_errorcount++;
|
||||
loop_errorcount++;
|
||||
if (oldstyle_cmdline) {
|
||||
printf("(Error %ld): Unexpected result, %d != %d, %ld bytes since last error.\n", total_errorcount, inbuf[x],c, bytes);
|
||||
} else {
|
||||
if (1 <= verbose) {
|
||||
printf("Error %ld (loop %ld, offset %d, error %d): Unexpected result, Read: 0x%02x, Expected 0x%02x.\n",
|
||||
total_errorcount,
|
||||
currentloop,
|
||||
x,
|
||||
loop_errorcount,
|
||||
inbuf[x],
|
||||
c);
|
||||
}
|
||||
if (2 <= verbose) {
|
||||
show_error_context(inbuf, x, bs);
|
||||
}
|
||||
}
|
||||
/* Reset the expected data to what was just read. so test can resynch on skipped data */
|
||||
c = inbuf[x];
|
||||
bytes=0; /* Reset the count from the last encountered error */
|
||||
}
|
||||
c++;
|
||||
bytes++;
|
||||
}
|
||||
/* If the user wants to see some of each buffer transaction */
|
||||
if (0 < buff_disp) {
|
||||
printf("Buffer Display %d (errors =%d)\nIN: ", buff_disp, loop_errorcount);
|
||||
print_packet(inbuf, 64);
|
||||
printf("OUT:");
|
||||
print_packet(outbuf, 64);
|
||||
}
|
||||
|
||||
currentloop++;
|
||||
/* Update stats if the user has specified it */
|
||||
if (0 < reportloops && 0 == (currentloop % reportloops)) {
|
||||
printf("Status on loop %lu: Total errors = %lu\n", currentloop, total_errorcount);
|
||||
|
||||
}
|
||||
#if 0
|
||||
printf("(%d) Wrote %d bytes\n", packets++, res);
|
||||
#endif
|
||||
if(timeout && (time(NULL)-start_time) > timeout){
|
||||
printf("Timeout achieved Ending Program\n");
|
||||
printf("Test ran %ld loops of %d bytes/loop with %ld errors\n", currentloop, bs, total_errorcount);
|
||||
return total_errorcount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ppp_defs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "bittest.h"
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define BLOCK_SIZE 2039
|
||||
#define DEVICE "/dev/dahdi/channel"
|
||||
|
||||
static const char rcsid[] = "$Id$";
|
||||
char *prog_name;
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <dahdi_chan>\n", prog_name);
|
||||
fprintf(stderr, " e.g.: %s /dev/dahdi/55\n", prog_name);
|
||||
fprintf(stderr, " %s 455\n", prog_name);
|
||||
fprintf(stderr, "%s version %s\n", prog_name, rcsid);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void print_packet(unsigned char *buf, int len)
|
||||
{
|
||||
int x;
|
||||
printf("{ ");
|
||||
for (x=0;x<len;x++)
|
||||
printf("%02x ",buf[x]);
|
||||
printf("}\n");
|
||||
}
|
||||
|
||||
int channel_open(const char *name, int *bs)
|
||||
{
|
||||
int channo, fd;
|
||||
struct dahdi_params tp;
|
||||
struct stat filestat;
|
||||
|
||||
/* stat file, if character device, open it */
|
||||
channo = strtoul(name, NULL, 10);
|
||||
fd = stat(name, &filestat);
|
||||
if (!fd && S_ISCHR(filestat.st_mode)) {
|
||||
fd = open(name, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(name);
|
||||
return -1;
|
||||
}
|
||||
/* try out the dahdi_specify interface */
|
||||
} else if (channo > 0) {
|
||||
fd = open(DEVICE, O_RDWR, 0600);
|
||||
if (fd < 0) {
|
||||
perror(DEVICE);
|
||||
return -1;
|
||||
}
|
||||
if (ioctl(fd, DAHDI_SPECIFY, &channo) < 0) {
|
||||
perror("DAHDI_SPECIFY ioctl failed");
|
||||
return -1;
|
||||
}
|
||||
/* die */
|
||||
} else {
|
||||
fprintf(stderr, "Specified channel is not a valid character "
|
||||
"device or channel number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_SET_BLOCKSIZE, bs) < 0) {
|
||||
perror("SET_BLOCKSIZE");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ioctl(fd, DAHDI_GET_PARAMS, &tp)) {
|
||||
fprintf(stderr, "Unable to get channel parameters\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int res, x;
|
||||
int bs = BLOCK_SIZE;
|
||||
unsigned char c=0;
|
||||
unsigned char outbuf[BLOCK_SIZE];
|
||||
int setup=0;
|
||||
int errors=0;
|
||||
int bytes=0;
|
||||
|
||||
prog_name = argv[0];
|
||||
|
||||
if (argc < 2) {
|
||||
usage();
|
||||
}
|
||||
|
||||
fd = channel_open(argv[1], &bs);
|
||||
if (fd < 0)
|
||||
exit(1);
|
||||
|
||||
ioctl(fd, DAHDI_GETEVENT);
|
||||
for(;;) {
|
||||
res = bs;
|
||||
res = read(fd, outbuf, res);
|
||||
if (res < bs) {
|
||||
int e;
|
||||
struct dahdi_spaninfo zi;
|
||||
res = ioctl(fd,DAHDI_GETEVENT,&e);
|
||||
if (res == -1)
|
||||
{
|
||||
perror("DAHDI_GETEVENT");
|
||||
exit(1);
|
||||
}
|
||||
if (e == DAHDI_EVENT_NOALARM)
|
||||
printf("ALARMS CLEARED\n");
|
||||
if (e == DAHDI_EVENT_ALARM)
|
||||
{
|
||||
zi.spanno = 0;
|
||||
res = ioctl(fd,DAHDI_SPANSTAT,&zi);
|
||||
if (res == -1)
|
||||
{
|
||||
perror("DAHDI_SPANSTAT");
|
||||
exit(1);
|
||||
}
|
||||
printf("Alarm mask %x hex\n",zi.alarms);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!setup) {
|
||||
c = outbuf[0];
|
||||
setup++;
|
||||
}
|
||||
for (x=0;x<bs;x++) {
|
||||
if (outbuf[x] != c) {
|
||||
printf("(Error %d): Unexpected result, %d != %d, %d bytes since last error.\n", ++errors, outbuf[x], c, bytes);
|
||||
c = outbuf[x];
|
||||
bytes=0;
|
||||
}
|
||||
c = bit_next(c);
|
||||
bytes++;
|
||||
}
|
||||
#if 0
|
||||
printf("(%d) Wrote %d bytes\n", packets++, res);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
#COPTS = -O2 -g
|
||||
|
||||
-include ../makeopts
|
||||
|
||||
CFLAGS += $(COPTS) -fPIC
|
||||
LDFLAGS += -shared
|
||||
|
||||
INCLUDE_DIR = $(includedir)/pppd
|
||||
|
||||
LIBDIR = $(libdir)/pppd/$(PPPD_VERSION)
|
||||
|
||||
PLUGINS := dahdi.so
|
||||
|
||||
all: $(PLUGINS)
|
||||
|
||||
%.so: %.c
|
||||
ifeq (,$(PPPD_VERSION))
|
||||
@echo "pppd version not found (in patchlevel.h)."
|
||||
@echo "Install ppp source/headers and/or ./configure --with-ppp=PATH."
|
||||
exit 1
|
||||
endif
|
||||
$(CC) -o $@ $(CFLAGS) $^ $(LDFLAGS)
|
||||
|
||||
install: $(PLUGINS)
|
||||
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m 0644 $? $(DESTDIR)$(LIBDIR)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.a
|
|
@ -0,0 +1,293 @@
|
|||
/* dahdi.c - pppd plugin to implement PPP over DAHDI HDLC channel.
|
||||
*
|
||||
* Copyright 2002 Digium, Inc.
|
||||
* Mark Spencer <markster@digium.inc>
|
||||
*
|
||||
* Borrows from PPPoE by Michal Ostrowski <mostrows@styx.uwaterloo.ca>,
|
||||
* Jamal Hadi Salim <hadi@cyberus.ca>
|
||||
*
|
||||
* which in turn...
|
||||
*
|
||||
* Borrows heavily from the PPPoATM plugin by Mitchell Blank Jr.,
|
||||
* which is based in part on work from Jens Axboe and Paul Mackerras.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <pppd/pppd.h>
|
||||
#include <pppd/fsm.h>
|
||||
#include <pppd/lcp.h>
|
||||
#include <pppd/ipcp.h>
|
||||
#include <pppd/ccp.h>
|
||||
#include <pppd/pathnames.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
|
||||
extern int new_style_driver;
|
||||
|
||||
const char pppd_version[] = VERSION;
|
||||
|
||||
#define _PATH_DAHDI_OPT _ROOT_PATH "/etc/ppp/options."
|
||||
|
||||
#define DAHDI_MTU (DAHDI_DEFAULT_MTU_MRU - 16)
|
||||
extern int kill_link;
|
||||
int retries = 0;
|
||||
|
||||
int setdevname_dahdi(const char *cp);
|
||||
|
||||
static option_t dahdi_options[] = {
|
||||
{ "device name", o_wild, (void *) &setdevname_dahdi,
|
||||
"Serial port device name",
|
||||
OPT_DEVNAM | OPT_PRIVFIX | OPT_NOARG | OPT_A2STRVAL | OPT_STATIC,
|
||||
devnam},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int dahdi_fd = -1;
|
||||
static int dahdi_chan = 0;
|
||||
|
||||
static int connect_dahdi(void)
|
||||
{
|
||||
|
||||
struct dahdi_params dahdi_params;
|
||||
int res;
|
||||
int x;
|
||||
|
||||
info("DAHDI device is '%s'\n", devnam);
|
||||
|
||||
strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
|
||||
|
||||
if (strlen(devnam) && strcmp(devnam, "stdin")) {
|
||||
/* Get the channel number */
|
||||
dahdi_chan = atoi(devnam);
|
||||
if (dahdi_chan < 1) {
|
||||
fatal("'%s' is not a valid device name\n", devnam);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Open /dev/dahdi/channel interface */
|
||||
dahdi_fd = open("/dev/dahdi/channel", O_RDWR);
|
||||
if (dahdi_fd < 0) {
|
||||
fatal("Unable to open DAHDI channel interface: '%s'\n", strerror(errno));
|
||||
return dahdi_fd;
|
||||
}
|
||||
|
||||
/* Specify which channel we really want */
|
||||
x = dahdi_chan;
|
||||
res = ioctl(dahdi_fd, DAHDI_SPECIFY, &x);
|
||||
if (res) {
|
||||
fatal("Unable to specify channel %d: %s\n", dahdi_chan, strerror(errno));
|
||||
close(dahdi_fd);
|
||||
dahdi_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
} else
|
||||
dahdi_fd = STDIN_FILENO;
|
||||
|
||||
|
||||
/* Get channel parameters */
|
||||
memset(&dahdi_params, 0, sizeof(dahdi_params));
|
||||
dahdi_params.channo = -1;
|
||||
|
||||
res = ioctl(dahdi_fd, DAHDI_GET_PARAMS, &dahdi_params);
|
||||
|
||||
if (res) {
|
||||
fatal("Device '%s' does not appear to be a DAHDI device\n", devnam ? devnam : "<stdin>");
|
||||
}
|
||||
|
||||
x = 1;
|
||||
|
||||
/* Throw into HDLC/PPP mode */
|
||||
res = ioctl(dahdi_fd, DAHDI_HDLCPPP, &x);
|
||||
|
||||
if (res) {
|
||||
fatal("Unable to put device '%s' into HDLC mode\n", devnam);
|
||||
close(dahdi_fd);
|
||||
dahdi_fd = -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Once the logging is fixed, print a message here indicating
|
||||
connection parameters */
|
||||
dahdi_chan = dahdi_params.channo;
|
||||
info("Connected to DAHDI device '%s' (%d)\n", dahdi_params.name, dahdi_params.channo);
|
||||
|
||||
return dahdi_fd;
|
||||
}
|
||||
|
||||
static void disconnect_dahdi(void)
|
||||
{
|
||||
int res;
|
||||
int x = 0;
|
||||
/* Throw out of HDLC mode */
|
||||
res = ioctl(dahdi_fd, DAHDI_HDLCPPP, &x);
|
||||
|
||||
if (res) {
|
||||
warn("Unable to take device '%s' out of HDLC mode\n", devnam);
|
||||
}
|
||||
|
||||
/* Close if it's not stdin */
|
||||
if (strlen(devnam))
|
||||
close(dahdi_fd);
|
||||
warn("Disconnect from DAHDI");
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int setspeed_dahdi(const char *cp)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void dahdi_extra_options()
|
||||
{
|
||||
int ret;
|
||||
char buf[256];
|
||||
snprintf(buf, 256, _PATH_DAHDI_OPT "%s",devnam);
|
||||
if(!options_from_file(buf, 0, 0, 1))
|
||||
exit(EXIT_OPTION_ERROR);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void send_config_dahdi(int mtu,
|
||||
u_int32_t asyncmap,
|
||||
int pcomp,
|
||||
int accomp)
|
||||
{
|
||||
int sock;
|
||||
|
||||
if (mtu > DAHDI_MTU) {
|
||||
warn("Couldn't increase MTU to %d.", mtu);
|
||||
mtu = DAHDI_MTU;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void recv_config_dahdi(int mru,
|
||||
u_int32_t asyncmap,
|
||||
int pcomp,
|
||||
int accomp)
|
||||
{
|
||||
if (mru > DAHDI_MTU)
|
||||
error("Couldn't increase MRU to %d", mru);
|
||||
}
|
||||
|
||||
static void set_xaccm_pppoe(int unit, ext_accm accm)
|
||||
{
|
||||
/* NOTHING */
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct channel dahdi_channel;
|
||||
|
||||
/* Check is cp is a valid DAHDI device
|
||||
* return either 1 if "cp" is a reasonable thing to name a device
|
||||
* or die.
|
||||
* Note that we don't actually open the device at this point
|
||||
* We do need to fill in:
|
||||
* devnam: a string representation of the device
|
||||
*/
|
||||
|
||||
int (*old_setdevname_hook)(const char* cp) = NULL;
|
||||
int setdevname_dahdi(const char *cp)
|
||||
{
|
||||
int ret;
|
||||
int chan;
|
||||
|
||||
/* If already set, forgoe */
|
||||
if (strlen(devnam))
|
||||
return 1;
|
||||
|
||||
|
||||
if (strcmp(cp, "stdin")) {
|
||||
ret = sscanf(cp, "%d", &chan);
|
||||
if (ret != 1) {
|
||||
fatal("DAHDI: Invalid channel: '%s'\n", cp);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dahdi_copy_string(devnam, cp, sizeof(devnam));
|
||||
|
||||
info("Using DAHDI device '%s'\n", devnam);
|
||||
|
||||
ret = 1;
|
||||
|
||||
if( ret == 1 && the_channel != &dahdi_channel ){
|
||||
|
||||
the_channel = &dahdi_channel;
|
||||
|
||||
modem = 0;
|
||||
|
||||
lcp_allowoptions[0].neg_accompression = 0;
|
||||
lcp_wantoptions[0].neg_accompression = 0;
|
||||
|
||||
lcp_allowoptions[0].neg_pcompression = 0;
|
||||
lcp_wantoptions[0].neg_pcompression = 0;
|
||||
|
||||
ccp_allowoptions[0].deflate = 0 ;
|
||||
ccp_wantoptions[0].deflate = 0 ;
|
||||
|
||||
ipcp_allowoptions[0].neg_vj=0;
|
||||
ipcp_wantoptions[0].neg_vj=0;
|
||||
|
||||
ccp_allowoptions[0].bsd_compress = 0;
|
||||
ccp_wantoptions[0].bsd_compress = 0;
|
||||
|
||||
lcp_allowoptions[0].neg_asyncmap = 0;
|
||||
lcp_wantoptions[0].neg_asyncmap = 0;
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void plugin_init(void)
|
||||
{
|
||||
if (!ppp_available() && !new_style_driver)
|
||||
fatal("Kernel doesn't support ppp_generic needed for DAHDI PPP");
|
||||
add_options(dahdi_options);
|
||||
|
||||
info("DAHDI Plugin Initialized");
|
||||
}
|
||||
|
||||
struct channel dahdi_channel = {
|
||||
options: dahdi_options,
|
||||
process_extra_options: &dahdi_extra_options,
|
||||
check_options: NULL,
|
||||
connect: &connect_dahdi,
|
||||
disconnect: &disconnect_dahdi,
|
||||
establish_ppp: &generic_establish_ppp,
|
||||
disestablish_ppp: &generic_disestablish_ppp,
|
||||
send_config: &send_config_dahdi,
|
||||
recv_config: &recv_config_dahdi,
|
||||
close: NULL,
|
||||
cleanup: NULL
|
||||
};
|
||||
|
|
@ -0,0 +1,704 @@
|
|||
/*
|
||||
* sethdlc.c
|
||||
*
|
||||
* Copyright (C) 1999 - 2002 Krzysztof Halasa <khc@pm.waw.pl>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <asm/types.h>
|
||||
#include <linux/hdlc.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/if.h>
|
||||
#include <linux/sockios.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#if GENERIC_HDLC_VERSION != 4
|
||||
#error Generic HDLC layer version mismatch, please get correct sethdlc.c
|
||||
#endif
|
||||
|
||||
#if !defined(IF_PROTO_HDLC_ETH) || !defined(IF_PROTO_FR_ETH_PVC)
|
||||
#warning "No kernel support for Ethernet over Frame Relay / HDLC, skipping it"
|
||||
#endif
|
||||
|
||||
|
||||
static struct ifreq req; /* for ioctl */
|
||||
static int argc;
|
||||
static char **argv;
|
||||
int sock;
|
||||
|
||||
|
||||
static void error(const char *format, ...) __attribute__ ((noreturn, format(printf, 1, 2)));
|
||||
|
||||
static void error(const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, format);
|
||||
fprintf(stderr, "%s: ", req.ifr_name);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const unsigned int value;
|
||||
} parsertab;
|
||||
|
||||
|
||||
|
||||
static int checkkey(const char* name)
|
||||
{
|
||||
if (argc < 1)
|
||||
return -1; /* no enough parameters */
|
||||
|
||||
if (strcmp(name, argv[0]))
|
||||
return -1;
|
||||
argc--;
|
||||
argv++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int checktab(parsertab *tab, unsigned int *value)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc < 1)
|
||||
return -1; /* no enough parameters */
|
||||
|
||||
for (i = 0; tab[i].name; i++)
|
||||
if (!strcmp(tab[i].name, argv[0])) {
|
||||
argc--;
|
||||
argv++;
|
||||
*value = tab[i].value;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1; /* Not found */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const char* tabstr(unsigned int value, parsertab *tab,
|
||||
const char* unknown)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; tab[i].name; i++)
|
||||
if (tab[i].value == value)
|
||||
return tab[i].name;
|
||||
|
||||
return unknown; /* Not found */
|
||||
}
|
||||
|
||||
|
||||
|
||||
static unsigned int match(const char* name, unsigned int *value,
|
||||
unsigned int minimum, unsigned int maximum)
|
||||
{
|
||||
char test;
|
||||
|
||||
if (argc < 1)
|
||||
return -1; /* no enough parameters */
|
||||
|
||||
if (name) {
|
||||
if (strcmp(name, argv[0]))
|
||||
return -1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
error("Missing parameter\n");
|
||||
|
||||
if (sscanf(argv[0], "%u%c", value, &test) != 1)
|
||||
error("Invalid parameter: %s\n", argv[0]);
|
||||
|
||||
if ((*value > maximum) || (*value < minimum))
|
||||
error("Parameter out of range [%u - %u]: %u\n",
|
||||
minimum, maximum, *value);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static parsertab ifaces[] = {{ "v35", IF_IFACE_V35 },
|
||||
{ "v24", IF_IFACE_V24 },
|
||||
{ "x21", IF_IFACE_X21 },
|
||||
{ "e1", IF_IFACE_E1 },
|
||||
{ "t1", IF_IFACE_T1 },
|
||||
{ NULL, 0 }};
|
||||
|
||||
static parsertab clocks[] = {{ "int", CLOCK_INT },
|
||||
{ "ext", CLOCK_EXT },
|
||||
{ "txint", CLOCK_TXINT },
|
||||
{ "txfromrx", CLOCK_TXFROMRX },
|
||||
{ NULL, 0 }};
|
||||
|
||||
|
||||
static parsertab protos[] = {{ "hdlc", IF_PROTO_HDLC},
|
||||
{ "cisco", IF_PROTO_CISCO},
|
||||
{ "fr", IF_PROTO_FR},
|
||||
{ "ppp", IF_PROTO_PPP},
|
||||
{ "x25", IF_PROTO_X25},
|
||||
#ifdef IF_PROTO_HDLC_ETH
|
||||
{ "hdlc-eth", IF_PROTO_HDLC_ETH},
|
||||
#endif
|
||||
{ NULL, 0 }};
|
||||
|
||||
|
||||
static parsertab hdlc_enc[] = {{ "nrz", ENCODING_NRZ },
|
||||
{ "nrzi", ENCODING_NRZI },
|
||||
{ "fm-mark", ENCODING_FM_MARK },
|
||||
{ "fm-space", ENCODING_FM_SPACE },
|
||||
{ "manchester", ENCODING_MANCHESTER },
|
||||
{ NULL, 0 }};
|
||||
|
||||
static parsertab hdlc_par[] = {{ "no-parity", PARITY_NONE },
|
||||
{ "crc16", PARITY_CRC16_PR1 },
|
||||
{ "crc16-pr0", PARITY_CRC16_PR0 },
|
||||
{ "crc16-itu", PARITY_CRC16_PR1_CCITT },
|
||||
{ "crc16-itu-pr0", PARITY_CRC16_PR0_CCITT },
|
||||
{ "crc32-itu", PARITY_CRC32_PR1_CCITT },
|
||||
{ NULL, 0 }};
|
||||
|
||||
static parsertab lmi[] = {{ "none", LMI_NONE },
|
||||
{ "ansi", LMI_ANSI },
|
||||
{ "ccitt", LMI_CCITT },
|
||||
{ NULL, 0 }};
|
||||
|
||||
|
||||
static void set_iface(void)
|
||||
{
|
||||
int orig_argc = argc;
|
||||
te1_settings te1;
|
||||
|
||||
memset(&te1, 0, sizeof(te1));
|
||||
req.ifr_settings.type = IF_IFACE_SYNC_SERIAL;
|
||||
|
||||
while (argc > 0) {
|
||||
if (req.ifr_settings.type == IF_IFACE_SYNC_SERIAL)
|
||||
if (!checktab(ifaces, &req.ifr_settings.type))
|
||||
continue;
|
||||
|
||||
if (!te1.clock_type)
|
||||
if (!checkkey("clock")) {
|
||||
if (!checktab(clocks, &te1.clock_type))
|
||||
continue;
|
||||
error("Invalid clock type\n");
|
||||
}
|
||||
|
||||
if (!te1.clock_rate &&
|
||||
(te1.clock_type == CLOCK_INT ||
|
||||
te1.clock_type == CLOCK_TXINT))
|
||||
if (!match("rate", &te1.clock_rate, 1, 0xFFFFFFFF))
|
||||
continue;
|
||||
if (!te1.loopback) {
|
||||
if (!checkkey("loopback") ||
|
||||
!checkkey("lb")) {
|
||||
te1.loopback = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/* slotmap goes here */
|
||||
|
||||
if (orig_argc == argc)
|
||||
return; /* not an iface definition */
|
||||
error("Invalid parameter: %s\n", argv[0]);
|
||||
}
|
||||
|
||||
if (!te1.clock_rate &&
|
||||
(te1.clock_type == CLOCK_INT ||
|
||||
te1.clock_type == CLOCK_TXINT))
|
||||
te1.clock_rate = 64000;
|
||||
|
||||
/* FIXME stupid hack, will remove it later */
|
||||
req.ifr_settings.ifs_ifsu.te1 = &te1;
|
||||
if (req.ifr_settings.type == IF_IFACE_E1 ||
|
||||
req.ifr_settings.type == IF_IFACE_T1)
|
||||
req.ifr_settings.size = sizeof(te1_settings);
|
||||
else
|
||||
req.ifr_settings.size = sizeof(sync_serial_settings);
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
error("Unable to set interface information: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_proto_fr(void)
|
||||
{
|
||||
unsigned int lmi_type = 0;
|
||||
fr_proto fr;
|
||||
|
||||
memset(&fr, 0, sizeof(fr));
|
||||
|
||||
while (argc > 0) {
|
||||
if (!lmi_type)
|
||||
if (!checkkey("lmi")) {
|
||||
if (!checktab(lmi, &lmi_type))
|
||||
continue;
|
||||
error("Invalid LMI type: %s\n",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
if (lmi_type && lmi_type != LMI_NONE) {
|
||||
if (!fr.dce)
|
||||
if (!checkkey("dce")) {
|
||||
fr.dce = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!fr.t391)
|
||||
if (!match("t391", &fr.t391,
|
||||
1, 1000))
|
||||
continue;
|
||||
if (!fr.t392)
|
||||
if (!match("t392", &fr.t392,
|
||||
1, 1000))
|
||||
continue;
|
||||
if (!fr.n391)
|
||||
if (!match("n391", &fr.n391,
|
||||
1, 1000))
|
||||
continue;
|
||||
if (!fr.n392)
|
||||
if (!match("n392", &fr.n392,
|
||||
1, 1000))
|
||||
continue;
|
||||
if (!fr.n393)
|
||||
if (!match("n393", &fr.n393,
|
||||
1, 1000))
|
||||
continue;
|
||||
}
|
||||
error("Invalid parameter: %s\n", argv[0]);
|
||||
}
|
||||
|
||||
/* polling verification timer*/
|
||||
if (!fr.t391) fr.t391 = 10;
|
||||
/* link integrity verification polling timer */
|
||||
if (!fr.t392) fr.t392 = 15;
|
||||
/* full status polling counter*/
|
||||
if (!fr.n391) fr.n391 = 6;
|
||||
/* error threshold */
|
||||
if (!fr.n392) fr.n392 = 3;
|
||||
/* monitored events count */
|
||||
if (!fr.n393) fr.n393 = 4;
|
||||
|
||||
if (!lmi_type)
|
||||
fr.lmi = LMI_DEFAULT;
|
||||
else
|
||||
fr.lmi = lmi_type;
|
||||
|
||||
req.ifr_settings.ifs_ifsu.fr = &fr;
|
||||
req.ifr_settings.size = sizeof(fr);
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
error("Unable to set FR protocol information: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_proto_hdlc(int eth)
|
||||
{
|
||||
unsigned int enc = 0, par = 0;
|
||||
raw_hdlc_proto raw;
|
||||
|
||||
memset(&raw, 0, sizeof(raw));
|
||||
|
||||
while (argc > 0) {
|
||||
if (!enc)
|
||||
if (!checktab(hdlc_enc, &enc))
|
||||
continue;
|
||||
if (!par)
|
||||
if (!checktab(hdlc_par, &par))
|
||||
continue;
|
||||
|
||||
error("Invalid parameter: %s\n", argv[0]);
|
||||
}
|
||||
|
||||
if (!enc)
|
||||
raw.encoding = ENCODING_DEFAULT;
|
||||
else
|
||||
raw.encoding = enc;
|
||||
|
||||
if (!par)
|
||||
raw.parity = ENCODING_DEFAULT;
|
||||
else
|
||||
raw.parity = par;
|
||||
|
||||
req.ifr_settings.ifs_ifsu.raw_hdlc = &raw;
|
||||
req.ifr_settings.size = sizeof(raw);
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
error("Unable to set HDLC%s protocol information: %s\n",
|
||||
eth ? "-ETH" : "", strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_proto_cisco(void)
|
||||
{
|
||||
cisco_proto cisco;
|
||||
memset(&cisco, 0, sizeof(cisco));
|
||||
|
||||
while (argc > 0) {
|
||||
if (!cisco.interval)
|
||||
if (!match("interval", &cisco.interval,
|
||||
1, 100))
|
||||
continue;
|
||||
if (!cisco.timeout)
|
||||
if (!match("timeout", &cisco.timeout,
|
||||
1, 100))
|
||||
continue;
|
||||
|
||||
error("Invalid parameter: %s\n",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
if (!cisco.interval)
|
||||
cisco.interval = 10;
|
||||
if (!cisco.timeout)
|
||||
cisco.timeout = 25;
|
||||
|
||||
req.ifr_settings.ifs_ifsu.cisco = &cisco;
|
||||
req.ifr_settings.size = sizeof(cisco);
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
error("Unable to set Cisco HDLC protocol information: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_proto(void)
|
||||
{
|
||||
if (checktab(protos, &req.ifr_settings.type))
|
||||
return;
|
||||
|
||||
switch(req.ifr_settings.type) {
|
||||
case IF_PROTO_HDLC: set_proto_hdlc(0); break;
|
||||
#ifdef IF_PROTO_HDLC_ETH
|
||||
case IF_PROTO_HDLC_ETH: set_proto_hdlc(1); break;
|
||||
#endif
|
||||
case IF_PROTO_CISCO: set_proto_cisco(); break;
|
||||
case IF_PROTO_FR: set_proto_fr(); break;
|
||||
|
||||
case IF_PROTO_PPP:
|
||||
case IF_PROTO_X25:
|
||||
req.ifr_settings.ifs_ifsu.sync = NULL; /* FIXME */
|
||||
req.ifr_settings.size = 0;
|
||||
|
||||
if (!ioctl(sock, SIOCWANDEV, &req))
|
||||
break;
|
||||
|
||||
error("Unable to set %s protocol information: %s\n",
|
||||
req.ifr_settings.type == IF_PROTO_PPP
|
||||
? "PPP" : "X.25", strerror(errno));
|
||||
|
||||
default: error("Unknown protocol %u\n", req.ifr_settings.type);
|
||||
}
|
||||
|
||||
if (argc > 0)
|
||||
error("Unexpected parameter: %s\n", argv[0]);
|
||||
|
||||
close(sock);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void set_pvc(void)
|
||||
{
|
||||
char *op = argv[0];
|
||||
parsertab ops[] = {{ "create", IF_PROTO_FR_ADD_PVC },
|
||||
{ "delete", IF_PROTO_FR_DEL_PVC },
|
||||
{ NULL, 0 }};
|
||||
fr_proto_pvc pvc;
|
||||
|
||||
memset(&pvc, 0, sizeof(pvc));
|
||||
|
||||
if (checktab(ops, &req.ifr_settings.type))
|
||||
return;
|
||||
|
||||
#ifdef IF_PROTO_FR_ETH_PVC
|
||||
if (!match("ether", &pvc.dlci, 0, 1023)) {
|
||||
if (req.ifr_settings.type == IF_PROTO_FR_ADD_PVC)
|
||||
req.ifr_settings.type = IF_PROTO_FR_ADD_ETH_PVC;
|
||||
else
|
||||
req.ifr_settings.type = IF_PROTO_FR_DEL_ETH_PVC;
|
||||
|
||||
} else
|
||||
#endif
|
||||
if (match(NULL, &pvc.dlci, 0, 1023))
|
||||
return;
|
||||
|
||||
if (argc != 0)
|
||||
return;
|
||||
|
||||
req.ifr_settings.ifs_ifsu.fr_pvc = &pvc;
|
||||
req.ifr_settings.size = sizeof(pvc);
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
error("Unable to %s PVC: %s\n", op, strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void private(void)
|
||||
{
|
||||
if (argc < 1)
|
||||
return;
|
||||
|
||||
if (!strcmp(argv[0], "private")) {
|
||||
if (argc != 1)
|
||||
return;
|
||||
if (ioctl(sock, SIOCDEVPRIVATE, &req))
|
||||
error("SIOCDEVPRIVATE: %s\n", strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void show_port(void)
|
||||
{
|
||||
const char *s;
|
||||
char buffer[128];
|
||||
const te1_settings *te1 = (void*)buffer;
|
||||
const raw_hdlc_proto *raw = (void*)buffer;
|
||||
const cisco_proto *cisco = (void*)buffer;
|
||||
const fr_proto *fr = (void*)buffer;
|
||||
#ifdef IF_PROTO_FR_PVC
|
||||
const fr_proto_pvc_info *pvc = (void*)buffer;
|
||||
#endif
|
||||
req.ifr_settings.ifs_ifsu.sync = (void*)buffer; /* FIXME */
|
||||
|
||||
printf("%s: ", req.ifr_name);
|
||||
|
||||
req.ifr_settings.size = sizeof(buffer);
|
||||
req.ifr_settings.type = IF_GET_IFACE;
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req))
|
||||
if (errno != EINVAL) {
|
||||
printf("unable to get interface information: %s\n",
|
||||
strerror(errno));
|
||||
close(sock);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* Get and print physical interface settings */
|
||||
if (req.ifr_settings.type == IF_IFACE_SYNC_SERIAL)
|
||||
s = ""; /* Unspecified serial interface */
|
||||
else
|
||||
s = tabstr(req.ifr_settings.type, ifaces, NULL);
|
||||
|
||||
if (!s)
|
||||
printf("unknown interface 0x%x\n", req.ifr_settings.type);
|
||||
else {
|
||||
if (*s)
|
||||
printf("interface %s ", s);
|
||||
|
||||
printf("clock %s", tabstr(te1->clock_type, clocks,
|
||||
"type unknown"));
|
||||
if (te1->clock_type == CLOCK_INT ||
|
||||
te1->clock_type == CLOCK_TXINT)
|
||||
printf(" rate %u", te1->clock_rate);
|
||||
|
||||
if (te1->loopback)
|
||||
printf(" loopback");
|
||||
|
||||
if (req.ifr_settings.type == IF_IFACE_E1 ||
|
||||
req.ifr_settings.type == IF_IFACE_T1) {
|
||||
unsigned int u;
|
||||
printf(" slotmap ");
|
||||
for (u = te1->slot_map; u != 0; u /= 2)
|
||||
printf("%u", u % 2);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/* Get and print protocol settings */
|
||||
do {
|
||||
printf("\t");
|
||||
req.ifr_settings.size = sizeof(buffer);
|
||||
req.ifr_settings.type = IF_GET_PROTO;
|
||||
|
||||
if (ioctl(sock, SIOCWANDEV, &req)) {
|
||||
if (errno == EINVAL)
|
||||
printf("no protocol set\n");
|
||||
else
|
||||
printf("unable to get protocol information: "
|
||||
"%s\n", strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
switch(req.ifr_settings.type) {
|
||||
case IF_PROTO_FR:
|
||||
printf("protocol fr lmi %s",
|
||||
tabstr(fr->lmi, lmi, "unknown"));
|
||||
if (fr->lmi == LMI_ANSI ||
|
||||
fr->lmi == LMI_CCITT)
|
||||
printf("%s t391 %u t392 %u n391 %u n392 %u "
|
||||
"n393 %u\n",
|
||||
fr->dce ? " dce" : "",
|
||||
fr->t391,
|
||||
fr->t392,
|
||||
fr->n391,
|
||||
fr->n392,
|
||||
fr->n393);
|
||||
else
|
||||
putchar('\n');
|
||||
break;
|
||||
|
||||
#ifdef IF_PROTO_FR_PVC
|
||||
case IF_PROTO_FR_PVC:
|
||||
printf("Frame-Relay PVC: DLCI %u, master device %s\n",
|
||||
pvc->dlci, pvc->master);
|
||||
break;
|
||||
#endif
|
||||
|
||||
#ifdef IF_PROTO_FR_ETH_PVC
|
||||
case IF_PROTO_FR_ETH_PVC:
|
||||
printf("Frame-Relay PVC (Ethernet emulation): DLCI %u,"
|
||||
" master device %s\n", pvc->dlci, pvc->master);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case IF_PROTO_HDLC:
|
||||
printf("protocol hdlc %s %s\n",
|
||||
tabstr(raw->encoding, hdlc_enc, "unknown"),
|
||||
tabstr(raw->parity, hdlc_par, "unknown"));
|
||||
break;
|
||||
|
||||
#ifdef IF_PROTO_HDLC_ETH
|
||||
case IF_PROTO_HDLC_ETH:
|
||||
printf("protocol hdlc-eth %s %s\n",
|
||||
tabstr(raw->encoding, hdlc_enc, "unknown"),
|
||||
tabstr(raw->parity, hdlc_par, "unknown"));
|
||||
break;
|
||||
#endif
|
||||
|
||||
case IF_PROTO_CISCO:
|
||||
printf("protocol cisco interval %u timeout %u\n",
|
||||
cisco->interval,
|
||||
cisco->timeout);
|
||||
break;
|
||||
|
||||
case IF_PROTO_PPP:
|
||||
printf("protocol ppp\n");
|
||||
break;
|
||||
|
||||
case IF_PROTO_X25:
|
||||
printf("protocol x25\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("unknown protocol %u\n", req.ifr_settings.type);
|
||||
}
|
||||
}while(0);
|
||||
|
||||
close(sock);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "sethdlc version 1.15\n"
|
||||
"Copyright (C) 2000 - 2003 Krzysztof Halasa <khc@pm.waw.pl>\n"
|
||||
"\n"
|
||||
"Usage: sethdlc INTERFACE [PHYSICAL] [clock CLOCK] [LOOPBACK] "
|
||||
"[slotmap SLOTMAP]\n"
|
||||
" sethdlc INTERFACE [PROTOCOL]\n"
|
||||
" sethdlc INTERFACE create | delete"
|
||||
#ifdef IF_PROTO_FR_ETH_PVC
|
||||
" [ether]"
|
||||
#endif
|
||||
" DLCI\n"
|
||||
" sethdlc INTERFACE private...\n"
|
||||
"\n"
|
||||
"PHYSICAL := v24 | v35 | x21 | e1 | t1\n"
|
||||
"CLOCK := int [rate RATE] | ext | txint [rate RATE] | txfromrx\n"
|
||||
"LOOPBACK := loopback | lb\n"
|
||||
"\n"
|
||||
"PROTOCOL := hdlc [ENCODING] [PARITY] |\n"
|
||||
#ifdef IF_PROTO_HDLC_ETH
|
||||
" hdlc-eth [ENCODING] [PARITY] |\n"
|
||||
#endif
|
||||
" cisco [interval val] [timeout val] |\n"
|
||||
" fr [lmi LMI] |\n"
|
||||
" ppp |\n"
|
||||
" x25\n"
|
||||
"\n"
|
||||
"ENCODING := nrz | nrzi | fm-mark | fm-space | manchester\n"
|
||||
"PARITY := no-parity | crc16 | crc16-pr0 | crc16-itu | crc16-itu-pr0 | crc32-itu\n"
|
||||
"LMI := none | ansi [LMI_SPEC] | ccitt [LMI_SPEC]\n"
|
||||
"LMI_SPEC := [dce] [t391 val] [t392 val] [n391 val] [n392 val] [n393 val]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int arg_c, char *arg_v[])
|
||||
{
|
||||
argc = arg_c;
|
||||
argv = arg_v;
|
||||
|
||||
if (argc <= 1)
|
||||
usage();
|
||||
|
||||
sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
|
||||
if (sock < 0)
|
||||
error("Unable to create socket: %s\n", strerror(errno));
|
||||
|
||||
dahdi_copy_string(req.ifr_name, argv[1], sizeof(req.ifr_name)); /* Device name */
|
||||
|
||||
if (argc == 2)
|
||||
show_port();
|
||||
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
set_iface();
|
||||
set_proto();
|
||||
set_pvc();
|
||||
private();
|
||||
|
||||
close(sock);
|
||||
usage();
|
||||
exit(0);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
#
|
||||
# /etc/dahdi/spantype.conf: Set E1/T1/J1 per-device
|
||||
#
|
||||
# Built as a table of two columns:
|
||||
# <id> <local_spanno>:<type>
|
||||
#
|
||||
# Where:
|
||||
# * The <id> field may be either:
|
||||
# hardware_id
|
||||
# @location
|
||||
# devpath (in sysfs)
|
||||
# * The <local_spanno> is the relative span number
|
||||
# in the device (starting from 1)
|
||||
# In this filed globbing rules apply. E.g:
|
||||
# - * are all the spans in this device
|
||||
# - [12] are the first two spans in this device
|
||||
# * The <type> may be E1, T1 or J1
|
||||
#
|
||||
# Examples:
|
||||
# Set the first two spans of a specific Astribank to T1
|
||||
#usb:000156 [12]:T1
|
||||
|
||||
# Set all spans of another Astribank to T1
|
||||
#usb:INT03165 *:E1
|
||||
|
||||
# Set the first two spans of an Astribank to T1. The
|
||||
# Astribanks is specified by its location instead of hardware_id
|
||||
#@usb-0000:00:1d.7-3 [12]:T1
|
|
@ -0,0 +1,326 @@
|
|||
#
|
||||
# DAHDI Configuration File
|
||||
#
|
||||
# This file is parsed by the DAHDI Configurator, dahdi_cfg
|
||||
#
|
||||
# Span Configuration
|
||||
# ++++++++++++++++++
|
||||
# First come the span definitions, in the format
|
||||
#
|
||||
# span=<span num>,<timing source>,<line build out (LBO)>,<framing>,<coding>[,yellow]
|
||||
#
|
||||
# All T1/E1/BRI spans generate a clock signal on their transmit side. The
|
||||
# <timing source> parameter determines whether the clock signal from the far
|
||||
# end of the T1/E1/BRI is used as the master source of clock timing. If it is, our
|
||||
# own clock will synchronise to it. T1/E1/BRI connected directly or indirectly to
|
||||
# a PSTN provider (telco) should generally be the first choice to sync to. The
|
||||
# PSTN will never be a slave to you. You must be a slave to it.
|
||||
#
|
||||
# Choose 1 to make the equipment at the far end of the E1/T1/BRI link the preferred
|
||||
# source of the master clock. Choose 2 to make it the second choice for the master
|
||||
# clock, if the first choice port fails (the far end dies, a cable breaks, or
|
||||
# whatever). Choose 3 to make a port the third choice, and so on. If you have, say,
|
||||
# 2 ports connected to the PSTN, mark those as 1 and 2. The number used for each
|
||||
# port should be different.
|
||||
#
|
||||
# If you choose 0, the port will never be used as a source of timing. This is
|
||||
# appropriate when you know the far end should always be a slave to you. If
|
||||
# the port is connected to a channel bank, for example, you should always be
|
||||
# its master. Likewise, BRI TE ports should always be configured as a slave.
|
||||
# Any number of ports can be marked as 0.
|
||||
#
|
||||
# Incorrect timing sync may cause clicks/noise in the audio, poor quality or failed
|
||||
# faxes, unreliable modem operation, and is a general all round bad thing.
|
||||
#
|
||||
# NOTE: The B410P card cannot reliably connect one of its four ports
|
||||
# configured in TE mode to another one configured in NT mode. It will not
|
||||
# reliably sync clock from itself. Please use another physical card and
|
||||
# configure one to provide clock and one to recover clock in any B410P test
|
||||
# environments.
|
||||
#
|
||||
# The line build-out (or LBO) is an integer, from the following table:
|
||||
#
|
||||
# 0: 0 db (CSU) / 0-133 feet (DSX-1)
|
||||
# 1: 133-266 feet (DSX-1)
|
||||
# 2: 266-399 feet (DSX-1)
|
||||
# 3: 399-533 feet (DSX-1)
|
||||
# 4: 533-655 feet (DSX-1)
|
||||
# 5: -7.5db (CSU)
|
||||
# 6: -15db (CSU)
|
||||
# 7: -22.5db (CSU)
|
||||
#
|
||||
# If the span is a BRI port the line build-out is not used and should be set
|
||||
# to 0.
|
||||
#
|
||||
# framing::
|
||||
# one of 'd4' or 'esf' for T1 or 'cas' or 'ccs' for E1. Use 'ccs' for BRI.
|
||||
# 'd4' could be referred to as 'sf' or 'superframe'
|
||||
#
|
||||
# coding::
|
||||
# one of 'ami' or 'b8zs' for T1 or 'ami' or 'hdb3' for E1. Use 'ami' for
|
||||
# BRI.
|
||||
#
|
||||
# * For E1 there is the optional keyword 'crc4' to enable CRC4 checking.
|
||||
# * If the keyword 'yellow' follows, yellow alarm is transmitted when no
|
||||
# channels are open.
|
||||
#
|
||||
#span=1,0,0,esf,b8zs
|
||||
#span=2,1,0,esf,b8zs
|
||||
#span=3,0,0,ccs,hdb3,crc4
|
||||
#
|
||||
# Dynamic Spans
|
||||
# +++++++++++++
|
||||
# Next come the dynamic span definitions, in the form:
|
||||
#
|
||||
# dynamic=<driver>,<address>,<numchans>,<timing>
|
||||
#
|
||||
# Where <driver> is the name of the driver (e.g. eth), <address> is the
|
||||
# driver specific address (like a MAC for eth), <numchans> is the number
|
||||
# of channels, and <timing> is a timing priority, like for a normal span.
|
||||
# use "0" to not use this as a timing source, or prioritize them as
|
||||
# primary, secondard, etc. Note that you MUST have a REAL DAHDI device
|
||||
# if you are not using external timing.
|
||||
#
|
||||
# dynamic=eth,eth0/00:02:b3:35:43:9c,24,0
|
||||
#
|
||||
# If a non-zero timing value is used, as above, only the last span should
|
||||
# have the non-zero value.
|
||||
#
|
||||
# Channel Configuration
|
||||
# +++++++++++++++++++++
|
||||
# Next come the definitions for using the channels. The format is:
|
||||
# <device>=<channel list>
|
||||
#
|
||||
# Valid devices are:
|
||||
#
|
||||
# e&m::
|
||||
# Channel(s) are signalled using E&M signalling on a T1 line.
|
||||
# Specific implementation, such as Immediate, Wink, or Feature
|
||||
# Group D are handled by the userspace library.
|
||||
# e&me1::
|
||||
# Channel(s) are signalled using E&M signalling on an E1 line.
|
||||
# fxsls::
|
||||
# Channel(s) are signalled using FXS Loopstart protocol.
|
||||
# fxsgs::
|
||||
# Channel(s) are signalled using FXS Groundstart protocol.
|
||||
# fxsks::
|
||||
# Channel(s) are signalled using FXS Koolstart protocol.
|
||||
# fxols::
|
||||
# Channel(s) are signalled using FXO Loopstart protocol.
|
||||
# fxogs::
|
||||
# Channel(s) are signalled using FXO Groundstart protocol.
|
||||
# fxoks::
|
||||
# Channel(s) are signalled using FXO Koolstart protocol.
|
||||
#
|
||||
# unused::
|
||||
# No signalling is performed, each channel in the list remains idle
|
||||
# clear::
|
||||
# Channel(s) are bundled into a single span. No conversion or
|
||||
# signalling is performed, and raw data is available on the master.
|
||||
# bchan::
|
||||
# Like 'clear' except all channels are treated individually and
|
||||
# are not bundled. 'inclear' is an alias for this.
|
||||
# rawhdlc::
|
||||
# The DAHDI driver performs HDLC encoding and decoding on the
|
||||
# bundle, and the resulting data is communicated via the master
|
||||
# device.
|
||||
# dchan::
|
||||
# The DAHDI driver performs HDLC encoding and decoding on the
|
||||
# bundle and also performs incoming and outgoing FCS insertion
|
||||
# and verification. 'fcshdlc' is an alias for this.
|
||||
# hardhdlc::
|
||||
# The hardware driver performs HDLC encoding and decoding on the
|
||||
# bundle and also performs incoming and outgoing FCS insertion
|
||||
# and verification. Is subject to limitations and support of underlying
|
||||
# hardware. BRI spans serviced by the wcb4xxp driver must use hardhdlc
|
||||
# channels for the signalling channels.
|
||||
# nethdlc::
|
||||
# The DAHDI driver bundles the channels together into an
|
||||
# hdlc network device, which in turn can be configured with
|
||||
# sethdlc (available separately). In 2.6.x kernels you can also optionally
|
||||
# pass the name for the network interface after the channel list.
|
||||
# Syntax:
|
||||
#
|
||||
# nethdlc=<channel list>[:interface name]
|
||||
# Use original names, don't use the names which have been already registered
|
||||
# in system e.g eth.
|
||||
#
|
||||
# dacs::
|
||||
# The DAHDI driver cross connects the channels starting at
|
||||
# the channel number listed at the end, after a colon
|
||||
# dacsrbs::
|
||||
# The DAHDI driver cross connects the channels starting at
|
||||
# the channel number listed at the end, after a colon and
|
||||
# also performs the DACSing of RBS bits
|
||||
#
|
||||
# The channel list is a comma-separated list of channels or ranges, for
|
||||
# example:
|
||||
#
|
||||
# 1,3,5 (channels one, three, and five)
|
||||
# 16-23, 29 (channels 16 through 23, as well as channel 29)
|
||||
#
|
||||
# So, some complete examples are:
|
||||
#
|
||||
# e&m=1-12
|
||||
# nethdlc=13-24
|
||||
# fxsls=25,26,27,28
|
||||
# fxols=29-32
|
||||
#
|
||||
# An example of BRI port:
|
||||
#
|
||||
# span=1,1,0,ccs,ami
|
||||
# bchan=1,2
|
||||
# hardhdlc=3
|
||||
#
|
||||
# NOTE: When using BRI channels in asterisk, use the bri_cpe, bri_net, or
|
||||
# bri_cpe_ptmp (for point to multipoint mode). libpri does not currently
|
||||
# support point to multipoint when in NT mode. Otherwise, the bearer channel
|
||||
# are configured identically to other DAHDI channels.
|
||||
#
|
||||
#fxoks=1-24
|
||||
#bchan=25-47
|
||||
#dchan=48
|
||||
#fxols=1-12
|
||||
#fxols=13-24
|
||||
#e&m=25-29
|
||||
#nethdlc=30-33
|
||||
#clear=44
|
||||
#clear=45
|
||||
#clear=46
|
||||
#clear=47
|
||||
#fcshdlc=48
|
||||
#dacs=1-24:48
|
||||
#dacsrbs=1-24:48
|
||||
#
|
||||
# Tone Zone Data
|
||||
# ++++++++++++++
|
||||
# Finally, you can preload some tone zones, to prevent them from getting
|
||||
# overwritten by other users (if you allow non-root users to open /dev/dahdi/*
|
||||
# interfaces anyway. Also this means they won't have to be loaded at runtime.
|
||||
# The format is "loadzone=<zone>" where the zone is a two letter country code.
|
||||
#
|
||||
# You may also specify a default zone with "defaultzone=<zone>" where zone
|
||||
# is a two letter country code.
|
||||
#
|
||||
# An up-to-date list of the zones can be found in the file zonedata.c
|
||||
#
|
||||
loadzone = us
|
||||
#loadzone = us-old
|
||||
#loadzone=gr
|
||||
#loadzone=it
|
||||
#loadzone=fr
|
||||
#loadzone=de
|
||||
#loadzone=uk
|
||||
#loadzone=fi
|
||||
#loadzone=jp
|
||||
#loadzone=sp
|
||||
#loadzone=no
|
||||
#loadzone=hu
|
||||
#loadzone=lt
|
||||
#loadzone=pl
|
||||
defaultzone=us
|
||||
#
|
||||
# PCI Radio Interface
|
||||
# +++++++++++++++++++
|
||||
# (see http://www.zapatatelephony.org/app_rpt.html)
|
||||
#
|
||||
# The PCI Radio Interface card interfaces up to 4 two-way radios (either
|
||||
# a base/mobile radio or repeater system) to DAHDI channels. The driver
|
||||
# may work either independent of an application, or with it, through
|
||||
# the driver;s ioctl() interface. This file gives you access to specify
|
||||
# load-time parameters for Radio channels, so that the driver may run
|
||||
# by itself, and just act like a generic DAHDI radio interface.
|
||||
#
|
||||
# Unlike the rest of this file, you specify a block of parameters, and
|
||||
# then the channel(s) to which they apply. CTCSS is specified as a frequency
|
||||
# in tenths of hertz, for example 131.8 HZ is specified as 1318. DCS
|
||||
# for receive is specified as the code directly, for example 223. DCS for
|
||||
# transmit is specified as D and then the code, for example D223.
|
||||
#
|
||||
# The hardware supports a "community" CTCSS decoder system that has
|
||||
# arbitrary transmit CTCSS or DCS codes associated with them, unlike
|
||||
# traditional "community" systems that encode the same tone they decode.
|
||||
#
|
||||
# this example is a single tone DCS transmit and receive
|
||||
#
|
||||
# specify the transmit tone (in DCS mode this stays constant):
|
||||
#tx=D371
|
||||
#
|
||||
# specify the receive DCS code:
|
||||
#dcsrx=223
|
||||
#
|
||||
# this example is a "community" CTCSS (if you only want a single tone, then
|
||||
# only specify 1 in the ctcss list)
|
||||
#
|
||||
# specify the default transmit tone (when not receiving):
|
||||
#tx=1000
|
||||
#
|
||||
# Specify the receive freq, the tag (use 0 if none), and the transmit code.
|
||||
# The tag may be used by applications to determine classification of tones.
|
||||
# The tones are to be specified in order of presedence, most important first.
|
||||
# Currently, 15 tones may be specified..
|
||||
#
|
||||
#ctcss=1318,1,1318
|
||||
#ctcss=1862,1,1862
|
||||
#
|
||||
# The following parameters may be omitted if their default value is acceptible
|
||||
#
|
||||
# Set the receive debounce time in milliseconds:
|
||||
#debouncetime=123
|
||||
#
|
||||
# set the transmit quiet dropoff burst time in milliseconds:
|
||||
#bursttime=234
|
||||
#
|
||||
# set the COR level threshold (specified in tenths of millivolts)
|
||||
# valid values are {3125,6250,9375,12500,15625,18750,21875,25000}
|
||||
#corthresh=12500
|
||||
#
|
||||
# Invert COR signal {y,n}
|
||||
#invertcor=y
|
||||
# Set the external tone mode; yes, no, internal {y,n,i}
|
||||
#exttone=y
|
||||
#
|
||||
# Now apply the configuration to the specified channels:
|
||||
#
|
||||
# We are all done with our channel parameters, so now we specify what
|
||||
# channels they apply to
|
||||
#channels=1-4
|
||||
#
|
||||
# Overiding PCM encoding
|
||||
# ++++++++++++++++++++++
|
||||
# Usually the channel driver sets the encoding of the PCM for the
|
||||
# channel (mulaw / alaw. That is: g711u or g711a). However there are
|
||||
# some cases where you would like to override that. 'mulaw' and 'alaw'
|
||||
# set different such encoding. Use them for channels you have already
|
||||
# defined with e.g. 'bchan' or 'fxoks'.
|
||||
#mulaw=1-4
|
||||
#alaw=1-4
|
||||
#
|
||||
# 'deflaw' is similar, but resets the encoding to the channel driver's
|
||||
# default. It must be useful for something, I guess.
|
||||
#mulaw=1-10
|
||||
#deflaw=5
|
||||
#
|
||||
# Echo Cancellers
|
||||
# +++++++++++++++
|
||||
# DAHDI uses modular echo cancellers that are configured per channel. The echo
|
||||
# cancellers are compiled and installed as part of the dahdi-linux package.
|
||||
# You can specify in this file the echo canceller to be used for each
|
||||
# channel. The default behavior is for there to be NO echo canceller on any
|
||||
# channel, so it is very important that you specify one here.
|
||||
#
|
||||
# Valid echo cancellers are: hwec, mg2, kb1, sec2, and sec.
|
||||
# 'hwec' is a special echo canceller that should be used if hardware echo
|
||||
# cancellation is desired on and available on the specified channels.
|
||||
# If compiled, 'hpec' is also a valid echo canceller.
|
||||
#
|
||||
# To configure the default echo cancellers, use the format:
|
||||
# echocanceller=<echocanceller name>,<channel(s)>
|
||||
#
|
||||
# Example:
|
||||
# Configure channels 1 through 8 to use the mg2 echo canceller
|
||||
#echocanceller=mg2,1-8
|
||||
#
|
||||
# And change channel 2 to use the kb1 echo canceller.
|
||||
#echocanceller=kb1,2
|
||||
#
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Written by Mark Spencer <markster@digium.com>
|
||||
* Based on previous works, designs, and architectures conceived and
|
||||
* written by Jim Dixon <jim@lambdatel.com>.
|
||||
*
|
||||
* Copyright (C) 2001 Jim Dixon / Zapata Telephony.
|
||||
* Copyright (C) 2001-2008 Digium, Inc.
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
* Radio Support by Jim Dixon <jim@lambdatel.com>
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <dahdi/user.h>
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int x = 8000;
|
||||
int res;
|
||||
fd_set fds;
|
||||
struct timeval orig, now;
|
||||
fd = open("/dev/dahdi/timer", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Unable to open timer: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
printf("Opened timer...\n");
|
||||
if (ioctl(fd, DAHDI_TIMERCONFIG, &x)) {
|
||||
fprintf(stderr, "Unable to set timer: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
printf("Set timer duration to %d samples (%d ms)\n", x, x/8);
|
||||
printf("Waiting...\n");
|
||||
gettimeofday(&orig, NULL);
|
||||
for(;;) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(fd, &fds);
|
||||
res = select(fd + 1, NULL, NULL, &fds, NULL);
|
||||
if (res != 1) {
|
||||
fprintf(stderr, "Unexpected result %d: %s\n", res, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
x = -1;
|
||||
if (ioctl(fd, DAHDI_TIMERACK, &x)) {
|
||||
fprintf(stderr, "Unable to ack timer: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
gettimeofday(&now, NULL);
|
||||
printf("Timer Expired (%ld ms)!\n", (now.tv_sec - orig.tv_sec) * 1000 + (now.tv_usec - orig.tv_usec) / 1000);
|
||||
}
|
||||
exit(0);
|
||||
}
|
|
@ -0,0 +1,529 @@
|
|||
/*
|
||||
* BSD Telephony Of Mexico "Tormenta" Tone Zone Support 2/22/01
|
||||
*
|
||||
* Working with the "Tormenta ISA" Card
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU Lesser General Public License Version 2.1 as published
|
||||
* by the Free Software Foundation. See the LICENSE.LGPL file
|
||||
* included with this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "dahdi/user.h"
|
||||
#include "tonezone.h"
|
||||
#include "dahdi_tools_version.h"
|
||||
|
||||
#define DEFAULT_DAHDI_DEV "/dev/dahdi/ctl"
|
||||
|
||||
#define MAX_SIZE 16384
|
||||
#define CLIP 32635
|
||||
#define BIAS 0x84
|
||||
|
||||
#if 0
|
||||
# define PRINT_DEBUG(x, ...) printf(x, __VA_ARGS__)
|
||||
#else
|
||||
# define PRINT_DEBUG(x, ...)
|
||||
#endif
|
||||
|
||||
#ifndef ENODATA
|
||||
#define ENODATA EINVAL
|
||||
#endif
|
||||
|
||||
struct tone_zone *tone_zone_find(char *country)
|
||||
{
|
||||
struct tone_zone *z;
|
||||
z = builtin_zones;
|
||||
while(z->zone > -1) {
|
||||
if (!strcasecmp(country, z->country))
|
||||
return z;
|
||||
z++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct tone_zone *tone_zone_find_by_num(int id)
|
||||
{
|
||||
struct tone_zone *z;
|
||||
z = builtin_zones;
|
||||
while(z->zone > -1) {
|
||||
if (z->zone == id)
|
||||
return z;
|
||||
z++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define LEVEL -10
|
||||
|
||||
static int build_tone(void *data, size_t size, struct tone_zone_sound *t, int *count)
|
||||
{
|
||||
char *dup, *s;
|
||||
struct dahdi_tone_def *td=NULL;
|
||||
int firstnobang = -1;
|
||||
int freq1, freq2, time;
|
||||
int modulate = 0;
|
||||
float db = 1.0;
|
||||
float gain;
|
||||
int used = 0;
|
||||
dup = strdup(t->data);
|
||||
s = strtok(dup, ",");
|
||||
while(s && strlen(s)) {
|
||||
/* Handle optional ! which signifies don't start here*/
|
||||
if (s[0] == '!') {
|
||||
s++;
|
||||
} else if (firstnobang < 0) {
|
||||
PRINT_DEBUG("First no bang: %s\n", s);
|
||||
firstnobang = *count;
|
||||
}
|
||||
|
||||
if (sscanf(s, "%d+%d/%d", &freq1, &freq2, &time) == 3) {
|
||||
/* f1+f2/time format */
|
||||
PRINT_DEBUG("f1+f2/time format: %d, %d, %d\n", freq1, freq2, time);
|
||||
} else if (sscanf(s, "%d*%d/%d", &freq1, &freq2, &time) == 3) {
|
||||
/* f1*f2/time format */
|
||||
PRINT_DEBUG("f1+f2/time format: %d, %d, %d\n", freq1, freq2, time);
|
||||
modulate = 1;
|
||||
} else if (sscanf(s, "%d+%d", &freq1, &freq2) == 2) {
|
||||
PRINT_DEBUG("f1+f2 format: %d, %d\n", freq1, freq2);
|
||||
time = 0;
|
||||
} else if (sscanf(s, "%d*%d", &freq1, &freq2) == 2) {
|
||||
PRINT_DEBUG("f1+f2 format: %d, %d\n", freq1, freq2);
|
||||
modulate = 1;
|
||||
time = 0;
|
||||
} else if (sscanf(s, "%d/%d", &freq1, &time) == 2) {
|
||||
PRINT_DEBUG("f1/time format: %d, %d\n", freq1, time);
|
||||
freq2 = 0;
|
||||
} else if (sscanf(s, "%d@/%d", &freq1, &time) == 2) {
|
||||
/* The "@" character has been added to enable an
|
||||
* approximately -20db tone generation of any frequency This has been done
|
||||
* primarily to generate the Australian congestion tone.
|
||||
* Example: "425/375,0/375,425@/375,0/375"
|
||||
*/
|
||||
PRINT_DEBUG("f1 reduced amplitude/time format: %d, %d\n", freq1,time);
|
||||
db = 0.3;
|
||||
freq2 = 0;
|
||||
} else if (sscanf(s, "%d", &freq1) == 1) {
|
||||
PRINT_DEBUG("f1 format: %d\n", freq1);
|
||||
firstnobang = *count;
|
||||
freq2 = 0;
|
||||
time = 0;
|
||||
} else {
|
||||
fprintf(stderr, "tone component '%s' of '%s' is a syntax error\n", s,t->data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
PRINT_DEBUG("Using %d samples for %d and %d\n", time * 8, freq1, freq2);
|
||||
|
||||
if (size < sizeof(*td)) {
|
||||
fprintf(stderr, "Not enough space for tones\n");
|
||||
return -1;
|
||||
}
|
||||
td = data;
|
||||
|
||||
/* Bring it down -8 dbm */
|
||||
gain = db*(pow(10.0, (LEVEL - 3.14) / 20.0) * 65536.0 / 2.0);
|
||||
|
||||
td->fac1 = 2.0 * cos(2.0 * M_PI * (freq1 / 8000.0)) * 32768.0;
|
||||
td->init_v2_1 = sin(-4.0 * M_PI * (freq1 / 8000.0)) * gain;
|
||||
td->init_v3_1 = sin(-2.0 * M_PI * (freq1 / 8000.0)) * gain;
|
||||
|
||||
td->fac2 = 2.0 * cos(2.0 * M_PI * (freq2 / 8000.0)) * 32768.0;
|
||||
td->init_v2_2 = sin(-4.0 * M_PI * (freq2 / 8000.0)) * gain;
|
||||
td->init_v3_2 = sin(-2.0 * M_PI * (freq2 / 8000.0)) * gain;
|
||||
|
||||
td->modulate = modulate;
|
||||
|
||||
data += sizeof(*td);
|
||||
used += sizeof(*td);
|
||||
size -= sizeof(*td);
|
||||
td->tone = t->toneid;
|
||||
if (time) {
|
||||
/* We should move to the next tone */
|
||||
td->next = *count + 1;
|
||||
td->samples = time * 8;
|
||||
} else {
|
||||
/* Stay with us */
|
||||
td->next = *count;
|
||||
td->samples = 8000;
|
||||
}
|
||||
*count += 1;
|
||||
s = strtok(NULL, ",");
|
||||
}
|
||||
if (td && time) {
|
||||
/* If we don't end on a solid tone, return */
|
||||
td->next = firstnobang;
|
||||
}
|
||||
if (firstnobang < 0)
|
||||
fprintf(stderr, "tone '%s' does not end with a solid tone or silence (all tone components have an exclamation mark)\n", t->data);
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
char *tone_zone_tone_name(int id)
|
||||
{
|
||||
static char tmp[80];
|
||||
switch(id) {
|
||||
case DAHDI_TONE_DIALTONE:
|
||||
return "Dialtone";
|
||||
case DAHDI_TONE_BUSY:
|
||||
return "Busy";
|
||||
case DAHDI_TONE_RINGTONE:
|
||||
return "Ringtone";
|
||||
case DAHDI_TONE_CONGESTION:
|
||||
return "Congestion";
|
||||
case DAHDI_TONE_CALLWAIT:
|
||||
return "Call Waiting";
|
||||
case DAHDI_TONE_DIALRECALL:
|
||||
return "Dial Recall";
|
||||
case DAHDI_TONE_RECORDTONE:
|
||||
return "Record Tone";
|
||||
case DAHDI_TONE_CUST1:
|
||||
return "Custom 1";
|
||||
case DAHDI_TONE_CUST2:
|
||||
return "Custom 2";
|
||||
case DAHDI_TONE_INFO:
|
||||
return "Special Information";
|
||||
case DAHDI_TONE_STUTTER:
|
||||
return "Stutter Dialtone";
|
||||
default:
|
||||
snprintf(tmp, sizeof(tmp), "Unknown tone %d", id);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TONEZONE_DRIVER
|
||||
static void dump_tone_zone(void *data, int size)
|
||||
{
|
||||
struct dahdi_tone_def_header *z;
|
||||
struct dahdi_tone_def *td;
|
||||
int x;
|
||||
int len = sizeof(*z);
|
||||
|
||||
z = data;
|
||||
data += sizeof(*z);
|
||||
printf("Header: %d tones, %d bytes of data, zone %d (%s)\n",
|
||||
z->count, size, z->zone, z->name);
|
||||
for (x = 0; x < z->count; x++) {
|
||||
td = data;
|
||||
printf("Tone Fragment %d: tone is %d, next is %d, %d samples\n",
|
||||
x, td->tone, td->next, td->samples);
|
||||
data += sizeof(*td);
|
||||
len += sizeof(*td);
|
||||
}
|
||||
printf("Total measured bytes of data: %d\n", len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Tone frequency tables */
|
||||
struct mf_tone {
|
||||
int tone;
|
||||
float f1; /* first freq */
|
||||
float f2; /* second freq */
|
||||
};
|
||||
|
||||
static struct mf_tone dtmf_tones[] = {
|
||||
{ DAHDI_TONE_DTMF_0, 941.0, 1336.0 },
|
||||
{ DAHDI_TONE_DTMF_1, 697.0, 1209.0 },
|
||||
{ DAHDI_TONE_DTMF_2, 697.0, 1336.0 },
|
||||
{ DAHDI_TONE_DTMF_3, 697.0, 1477.0 },
|
||||
{ DAHDI_TONE_DTMF_4, 770.0, 1209.0 },
|
||||
{ DAHDI_TONE_DTMF_5, 770.0, 1336.0 },
|
||||
{ DAHDI_TONE_DTMF_6, 770.0, 1477.0 },
|
||||
{ DAHDI_TONE_DTMF_7, 852.0, 1209.0 },
|
||||
{ DAHDI_TONE_DTMF_8, 852.0, 1336.0 },
|
||||
{ DAHDI_TONE_DTMF_9, 852.0, 1477.0 },
|
||||
{ DAHDI_TONE_DTMF_s, 941.0, 1209.0 },
|
||||
{ DAHDI_TONE_DTMF_p, 941.0, 1477.0 },
|
||||
{ DAHDI_TONE_DTMF_A, 697.0, 1633.0 },
|
||||
{ DAHDI_TONE_DTMF_B, 770.0, 1633.0 },
|
||||
{ DAHDI_TONE_DTMF_C, 852.0, 1633.0 },
|
||||
{ DAHDI_TONE_DTMF_D, 941.0, 1633.0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct mf_tone mfr1_tones[] = {
|
||||
{ DAHDI_TONE_MFR1_0, 1300.0, 1500.0 },
|
||||
{ DAHDI_TONE_MFR1_1, 700.0, 900.0 },
|
||||
{ DAHDI_TONE_MFR1_2, 700.0, 1100.0 },
|
||||
{ DAHDI_TONE_MFR1_3, 900.0, 1100.0 },
|
||||
{ DAHDI_TONE_MFR1_4, 700.0, 1300.0 },
|
||||
{ DAHDI_TONE_MFR1_5, 900.0, 1300.0 },
|
||||
{ DAHDI_TONE_MFR1_6, 1100.0, 1300.0 },
|
||||
{ DAHDI_TONE_MFR1_7, 700.0, 1500.0 },
|
||||
{ DAHDI_TONE_MFR1_8, 900.0, 1500.0 },
|
||||
{ DAHDI_TONE_MFR1_9, 1100.0, 1500.0 },
|
||||
{ DAHDI_TONE_MFR1_KP, 1100.0, 1700.0 }, /* KP */
|
||||
{ DAHDI_TONE_MFR1_ST, 1500.0, 1700.0 }, /* ST */
|
||||
{ DAHDI_TONE_MFR1_STP, 900.0, 1700.0 }, /* KP' or ST' */
|
||||
{ DAHDI_TONE_MFR1_ST2P, 1300.0, 1700.0 }, /* KP'' or ST'' */
|
||||
{ DAHDI_TONE_MFR1_ST3P, 700.0, 1700.0 }, /* KP''' or ST''' */
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct mf_tone mfr2_fwd_tones[] = {
|
||||
{ DAHDI_TONE_MFR2_FWD_1, 1380.0, 1500.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_2, 1380.0, 1620.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_3, 1500.0, 1620.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_4, 1380.0, 1740.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_5, 1500.0, 1740.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_6, 1620.0, 1740.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_7, 1380.0, 1860.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_8, 1500.0, 1860.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_9, 1620.0, 1860.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_10, 1740.0, 1860.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_11, 1380.0, 1980.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_12, 1500.0, 1980.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_13, 1620.0, 1980.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_14, 1740.0, 1980.0 },
|
||||
{ DAHDI_TONE_MFR2_FWD_15, 1860.0, 1980.0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct mf_tone mfr2_rev_tones[] = {
|
||||
{ DAHDI_TONE_MFR2_REV_1, 1020.0, 1140.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_2, 900.0, 1140.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_3, 900.0, 1020.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_4, 780.0, 1140.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_5, 780.0, 1020.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_6, 780.0, 900.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_7, 660.0, 1140.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_8, 660.0, 1020.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_9, 660.0, 900.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_10, 660.0, 780.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_11, 540.0, 1140.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_12, 540.0, 1020.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_13, 540.0, 900.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_14, 540.0, 780.0 },
|
||||
{ DAHDI_TONE_MFR2_REV_15, 540.0, 660.0 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static int build_mf_tones(void *data, size_t size, int *count, struct mf_tone *tone, int low_tone_level, int high_tone_level)
|
||||
{
|
||||
struct dahdi_tone_def *td;
|
||||
float gain;
|
||||
int used = 0;
|
||||
|
||||
while (tone->tone) {
|
||||
if (size < sizeof(*td)) {
|
||||
fprintf(stderr, "Not enough space for samples\n");
|
||||
return -1;
|
||||
}
|
||||
td = data;
|
||||
data += sizeof(*td);
|
||||
used += sizeof(*td);
|
||||
size -= sizeof(*td);
|
||||
td->tone = tone->tone;
|
||||
*count += 1;
|
||||
|
||||
/* Bring it down 6 dBm */
|
||||
gain = pow(10.0, (low_tone_level - 3.14) / 20.0) * 65536.0 / 2.0;
|
||||
td->fac1 = 2.0 * cos(2.0 * M_PI * (tone->f1 / 8000.0)) * 32768.0;
|
||||
td->init_v2_1 = sin(-4.0 * M_PI * (tone->f1 / 8000.0)) * gain;
|
||||
td->init_v3_1 = sin(-2.0 * M_PI * (tone->f1 / 8000.0)) * gain;
|
||||
|
||||
gain = pow(10.0, (high_tone_level - 3.14) / 20.0) * 65536.0 / 2.0;
|
||||
td->fac2 = 2.0 * cos(2.0 * M_PI * (tone->f2 / 8000.0)) * 32768.0;
|
||||
td->init_v2_2 = sin(-4.0 * M_PI * (tone->f2 / 8000.0)) * gain;
|
||||
td->init_v3_2 = sin(-2.0 * M_PI * (tone->f2 / 8000.0)) * gain;
|
||||
|
||||
tone++;
|
||||
}
|
||||
|
||||
return used;
|
||||
}
|
||||
|
||||
int tone_zone_register_zone(int fd, struct tone_zone *z)
|
||||
{
|
||||
char buf[MAX_SIZE];
|
||||
int res;
|
||||
int count = 0;
|
||||
int x;
|
||||
size_t space = MAX_SIZE;
|
||||
void *ptr = buf;
|
||||
int iopenedit = 1;
|
||||
struct dahdi_tone_def_header *h;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
h = ptr;
|
||||
ptr += sizeof(*h);
|
||||
space -= sizeof(*h);
|
||||
h->zone = z->zone;
|
||||
|
||||
dahdi_copy_string(h->name, z->description, sizeof(h->name));
|
||||
|
||||
for (x = 0; x < DAHDI_MAX_CADENCE; x++)
|
||||
h->ringcadence[x] = z->ringcadence[x];
|
||||
|
||||
for (x = 0; x < DAHDI_TONE_MAX; x++) {
|
||||
if (!strlen(z->tones[x].data))
|
||||
continue;
|
||||
|
||||
PRINT_DEBUG("Tone: %d, string: %s\n", z->tones[x].toneid, z->tones[x].data);
|
||||
|
||||
if ((res = build_tone(ptr, space, &z->tones[x], &count)) < 0) {
|
||||
fprintf(stderr, "Tone %d not built.\n", x);
|
||||
return -1;
|
||||
}
|
||||
ptr += res;
|
||||
space -= res;
|
||||
}
|
||||
|
||||
if ((res = build_mf_tones(ptr, space, &count, dtmf_tones, z->dtmf_low_level, z->dtmf_high_level)) < 0) {
|
||||
fprintf(stderr, "Could not build DTMF tones.\n");
|
||||
return -1;
|
||||
}
|
||||
ptr += res;
|
||||
space -= res;
|
||||
|
||||
if ((res = build_mf_tones(ptr, space, &count, mfr1_tones, z->mfr1_level, z->mfr1_level)) < 0) {
|
||||
fprintf(stderr, "Could not build MFR1 tones.\n");
|
||||
return -1;
|
||||
}
|
||||
ptr += res;
|
||||
space -= res;
|
||||
|
||||
if ((res = build_mf_tones(ptr, space, &count, mfr2_fwd_tones, z->mfr2_level, z->mfr2_level)) < 0) {
|
||||
fprintf(stderr, "Could not build MFR2 FWD tones.\n");
|
||||
return -1;
|
||||
}
|
||||
ptr += res;
|
||||
space -= res;
|
||||
|
||||
if ((res = build_mf_tones(ptr, space, &count, mfr2_rev_tones, z->mfr2_level, z->mfr2_level)) < 0) {
|
||||
fprintf(stderr, "Could not build MFR2 REV tones.\n");
|
||||
return -1;
|
||||
}
|
||||
ptr += res;
|
||||
space -= res;
|
||||
|
||||
h->count = count;
|
||||
|
||||
if (fd < 0) {
|
||||
if ((fd = open(DEFAULT_DAHDI_DEV, O_RDWR)) < 0) {
|
||||
fprintf(stderr, "Unable to open %s and fd not provided\n", DEFAULT_DAHDI_DEV);
|
||||
return -1;
|
||||
}
|
||||
iopenedit = 1;
|
||||
}
|
||||
|
||||
x = z->zone;
|
||||
if ((res = ioctl(fd, DAHDI_FREEZONE, &x))) {
|
||||
if (errno != EBUSY)
|
||||
fprintf(stderr, "ioctl(DAHDI_FREEZONE) failed: %s\n", strerror(errno));
|
||||
return res;
|
||||
}
|
||||
|
||||
#if defined(TONEZONE_DRIVER)
|
||||
dump_tone_zone(h, MAX_SIZE - space);
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
if ((res = ioctl(fd, DAHDI_LOADZONE, &h))) {
|
||||
#else
|
||||
if ((res = ioctl(fd, DAHDI_LOADZONE, h))) {
|
||||
#endif
|
||||
fprintf(stderr, "ioctl(DAHDI_LOADZONE) failed: %s\n", strerror(errno));
|
||||
return res;
|
||||
}
|
||||
|
||||
if (iopenedit)
|
||||
close(fd);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
int tone_zone_register(int fd, char *country)
|
||||
{
|
||||
struct tone_zone *z;
|
||||
z = tone_zone_find(country);
|
||||
if (z) {
|
||||
return tone_zone_register_zone(-1, z);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int tone_zone_set_zone(int fd, char *country)
|
||||
{
|
||||
int res=-1;
|
||||
struct tone_zone *z;
|
||||
if (fd > -1) {
|
||||
z = tone_zone_find(country);
|
||||
if (z)
|
||||
res = ioctl(fd, DAHDI_SETTONEZONE, &z->zone);
|
||||
if ((res < 0) && (errno == ENODATA)) {
|
||||
tone_zone_register_zone(fd, z);
|
||||
res = ioctl(fd, DAHDI_SETTONEZONE, &z->zone);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int tone_zone_get_zone(int fd)
|
||||
{
|
||||
int x=-1;
|
||||
if (fd > -1) {
|
||||
ioctl(fd, DAHDI_GETTONEZONE, &x);
|
||||
return x;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int tone_zone_play_tone(int fd, int tone)
|
||||
{
|
||||
struct tone_zone *z;
|
||||
int res = -1;
|
||||
int zone;
|
||||
|
||||
#if 0
|
||||
fprintf(stderr, "Playing tone %d (%s) on %d\n", tone, tone_zone_tone_name(tone), fd);
|
||||
#endif
|
||||
if (fd > -1) {
|
||||
res = ioctl(fd, DAHDI_SENDTONE, &tone);
|
||||
if ((res < 0) && (errno == ENODATA)) {
|
||||
ioctl(fd, DAHDI_GETTONEZONE, &zone);
|
||||
z = tone_zone_find_by_num(zone);
|
||||
if (z) {
|
||||
res = tone_zone_register_zone(fd, z);
|
||||
/* Recall the zone */
|
||||
ioctl(fd, DAHDI_SETTONEZONE, &zone);
|
||||
if (res < 0) {
|
||||
fprintf(stderr, "Failed to register zone '%s': %s\n", z->description, strerror(errno));
|
||||
} else {
|
||||
res = ioctl(fd, DAHDI_SENDTONE, &tone);
|
||||
}
|
||||
} else
|
||||
fprintf(stderr, "Don't know anything about zone %d\n", zone);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
* BSD Telephony Of Mexico "Tormenta" Tone Zone Support 2/22/01
|
||||
*
|
||||
* Working with the "Tormenta ISA" Card
|
||||
*
|
||||
* Copyright (C) 2001-2008, Digium, Inc.
|
||||
*
|
||||
* Primary Author: Mark Spencer <markster@digium.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU Lesser General Public License Version 2.1 as published
|
||||
* by the Free Software Foundation. See the LICENSE.LGPL file
|
||||
* included with this program for more details.
|
||||
*
|
||||
* In addition, when this program is distributed with Asterisk in
|
||||
* any form that would qualify as a 'combined work' or as a
|
||||
* 'derivative work' (but not mere aggregation), you can redistribute
|
||||
* and/or modify the combination under the terms of the license
|
||||
* provided with that copy of Asterisk, instead of the license
|
||||
* terms granted here.
|
||||
*/
|
||||
|
||||
#ifndef _TONEZONE_H
|
||||
#define _TONEZONE_H
|
||||
|
||||
#include <dahdi/user.h>
|
||||
|
||||
struct tone_zone_sound {
|
||||
int toneid;
|
||||
char data[256]; /* Actual zone description */
|
||||
/* Description is a series of tones of the format:
|
||||
[!]freq1[+freq2][/time] separated by commas. There
|
||||
are no spaces. The sequence is repeated back to the
|
||||
first tone description not preceeded by !. time is
|
||||
specified in milliseconds */
|
||||
};
|
||||
|
||||
struct tone_zone {
|
||||
int zone; /* Zone number */
|
||||
char country[10]; /* Country code */
|
||||
char description[40]; /* Description */
|
||||
int ringcadence[DAHDI_MAX_CADENCE]; /* Ring cadence */
|
||||
struct tone_zone_sound tones[DAHDI_TONE_MAX];
|
||||
int dtmf_high_level; /* Power level of high frequency component
|
||||
of DTMF, expressed in dBm0. */
|
||||
int dtmf_low_level; /* Power level of low frequency component
|
||||
of DTMF, expressed in dBm0. */
|
||||
int mfr1_level; /* Power level of MFR1, expressed in dBm0. */
|
||||
int mfr2_level; /* Power level of MFR2, expressed in dBm0. */
|
||||
};
|
||||
|
||||
extern struct tone_zone builtin_zones[];
|
||||
|
||||
/* Register a given two-letter tone zone if we can */
|
||||
int tone_zone_register(int fd, char *country);
|
||||
|
||||
/* Register a given two-letter tone zone if we can */
|
||||
int tone_zone_register_zone(int fd, struct tone_zone *z);
|
||||
|
||||
/* Retrieve a raw tone zone structure */
|
||||
struct tone_zone *tone_zone_find(char *country);
|
||||
|
||||
/* Retrieve a raw tone zone structure by id instead of country*/
|
||||
struct tone_zone *tone_zone_find_by_num(int id);
|
||||
|
||||
/* Retrieve a string name for a given tone id */
|
||||
char *tone_zone_tone_name(int id);
|
||||
|
||||
/* Set a given file descriptor into a given country -- USE THIS
|
||||
INTERFACE INSTEAD OF THE IOCTL ITSELF. Auto-loads tone
|
||||
zone if necessary */
|
||||
int tone_zone_set_zone(int fd, char *country);
|
||||
|
||||
/* Get the current tone zone */
|
||||
int tone_zone_get_zone(int fd);
|
||||
|
||||
/* Play a given tone, loading tone zone automatically
|
||||
if necessary */
|
||||
int tone_zone_play_tone(int fd, int toneid);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* wavformat.h -- data structures and associated definitions for wav files
|
||||
*
|
||||
* By Michael Spiceland (mspiceland@digium.com)
|
||||
*
|
||||
* (C) 2009 Digium, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* See http://www.asterisk.org for more information about
|
||||
* the Asterisk project. Please do not directly contact
|
||||
* any of the maintainers of this project for assistance;
|
||||
* the project provides a web site, mailing lists and IRC
|
||||
* channels for your use.
|
||||
*
|
||||
* This program is free software, distributed under the terms of
|
||||
* the GNU General Public License Version 2 as published by the
|
||||
* Free Software Foundation. See the LICENSE file included with
|
||||
* this program for more details.
|
||||
*/
|
||||
|
||||
#ifndef WAVFORMAT_H
|
||||
#define WAVFORMAT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct wavheader {
|
||||
/* riff type chunk */
|
||||
char riff_chunk_id[4];
|
||||
uint32_t riff_chunk_size;
|
||||
char riff_type[4];
|
||||
|
||||
/* format chunk */
|
||||
char fmt_chunk_id[4];
|
||||
uint32_t fmt_data_size;
|
||||
uint16_t fmt_compression_code;
|
||||
uint16_t fmt_num_channels;
|
||||
uint32_t fmt_sample_rate;
|
||||
uint32_t fmt_avg_bytes_per_sec;
|
||||
uint16_t fmt_block_align;
|
||||
uint16_t fmt_significant_bps;
|
||||
|
||||
/* data chunk */
|
||||
char data_chunk_id[4];
|
||||
uint32_t data_data_size;
|
||||
} __attribute__((packed));
|
||||
|
||||
#endif
|
|
@ -0,0 +1,202 @@
|
|||
PEDANTIC = -ansi -pedantic -std=c99
|
||||
|
||||
INSTALL = install
|
||||
INSTALL_DATA = install -m 644
|
||||
|
||||
#
|
||||
# Ugly hack to find kernel directories before/after the split
|
||||
# to kernel/user-space.
|
||||
#
|
||||
# These variables should be passed to us. But until then...
|
||||
#
|
||||
DAHDI_TOOLSDIR ?= ..
|
||||
DAHDI_KERNELDIR =
|
||||
|
||||
-include $(DAHDI_TOOLSDIR)/makeopts
|
||||
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
# In 1.4 those are provided by autoconf through makeopts
|
||||
prefix ?= /usr
|
||||
datadir ?= $(prefix)/share
|
||||
mandir ?= $(datadir)/man
|
||||
sysconfdir ?= $(prefix)/etc
|
||||
udevrulesdir ?= $(sysconfdir)/udev/rules.d
|
||||
INSTALL ?= install
|
||||
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
|
||||
SBINDIR = $(prefix)/sbin
|
||||
DATADIR = $(datadir)/dahdi
|
||||
MANDIR = $(mandir)/man8
|
||||
HOTPLUG_USB_DIR = $(sysconfdir)/hotplug/usb
|
||||
PERLLIBDIR := $(shell eval `perl -V:sitelib`; echo "$$sitelib")
|
||||
PERL_DIRS := $(shell cd perl_modules; find * -name '[A-Z]*' -type d| xargs)
|
||||
PERL_MODS_PAT := *.pm $(PERL_DIRS:%=%/*.pm)
|
||||
PERL_MODS := $(shell cd perl_modules; echo $(PERL_MODS_PAT))
|
||||
|
||||
# Variables that should be defined above, but need sane defaults:
|
||||
# FIXME: Are those values really sane?
|
||||
HOSTCC ?= $(CC)
|
||||
|
||||
USE_OCTASIC := yes
|
||||
OCTASIC_DIR := oct612x
|
||||
|
||||
ifneq (no,$(USE_OCTASIC))
|
||||
|
||||
OCT_OBJS = $(shell $(OCTASIC_DIR)/octasic-helper objects $(OCTASIC_DIR))
|
||||
OCT_SRCS = $(shell echo $(OCT_OBJS) | tr -s ' ' '\n' | sed 's/\.o$$/.c/g')
|
||||
OCT_HERE_OBJS = $(shell echo $(OCT_OBJS) | tr -s ' ' '\n' | sed 's,^.*/,,')
|
||||
OCT_CFLAGS = $(shell $(OCTASIC_DIR)/octasic-helper cflags $(OCTASIC_DIR))
|
||||
OCT_DEFINES = \
|
||||
-DPTR_TYPE=uint32_t \
|
||||
-DcOCT6100_INTERNAL_SUPER_ARRAY_SIZE=1024 \
|
||||
-DcOCT6100_MAX_ECHO_CHANNELS=672 \
|
||||
-DcOCT6100_MAX_MIXER_EVENTS=1344
|
||||
|
||||
ECHO_LOADER_SRC = echo_loader.c parse_span_specs.c
|
||||
ECHO_LOADER = $(ECHO_LOADER_SRC:.c=.o)
|
||||
endif
|
||||
|
||||
%.8: %
|
||||
pod2man --section 8 $^ > $@ || $(RM) $@
|
||||
PERL_SCRIPTS = \
|
||||
dahdi_registration \
|
||||
xpp_sync \
|
||||
lsdahdi \
|
||||
xpp_blink \
|
||||
dahdi_genconf \
|
||||
dahdi_hardware \
|
||||
twinstar \
|
||||
#
|
||||
|
||||
PERL_MANS = $(PERL_SCRIPTS:%=%.8)
|
||||
|
||||
# List all our sources
|
||||
XUSB_SRCS = xtalk/xusb.c xtalk/xlist.c xtalk/debug.c
|
||||
XTALK_SRCS = xtalk/xtalk.c
|
||||
MPPTALK_SRCS = mpptalk.c
|
||||
ASTRIBANK_SRCS = astribank_usb.c
|
||||
ABHEXLOAD_SRCS = astribank_hexload.c hexfile.c pic_loader.c
|
||||
ABTOOL_SRCS = astribank_tool.c
|
||||
ABALLOW_SRCS = astribank_allow.c astribank_license.c
|
||||
|
||||
SRCS = \
|
||||
$(XUSB_SRCS) \
|
||||
$(XTALK_SRCS) \
|
||||
$(MPPTALK_SRCS) \
|
||||
$(ASTRIBANK_SRCS) \
|
||||
$(ABHEXLOAD_SRCS) \
|
||||
$(ABTOOL_SRCS) \
|
||||
$(ABALLOW_SRCS) \
|
||||
$(ECHO_LOADER_SRC)
|
||||
|
||||
# Derive object files from source list
|
||||
XUSB_OBJS = $(XUSB_SRCS:.c=.o)
|
||||
XTALK_OBJS = $(XTALK_SRCS:.c=.o) $(XUSB_OBJS)
|
||||
MPPTALK_OBJS = $(MPPTALK_SRCS:.c=.o) $(XTALK_OBJS)
|
||||
ASTRIBANK_OBJS = $(ASTRIBANK_SRCS:.c=.o) $(MPPTALK_OBJS)
|
||||
ABHEXLOAD_OBJS = $(ABHEXLOAD_SRCS:.c=.o) $(ASTRIBANK_OBJS) $(ECHO_LOADER) $(OCT_HERE_OBJS)
|
||||
ABTOOL_OBJS = $(ABTOOL_SRCS:.c=.o) $(ASTRIBANK_OBJS)
|
||||
ABALLOW_OBJS = $(ABALLOW_SRCS:.c=.o) $(ASTRIBANK_OBJS)
|
||||
|
||||
TARGETS = .perlcheck astribank_is_starting
|
||||
PROG_INSTALL = astribank_is_starting
|
||||
MAN_INSTALL = $(PROG_INSTALL:%=%.8)
|
||||
ifeq (1,$(PBX_USB))
|
||||
TARGETS += \
|
||||
astribank_tool \
|
||||
astribank_hexload \
|
||||
astribank_allow \
|
||||
test_parse
|
||||
PROG_INSTALL += astribank_tool astribank_hexload astribank_allow
|
||||
endif
|
||||
ifneq (,$(PERLLIBDIR))
|
||||
PROG_INSTALL += $(PERL_SCRIPTS)
|
||||
TARGETS += $(PERL_MANS)
|
||||
endif
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
docs: $(PERL_MANS)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d $(DESTDIR)$(SBINDIR)
|
||||
$(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(SBINDIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(DATADIR)
|
||||
$(INSTALL) xpp_fxloader astribank_hook $(DESTDIR)$(DATADIR)/
|
||||
$(INSTALL) waitfor_xpds $(DESTDIR)$(DATADIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(udevrulesdir)
|
||||
$(INSTALL_DATA) xpp.rules $(DESTDIR)$(udevrulesdir)/
|
||||
$(INSTALL) -d $(DESTDIR)$(MANDIR)
|
||||
$(INSTALL_DATA) $(MAN_INSTALL) $(DESTDIR)$(MANDIR)/
|
||||
$(INSTALL) -d $(DESTDIR)$(HOTPLUG_USB_DIR)
|
||||
$(INSTALL_DATA) xpp_fxloader.usermap $(DESTDIR)$(HOTPLUG_USB_DIR)/
|
||||
# for backward compatibility and for hotplug users:
|
||||
ln -sf $(DATADIR)/xpp_fxloader $(DESTDIR)$(HOTPLUG_USB_DIR)/
|
||||
ifneq (,$(PERLLIBDIR))
|
||||
$(INSTALL) -d $(DESTDIR)$(PERLLIBDIR)
|
||||
for i in $(PERL_DIRS); \
|
||||
do \
|
||||
$(INSTALL) -d "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
|
||||
done
|
||||
for i in $(PERL_MODS); \
|
||||
do \
|
||||
$(INSTALL_DATA) "perl_modules/$$i" "$(DESTDIR)$(PERLLIBDIR)/$$i"; \
|
||||
done
|
||||
endif
|
||||
|
||||
CFLAGS += -I. -Ixtalk -Wall -Werror
|
||||
|
||||
astribank_hexload: $(ABHEXLOAD_OBJS)
|
||||
astribank_hexload: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
astribank_hexload: CFLAGS+=$(OCT_CFLAGS)
|
||||
|
||||
astribank_tool: $(ABTOOL_OBJS)
|
||||
astribank_tool: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
astribank_allow: $(ABALLOW_OBJS)
|
||||
astribank_allow: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
astribank_is_starting: astribank_is_starting.o
|
||||
astribank_is_starting: LIBS+=$(EXTRA_LIBS)
|
||||
|
||||
hex2iic: hex2iic.o iic.o hexfile.o
|
||||
|
||||
test_parse: test_parse.o hexfile.o
|
||||
test_parse: LIBS+=$(EXTRA_LIBS) $(USB_LIB)
|
||||
|
||||
ifneq (no,$(USE_OCTASIC))
|
||||
.octasic.depend: $(OCTASIC_DIR)/octasic-helper Makefile ../config.status
|
||||
$(CC) -MM $(OCT_CFLAGS) \
|
||||
`$(OCTASIC_DIR)/octasic-helper objects | \
|
||||
tr -s ' ' '\n' | \
|
||||
sed -e 's,.*,$(OCTASIC_DIR)/&,' -e 's/\.o$$/.c/'` > $@
|
||||
|
||||
-include .octasic.depend
|
||||
|
||||
$(OCT_HERE_OBJS): Makefile
|
||||
$(CC) -c $(CFLAGS) $(OCT_CFLAGS) $(OCT_DEFINES) $(OCT_SRCS)
|
||||
|
||||
endif
|
||||
|
||||
|
||||
%: %.o
|
||||
$(CC) $(LDFLAGS) $^ $(LIBS) -o $@
|
||||
|
||||
.perlcheck: $(PERL_SCRIPTS)
|
||||
for i in $^; do perl -I./perl_modules -c $$i || exit 1; done
|
||||
touch $@
|
||||
|
||||
clean:
|
||||
$(RM) .depend .octasic.depend *.o xtalk/*.o $(OCT_HERE_OBJS) $(TARGETS)
|
||||
|
||||
.PHONY: depend
|
||||
ifeq (1,$(PBX_USB))
|
||||
depend: .depend
|
||||
.depend: *.c *.h xtalk/*.c
|
||||
@echo "Calculating dependencies"
|
||||
@if ! $(CC) $(CFLAGS) $(OCT_CFLAGS) -MM $(SRCS) > $@; then $(RM) $@; exit 1; fi
|
||||
|
||||
include .depend
|
||||
endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,80 @@
|
|||
.TH "ASTRIBANK_ALLOW" "8" "29 March 2009" "" ""
|
||||
|
||||
.SH NAME
|
||||
astribank_allow \- License Xorcom Astribank (xpp) capabilities.
|
||||
.SH SYNOPSIS
|
||||
.B astribank_allow \-D \fIdevice-path\fR [ options ]
|
||||
|
||||
.B astribank_allow [\-h]
|
||||
|
||||
.SH DESCRIPTION
|
||||
Modern Astribanks (with USB product id's 116x) contain capabilities
|
||||
that may be licensed.
|
||||
|
||||
.B astribank_allow
|
||||
is used to upload/download the licensing information to/from the device.
|
||||
|
||||
Uploading a valid license file to an Astribank, changes its capabilities.
|
||||
The change becomes effective after a firmware reset (either by powering
|
||||
the device off and on again, or via the \fBastribank_tool\fR full reset option).
|
||||
|
||||
Downloading license from the device, produces a valid license file for its
|
||||
current capabilities. This may be backed up, so the device may be later
|
||||
restored to its previous capabilities.
|
||||
|
||||
The license file contains both a human readable description of the
|
||||
device capabilities for the end user and a hash of the licensing
|
||||
information used by Xorcom to generate/modify licensed capabilities.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-D
|
||||
.I device-path
|
||||
.RS
|
||||
Required. The device to read from/write to. This is
|
||||
\fIbus_num\fR/\fIdevice_num\fR, where \fIbus_num\fR and \fIdevice_num\fR
|
||||
are the first two numbers in the output of lsusb(8) or dahdi_hardware(8).
|
||||
On older versions of this tool you needed a complete path to the device,
|
||||
which would be /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR, or
|
||||
/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
|
||||
.RE
|
||||
|
||||
.B \-w
|
||||
.RS
|
||||
Write capabilities to EEPROM, otherwise read capabilities
|
||||
.RE
|
||||
|
||||
.B \-f \fIfilename\fR
|
||||
.RS
|
||||
License filename (stdin/stdout if not specified)
|
||||
.RE
|
||||
|
||||
.B \-m \fInum\fR
|
||||
.RS
|
||||
Choose the numeric code of license markers to generate.
|
||||
This code select the type of \fIBEGIN\fR.../\fIEND\fR... strings
|
||||
that delimit the license body.
|
||||
|
||||
Valid marker codes are listed with the \fB-h\fR option.
|
||||
The default (and first) code is \fB1\fR. Zero is illegal value.
|
||||
.RE
|
||||
|
||||
.B \-v
|
||||
.RS
|
||||
Increase verbosity. May be used multiple times.
|
||||
.RE
|
||||
|
||||
.B \-d \fImask\fR
|
||||
.RS
|
||||
Set debug mask to \fImask\fR. Default is 0, 0xFF is "everything".
|
||||
.RE
|
||||
|
||||
.B \-h
|
||||
.RS
|
||||
Displays usage message.
|
||||
.RE
|
||||
|
||||
.SH SEE ALSO
|
||||
fxload(8), lsusb(8), astribank_hexload(8), astribank_tool(8)
|
||||
|
||||
.SH AUTHOR
|
||||
Alex Landau
|
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* Written by Oron Peled <oron@actcom.co.il> and
|
||||
* Alex Landau <alex.landau@xorcom.com>
|
||||
* Copyright (C) 2008, Xorcom
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#include "mpp.h"
|
||||
#include "mpptalk.h"
|
||||
#include <debug.h>
|
||||
#include "astribank_license.h"
|
||||
|
||||
static const char rcsid[] = "$Id$";
|
||||
|
||||
#define DBG_MASK 0x80
|
||||
|
||||
static char *progname;
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> options\n", progname);
|
||||
fprintf(stderr, "\tOptions:\n");
|
||||
fprintf(stderr, "\t\t[-v] # Increase verbosity\n");
|
||||
fprintf(stderr, "\t\t[-d mask] # Debug mask (0xFF for everything)\n");
|
||||
fprintf(stderr, "\t\t[-w] # Write capabilities to EEPROM, otherwise read capabilities\n");
|
||||
fprintf(stderr, "\t\t[-f filename] # License filename (stdin/stdout if not specified)\n\n");
|
||||
fprintf(stderr, "\t\t[-m num] # Numeric code of License markers to generate\n");
|
||||
license_markers_help("\t", stderr);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static int capabilities_burn(
|
||||
struct astribank_device *astribank,
|
||||
struct eeprom_table *eeprom_table,
|
||||
struct capabilities *capabilities,
|
||||
struct capkey *key)
|
||||
{
|
||||
int ret;
|
||||
|
||||
INFO("Burning capabilities\n");
|
||||
ret = mpp_caps_set(astribank, eeprom_table, capabilities, key);
|
||||
if(ret < 0) {
|
||||
ERR("Capabilities burning failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
INFO("Done\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *devpath = NULL;
|
||||
struct astribank_device *astribank;
|
||||
struct eeprom_table eeprom_table;
|
||||
struct capabilities caps;
|
||||
struct capkey key;
|
||||
const char options[] = "vd:D:wf:m:";
|
||||
int do_write = 0;
|
||||
unsigned int marker = LICENSE_MARKER_GENERIC;
|
||||
FILE *file;
|
||||
char *filename = NULL;
|
||||
int ret;
|
||||
|
||||
progname = argv[0];
|
||||
while (1) {
|
||||
int c;
|
||||
|
||||
c = getopt (argc, argv, options);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'D':
|
||||
devpath = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'd':
|
||||
debug_mask = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 'w':
|
||||
do_write = 1;
|
||||
break;
|
||||
case 'f':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'm':
|
||||
marker = strtoul(optarg, NULL, 0);
|
||||
if (!license_marker_valid(marker))
|
||||
usage();
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
ERR("Unknown option '%c'\n", c);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
if(!devpath) {
|
||||
ERR("Missing device path\n");
|
||||
usage();
|
||||
}
|
||||
DBG("Startup %s\n", devpath);
|
||||
if((astribank = mpp_init(devpath, 1)) == NULL) {
|
||||
ERR("Failed initializing MPP\n");
|
||||
return 1;
|
||||
}
|
||||
if(astribank->eeprom_type != EEPROM_TYPE_LARGE) {
|
||||
ERR("Cannot use this program with astribank EEPROM type %d (need %d)\n",
|
||||
astribank->eeprom_type, EEPROM_TYPE_LARGE);
|
||||
return 1;
|
||||
}
|
||||
ret = mpp_caps_get(astribank, &eeprom_table, &caps, &key);
|
||||
if(ret < 0) {
|
||||
ERR("Failed to get original capabilities: %d\n", ret);
|
||||
return 1;
|
||||
}
|
||||
if (do_write) {
|
||||
unsigned int used_marker;
|
||||
/* update capabilities based on input file */
|
||||
file = stdin;
|
||||
if (filename) {
|
||||
file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
ERR("Can't open file '%s'\n", filename);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ret = read_from_file(&eeprom_table, &caps, &key, &used_marker, file);
|
||||
if (ret < 0) {
|
||||
ERR("Failed to read capabilities from file: %d\n", ret);
|
||||
return 1;
|
||||
}
|
||||
show_capabilities(&caps, stderr);
|
||||
if (capabilities_burn(astribank, &eeprom_table, &caps, &key) < 0)
|
||||
return 1;
|
||||
if (file != stdin)
|
||||
fclose(file);
|
||||
} else {
|
||||
/* print capabilities to stdout */
|
||||
file = stdout;
|
||||
if (filename) {
|
||||
file = fopen(filename, "w");
|
||||
if (file == NULL) {
|
||||
ERR("Can't create file '%s'\n", filename);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ret = write_to_file(&eeprom_table, &caps, &key, marker, file);
|
||||
if (ret < 0) {
|
||||
ERR("Failed to write capabilities to file: %d\n", ret);
|
||||
return 1;
|
||||
}
|
||||
if (file != stdout)
|
||||
fclose(file);
|
||||
}
|
||||
mpp_exit(astribank);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
.TH "ASTRIBANK_HEXLOAD" "8" "30 May 2011" "" ""
|
||||
|
||||
.SH NAME
|
||||
astribank_hexload \- Xorcom Astribank (xpp) firmware loader
|
||||
.SH SYNOPSIS
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-F [\fIoptions\fR] \fIhexfile\fR
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-p [\fIoptions\fR] \fIhexfile1 .. hexfile4\fR
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-O [-A] [-S \fIspan-specs\fR] [\fIoptions\fR] \fIimagefile\fR
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-o [\fIoptions\fR]
|
||||
|
||||
.B astribank_hexload \-D \fIdevice-path\fR \-E [\fIoptions\fR] \fIhexfile\fR
|
||||
|
||||
.B astribank_hexload \-h
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B astribank_hexload
|
||||
is a second-stage firmware loader for Xorcom Astribanks.
|
||||
|
||||
Note that some very old models use fpga_load(8) instead.
|
||||
This legacy tool hasn't been used for several releases.
|
||||
It can be found in version 2.6 and below of dahdi-tools.
|
||||
|
||||
The astribank_hexload(8) program is used to load a file in the
|
||||
Intel HEX format into a Xorcom Astribank.
|
||||
It can be used to load either an FPGA firmware or a PIC
|
||||
firmware. It is normally run by the script xpp_fxloader.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-D
|
||||
.I device-path
|
||||
.RS
|
||||
Required. The device to read from/write to. This is
|
||||
\fIbus_num\fR/\fIdevice_num\fR, where \fIbus_num\fR and \fIdevice_num\fR
|
||||
are the first two numbers in the output of lsusb(8) or dahdi_hardware(8).
|
||||
On older versions of this tool you needed a complete path to the device,
|
||||
which would be /dev/bus/usb/\fIbus_num\fR/\fIdevice_num\fR, or
|
||||
/proc/bus/usb/\fIbus_num\fR/\fIdevice_num\fR.
|
||||
.RE
|
||||
|
||||
One of the following is required:
|
||||
|
||||
.B \-F
|
||||
.RS
|
||||
The firmware to load is a FPGA firmware.
|
||||
.RE
|
||||
|
||||
.B \-p
|
||||
.RS
|
||||
The firmwares to load is are PIC firmwares. All (typically 4) should be
|
||||
on the command-line.
|
||||
.RE
|
||||
|
||||
.B \-O
|
||||
.RS
|
||||
The firmware to load is an Octasic echo canceller firmware image file.
|
||||
.RE
|
||||
|
||||
.B \-o
|
||||
.RS
|
||||
Don't load firmware. Just print the version number of the currently-loaded
|
||||
Octasic echo canceller firmware.
|
||||
.RE
|
||||
|
||||
.B \-E
|
||||
.RS
|
||||
The firmware to load is a special EEPROM burning one.
|
||||
.RE
|
||||
|
||||
|
||||
Other options:
|
||||
|
||||
.B \-v
|
||||
.RS
|
||||
Increase verbosity. May be used multiple times.
|
||||
.RE
|
||||
|
||||
.B \-d \fImask\fR
|
||||
.RS
|
||||
Set debug mask to \fImask\fR. Default is 0, 0xFF is "everything".
|
||||
.RE
|
||||
|
||||
.B \-h
|
||||
.RS
|
||||
Displays usage message.
|
||||
.RE
|
||||
|
||||
.B \-A
|
||||
.RS
|
||||
When loading a Octasic echo canceller firmware, set the channels of the
|
||||
first Astribank module to use aLaw (G.711a). This is what you'd normally
|
||||
use for BRI and E1. If not set, the default mu-Law (G.711u), which is
|
||||
what you'd normally use for FXS, FXO and T1.
|
||||
.RE
|
||||
|
||||
.B \-S \fIspan-specs\fR
|
||||
.RS
|
||||
This option should only be used when loading Octasic echo canceller firmware
|
||||
and only if the first Astribank module is PRI.
|
||||
|
||||
Its goal is to allow specifying different \fIline-mode\fR (E1/T1/J1) in different
|
||||
ports of the PRI module. \fBastribank_hexload\fR use the \fIspan-specs\fR argument
|
||||
to select aLaw/uLaw for each of the PRI ports in the module.
|
||||
|
||||
The \fIspan-specs\fR is a list of items separated by whitespace or commas.
|
||||
Each item is composed of a port selector, colon and a \fIline-mode\fR specifier.
|
||||
This syntax follows the syntax of specifiers in \fB/etc/dahdi/span-types.conf\fR.
|
||||
|
||||
Examples:
|
||||
.RS
|
||||
3:E1 \- The 3'rd port is E1.
|
||||
|
||||
*:T1 \- Any unspecified port is T1 (wildcard match).
|
||||
|
||||
1:T1,2:T1,*:E1 \- First and second ports are T1, the rest are E1.
|
||||
.RE
|
||||
|
||||
If the \fB\-S\fR is not given, the PRI default is determined by the existance of the \fB\-A-fR option.
|
||||
.RE
|
||||
|
||||
.SH SEE ALSO
|
||||
fxload(8), lsusb(8), astribank_tool(8)
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> .
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
|
@ -0,0 +1,316 @@
|
|||
/*
|
||||
* Written by Oron Peled <oron@actcom.co.il>
|
||||
* Copyright (C) 2008, Xorcom
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <debug.h>
|
||||
#include "hexfile.h"
|
||||
#include "mpptalk.h"
|
||||
#include "pic_loader.h"
|
||||
#include "echo_loader.h"
|
||||
#include "astribank_usb.h"
|
||||
#include "../autoconfig.h"
|
||||
|
||||
#define DBG_MASK 0x80
|
||||
#define MAX_HEX_LINES 64000
|
||||
#define HAVE_OCTASIC 1
|
||||
#define DEF_SPAN_SPEC_FORMAT "*:%c1" /* %c: 'E' or 'T' */
|
||||
|
||||
static char *progname;
|
||||
|
||||
static void usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [options...] -D {/proc/bus/usb|/dev/bus/usb}/<bus>/<dev> hexfile...\n", progname);
|
||||
fprintf(stderr, "\tOptions: {-F|-p}\n");
|
||||
fprintf(stderr, "\t\t[-E] # Burn to EEPROM\n");
|
||||
#if HAVE_OCTASIC
|
||||
fprintf(stderr, "\t\t[-O] # Load Octasic firmware\n");
|
||||
fprintf(stderr, "\t\t[-o] # Show Octasic version\n");
|
||||
fprintf(stderr, "\t\t[-S <pri-spec>] # Set PRI type specification string\n");
|
||||
#endif
|
||||
fprintf(stderr, "\t\t[-F] # Load FPGA firmware\n");
|
||||
fprintf(stderr, "\t\t[-p] # Load PIC firmware\n");
|
||||
fprintf(stderr, "\t\t[-v] # Increase verbosity\n");
|
||||
fprintf(stderr, "\t\t[-A] # Set A-Law for 1st module\n");
|
||||
fprintf(stderr, "\t\t[-d mask] # Debug mask (0xFF for everything)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int handle_hexline(struct astribank_device *astribank, struct hexline *hexline)
|
||||
{
|
||||
uint16_t len;
|
||||
uint16_t offset_dummy;
|
||||
uint8_t *data;
|
||||
int ret;
|
||||
|
||||
assert(hexline);
|
||||
assert(astribank);
|
||||
if(hexline->d.content.header.tt != TT_DATA) {
|
||||
DBG("Non data record type = %d\n", hexline->d.content.header.tt);
|
||||
return 0;
|
||||
}
|
||||
len = hexline->d.content.header.ll;
|
||||
offset_dummy = hexline->d.content.header.offset;
|
||||
data = hexline->d.content.tt_data.data;
|
||||
if((ret = mpp_send_seg(astribank, data, offset_dummy, len)) < 0) {
|
||||
ERR("Failed hexfile send line: %d\n", ret);
|
||||
return -EINVAL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void print_parse_errors(int level, const char *msg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
if (verbose > level) {
|
||||
va_start (ap, msg);
|
||||
vfprintf (stderr, msg, ap);
|
||||
va_end (ap);
|
||||
}
|
||||
}
|
||||
|
||||
static int load_hexfile(struct astribank_device *astribank, const char *hexfile, enum dev_dest dest)
|
||||
{
|
||||
struct hexdata *hexdata = NULL;
|
||||
int finished = 0;
|
||||
int ret;
|
||||
unsigned i;
|
||||
char star[] = "+\\+|+/+-";
|
||||
const char *devstr;
|
||||
|
||||
parse_hexfile_set_reporting(print_parse_errors);
|
||||
if((hexdata = parse_hexfile(hexfile, MAX_HEX_LINES)) == NULL) {
|
||||
perror(hexfile);
|
||||
return -errno;
|
||||
}
|
||||
devstr = xusb_devpath(astribank->xusb);
|
||||
INFO("%s [%s]: Loading %s Firmware: %s (version %s)\n",
|
||||
devstr,
|
||||
xusb_serial(astribank->xusb),
|
||||
dev_dest2str(dest),
|
||||
hexdata->fname, hexdata->version_info);
|
||||
if((ret = mpp_send_start(astribank, dest, hexdata->version_info)) < 0) {
|
||||
ERR("%s: Failed hexfile send start: %d\n", devstr, ret);
|
||||
return ret;
|
||||
}
|
||||
for(i = 0; i < hexdata->maxlines; i++) {
|
||||
struct hexline *hexline = hexdata->lines[i];
|
||||
|
||||
if(!hexline)
|
||||
break;
|
||||
if(verbose > LOG_INFO) {
|
||||
printf("Sending: %4d%% %c\r", (100 * i) / hexdata->last_line, star[i % sizeof(star)]);
|
||||
fflush(stdout);
|
||||
}
|
||||
if(finished) {
|
||||
ERR("%s: Extra data after End Of Data Record (line %d)\n", devstr, i);
|
||||
return 0;
|
||||
}
|
||||
if(hexline->d.content.header.tt == TT_EOF) {
|
||||
DBG("End of data\n");
|
||||
finished = 1;
|
||||
continue;
|
||||
}
|
||||
if((ret = handle_hexline(astribank, hexline)) < 0) {
|
||||
ERR("%s: Failed hexfile sending in lineno %d (ret=%d)\n", devstr, i, ret);;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
if(verbose > LOG_INFO) {
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
}
|
||||
if((ret = mpp_send_end(astribank)) < 0) {
|
||||
ERR("%s: Failed hexfile send end: %d\n", devstr, ret);
|
||||
return ret;
|
||||
}
|
||||
#if 0
|
||||
fclose(fp);
|
||||
#endif
|
||||
free_hexdata(hexdata);
|
||||
DBG("hexfile loaded successfully\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *devpath = NULL;
|
||||
int opt_pic = 0;
|
||||
int opt_echo = 0;
|
||||
int opt_ecver = 0;
|
||||
#if HAVE_OCTASIC
|
||||
int opt_alaw = 0;
|
||||
const char *span_spec = NULL;
|
||||
char def_span_spec[sizeof(DEF_SPAN_SPEC_FORMAT)];
|
||||
#endif
|
||||
int opt_dest = 0;
|
||||
int opt_sum = 0;
|
||||
enum dev_dest dest = DEST_NONE;
|
||||
const char options[] = "vd:D:EFOopAS:";
|
||||
int iface_num;
|
||||
int ret;
|
||||
|
||||
progname = argv[0];
|
||||
while (1) {
|
||||
int c;
|
||||
|
||||
c = getopt (argc, argv, options);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
switch (c) {
|
||||
case 'D':
|
||||
devpath = optarg;
|
||||
break;
|
||||
case 'E':
|
||||
if(dest != DEST_NONE) {
|
||||
ERR("The -F and -E options are mutually exclusive.\n");
|
||||
usage();
|
||||
}
|
||||
opt_dest++;
|
||||
dest = DEST_EEPROM;
|
||||
break;
|
||||
case 'F':
|
||||
if(dest != DEST_NONE) {
|
||||
ERR("The -F and -E options are mutually exclusive.\n");
|
||||
usage();
|
||||
}
|
||||
opt_dest++;
|
||||
dest = DEST_FPGA;
|
||||
break;
|
||||
#if HAVE_OCTASIC
|
||||
case 'O':
|
||||
opt_echo = 1;
|
||||
break;
|
||||
case 'o':
|
||||
opt_ecver = 1;
|
||||
break;
|
||||
case 'A':
|
||||
opt_alaw = 1;
|
||||
break;
|
||||
case 'S':
|
||||
span_spec = optarg;
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
opt_pic = 1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'd':
|
||||
debug_mask = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
ERR("Unknown option '%c'\n", c);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
opt_sum = opt_dest + opt_pic + opt_echo;
|
||||
if(opt_sum > 1 || (opt_sum == 0 && opt_ecver == 0)) {
|
||||
ERR("The -F, -E"
|
||||
#if HAVE_OCTASIC
|
||||
", -O"
|
||||
#endif
|
||||
" and -p options are mutually exclusive, if neither is used then -o should present\n");
|
||||
usage();
|
||||
}
|
||||
iface_num = (opt_dest) ? 1 : 0;
|
||||
if(!opt_pic && !opt_ecver) {
|
||||
if(optind != argc - 1) {
|
||||
ERR("Got %d hexfile names (Need exactly one hexfile)\n",
|
||||
argc - 1 - optind);
|
||||
usage();
|
||||
}
|
||||
}
|
||||
if(!devpath) {
|
||||
ERR("Missing device path.\n");
|
||||
usage();
|
||||
}
|
||||
# ifdef HAVE_OCTASIC
|
||||
if (!span_spec) {
|
||||
snprintf(def_span_spec, sizeof(def_span_spec),
|
||||
DEF_SPAN_SPEC_FORMAT, opt_alaw? 'E' : 'T');
|
||||
span_spec = def_span_spec;
|
||||
}
|
||||
#endif
|
||||
if(opt_dest) {
|
||||
/*
|
||||
* MPP Interface
|
||||
*/
|
||||
struct astribank_device *astribank;
|
||||
|
||||
if((astribank = mpp_init(devpath, iface_num)) == NULL) {
|
||||
ERR("%s: Opening astribank failed\n", devpath);
|
||||
return 1;
|
||||
}
|
||||
//show_astribank_info(astribank);
|
||||
if(load_hexfile(astribank, argv[optind], dest) < 0) {
|
||||
ERR("%s: Loading firmware to %s failed\n", devpath, dev_dest2str(dest));
|
||||
return 1;
|
||||
}
|
||||
astribank_close(astribank, 0);
|
||||
} else if(opt_pic || opt_echo || opt_ecver) {
|
||||
/*
|
||||
* XPP Interface
|
||||
*/
|
||||
struct astribank_device *astribank;
|
||||
|
||||
if((astribank = astribank_open(devpath, iface_num)) == NULL) {
|
||||
ERR("%s: Opening astribank failed\n", devpath);
|
||||
return 1;
|
||||
}
|
||||
//show_astribank_info(astribank);
|
||||
#if HAVE_OCTASIC
|
||||
if (opt_ecver) {
|
||||
if((ret = echo_ver(astribank)) < 0) {
|
||||
ERR("%s: Get Octasic version failed (Is Echo canceller card connected?)\n", devpath);
|
||||
return 1;
|
||||
} else
|
||||
INFO("Octasic version: 0x%0X\n", ret);
|
||||
}
|
||||
#endif
|
||||
if (opt_pic) {
|
||||
if ((ret = load_pic(astribank, argc - optind, argv + optind)) < 0) {
|
||||
ERR("%s: Loading PIC's failed\n", devpath);
|
||||
return 1;
|
||||
}
|
||||
#if HAVE_OCTASIC
|
||||
} else if (opt_echo) {
|
||||
if((ret = load_echo(astribank, argv[optind], opt_alaw, span_spec)) < 0) {
|
||||
ERR("%s: Loading ECHO's failed\n", devpath);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
astribank_close(astribank, 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,234 @@
|
|||
#! /bin/sh
|
||||
|
||||
me=`basename $0`
|
||||
dir=`dirname $0`
|
||||
LOGGER="logger -i -t '$me'"
|
||||
|
||||
# Always redirect stderr somewhere, otherwise the shell script will die
|
||||
# when it tries to do I/O related stuff on closed file descriptor.
|
||||
# Our default is to throw it down the bit-bucket.
|
||||
#exec 2> /dev/console
|
||||
## If you wish to trace this script:
|
||||
#exec 2> "/tmp/${me}_$XBUS_NAME" 1>&2
|
||||
|
||||
# Our directory in the beginning, so we can use local lab setup
|
||||
PATH="$dir:/usr/sbin:/sbin:/usr/bin:/bin"
|
||||
|
||||
set -e
|
||||
|
||||
LOCK="/var/lock/twinstar_startup"
|
||||
|
||||
[ -r /etc/dahdi/init.conf ] && . /etc/dahdi/init.conf
|
||||
|
||||
# For lab testing
|
||||
liveconf="$dir/liveconf/dahdi"
|
||||
|
||||
if [ -d "$liveconf" ]; then
|
||||
dahdi_conf="$liveconf"
|
||||
else
|
||||
dahdi_conf="/etc/dahdi"
|
||||
fi
|
||||
|
||||
if [ "$XPP_HOTPLUG_DAHDI" != yes ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
export XPPORDER_CONF="$dahdi_conf/xpp_order"
|
||||
export DAHDI_CFG_CMD="dahdi_cfg -c $dahdi_conf/system.conf"
|
||||
export CALLED_FROM_ATRIBANK_HOOK=yes
|
||||
|
||||
can_full_async() {
|
||||
# Can we work aynchronously:
|
||||
# - Need modern Asterisk that accept hotplug DAHDI devices.
|
||||
# - Need DAHDI with "auto_assign_spans" == 0
|
||||
if [ "$ASTERISK_SUPPORTS_DAHDI_HOTPLUG" = yes ]; then
|
||||
aas_param='/sys/module/dahdi/parameters/auto_assign_spans'
|
||||
aas=`cat "$aas_param" 2>/dev/null`
|
||||
if [ "$aas" = 0 ]; then
|
||||
return 0
|
||||
else
|
||||
$LOGGER "No async operation ($aas_param != 0)"
|
||||
fi
|
||||
else
|
||||
$LOGGER "No async operation (ASTERISK_SUPPORTS_DAHDI_HOTPLUG!=yes)"
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
check_xpporder_conf() {
|
||||
if [ ! -r "$XPPORDER_CONF" ]; then
|
||||
(
|
||||
echo "Skip($ACTION): No '$XPPORDER_CONF'"
|
||||
echo "Removing uneeded startup semaphore"
|
||||
astribank_is_starting -v -r 2>&1
|
||||
) 2>&1 | $LOGGER
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
clean_lines() {
|
||||
sed -e 's/#.*//' -e 'y/\t/ /' -e 's/^ *//' -e 's/ *$//' -e '$s/$/\n/' "$XPPORDER_CONF"
|
||||
}
|
||||
|
||||
matched_devices() {
|
||||
ready=`grep -H READY /sys/bus/astribanks/devices/*/xbus_state | sed 's,/xbus_state.*,,'`
|
||||
for dev in $ready
|
||||
do
|
||||
label=`cat "$dev/label"`
|
||||
connector=`cat "$dev/connector"`
|
||||
xbus=`echo "$dev" | sed 's,.*/,,'`
|
||||
lineno=`clean_lines | egrep -n "^${label}$|^@${connector}$" | cut -d: -f1`
|
||||
if [ "$lineno" != "" ]; then
|
||||
#echo "$xbus: $XPPORDER_CONF:$lineno -- Match ${label} @${connector}" | $LOGGER
|
||||
printf "${xbus}\t${label}\n"
|
||||
else
|
||||
echo "${xbus}: ${label} @${connector} not found in $XPPORDER_CONF: Ignore($ACTION)" | $LOGGER
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Wait until udev finished processing our requests
|
||||
# so we know the device files were actually created
|
||||
# before trying dahdi_cfg et-al.
|
||||
wait_for_udev() {
|
||||
UDEV_SETTLE_MAX_TIME=10
|
||||
|
||||
echo "Waiting for udev to settle down..."
|
||||
if [ -x /sbin/udevsettle ]; then
|
||||
# Old system, stand-alone udevsettle command
|
||||
/sbin/udevsettle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
elif [ -x /sbin/udevadm ]; then
|
||||
# Assume modern system, udevadm has settle parameter
|
||||
if ! /sbin/udevadm settle --timeout="$UDEV_SETTLE_MAX_TIME"
|
||||
then
|
||||
echo "udevadm failed ($?)."
|
||||
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
|
||||
sleep "$UDEV_SETTLE_MAX_TIME"
|
||||
fi
|
||||
else
|
||||
echo "No udevsettle/udevadm."
|
||||
echo "Fallback to sleep $UDEV_SETTLE_MAX_TIME seconds."
|
||||
sleep "$UDEV_SETTLE_MAX_TIME"
|
||||
fi
|
||||
sleep 1 # Wait a bit more (races)
|
||||
}
|
||||
|
||||
start_dahdi() {
|
||||
wait_for_udev
|
||||
script=/etc/init.d/dahdi
|
||||
echo "Starting $script."
|
||||
"$script" start | logger -i -t "$script"
|
||||
status=$?
|
||||
echo "Status($script): $status"
|
||||
if [ -x "$dir/twinstar_hook" ]; then
|
||||
"$dir/twinstar_hook"
|
||||
fi
|
||||
# Finished astribanks
|
||||
echo "Removing semaphore"
|
||||
astribank_is_starting -v -r
|
||||
rm -f "$LOCK"
|
||||
}
|
||||
|
||||
old_synchronous_start() {
|
||||
NUM_GOOD=`matched_devices | wc -l`
|
||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||
if [ "$NUM_GOOD" -eq "$NUM_WANTED" ]; then
|
||||
(
|
||||
# Delay the initialization of the Astribank until the filesystem
|
||||
# is mounted read-write:
|
||||
test_file="/var/lock/astribank_test_file"
|
||||
for i in `seq 1 20`; do
|
||||
if touch $test_file 2> /dev/null; then
|
||||
rm -f $test_file
|
||||
break
|
||||
else
|
||||
echo "$0: [$i] - Failed writing '$test_file'...waiting" | $LOGGER
|
||||
sleep 1;
|
||||
fi
|
||||
done
|
||||
|
||||
if ln -s "$XBUS_NAME" "$LOCK"; then
|
||||
echo "START-DAHDI: Total $NUM_GOOD online." | $LOGGER
|
||||
# Fork services
|
||||
start_dahdi < /dev/null 2>&1 | $LOGGER
|
||||
else
|
||||
echo "$0: Was started: $(ls -l $LOCK)" | $LOGGER
|
||||
fi
|
||||
) < /dev/null 2>&1 | $LOGGER &
|
||||
fi
|
||||
}
|
||||
|
||||
old_synchronous_stop() {
|
||||
NUM_GOOD=`matched_devices | wc -l`
|
||||
NUM_WANTED=`clean_lines | sed '/^$/d' | wc -l`
|
||||
echo "$ACTION($XBUS_NAME): $NUM_GOOD/$NUM_WANTED from $XPPORDER_CONF" | $LOGGER
|
||||
if [ "$NUM_GOOD" -eq 0 ]; then
|
||||
echo "All Astribanks offline" | $LOGGER
|
||||
if [ -x "$dir/twinstar_hook" ]; then
|
||||
"$dir/twinstar_hook" || :
|
||||
fi
|
||||
rm -f "$LOCK"
|
||||
fi
|
||||
}
|
||||
|
||||
ab_list() {
|
||||
find /sys/devices -name idVendor 2>/dev/null | \
|
||||
xargs grep -H 'e4e4' 2>/dev/null | \
|
||||
sed -e 's/idVendor.*/idProduct/' | xargs grep -H '11[3456]' | \
|
||||
sed 's,/[^/]*$,,' || :
|
||||
}
|
||||
|
||||
tws_watchdog_enable() {
|
||||
devdir="/sys$DEVPATH"
|
||||
label=`cat "$devdir/label"`
|
||||
connector=`cat "$devdir/connector"`
|
||||
xbus=`echo "$devdir" | sed 's,.*/,,'`
|
||||
prefix="${xbus}: [${label}] @${connector}"
|
||||
TWS_NOAUTOJUMPFILE="$TWS_DIR/twinstar_no_autojump"
|
||||
if [ -e "$TWS_NOAUTOJUMPFILE" ]; then
|
||||
$LOGGER "$prefix: ignore wd (found $TWS_NOAUTOJUMPFILE)"
|
||||
else
|
||||
# Re-arm Astribank watchdog
|
||||
transportdir="$devdir/transport"
|
||||
busnum=`cat "$transportdir/busnum" 2>/dev/null || :`
|
||||
devnum=`cat "$transportdir/devnum" 2>/dev/null || :`
|
||||
devaddr=`printf "%03d/%03d" "$busnum" "$devnum"`
|
||||
$LOGGER "$prefix: enabling twinstar watchdog"
|
||||
astribank_tool -D "$devaddr" -w 1 2>&1 | $LOGGER
|
||||
fi
|
||||
}
|
||||
|
||||
#echo "$0: $ACTION($XBUS_NAME)" | $LOGGER
|
||||
case "$ACTION" in
|
||||
add)
|
||||
;;
|
||||
remove)
|
||||
ab=`ab_list | wc -l`
|
||||
if [ "$ab" -eq 0 ]; then
|
||||
$LOGGER "$prefix: No more Astribanks -- remove astribank_is_starting semaphore"
|
||||
astribank_is_starting -v -r 2>&1 | $LOGGER
|
||||
fi
|
||||
;;
|
||||
online)
|
||||
if can_full_async; then
|
||||
tws_watchdog_enable
|
||||
else
|
||||
old_synchronous_start
|
||||
fi
|
||||
;;
|
||||
offline)
|
||||
if can_full_async; then
|
||||
: # Nothing to do
|
||||
else
|
||||
old_synchronous_stop
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "$0: Unknown ACTION='$ACTION'" | $LOGGER
|
||||
echo "$0: ARGS='$*'" | $LOGGER
|
||||
echo "$0: ENV:" | $LOGGER
|
||||
env | $LOGGER
|
||||
exit 1
|
||||
esac
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
.TH "ASTRIBANK_IS_STARTING" "8" "16 August 2009" "" ""
|
||||
|
||||
.SH NAME
|
||||
astribank_is_starting \- Mark / check is a Xorcom Astribank (xpp) is starting
|
||||
.SH SYNOPSIS
|
||||
.B astribank_is_starting [\-d] [\-v] [\-t \fItimeout\fB] <\-a|\-r|\-w>
|
||||
|
||||
.B astribank_is_starting [\-d] [\-v]
|
||||
|
||||
.B astribank_is_starting \-h
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B astribank_is_starting
|
||||
is an internal tool used by various xpp scripts to mark that there may
|
||||
be an Astribank device currently initializing, and to check for that mark.
|
||||
|
||||
Technically the mark is a SysV semaphore.
|
||||
|
||||
.SH OPTIONS
|
||||
.B \-a
|
||||
.RS
|
||||
.B Add.
|
||||
Set the mark. Should return 0 unless there's an error.
|
||||
.RE
|
||||
|
||||
.B \-r
|
||||
.RS
|
||||
.B Remove.
|
||||
Reset the mark. Should return 0 unless there's an error.
|
||||
.RE
|
||||
|
||||
.BI \-t timeout
|
||||
.RS
|
||||
.B Timeout.
|
||||
Set the timeout value for the \fB\-w\fR option. Default is 60 seconds.
|
||||
.RE
|
||||
|
||||
.B \-w
|
||||
.RS
|
||||
.B Wait.
|
||||
Wait for mark to be reset. Should return 0 unless there's an error.
|
||||
.RE
|
||||
|
||||
Without \-a or \-r: return 0 if the mark has been set, or a non-zero value
|
||||
otherwise.
|
||||
|
||||
.B \-d
|
||||
.RS
|
||||
Print debug information to stderr.
|
||||
.RE
|
||||
|
||||
.B \-v
|
||||
.RS
|
||||
Verbose execution.
|
||||
.RE
|
||||
|
||||
.B \-h
|
||||
.RS
|
||||
Displays usage message.
|
||||
.RE
|
||||
|
||||
.SH FILES
|
||||
.B /proc/sysvipc/sem
|
||||
.RS
|
||||
If set, the astribank should appear there with the ID 11211168 (0xAB11A0).
|
||||
Naturally the ID (or rather, the usage of a semaphore in the first place)
|
||||
is an implementation detail that may change.
|
||||
.RE
|
||||
|
||||
.SH NOTES
|
||||
.B astribank_is_starting
|
||||
is used to mark the fact that an Astribank may be currently reenumerating
|
||||
(technically: distonnecting and connecting as a new USB device) after
|
||||
loading the firmware. Thus the script that loads the firmware
|
||||
(/usr/share/dahdi/xpp_fxloader) uses this utility to set the mark.
|
||||
|
||||
The mark is reset by /usr/share/dahdi/waitfor_xpds , which is typically
|
||||
run by the DAHDI init script and waits for all Astribanks to finish
|
||||
loading.
|
||||
|
||||
Q: Why do you use a semaphore?
|
||||
|
||||
A: because, unlike the filesystem, it is writable at any given time.
|
||||
|
||||
.SH BUGS
|
||||
Option ordering matter. The \fB\-v\fR and \fB\-d\fR options should preceed
|
||||
the actions (\fB\-a\fR, \fB\-r\fR and \fB\-w\fR).
|
||||
The \fB\-t\fItimeout\fR option should preceed the \fB\-w\fR option.
|
||||
|
||||
.SH SEE ALSO
|
||||
semctl(3)
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> .
|
||||
Permission is granted to copy, distribute and/or modify this document under
|
||||
the terms of the GNU General Public License, Version 2 any
|
||||
later version published by the Free Software Foundation.
|
||||
|
||||
On Debian systems, the complete text of the GNU General Public
|
||||
License can be found in /usr/share/common\-licenses/GPL.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue