wanpipe-2.3.3-7.tgz

This commit is contained in:
Harald Welte 2021-12-29 17:57:21 +01:00
parent 328a4d6c83
commit f5f46b9e5e
320 changed files with 42053 additions and 13637 deletions

View File

339
COPYING Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, 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
Appendix: 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., 675 Mass Ave, Cambridge, MA 02139, 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.

542
README
View File

@ -1,10 +1,10 @@
------------------------------------------------------------------------------
Linux WAN Router Utilities Package
------------------------------------------------------------------------------
Version 2.3.2-7
Jan 5 2006
Version Stable 2.3.3-7
Oct 03 2006
Author: Nenad Corbic <ncorbic@sangoma.com>
Copyright (c) 1995-2005 Sangoma Technologies Inc.
Copyright (c) 1995-2006 Sangoma Technologies Inc.
------------------------------------------------------------------------------
INTRODUCTION
@ -145,541 +145,11 @@ Special thanks to all the WANPIPE users who performed field-testing, reported
bugs and made valuable comments and suggestions that help us to improve this
product.
o The 2.3.2 release contains:
Stable TDMV Wanpipe drivers for Asterisk.
The TDMV drivers support both A102 and A104 cars.
Please read wanpipe/doc/README.asterisk
Stable TE3 Drivers for AFT A301 TE3 Unchannelized Card.
All WAN protocols are supported: Frame Relay, PPP, CHDLC..
For Latest Documentation Please visit:
Stable LIP Network Layer: Separates Wanpipe hardware from
the Network Protocols: Frame Relay, CHDLC,
PPP, LAPB API, XDLC API
Sangoma Wiki
o The 2.3.1 contains major structural driver changes.
The new Hardware Abstraction layer cleanly separates, the
physical layer from the driver/protocol layers.
Support for 2.6.X kernel.
o From 2.3.0 contains major structural driver changes
most notably the ADSL OS abstraction layer. ADLS drivers
can now be compiled against any custom kernel.
o From 2.2.6 release forward the new S514-7 Dual T/E1,
S514-8 Single TE1 and S518 ADSL cards are supproted.
o From 2.2.4 release forward the new S514-4 T/E1 and S514-5 56K
cards are supported.
o From 2.2.3 release forward ALL wanpipe modules
including API modules, can be recompiled from
./Setup installation script!
NO KERNEL RECOMPILATION is necessary.
o From 2.2.3 release forward, wanpipe directory
architecture has been changed. New home directory
for wanpipe is /etc/wanpipe.
o All old releases are in ../old_releases/wanpipe directory.
o Custom RPMs can be build based on current kernel image
by using the ./Setup buildrpm command.
Read the README.rpmbuild.
NEW IN STABLE 2.3.2-7 RELEASE
==============================
2.3.2-7
Jan 05 2005
o Allow CHDLC API to run in Non-Root mode
o LIP over Async Mode
o Bug fix in XDLC transmit code
o New Setup Driver Build logic using 2.6 Kbuild make files
2.3.2-6
Sep 24 2005
o AFT A102 TDM Bug Fix
The AFT A102 card could experience unpredicted
behaviour on extermely noisy T1/E1 lines.
This issue has now been fixed.
2.3.2-5
Sep 12 2005
o AFT A101/2 Drivers E1 State Update
Bug fix on displaying initial E1 state.
The LED displayed green on inital E1
start.
o AFT A101/2 Drivers Update
The AFT A101/2 cards configured for LIP PPP
segfaulted in some instances during shutdown.
o AFT A301 T3 Driver Updated
Tighter timeout conditions as well as
bug fix in rx,tx error handling.
o New Wanpipe firmware update program.
Option to auto update firmware on all
AFT cards.
./wanpipe/util/wan_aftup/update_aft_firm.sh -auto
2.3.2-4
Jun 14 2005
o Wanpipe PPP protocol
Bug fix in ip negotiation code
o Updates to ./Setup installation script
Added fixes for new distributions
Wanpipe compilation will now work on
partial linux HEADER source.
Therefore, no full source is necessary.
o Driver updates for new 2.6.12 kernel
Internals of the SOCKET API code.
af_wanpipe.c
2.3.2-3
May 06 2005
o A102 TDMV Driver Update
The A102 Driver will now provide clocking to
zaptel even if the front end is disconnected.
o A104 TDMV Driver
The A104 Driver failed to unload properly if
one tried to stop it before Asterisk.
This has now been fixed :)
2.3.2-2
Apr 28 2005
o Update to A102 Channelized Driver
The bug affected the shutdown of last
channelized interface. The last channelized
interface brought down all other interfaces
except the first one.
o Update to Bitstreaming driver
Failed to compile on gcc 3.3.
o Updated Setup installation script.
Setup will now catch common ZAPTEL
misconfigurations.
2.3.2-1
Apr 05 2005
Stable TDMV Wanpipe drivers for Asterisk.
The TDMV drivers support both A102 and A104 cars.
Please read wanpipe/doc/README.asterisk
Stable TE3 Drivers for AFT A301 TE3 Unchannelized Card.
All WAN protocols are supported: Frame Relay, PPP, CHDLC..
Stable LIP Network Layer: Separates Wanpipe hardware from
the Network Protocols: Frame Relay, CHDLC,
PPP, LAPB API, XDLC API
o 2.6 Kernel PCI Routing problem Fixed on S514 Cards
The S514 Card failed to initialize routed
irq.
o Minor bug fixes in statistic reporting
AFT and ADSL drivers.
o New README.asterisk
beta7-2.3.2
Mar 16 2005
o AFT TDMV Update
Added WINK support to TDMV driver.
o AFT TDMV Update
Fixed up latecny issues with RBS signalling
For A104 and A101/2 cards.
o AFT A104 and 101/2 drivers updates
Added checks to prevent stopping wanpipe while
Asterisk is running
o AFT A300 TE3 Update
Fixed the link restart recovery.
o AFT A104 TE1 Configuration Update
Update to the TE1 physical layer paramters
o AFT Firmware Update
The firmware update utility was updated
from the AFT300 TE3 card.
o AFT TE3 Driver Update
Removed the chip security check
beta6-2.3.2
Feb 25 2005
o AFT A104 Drivers: TDMV Update
The A104 cards did not default to bit
swapping in TDMV voice mode. This was
a configuration option. This update configures
the board for automatic bitswapping in
hardware by default.
beta5-2.3.2
Feb 21 2005
o AFT A104 Drivers
Fixed the FIFO leveling so that single timeslot
interfaces can operate properly
(TDMV Voice Only)
o AFT Front End TE1 Update
Synchronized fe timers and added checks
to avoid adding an already pending timer.
o AFT A101/2 Driver update
Fixed the 2 HDLC channel operation on
unchannelized card.
Add support for Master clocking from
a adjacent line, instead of the oscillator.
Used by TDM_VOICE switching applications.
Need: AFT A101/2 Firmware version V24
Fixed Synchronization issues with TDM VOICE
Racing condition exists during driver startup.
If the Front End comes up before interfaces
come up, timeslot synchornization can go out
of sync.
o New wan_aftup Utility
Located wanpipe/util/wan_aftup
Used to update AFT firmware.
Please read the README file
wanpipe/util/wan_aftup/README
o LIP Update
Updated Carrier loss recover on all LIP protocols.
Frame Relay, PPP, CHDLC
o Updated LIP Frame Relay API
Support for 1 byte reception
o Updated Hardware Probe
Includes the distinction between Channalized and
UnChannalized AFT cards.
o TDMV Echo Update
Improved echo canceling performance
o Wancfg
Updated the TDMV parameters
o Wanpipe TE3 Driver Update
Better front end recovery after
a front end disconnect.
o Wanpipe LIP Frame Relay API update
Wanpipe LIP debug messages removed
o Wanpipe hwprobe
Distinction between Channalized and Unchannalized cards
o AFT Security Check
Due to some bad pci busses, the chip security
checking has been made more robust.
o TDMV Span Number Update
beta4-2.3.2
Feb 04 2005
o Voice TDM BUG FIX
Both A104 and A101/2 card had a bug where
on T1/E1 re-connect an rx buffer would get
deallocated by mistake. After enough re-connects
all reallocated rx buffers would run out,
causing stop in commnunications.
o LIP Frame Relay Update
Added Frame Relay API capability
Added Frame Relay Q933 Signalling
o Voice TDM for European Standars BRI
If you compile zaptel with the BRI
patch, you must manually edit the
patches/kdrivers/src/net/sdla_tdmv.c file
and uncomment the:
CONFIG_ZAPATA_BRI_DCHANS option.
o Lip Frame Relay API Support
Update LIP API frame releay
support
o General Driver Update
Network interface behaviour on carrier
disconnect.
This update changes the network interface
state in case of carrier state change.
TEQL will now work properly over AFT
and LIP interfaces.
o TDM Voice
Added on an extra option under the
TDM network interface section:
TDMV_ECHO_OFF=[YES/NO]
This option should be used to disable
echo on particular span, since asterisk
echo configuration is global to all spans.
This way echo cancellation can be performed
only on a span that needs this service.
o Wanpipemon Update
A more integrated wanpipemon that works with
the different layers of LIP and AFT.
beta3-2.3.2
Jan 04 2005
o A104 Quad Port TE1 Hardware Support
o X86_64 bit support for AMD Opteron and
Intel Itanium.
o Lip layer TTY support for Multilink PPP
Support up to 32 TTY links
o Major Bug Fix in LIP Layer
The bug could result in unexpected behaviour
on some distributions.
o Updated /proc/net/wanrouter/interface
statistics.
o PPP Multilink Support for AFT and ADSL cards.
Refer to wanpipe/doc/README.multilink
o Support for Fedora Core 3 distribution.
o Fixed support for REGPARM kernels.
o Updated Sangoma ASTERISK drivers.
Voice TDM update for A104 drivers.
o wanpipemon update
Works with LIP layer only.
o wanpipemon_legacy
Works with legacy drivers.
o wancfg update
Configures all drivers AFT,S514,ADSL
using LIP layer only.
o wancfg_legacy created
Used to configure legacy protocols
and API's.
beta2-2.3.2
Nov 8 2004
o AFT Update
Cleaned up messages in case of PCI errors
o TDM Voice Update
Added echo cancelation to the Asterisk
support.
beta1-2.3.2
Oct 18 2004
o Support for 2.6.X kernels
Fixed broken support for 2.6.9 kernel
o New Hardware Abstracion Layer
Cleanly separates the hardware
layer from the data/protocol layers.
o New AFT Hardware Support
Sangomas new high-speed T1/E1
adapters.
o New AFT T3 Support
Sangomas new high-speed T3/E3
adapters
o New LIP Network Layer
Separates Wanpipe hardware from
the Network Protocols.
Frame Relay Protocol
CHDLC Protocol
PPP Protocol
LAPB API
XDLC API
o New wancfg configuration utilty
One can only configure:
Frame Relay
PPP,
CHDLC,
HDLC (RAW) (TDM VOICE)
Note:
The old wancfg utility is called wancfg_adv.
PRODUCT COMPONENTS AND RELATED FILES
/etc/wanpipe/: (or user defined)
wanpipe1.conf default router configuration file
etc/wanpipe/samples:
interface sample interface configuration file
wanpipe1.cpri CHDLC primary port
wanpipe2.csec CHDLC secondary port
wanpipe1.fr Frame Relay protocol
wanpipe1.ppp PPP protocol )
wanpipe1.asy CHDLC ASYNC protocol
wanpipe1.x25 X25 protocol
wanpipe1.stty Sync TTY driver (Used by Kernel PPPD daemon)
wanpipe1.atty Async TTY driver (Used by Kernel PPPD daemon)
wanrouter.rc sample meta-configuration file
/etc/wanpipe/firmware:
fr514.sfm Frame relay firmware for Sangoma S508/S514 card
cdual514.sfm Dual Port Cisco HDLC firmware for Sangoma S508/S514 card
ppp514.sfm PPP Firmware for Sangoma S508 and S514 cards
x25_508.sfm X25 Firmware for Sangoma S508 card.
bscmp514.sfm Multi point bisync
edu_kit.sfm Education driver
bitstrm.sfm Bit streaming firmware
bscstrm514.sfm Bisync streaming firware
/lib/modules/X.Y.Z/misc:
wanrouter.o router kernel loadable module
af_wanpipe.o wanpipe api socket module
/lib/modules/X.Y.Z/net:
sdladrv.o Sangoma SDLA support module
wanpipe.o Sangoma WANPIPE(tm) driver module
syncppp.o Kernel Sync PPP module
/proc/net/wanrouter
Config reads current router configuration
Status reads current router status
{name} reads WAN driver statistics
/usr/sbin:
wanrouter wanrouter start-up script
wanconfig wanrouter configuration utility
sdladump WANPIPE adapter memory dump utility
wanpipemon Debugging Monitor for all WANPIPE protocols
wpkbdmon WANPIPE keyboard led monitor/debugger
wancfg WANPIPE GUI configuration program.
Creates wanpipe#.conf files.
cfgft1 GUI CSU/DSU configuration program.
wanpipe/ (temporary untar directory):
README this file
COPYING GNU General Public License
Setup installation script
Filelist distribution definition file
wanrouter.rc meta-configuration file
(used by the Setup and wanrouter script)
/usr/share/doc/wanpipe:
WanpipeInstallation.pdf WAN Router User's Manual
WanpipeInstallation.txt
WanpipeConfiguration.pdf
WanpipeConfiguration.txt
WanpipeOperation.pdf
WanpipeOperation.txt
wanpipe/patches:
wanrouter-v2213.gz patch for Linux kernels 2.2.11 up to 2.2.13.
wanrouter-v2214.gz patch for Linux kernel 2.2.14.
wanrouter-v2215.gz patch for Linux kernels 2.2.15 to 2.2.17.
wanrouter-v2218.gz patch for Linux kernels 2.2.18 and up.
wanrouter-v240.gz patch for Linux kernel 2.4.0.
wanrouter-v242.gz patch for Linux kernel 2.4.2.
wanrouter-v243.gz patch for Linux kernel 2.4.3
wanrouter-v244.gz patch for Linux kernel 2.4.4
wanrouter-v245.gz patch for Linux kernel 2.4.5
wanrouter-v246.gz patch for Linux kernel 2.4.6 and up
wanrouter-v249.gz patch for Linux kernel 2.4.9 and up
wanrouter-v2416.gz patch for Linux kenrel 2.4.16 and up
wanrouter-v2034.gz patch for Linux kernel 2.0.34
wanrouter-v2036.gz patch for Linux kernel 2.0.36 and up.
wanpipe/patches/kdrivers:
Sources of the latest WANPIPE device drivers.
These are used to UPGRADE the linux kernel to the newest
version if the kernel source has already been pathced with
WANPIPE drivers.
/etc/wanpipe/api/x25:
* x25 api sample programs.
/etc/wanpipe/api/chdlc:
* chdlc api sample programs.
/etc/wanpipe/api/fr:
* fr api sample programs.
/usr/src/linux/include/linux:
wanrouter.h router API definitions
wanpipe.h WANPIPE API definitions
sdladrv.h SDLA support module API definitions
sdlasfm.h SDLA firmware module definitions
if_wanpipe.h WANPIPE Socket definitions
if_wanpipe_common.h WANPIPE Socket/Driver common definitions.
sdlapci.h WANPIPE PCI definitions
/usr/src/linux/net/wanrouter:
* wanrouter source code
/usr/src/linux/drivers/net/wan:
sdla* and
wanpipe* wanpipe source code
/var/log:
wanrouter wanrouter start-up log (created by the Setup script)
/var/lock: (or /var/lock/subsys for RedHat)
wanrouter wanrouter lock file (created by the Setup script)
http://sangoma.editme.com

View File

@ -1,396 +0,0 @@
WANPIPE PACKAGE INSTALLATION/UN-INSTALLATION
============================================
Author: Nenad Corbic
WANPIPE PACKAGES
================
Wanpipe RPM packages are located in:
ftp.sangoma.com/linux/RPMS
Please refer to RPM package installation
below.
Wanpipe SOURCE packages are located in:
ftp.sangoma.com/linux/current_wanpipe
Download the latest SOURCE wanpipe release
in ANY directory:
ex: cd /tmp
tar xvfz wanpipe-<version>.tgz
The tar will create the temporary
wanpipe/ directory.
WANPIPE SOURCE PACKAGE Installation
====================================
The 'Setup' script located in temporary wanpipe/
directory should be used to install/un-install
and re-configure all WANPIPE driver and utilities.
The Setup installation script contains numerous
options that can be used to customise wanpipe
installation. Run ./Setup without any arguments
for usage.
Run the Setup script from temporary wanpipe/ directory
(wanpipe directory was created by untaring the source package)
cd wanpipe/
./Setup install
The install option will do the following:
-------
1. Check that all WANPIPE files are accounted for.
2. Check/modify permissions on all WANPIPE files.
3. Prompt the user to Install/Upgrade WANPIPE
drivers into the Linux kernel source.
NOTE: The kernel source must be located
in /usr/src/linux.
Or the linux source directory
must be supplied with '--with-linux' argument.
It is always RECOMMENDED to upgrade/update
the kernel source tree with the latest
wanpipe source.
4. Prompt the user to re-compile all WANPIPE
kernel drivers and install them as modules
in the the current /lib/modules/<kernel-version>
directory.
Compilaton Options: Default or Custom
Default compilation:
option will compile the standard WANPIPE protocols
into the kernel device driver: Frame Relay, PPP, CHDLC
Multi-Port Frame Relay, Multi-Port PPP, and X25(API). "
Custom compilation:
option will offer a menu of all available WAN and
API protocols. The user will be able to enable
protocols individually or all at once,
as desired.
With this option, NO kernel recomilation is
necessary :)
5. Prompt the user to install bootstrap
scripts that will be used to start wanpipe
during boot up.
6. Setup the ENVIRONMENT configuration file that will
contain directory locations of WANPIPE configuration
interface and lock files.
7. Compile all WANPIPE utilities
8. Setup the WANPIPE working environment.
i.e. Install all binary files into
linux file tree.
/etc/wanpipe : config, library, sample
and firmware files.
/usr/sbin : user space, binary
utilites
/lib/modules/<uname-r> : wanpipe kernel
modules
/usr/share/doc/wanpipe : doc files
The last message in the 'Setup install' sequence will
inform you of the next step that you should take
in getting WANPIPE working.
o Read 'README-2.config' on how to configure wanpipe
device
CUSTOMIZING WANPIPE SOURCE INSTALLATION
=========================================
Installation using the '--silent' option
--------------------------------------
The '--silent' option is available to install wanpipe
without any user interaction:
./Setup install --silent
All defaults will be used!
--------------------------
1. Configuration directory /etc/wanpipe
2. Start wanpipe on boot up
3. Recompile modules for the kenrel source
in /usr/src/linux
Installation using the --builddir option
--------------------------------------
When customising the wanpipe package, it is
useful to install the package into a
virtual directory so not to pollute the
current environment.
This way a user can tar up the temporary
directory and create a custom binary
WANPIPE package.
eg ./Setup install --builddir=/tmp/wanpipe_build
Note: the /tmp/wanpipe_build directory must
exist.
Installation using the --protocol option
--------------------------------------
Standard Wanpipe installatin will only
include MAINSTREAM WAN protocols when building
the kernel modules to cut down on kernel
module size.
Mainstream Protocols:
Frame Relay, PPP, CHDLC, X25, API stack
To enable NON Mainstream protocols specify
extra protocols with the --protocol option.
Non Mainstream Protocols:
BSC : API for Multipoint Bisync
BSCSTRM : API for Bisync Streaming
SS7 : API for Level2 SS7 protocol
EDU : API for Educational software
SDLC : API for SDLC protocol
POS : API for POS (S515/S509) card.
BITSTRM : API for Bitstreaming protocol
eg: ./Setup install --protocol=<List of Protocols>
<List of Protocols> = <PROT>-<PROT>-<PROT>
eg:
Compile in Bitstreaming protocol
./Setup install --protocol=BITSTRM
Compile in BitStreaming and POS and SDLC
./Setup install --protocol=BITSTRM-POS-SDLC
Building a custom RPM
---------------------
./Setup buildrpm <extra options>
All defaults will be used!
--------------------------
1. Configuration directory /etc/wanpipe
2. Start wanpipe on boot up
3. Recompile modules for the kernel source
locatd in /usr/src/linux direcotory,
or directory supplied with --with-linux=<abs path>
argument.
Note: <extra options> start with -- and are defined above.
i.e.
user the --protocol filed to add in extra protocols
into the wanpipe kernel modules.
Refer to README.rpmbuild
WANPIPE Kernel Driver Compile/Update
====================================
This option should be used to update the kernel
source tree with the latest wanpipe drivers
and to compile the wanpipe kernel modules
against the updated kernel source tree.
Run the Setup script in temporary wanpipe/ directory:
ex: cd wanpipe/
./Setup drivers
The drivers option will do the following:
-------
1. Prompt the user to Install/Upgrade Wanpipe
drivers into the Linux kernel source.
NOTE: The kernel source must be located
in /usr/src/linux
It is always RECOMMENDED to upgrade/update
the kernel source tree with the latest
wanpipe source.
2. Prompt the user to re-compile all WANPIPE
kernel drivers and install the as modules
in the the current /lib/modules/<kernel-version>
directory.
Compilaton Options: Default or Custom
Default compilation:
option will compile the standard WANPIPE protocols
into the kernel device driver: Frame Relay, PPP, CHDLC
Multi-Port Frame Relay, Multi-Port PPP, and X25(API). "
Custom compilation:
option will offer a menu of all available WAN and
API protocols. The user will be able to enable
protocols individually or all at once,
as desired.
WANPIPE Utilities Re-Compilation
=================================
This option will re-compile all WANPIPE utilities
in temporary wanpipe/ directory.
NOTE: If this is a first time install you MUST run
the install option: Setup install.
Run the Setup script in temporary wanpipe/ directory:
ex: cd wanpipe/
./Setup utility
The utility option will do the following:
-------
1. Compile all WANPIPE utilities
in temporary wanpipe/ directory
To install utilities into /usr/sbin
directory one must run:
./Setup inst
For more info about Setup command run
./Setup without any arguments for full usage
info.
WANPIPE Un-Install
==================
Run the Setup script in temporary wanpipe/ directory:
ex: cd wanpipe/
./Setup remove
The remove option will do the following:
------
1. Remove all boot strap WANPIPE scripts.
2. Remove all utilities from /usr/sbin,
/etc/wanpipe, /usr/share/doc/wanpipe
directories.
After the 'Setup remove' command, it is safe
to remove the whole temporary wanpipe/ directory.
ex:
rm -rf wanpipe/
WANPIPE RPM PACKAGE Installation
================================
Choosing an RPM:
--------------
o Determine the Linux Distribution:
cat /etc/issue
(eg: RedHat 7.1)
o Determine the Kernel image you are running:
uname -r
(eg: 2.4.2-2 : it is not an smp kernel)
(eg: 2.4.2-2smp : smp kernel)
o Determine the processor type
uname -m
(eg: i686)
o Based on the above information choose an RPM package.
wanpipe-<version>.<linux distrib>.<kernel ver>.<processor>.rpm
eg: ftp.sangoma.com/linux/RPM/redhat/7.1/i686/
wanpipe-2.2.4-3.rh71up.k242-2.i686.rpm
Installing RPM
----------
o List the contents of the rpm
rpm -qipl <wanpipe rpm name>
Make sure that the /lib/modules/<kernel name> directory
matches your current kernel modules directory.
i.e. the output of command 'uname -r' must match the above
<kernel name> directory.
o The rpm must be installed using the --force option, to
override the old modules.
rpm -i --force <wanpipe rpm name>
o Read 'README-2.config' on how to configure wanpipe
device
For further info, refer to WanpipeInstallation.pdf

View File

@ -1,376 +0,0 @@
Wanpipe Configuration
======================
Before starting WANPIPE, a configuration file (wanpipeN.conf, where
N=1,2,3..etc.)must be created in /etc/wanpipe directory.
This file contains the line, hardware and interface definitions
for the WAN connection.
RELEASE 2.3.2 and on:
The new WANCFG utility has been release. It should
be used to configure standard WAN protocols like:
FR, PPP, CHDLC,
MULTILINK PPP (TTY), TDM_VOICE
HDLC API
ADSL
For both AFT and S514 series cards.
The old WANCFG utility has been renamed to wancfg_legacy.
This utility should be used for all API protocols like:
X25, SDLC, BITSTREAMING ...
The program /usr/sbin/wancfg should be used to create the
configuration file(s). It is a GUI, ncurses based,
configurator that contains all wanpipe options
as well as extended help information on each
option.
In case wancfg is not used, i.e. embedded systems, use
the sample configuration files located in
/etc/wanpipe/samples directory.
Things you should know before starting /usr/sbin/wancfg:
1. Protocol:
Frame Relay, MulitPort Frame Relay,
CHDLC, PPP, MultiPort PPP, ADSL, X25 ...
2. Protocol/IP Info:
Frame Relay: Type of Status Signaling (LMI,
ANSI, or Q.933
Number of DLCI to configure
DLCI numbers
IP info for each DLCI
CHDLC: IP info
PPP: IP info
X25: Maximum packet size
Number of SVCs/PVCs
IP info
ADSL: ATM encapsulation:
Bridged Ethernet LLC over ATM: (PPPoE)
Bridged Ethernet VC over ATM
Classical IP LLC over ATM
Router IP VC over ATM
PPP LLC over ATM
PPP VC over ATM: (PPPoA)
ATM configuration:
VPI and VCI
If not available use the auto
config option to autodetect
these values.
IP Info: (Not needed for PPPoE)
NOTE:
For PPPoE and PPPoA setup please refer to
APPENDIX A below.
ATM: ATM encapsulation:
Bridged Ethernet LLC over ATM: (PPPoE)
Bridged Ethernet VC over ATM
Classical IP LLC over ATM
Router IP VC over ATM
ATM configuration:
VPI and VCI
IP Info: (Not needed for PPPoE)
3. CSU/DSU Info:
T1/E1: Encoding
Framing
Active Channels/Baud Rate
56K: Internal or External Clocking
Internal clocking should only be used
in back to back situations.
Default: External
For the rest of this document, we will assume we are working with the
following ISP/Telco supplied data:
Protocol: Frame Relay
Prot Info:
Num of DLCI's = 2
DLCI=16 and 17
IP Info: DLCI 16
Local =201.1.1.1
PtoP =201.1.1.2
Netmask =255.255.255.0
Gateway =201.1.1.2 (i.e. this is the system
default gateway)
DLCI 17
Local =202.1.1.1
PtoP =202.1.1.2
Netmask =255.255.255.0
Gateway =N/A
WANCFG
======
IMPORTANT:
Use the "ADVANCED" sections only for non
standard configurations, otherwise leave
them default.
1. Start /usr/sbin/wancfg
2. Select Create opton
3. Select Card from Hardware Probe
4. Specify Hardware information:
T1/E1/V35
5. Specify Protocol
FR,PPP,CHDLC,TTY(Multilink PPP) ...
Frame Relay is by default configured
for Auto DLCI. Use the advanced sections
to change this.
6. Network Interface Setup
Specify Operation mode:
WANPIPE: IP mode proceed to specify IP addresss
API: Custom API mode, no IP addresses
Specify IP addresses:
7. Save and exit
For old WANCFG_LEGACY example refer to APPENDIX B below!
Troubleshooting the driver load process
=======================================
After a startup failure run wanrouter debug
option for more information and possible solutions:
wanrouter debug
Syntax Errors:
--------------
All wanpipe configuration file syntax errors are
reported in /var/log/wanrouter
wanrouter conflogs
Driver Messages:
----------------
All wanpipe driver events will be recorded in
/var/log/messages.
Thus if errors occur, first check /var/log/messages
to find out what exactly went wrong
with the drivers startup.
wanrouter messages
or
tail -f /var/log/messages
Once the device is started you should see a
"link connecting" message. This message
indicates that the card was been configured
successfully and that the link is trying to
connect.
Wanpipe Debugger:
-----------------
/usr/sbin/wanpipemon should be used to further debug
hardware, line and protocol problems.
/usr/sbin/wanpipemon -g
Sangoma Tech Support:
---------------------
When reporting problems to Sangoma Tech Support please
dump the current system debug information into
a temporary file and send it via email.
1. wanrouter debug if_name > sangoma_debug_file.txt
(where if_name is wanpipe interface name: eg wp1fr16)
2. Wait for 2-5 minutes
3. Stop the debug by pressing ENTER
4. Email sangoma_debug_file.txt to Sangoma Tech Support
Refer to README-4.debugging
APPENDIX A: ADSL PPPoE and PPPoA Configuration
==========
Refer to README.adsl
APPENDIX B: WANCFG_LEGACY (Old Configurator)
==========
1. Start /usr/sbin/wancfg
2. Select 'Create' option
3. Select a wanpipe device.
If this is a first device select wanpipe1
and hit <SELECT> button.
4. Choose a protocol
In this case choose Frame Relay and hit <BACK>
button.
5. Select Hardware Setup
Probing Hardware:
The top option is "Probe Hardware"
Select this option and press <ENTER>
Select a device. When selecting devices
note the PORT option. Usually PORT=PRI
would be used.
IMPORTANT:
~~~~~~~~~~
After the hardware probe section you will
notice that the next four fields have
been filled out. Thus, adapter type and
PCI info should be skipped.
All other options should normally be left as
DEFAULT unless you have special information.
Exit Hardware Setup
6. Network Interface Setup
The network interface set-up depends on the type of connection.
Instance Frame Relay supports many interfaces, each boud to
a DLCI. Thus, there are questions related to the number of
DLCIs and configuration information for each DLCI.
In the case of Point-to-Point protocols like PPP and CHDLC, there
is only one interface per physical port.
This example is Frame Relay with two DLCIs. The first input is:
"Please specify the number of DLCIs supported on this Frame Relay
connection"
Enter in number 2
For each network interface do the following:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DLCI Number:
Enter in the DLCI number. Note the default number
is always 16.
Interface Name:
The Interface name will also have default value.
You can leave it as is or change it. For instance,
you could change it to ?chicago? or ?toronto?.
IMPORTANT:
~~~~~~~~~
If you are using iptables you might want to change
the default interface name to something like "wan0".
Iptables and Ipchains don't like "_" in interface
name.
e.g.: 'iptables -o wp1_fr16 ...' will give you an error
Operation Mode:
WANPIPE is for IP Routing
BRIDGE is used to attach the network interface to
the kernel bridge
BRIDGE_NODE is used as a remote end of the line that is
connected to a bridge.
API is used for custom API applications.
Custom socket access to driver.
DLCI Protocol Setup:
In this section leave everything as default.
Unless the ISP has specified specific protocol
options such as CIR.
IP Setup:
Put in your IP info as supplied by ISP
Enable Default gateway for the first
interface.
Note: PointoPoint IP refers to the IP address of
the remote router that is connected at
the other end of the sync line.
7. Once all network interfaces are setup
keep hitting the <BACK> button until
Main Menu is reached.
Then select <EXIT> and save the config
file.
The new config file will be located in
/etc/wanpipe directory.
8. Start the device:
wanrouter start wanpipe1
Note: The card doesn't have to be connected to start the wanrouter.

View File

@ -1,328 +0,0 @@
Wanpipe Operation Manual
========================
At the heart of WANPIPE operation is the 'wanrouter' operation
script. It is used to start/stop/restart and display
WANPIPE current status and environment.
'wanrouter' usage
=================
/usr/sbin/wanrouter <cr>
WANPIPE: WAN Router startup script
Usage: wanrouter: {options} <wanpipe#> <interface>
wanrouter start : Starts all devices specified in
/etc/wanpipe/wanrouter.rc WAN_DEVICES
wanrouter stop : Stops all devices specified in
/etc/wanpipe/wanrouter.rc WAN_DEVICES
wanrouter start wanpipe# : Start a single device
wanrouter stop wanpipe# : Stops a single device
(# can range from 1 to 16)
wanrouter restart : Restart all devices specified in
/etc/wanpipe/wanrouter.rc WAN_DEVICES
wanrouter restart wanpipe# : Restart a single device
(# can range from 1 to 16)
wanrouter start wanpipe# if_name : Start a single interface on device
wanrouter stop wanpipe# if_name : Stops a single interface on device
(# can range from 1 to 16)
wanrouter restart wanpipe# if_name : Restart a single interface on device
(# can range from 1 to 16)
wanrouter list : List all active devices
wanrouter modules : Show wanpipe kernel modules
wanrouter status : Display status for all active devices
wanrouter summary : Summary of config files in /etc/wanpipe
wanrouter hwprobe : Display wanpipe hardware probe info.
wanrouter debug : Check current wanpipe environment.
Wanpipe startup debugging. After a startup error
run this command to get a possible solution
i.e. wanrouter start; wanrouter debug;
wanrouter debug if_name : Display common debugging statistics
In case of line problems save to file, wait 2-5min
and send to Sangoma Tech Support
i.e. wanrouter debug wp1fr16 > debug_file;
wanrouter conflogs : Display wanpipe configuration syntax errors
i.e. /var/log/wanrouter
wanrouter messages : Display wanpipe kernel event messages
i.e. /var/log/messages
wanrouter version : wanpipe version information.
WANPIPE Environment Check
=========================
The wanrouter debug option will check current
wanpipe environment, make sure that kernel modules
do load, and that /var/log/messages and /var/log/wanrouter
logs do not show any errors. It will also try
to give possible solutions.
/usr/sbin/wanrouter debug
Make sure that the new WANPIPE kernel modules have
been installed correcty and that they can be loaded
into the kernel, and the hardware is detected.
/usr/sbin/wanrouter hwprobe
Check that a configuration file exists in /etc/wanpipe
directory.
/usr/sbin/wanrouter summary
Make sure that no WANPIPE devices are currently running
on the system
/usr/sbin/wanrouter list
WANPIPE Startup
===============
Please note that all kernel driver output messages are
located in /var/log/messages file.
Run 'tail -f /var/log/messages' in a separate console
window, to monitor WANPIPE start/stop and operation
messages.
To start/stop/restart WANPIPE devices listed in
/etc/wanpipe/wanrouter.rc file: (default is wanpipe1)
/usr/sbin/wanrouter start
/usr/sbin/wanrouter stop
/usr/sbin/wanrouter restart
To start/stop/restart single wanpipe device: (eg: wanpipe2)
This command is useful when running multiple devices
and would like to operate on a singe device.
/usr/sbin/wanrouter start wanpipe2
/usr/sbin/wanrouter stop wanpipe2
/usr/sbin/wanrouter restart wanpipe2
To start/stop/restart a single network interface from a
/etc/wanpipe/wanpipe1.conf configuration file:
This command is useful when adding an extra frame
relay DLCI. Also to reconfigure a single DLCI.
/usr/sbin/wanrouter start wanpipe2 wp2_fr18
/usr/sbin/wanrouter stop wanpipe2 wp2_fr18
/usr/sbin/wanrouter restart wanpipe2 wp2_fr18
To view current status and configuration of active
devices:
/usr/sbin/wanrouter status
Error Debugging
===============
After a failed wanrouter start command
run:
wanrouter debug
The debug option will identify an error and
offer solutions.
Configuration Syntax Errors:
All configuration file syntax errors, generated
during WANPIPE starup, will be displayed in:
/var/log/wanrouter
(eg: cat /var/log/wanrouter)
Kernel Driver Errors:
All device driver errors and events will be
displayed in:
/var/log/messages
(eg: tail -f /var/log/messages)
Line Errors and Driver Statistics
After a successful WANPIPE startup any extra
debugging, such as line tracing or CSU/DSU
debugging will be done using:
/usr/sbin/wanpipemon -g
For automated Line Error debugging run
/usr/sbin/wanrouter debug <if_name>
where <if_name> is wanpipe interface name.
Sangoma Tech Support:
---------------------
When reporting problems to Sangoma Tech Support please
dump the current system debug information into
a temporary file and send it via email.
1. wanrouter debug if_name > sangoma_debug_file.txt
(where if_name is wanpipe interface name: eg wp1fr16)
2. Wait for 2-5 minutes
3. Stop the debug by pressing ENTER
4. Email sangoma_debug_file.txt to Sangoma Tech Support
Pleae refer to README-4.debugging
Wanpipe Power User Operation
-----------------------------
Wanpipe package contents
========================
1. Wanpipe Kernel Drivers
The drivers are listed in order of
dependency.
sdladrv.o : Hardware Layer
wanrouter.o : Wanpipe Protocol Interface Layer
wanpipe_syncpp.o: Wanpipe PPP/CHDLC Protocol
wanpipe.o : Wanpipe multi-protocol layer
(Frame-Relay,PPP,CHDLC,...)
af_wanpipe.o : Wanpipe API socket layer
2. User space programs
Configuration (/usr/sbin)
wancfg : Wanpipe configuration tool
cfgft1 : Wanpipe FT1 config tool for
S508FT1 and S5143 cards
(For all other cards use wancfg)
Operation (/usr/sbin)
wanconfig : Wanpipe operation tool that
parses the config file and
executed config ioctl() calls to
the kernel driver.
(C program)
wanconfig -a /etc/wanpipe/wan_adsl.list card wanpipe1 up
wanrouter : Wanpipe operation script
used to start/stop/restart
Wanpipe drivers. The wanrouter
script uses the above wanconfig
to start wanpipe as well as
standard "ifconfig" to bring
all necessary interfaces up.
Debugging
wanpipemon : Wanpipe debugging application
used to debug the hardware, drivers
and sync line.
wanpipemon -g
Wanpipe Operation
=================
If a power user desn't want to use
the wanrouter master script. Here is the
break down of the wanpipe startup
sequence:
wanrouter start
1. Load Kernel Modules
insmod sdladrv.o
insmod wanrouter.o
insmod wanpipe_syncppp.o
insmod wanpipe.o
insmod af_wanpipe.o
or
modprobe af_wanpipe
2. Configure and Start Drivers
/usr/sbin/wanconfig -a /etc/wanpipe/wan_adsl.list card wanpipe1 up
3. Start up all network interfaces
ifconfig wan0 <local ip> pointopoint <remote ip> netmask 255.255.255.255
4. Confirmation
tail -f /var/log/messages
Check the events and driver statistics.
cat /proc/net/wanrouter/status
Check driver state

View File

@ -1,179 +0,0 @@
Wanpipe Debugging Manual
========================
Automated Debugging:
--------------------
The wanrouter operation script can retrieve the
most common line error statistics that can
give the user a good idea of what is going on
with the line.
/usr/sbin/wanrouter debug if_name
or
/usr/sbin/wanrouter debug if_name > debug_file.txt
(where if_name is the name of wanpipe interface: eg: wp1fr16)
Sangoma Tech Support:
---------------------
When reporting problems to Sangoma Tech Support please
dump the current system debug information into
a temporary file and send it via email.
1. wanrouter debug wp1fr16 > sangoma_debug_file.txt
2. Wait for 2-5 minutes
3. Stop the debug by pressing ENTER
4. Email sangoma_debug_file.txt to Sangoma Tech Support
Wanpipe Debugger
----------------
At the heart of WANPIPE debugging is the 'wanpipemon'
debugging program. It is used to display line
traces, protocol statistics, hardware statistics
and configuration parameters.
/usr/sbin/wanpipemon -g
'wanpipemon' usage
==================
/usr/sbin/wanpipemon
Wanpipemon Verison 1.0
Copyright (C) 2002 - Sangoma Technologies
www.sangoma.com
This may be freely redistributed under the terms of the GNU GPL
Usage: (Options in {} brackets are optional)
#Command prompt Local debugging
wanpipemon -i <interface> -c <command> { -p <protocol> }
#Command prompt Remote debugging
wanpipemon -i <remote IP> -u <port> -c <command> { -p <protocol> }
#GUI interface
wanpipemon -g { -i <interface|IP> -u <port> -p <protocol> }
#Display usage for each protocol
wanpipemon -p [fr|ppp|chdlc|x25|adsl]
#Detailed usage for each option
wanpipemon -h
The 'wanpipemon' utility operates in two modes.
Local debugging:
The 'wanpipemon' utility is located on the same
machine as the WANPIPE card.
Thus, the wanpipemon utility needs only the
interface name (eg: wp1_fr16) to reach the driver.
/usr/sbin/wanpipemon -i wp1_fr16 -c xm
Remote debugging:
The 'wanpipemon' utility is located on a network
(LAN or WAN) and must use the UDP protocol to
reach the WANPIPE card.
In this case an IP and UDP addresses must be
specified, such that the packet will pass through
the WANPIPE driver!
Meaning a POINTOPOINT address must be used instead
of the LOCAL IP address.
The UDP port was specified in WANPIPE configuration
file. (Default=9000)
/usr/sbin/wanpipemon -i 201.1.1.2 -u 9000 -c xm
GUI Mode Operation
==================
The GUI mode is based on ncurses libraries, thus it
will work both in Terminal or Xwindows mode.
/usr/sbin/wanpipemon -g
Without any other arguments the GUI will offer a list
of network interfaces, for local debugging, or will
ask for an IP/UDP address, for remote debugging.
Use menu's to navigate through available commands.
Common Statistics
=================
Modem Status (-c xm):
(wanpipemon -i if_name -c xm)
Must be DCD=HIGH and CTS=HIGH if not there is
ether a cable problem or the sync line is
not turned ON.
Comm Error Stats (-c sc):
(wanpipemon -i if_name -c sc)
Check for CRC and Abort errors. If errors
are incrementing, there is a line issue.
Possible reasons: CSU/DSU misconfiguration
on local or remote side.
Noisy/Bad line.
Line trace (-c tr):
(wanpipemon -i if_name -c tr)
Make sure thare are incoming and outgoing frames.
If frames are outgoing and none incoming:
Frame relay: Check signalling (ANSI, LMI)
Make sure ISP uses IETF or CISCO
data encapsulation.
Other prot: Possible CRC errors in TX
direction. Contact your ISP.
If frames are both incoming and outgoing but
protocol is still down:
Run trace in Interpreted mode (-c ti) and
make sure that the incoming protocol is
indeed the one you are configured for.
Wanpipe Kernel Messages
/usr/sbin/wanrouter messages
or
tail -f /var/log/messages
All line/protocol events will be displayed in
the kernel logs.

593
README.asterisk Normal file
View File

@ -0,0 +1,593 @@
Asterisk Open PBC/IVR Project using the Sangoma A101 and A102 cards
===================================================================
For Latest Documenation please visit:
Sangoma Wiki
http://sangoma.editme.com
WANPIPE supports the Asterisk Open PBX/IVR project through an interface
of the Zaptel family of hardware devices. These devices share a common
driver suite, called the ZAPATA Telephony Driver Suite (zaptel).
IMPORTANT
---------
Please read the APPENDIX for IMPORTANT INFO
------------------------------------------------------------------
ASTERISK / ZAPTEL Installation
------------------------------------------------------------------
First install:
zaptel, zapata, libpri and asterisk
software on your system.
The Asterisk distributions can be found at http://www.asterisk.org.
1. Download the LATEST sources from http://www.asterisk.org;
2. Untar zaptel, libpri and asterisk source
in /usr/src directory
3. Proceed with ASTERISK/ZAPTEL installation as per
Asterisk instructions
Install: 1) Zaptel
2) LibPri
3) Asterisk
For each do: make clean
make
make install
Note:
Zaptel kernel drivers must compiled and
installed BEFORE loading WANPIPE drivers.
-----------------------------------------------------------------
WANPIPE Releases
-----------------------------------------------------------------
2.3.3: Latest Wanpipe Release
o New channelized TDMV Driver (A104 Only)
Voice data is channelized and grouped into
8 byte chunks in HARDWARE. Each voice
channel is then DMAed directly into the ZAPTEL
buffers. Thus there is ZERO copy from HARDWARE
to ZAPTEL, resulting in better performance and
scalability.
o New DCHAN PRI Hardware HDLC support:
A104 Supported from beta1-2.3.3 release,
A101/A102 Supported from beta6-2.3.3 release
Instead of using the ZAPTEL software HDLC engine,
WANPIPE drivers use FPGA-based HARDWARE HDLC engine to
handle the PRI HDLC traffic. The HDLC frames are
then passed directly into LIBPRI, resulting
in higher reliability, better performance and scalability.
o New TDMV API (A104 Only)
Customers that develop Voice Applications in User Space,
can now develop using Channelized TDMV API.
The TDMV API works in the same way as standard HDLC API.
Application creates a socket to a network interface and
uses standard system calls to read and write.
However, data received from the TDMV API socket, will be
in 8,16,32 or 63 byte CHUNKS for each configured timeslot.
Thus for full T1 1-23 voice channels the rx data would
look like:
__________________________________
| 8bytes | 8 | | ... | 8 |
----------------------------------
Slot 1 2 3 23
The DCHAN PRI HDLC frames would be received as OOB messages
on the same socket.
OR
The DCHAN PRI HDLC frames could be received using another
socket that is connected to a network interface that is
bound to channel 24.
2.3.2: Stable Wanpipe TDMV Release
o The ORIGINAL TDMV driver for both A101/2 and A104 cards.
TDMV Driver has been optimized for best Echo cancel
performance.
This driver has been fully tested in the field and is
considered stable.
----------------------------------------------------------------
WANPIPE Installation for Asterisk
----------------------------------------------------------------
1. Download the LATEST Wanpipe 2.3.3 Release or Greater!
Note: Wanpipe does not support Asterisk in releases
LOWER than 2.3.2!
ftp.sangoma.com/linux/current_wanpipe
2. Untar wanpipe release in /usr/src/ directory
eg: tar xvfz wanpipe-beta16-2.3.3.tgz
3. Run ./Setup install
Proceed with installation choose YES for each option.
IMPORTANT:
Under compilation mode:
Select Option 2: TDM Only drivers
OR
Select Option 3: TMD and WANPIPE drivers
Select [Y] to Enable TDMV_DCHAN option for Hardware HDLC for
DCHAN PRI.
This option will also PATCH the ZAPTEL driver.
Thus, ZAPTEL MUST be recompiled and installed
after the ./Setup is completed.
Note: ./Setup will automatically patch:
Latest CVS Head
and
Stable 1.0.9 Release (not CVS)
WARNING: ./Setup cannot distinguish between
CVS Head and 1.0.9 CVS releases.
In this case one should manually patch
1.0.9 CVS using 1.0.9 patch in wanpipe/zaptel
directory.
Proceed to compile wanpipe drivers.
Proceed with Defaults for the rest of the compilation.
4. Recompile ZAPTEL AGAIN
If you chose TDMV DHCAN option: Hardware HDLC for DCHAN PRI
./Setup has patched zaptel drivers.
Zaptel drivers must now be re-compiled and re-installed.
Proceed to zaptel/ source directory:
make clean
make
make install
5. To confirm successful installation run:
wanrouter hwprobe
Confirm that Sangoma cards have been found.
------------------------------------------------------------------------
WANPIPE Configuration for the A100 series of cards
------------------------------------------------------------------------
You can use the A101 or A102 cards for both data and voice. The
following describes how to configure the Asterisk system for
voice, with an auxiliary data interface, if needed.
1. Run the configuration utility wancfg.
/usr/sbin/wancfg
Hardware Setup:
Select Hardware: Specify AFT card from hardware probe.
----------------------------
Card Type-------> A104
Physical Medium-> T1
----------------------------
Sepecify Line Type: T1 (Default)
or
E1
Default configuration is complete: Select <BACK>
For Advanced configuration proceed below...
T1/E1 CSU/DSU Advanced Setup (OPTIONAL - non default)
-----------------------------------------------------
Select: Advanced Physical Medium Config
A104/2 TE1 Clock Synchronization (OPTIONAL - non default):
----------------------------------------------------------
TE1 Clock synchronization is used to propagate
a single clock source over the T1/E1 ports on a single card.
Example:
wanpipe1: Port 1 receives T1 Clock from Telco
wanpipe2: Port 2 provides MASTER transmit clock for the link,
synchronized to the clock on Port 1
TE_CLOCK = MASTER #Specify AFT card as Master clock source
FE_REF_CLOCK = 1 #Specify the clock source port
For more information refer to APPENDIX below.
Protocol Setup:
Select Protocol: TDM VOICE
No other options
Interface Setup:
Select: SPAN Number: 1 - Unlimited
The SPAN usually starts with 1
Select: Override Asterisk Echo Enable
Default: NO
This option will DISABLE/Override Asterisk
ECHO Cancellation setting for this SPAN.
Therefore, if you want to DISABLE Echo Cancellation
for this SPAN, ie: ignore what is configured in
zapata.conf, then set this option to YES.
*This is used in switching applications where one SPAN needs echo
cancellation and rest do not.
Select: DCHAN PRI Timeslot:
Hardware HDLC support for DCHAN PRI
A104: Supported from beta5-2.3.3 or greater
Release : beta5-2.3.3 or greater.
Firmware Version: V.11 or greater
A101/2: Supported from beta6-2.3.3 or greater
Release : beta6-2.3.3 or greater.
Firmware Version: All versions (V.24 latest)
Options: 0 : Disable Hardware HDLC on PRI
timeslot.
24 : T1 Line DCHAN is usually on timeslot 24
Enable Hardware HDLC on PRI timeslot. Default 24
16 : E1 Line DHCAN is usually on timeslot 16
Enable Hardware HDLC on PRI timeslot. Default 16
Note: TDMV_DCHAN values are ALWAYS [ 0 | 24 | 16 ]
(Don't confuse this with the Asterisk configuration that uses
values greater than 24/31 for the DCHAN specification)
No other options
------------------------------------------------------------------------
Zaptel configuration
------------------------------------------------------------------------
Download the documentation how to configure Zaptel driver from
(http://www.digium.com/downloads/configuring_zaptel.pdf).
When configuring the Zaptel driver (/etc/zaptel.conf)
1) Select the same span configurations as you used for WANPIPE
(i.e. LBO, framing, coding parameters).
Otherwise the Zaptel configuration is completely
standard, except that if there are data channels that
will be handled by WANPIPE, those channels should be ignored,
and not configured as 'nethdlc'.
2) If you are using multiple WANPIPE devices for Asterisk
For example, an A102 card might be configured as:
wanpipe1 and wanpipe2
then you need to set your starting scripts to start
the wanpipes in the same sequence as defined in zaptel.conf.
Run: wanrouter wanrc
to set the wanpipe startup order.
3) If you are using some channels for DATA
You don't need to set the channel list for this
interface under /etc/zaptel.conf because all data will go
through the separate WANPIPE driver to the kernel.
-------------------------------------------------------------
APPENDIX
-------------------------------------------------------------
1)HOTPLUG Conflicts with WANPIPE
===============================
The HOTPLUG Service should be disabled because it
conflicts with Wanpipe interface startup.
The HOTPLUG can conflict with startup of TDMV drivers.
Possible Solutions:
Insert wanpipe interface name into the hotplug
interface list, and restart hotplug.
vi /etc/hotplug/net.agent
Insert wanpipe interface name into
the ignore list:
...ppp*|lo*|w*)
Where w* relates to all wanpipe interfaces
starting with letter "w"
Restart hotplug agent:
/etc/init.d/hotplug restart
-------------------------------------------------------------------
2) Exec "ztcfg" after wanrouter start
==================================
The "ztcfg" tool must be executed before starting
asterisk. WANPIPE "wanrouter" script has the capability
to execute an external script after "wanrouter start"
command is competed.
The wanrouter looks to /etc/wanpipe/scripts directory
for any configured bash scripts.
1) Create a file called "start" (lower case)
vi start
----------Cut Here----------------
#!/bin/sh
#Make sure that udev/devfs zaptel device
#has come up.
while [ ! -e /dev/zap ];
do
echo "Waiting for zaptel device /dev/zap..."
sleep 2
done
sleep 1
ztcfg -vvvv
----------Cut Here----------------
2) Copy the file "start" into /etc/wanpipe/scripts directory.
(Note: the file doesn't have to have exec privileges)
The script "start" will execute each time the "wanrouter start"
command executes.
Please Refer to README.external_scripts for more info about
wanrouter and external scripts.
------------------------------------------------------------
2) Updating FLASH on AFT Cards
===========================
The AFT FLASH update utility is located in:
wanpipe/util/wan_aftup directory.
The same directory contains the latest AFT
FLASH Firmware BIN files since the release
of the driver.
The latest AFT Firmware bins are located in
ftp.sangoma.com/linux/current_wanpipe/firmware.
To update flash on ANY AFT card do the following:
1) Make sure you have the latest AFT Firmware BIN
The latest file necessary for the current release
will be in the wan_aftup/ directory.
One can also check the ftp site above.
The AFT Binary file must reside in wan_aftup/ directory.
2) Make sure that wanpipe drivers are NOT Loaded
lsmod | grep wanpipe
3) Run ./update_aft_firm.sh
Specify interface name that corresponds to the
AFT card.
Specify the latest AFT Firmware version
Once the flashing is done, select Y to reload firmware.
(This step only reloads flash, not your machine!)
4) Card is ready for normal operation. (No reboot needed)
---------------------------------------------------------------
3) Multiple ZAPTEL Releases AND Wanpipe Crashing
=============================================
On systems, where ZAPTEL has been upgraded from old
releases, it is possible for a kernel module directory
to contain MULTIPLE ZAPTEL drivers.
Old Zaptel install dir: /lib/modules/$(uname -r)/zaptel
New Zpatel install dir: /lib/modules/$(uname -r)/misc
If old zaptel installation was NOT removed, the new installation
would NOT overwrite the old kernel modules. In this case
the OLD modules would continue to be loaded, even though the
new ones were installed.
Check:
The check if this condition exists on your machine run:
modprobe -l | grep zaptel.*o
If multiple zaptel modules are found
the problem must be fixed before starting
WANPIPE !!!.
In this scenario, if a customer starts WANPIPE drivers based
on NEW ZAPTEL sources, the WANPIPE would CRASH !!!
The WANPIPE driver shares structures with ZAPTEL, thus, a
result of mismatched structures is a kernel panic.
Solution:
The solution in this case is to REMOVE the old zaptel modules.
rm -rf /lib/modules/$(uname -r)/zaptel
depmod -a
---------------------------------------------------------------
4) Multiple ZTCFG executions on bootup
====================================
On systems that have zaptel and digium drivers
installed, one must be careful to synchronize
wanpipe, digium and zaptel ztcfg on boot up.
Therefore, wanpipe and digim MUST start before ztcfg
is executed.
Check your /etc/rcS.d startup scripts. Make sure that
the startup numbers S## for zaptel are higher than those
of wanpipe and digium.
---------------------------------------------------------------
5) UDEV Conflicts with ZAPTEL
==========================
UDEV is a user space daemon, which handles all /dev
devices. On startup ZAPTEL schedules creation of
/dev/zap device. It takes about 10 seconds for the
UDEV daemon to create /dev/zap and all its devices after
zaptel has been started (wanrouter start).
On shutdown, ZAPTEL schedules deletion of /dev/zap
device. Again it takes about 1-5seconds for UDEV
daemon to delete /dev/zap device from user space.
A conflict can occur if one quickly starts and then stops
wanpipe/zaptel. In this case UDEV daemon might be in
process of creating /dev/zap devices, while zaptel kernel
driver tries to remove them.
To prevent this please install the wanpipe external
start script referenced in ITEM #2 of the APPENDIX above.
This script will delay wanpipe start until UDEV has
created the /dev/zap devices.
----------------------------------------------------------------
6) A104/2 TE1 Clock Synchronization:
=================================
TE1 Clock synchronization is used to propagate
a single clock source over the T1/E1 ports on a single card.
Example:
wanpipe1->Port 1 receives T1 Clock from Telco
wanpipe2->Port 2 provides MASTER transmit clock for the link,
synchronized to the clock on Port 1
Settings for wanpipe1, Port 1:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using wancfg, configure as slave with TE_CLOCK=NORMAL
Settings for wanpipe2, Port 2:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using wancfg, configure as master with
TE_CLOCK=MASTER
FE_REF_CLOCK=1
The FE_REF_CLOCK parameter refers to the source of the MASTER
clock for this port. On the A104 it can be any of the 4 ports.
On the A102, Port A=1 and Port B=2. Setting FE_REF_CLOCK=0
sets the clock source as the on-board oscillator, disabling
any synchronization.
IMPORTANT: When starting and stopping wanpipe devices make sure
that the wanpipe# that provides the synchronized clock source
is started first and stopped last. This is normally done automatically
by the wanrouter startup script.
If the wanpipe# that provides the synchronized clock source is
stopped, the other devices using the clock source will
behave unpredictably.

848
README.changes Normal file
View File

@ -0,0 +1,848 @@
------------------------------------------------------------------------------
WANPIPE
Linux WAN Router Package
------------------------------------------------------------------------------
Author: Nenad Corbic <ncorbic@sangoma.com>
Copyright (c) 1995-2006 Sangoma Technologies Inc.
------------------------------------------------------------------------------
Release Stable 2.3.3-7
=======================
Oct 03 2006
o Bug fix in AFT T3 drivers.
o Bug fix in hwprobe for AFT 300 cards
o CHDLC Protocol
The wancfg does not properly configures CHDLC
keepalive values. One has to set them in
CHDLC profile section as follows:
[w1g1.chdlc]
KEEPALIVE_TIMER = 5
KEEPALIVE_ERROR_MARGIN = 5
By default if initial values are NOT Set, driver
initializes the keepalive values to above.
Release Stable 2.3.3-6
=======================
Sep 14 2006
o Latency Update for AFT and S514 Cards.
New interface config option SINGLE_TX_BUF=YES
-> Configures hardware for single tx buffer.
o Adjustable tx queue in driver via ifconfig txqueuelen field.
When one decreases the value of txqueuelen using ifconfig
below the driver treshold, Driver will lower its queue len
to the value of txqueuelen.
When txqueuelen is increased the driver will reset its queue
len to the original value.
Release Stable 2.3.3-5
======================
Aug 23 2006
o Added new features to LIP PPP Protocol
Three IP Configuration Modes
STATIC: No ip negotiation. Will not give away IP address to peer.
HOST: Same as static, but will give away local IP address to peer.
PEER: Dynamic IP mode. PPP will ask for IP address from peer.
o Added checks to /proc file system, when interigating interface status.
o Bug fix in LIP TX algorithm.
In some conditions on high load and very small packets its possible
for the LIP TX handler to hang and 2sec timeout.
After the timeout the operation would continue.
Release Stable 2.3.3-4
======================
Jul 05 2006
o Bug fix for all LIP API protocols.
Possible memory leak if rx socket is full, and packet
cannot be delivered up the stack.
o Updated AFT firmware update program.
o Added wanpipe firmware version to wanrouter hwprobe.
o Updated Frame Relay EEK Protocol
EEK_CFG=[NO | EEK_REQ ]
EEK_TIMER=[intiger]
Release Stable 2.3.3-3
======================
Apr 12 2006
o Driver updates for 2.6.16 kernel and greater.
The TTY Layer has been updated which broke wanpipe drivers.
o LIP Frame Relay Protocol Update
Added NO_LMI option
Updated Frame Relay Bridging
Potential bug fix where top layer gives us
a packet with zero length headroom
Updated MAX DLCI to 1007. Used by CISCO LMI.
o LIP PPP/CHDLC Protocol Update
Potential bug fix where top layer gives us
a packet with zero length headroom
Updated PAP/CHAP to follow the spec and not attemp
authentication until LCP is finished.
o LIP ATM Protocol Update
The ATM protocol has been completed to comply with
full ATM specifications and RFCs.
o LIP Layer: Interface UP/DOWN Optional Feature
Added a neceassary feature in LIP Interface layer.
The Interface will follow the line status.
If interface state is disconnected the interface
IFF_UP flag will be cleared.
If interface state is connected teh interface
IFF_UP flags will be set.
This feature is useful on 2.4 kernels in SNMP and TEQL
applications where higher service wants to know the
state of the underlining protocol based on interface state.
Note: This feature will support ALL LIP protocols:
Frame Relay, PPP, CHDLC ..etc
Wanpipe configuration option: DYN_INTER_CFG=YES
By default its set to NO.
o AFT A104/A104D HDLC API Update
The API will not pass up CRC values, unless the configuration
option RX_CRC_BYTES=2 is set in wanpipe1.conf file.
o S514 CHDLC Protocol
Allow to bind to API interface without having to be super-user.
o AFT Firmware Flash Utility
Firmware flash utility caused unpredicatable behaviour on some
new systems with advanced PCI bridges. The fix prevents
back-to-back pci accesses.
Release Stable 2.3.3-2
======================
Mar 03 2006
o AFT Front End T1/E1 Alarm Update/Polling
On some embedded machines the A104D cards exhibited
unreliable ports i.e. The port would not come up due to
missing interrupts from the front end chip.
The Front End polling mechanism has been updated to solve this problem.
Feature pushed back from 2.3.4 release
o Compilation support on 2.4 Kernels
Feature pushed back from 2.3.4 release
o The A104D LED Update
The A104-Shark card can be used without
hardware echo cancellation on 2.3.3 release.
Feature pushed back from 2.3.4 release
o AFT A101/2 TDM Voice Update
On extremely noisy lines that can occur during a
lightning strike, the TDM Driver on A101/2 cards could
print a lot of messages into the log that can cause
unstable system behavior. This has now be fix.
Feature pushed back from 2.3.4 release
o Setup Installation updates
Compilation on 2.4 64bit kernels
Features pushed back from 2.3.4 release
Release Stable 2.3.3-1
======================
Feb 06 2006
o The Beta18 has been stable for months now thus the whole
2.3.3 release is now stable.
Release Beta18-2.3.3
====================
Dec 05 2005
o Updated support for 2.6.14 kernels.
This change only affects S514 bitstreaming drivers.
The bitstreaming driver was not updated for 2.6.14
Release Beta17-2.3.3
====================
Nov 22 2005
o Support for Linux kernel 2.6.14
The new kernel broke wanpipe drivers
o A102 Driver BUG Fix introducted in Beta16
When two ports are running, if one port is shutdown
the second port becomes disabled as well.
o Bug fix in A104 TDM Clock Sync
The clock sync feature where port 2 would
use the T1/E1 clock from port 1 had issues.
A new AFT 104 firmware V14 has been release to
fix this problem.
NOTE: The Clock Sync bug fix has two parts
1.Driver update
2.Firmware update
o New AFT A104 Firmware V14.
Fixes the ClockSync problem
o Minor updates to PPP Dynamic/Static IP negotiation.
Release Beta16-2.3.3
====================
Oct 24 2005
o AFT Update for 64Bit Kernels
Updated how AFT cards map dma buffers in 64 bit space.
o AFT Hardware support for ia64 architectures
o Setup update: Startup Sequence
Setup installation will now check for current wanpipe
startup sequence and will give the use an option of
keeping the original wanpipe startup sequence.
Wanpipe startup scripts now moved to order number 03
This will start wanpipe before zaptel on bootup.
Release Beta15-2.3.3
====================
Oct 05 2005
o AFT A101/2 HDLC Bug Fix
An HDLC bug was been introduced in beta13/14 release.
It has now been fixed.
Release Beta14-2.3.3
====================
Oct 02 2005
o Wanpipe ZAPTEL DCHAN Patch Update
The zaptel cvs head broke wanpipe
zaptel patches.
Created new zaptel patches :)
Re-Releaes Beta13-2.3.3
====================
Sep 26 2005
o AFT Firmware update bug fix.
A debug code was left in the AFT
firmware update utility.
Releaes Beta13-2.3.3
====================
Sep 24 2005
o AFT A102 TDM Bug Fix
The AFT A102 card could experience unpredicted
behavior on extremely noisy T1/E1 lines.
This issue has now been fixed.
o New AFT A104 Firmware Update V13
Fixes PCI issues on new high-end Servers.
The symptom of this bug is distorted metallic
Voice sound on TDM calls.
New firmware is located at:
ftp.sangoma.com/linux/current_wanpipe/firmware
o TDMV Driver Feature
EDAC: Echo Cancel and Control Support
Dynamically tests whether the echo is present
on the line at the beginning of each call.
If no echo is present the echo canceler is turned
OFF on that particular channel to improve resources.
Since EDAC is in BETA release one has to specify
edac option during install in order to install it:
./Setup install --edac
o TDMV Updates
RBS Bug Fix and Updates
o TDMV Timing Update
TDMV provides Asterisk Timing while the link
is disconnected
o XMTP2 Updates
o Added Async for S514 Cards.
One can now configure LIP one a PRI port of S514 card
and Async API SEC port.
Needs old firmware: cdual514asy.sfm
Release Beta11-2.3.3
Jun 23 2005
====================
o TDMV AFT A104 DCHAN Bug Fix
The A104 drivers failed to unload
cleanly on AMI Wink setup.
o New ADSL drivers
Update to ADSL drivers, with major bug
fixes to handle DMA Timeouts.
These fixes have been tested on customer
production boxes.
o Driver and Installation updates for
Itanium64 Kernel.
Note: Compilation Option #2 is only valid
compilation option for Itanium64.
Option#2: TDM Voice Only Mode.
o Further updates to ./Setup installation script.
Release Beta10-2.3.3
Jun 15 2005
===================
o TDMV AFT A102 DCHAN Bug Fix
The A101/2 card dropped DCHAN on some
bad/noisy T1/E1 lines.
This problem has now been resolved.
o Major update to ./Setup installation script.
Wanpipe driver compilation will now work
against partial linux headers.
Thus no need for full linux sources.
Furthermore, latest distributions of Fedora,
Suse and others will compile much easier now.
o Updates for Linux kernel 2.6.12
Updated for Fedora Core 4
o Front End TX TriState Option.
Option to disable the TE1 Front End
Transmitter. This option is useful in backup
recovery situations, where multiple TE1
ports are connected to a single TE1 line.
Master port would have TX/RX enabled and
the rest would have only RX enabled.
Release Beta9-2.3.3
Jun 09 2005
===================
o TDMV AFT A102 DCHAN Bug Fix
The A101/2 card dropped DCHAN on some
bad/noisy T1/E1 lines.
This problem has now been resolved.
o Wanpipemon TDMV DCHAN Tracing
wanpipemon utility can now trace
TDMV DCHAN.
eg: wanpipemon -i w1g1 -c trd
On T1 Dchan is hardcoded to 24
On E1 Dchan is hardcoded to 16
Release Beta8-2.3.3
May 30 2005
===================
o AFT TDMV A104 Driver
Bug fix on A104 shutdown.
o AFT TDMV Driver
Added additional sanity checks.
o A102 TDMV Driver
The A102 Driver will now provide clocking to
zaptel even if the front end is disconnected.
o TDMV Driver Update
Wink/RBS Update
Further updates for E1
o AMI Support for AFT TDMV Drivers
Cards: A101/2/4
o A104 Clock Sync Support
New AFT V.12 Firmware Required
o Setup Installation Script Update
New TDMV compilation Option
o A104 TDMV Driver
On some machines A104 TDMV driver failed to unload
cleanly.
Release A104 Firmware V.11
Apr 25 2005
===============
o The A104 Firmware update contains
fixes to the A104 HDLC engine.
The A104 HDLC engine contained a flaw that
caused packet loss on some hdlc lines.
This is an important update and should be
applied ASAP.
No device driver upgrade is required!
Location: ftp.sangoma.com/linux/current_wanpipe/firmware
Release Beta7-2.3.3
Apr 26 2005
===============
o TDMV Driver updates to A104 and A101
drivers. Minor fixes to DCHAN driver
for E1.
o A104 Firmware V.11 Update required for
A104 drivers.
NOTE: A104 Drivers will not load on cards that
have firmware versions lower than V.11
Update Utility Located: wanpipe/utils/wan_aftup
Instructions: wanpipe/utils/wan_aftup/README
o The A104 V.11 Firmware update contains
fixes to the A104 HDLC engine.
The A104 HDLC engine contained a flaw that
caused packet loss on some hdlc lines.
This is an important update and should be
applied ASAP.
Release Beta6-2.3.3
Apr 21 2005
===============
o TDMV DCHAN PRI HDLC channelized driver
for A101/A102 cards.
Using the TDMV_DCHAN option one can enable
the hardware HDLC engine for the PRI
T1/E1 timeslot.
Read README.asterisk for more info
o Updates to TE1 front end. Improved
front end handling.
Re-Release Beta5-2.3.3
Apr 15 2005
===============
o Minor WanCfg compile bug on gcc 3.X
Wancfg failed to compile on some gcc versions.
Release Beta5-2.3.3
Apr 12 2005
===============
o New Async HDLC API Protocol
Read the wanpipe/doc/README.asyhdlc_api
o WANCFG Update for DCHAN PRI HW HDLC
The DCHAN PRI hardware HDLC Timeslot option
is now part of the WanCfg Interface Setup.
Use the HELP button for more information, or
read the README.asterisk
o TDMV Update for E1 (A104)
A minor bug fix for E1 Channelized driver.
Channel 31 was not being configured properly.
Releaes Beta-4-2.3.3
Apr 07 2005
===============
o Optimized AFT Front End (TE1) Performance
o Fixed the A101/2 TDMV Driver
From now on the AFT A101/2 driver is equivalent
to the STABLE 2.3.2 release driver.
o Updated ./Setup script to catch common
ZAPTEL misconfigurations.
Releaes Beta-3-2.3.3
Apr 05 2005
===============
o AFT A104 TDMV Driver Channelization
The A104 TDMV Driver uses the channelization feature
of the A104 Card, to DMA 8byte chunks directly
into Zaptel buffers. Thus, there is no copying of data
inside the interrupt. Results in better performance and
scalability.
o AFT TDMV DCHAN Feature
The DCHAN PRI has hardware HDLC support.
The configuration option is TDMV_DCHAN=<Ch number>
eg: TDMV_CHAN=24 Identifies the channel
24 as pri DCHAN.
Note: This option is not part of wancfg configurator.
One must insert this option manually under the
TDMV_SPAN option:
eg.
.
.
TDMV_SPAN=1
TDMV_DCHAN=24
.
.
o AFT TDMV Update
Added WINK support to TDMV driver.
o AFT Updates to the Front End TE1
Results in faster T1/E1 connections.
o HOTPLUG Conflicts with WANPIPE
The HOTPLUG Service should be disabled because it
conflicts with Wanpipe interface startup.
The HOTPLUG can conflict with startup of TDMV drivers.
Please read the README.faq on how to prevent this.
Release beta7-2.3.2
Mar 16 2005
================
o AFT TDMV Update
Added WINK support to TDMV driver.
o AFT TDMV Update
Fixed up latecny issues with RBS signalling
For A104 and A101/2 cards.
o AFT A104 and 101/2 drivers updates
Added checks to prevent stopping wanpipe while
Asterisk is running
o AFT A300 TE3 Update
Fixed the link restart recovery.
o AFT A104 TE1 Configuration Update
Update to the TE1 physical layer paramters
o AFT Firmware Update
The firmware update utility was updated
from the AFT300 TE3 card.
o AFT TE3 Driver Update
Removed the chip security check
Re-release of bata6-2.3.2
Mar 01 2005
===================
o AFT A104 TE1 Update
This is a front end configuration update.
The A104 TE1 doesn't connect to some TE1 lines.
This update fixes that problem.
Release of beta6-2.3.2
=================
o AFT A104 Drivers: TDMV Update
The A104 cards did not default to bit
swapping in TDMV voice mode. This was
available as a configuration option.
[wanpipe1]
...
DATA_MUX_MAP=0x01234567
...
This update configures the board for
automatic bitswapping in hardware by default.
This is an important update for all customers
using A104 Quad prot card in TDMV voice mode.
Release beta5-2.3.2
===============
o AFT A104 Drivers
Fixed the FIFO leveling so that single timeslot
interfaces can operate properly
(TDMV Voice Only)
o AFT Front End TE1 Update
Synchronized fe timers and added checks
to avoid adding an already pending timer.
o AFT A101/2 Driver update
Fixed the 2 HDLC channel operation on
unchannelized card.
Add support for Master clocking from
a adjacent line, instead of the oscillator.
Used by TDM_VOICE switching applications.
Need: AFT A101/2 Firmware version V24
Fixed Synchronization issues with TDM VOICE
Racing condition exists during driver startup.
If the Front End comes up before interfaces
come up, timeslot synchornization can go out
of sync.
o New wan_aftup Utility
Located wanpipe/util/wan_aftup
Used to update AFT firmware.
Please read the README file
wanpipe/util/wan_aftup/README
o LIP Update
Updated Carrier loss recover on all LIP protocols.
Frame Relay, PPP, CHDLC
o Updated LIP Frame Relay API
Support for 1 byte reception
o Updated Hardware Probe
Includes the distinction between Channalized and
UnChannalized AFT cards.
o TDMV Echo Update
Improved echo canceling performance
o Wancfg
Updated the TDMV parameters
o Wanpipe TE3 Driver Update
Better front end recovery after
a front end disconnect.
o Wanpipe LIP Frame Relay API update
Wanpipe LIP debug messages removed
o Wanpipe hwprobe
Distinction between Channalized and Unchannalized cards
o AFT Security Check
Due to some bad pci busses, the chip security
checking has been made more robust.
o TDMV Span Number Update
Re-Release beta4-2.3.2
Feb 09 2005
==================
o Wancfg Update
Updated echo cancel cfg option
o TDMV Echo Cancellation Tweak
Improved echo cancellation
Updates also included in beta5 prerelease
in linux/custom/2.3.2 directory
Re-Release beta4-2.3.2
Feb 07 2005
==================
o Update to LIP API driver
This update only affects Frame Relay API
in the LIP layer.
Release beta4-2.3.2
Feb 04 2005
===============
o Voice TDM BUG FIX
Both A104 and A101/2 card had a bug where
on T1/E1 re-connect an rx buffer would get
deallocated by mistake. After enough re-connects
all reallocated rx buffers would run out,
causing stop in commnunications.
o LIP Frame Relay Update
Added Frame Relay API capability
Added Frame Relay Q933 Signalling
o Voice TDM for European Standars BRI
If you compile zaptel with the BRI
patch, you must manually edit the
patches/kdrivers/src/net/sdla_tdmv.c file
and uncomment the:
CONFIG_ZAPATA_BRI_DCHANS option.
o Lip Frame Relay API Support
Update LIP API frame releay
support
o General Driver Update
Network interface behaviour on carrier
disconnect.
This update changes the network interface
state in case of carrier state change.
TEQL will now work properly over AFT
and LIP interfaces.
o TDM Voice
Added on an extra option under the
TDM network interface section:
TDMV_ECHO_OFF=[YES/NO]
This option should be used to disable
echo on particular span, since asterisk
echo configuration is global to all spans.
This way echo cancellation can be performed
only on a span that needs this service.
o Wanpipemon Update
A more integrated wanpipemon that works with
the different layers of LIP and AFT.
beta3-2.3.2
Jan 04 2005
o A104 Quad Port TE1 Hardware Support
o X86_64 bit support for AMD Opteron and
Intel Itanium.
o Lip layer TTY support for Multilink PPP
Support up to 32 TTY links
o Major Bug Fix in LIP Layer
The bug could result in unexpected behaviour
on some distributions.
o Updated /proc/net/wanrouter/interface
statistics.
o PPP Multilink Support for AFT and ADSL cards.
Refer to wanpipe/doc/README.multilink
o Support for Fedora Core 3 distribution.
o Fixed support for REGPARM kernels.
o Updated Sangoma ASTERISK drivers.
Voice TDM update for A104 drivers.
o wanpipemon update
Works with LIP layer only.
o wanpipemon_legacy
Works with legacy drivers.
o wancfg update
Configures all drivers AFT,S514,ADSL
using LIP layer only.
o wancfg_legacy created
Used to configure legacy protocols
and API's.
beta2-2.3.2
Nov 8 2004
o AFT Update
Cleaned up messages in case of PCI errors
o TDM Voice Update
Added echo cancelation to the Asterisk
support.
beta1-2.3.2
Oct 18 2004
o Support for 2.6.X kernels
Fixed broken support for 2.6.9 kernel
o New Hardware Abstracion Layer
Cleanly separates the hardware
layer from the data/protocol layers.
o New AFT Hardware Support
Sangomas new high-speed T1/E1
adapters.
o New AFT T3 Support
Sangomas new high-speed T3/E3
adapters
o New LIP Network Layer
Separates Wanpipe hardware from
the Network Protocols.
Frame Relay Protocol
CHDLC Protocol
PPP Protocol
LAPB API
XDLC API
o New wancfg configuration utilty
One can only configure:
Frame Relay
PPP,
CHDLC,
HDLC (RAW) (TDM VOICE)
Note:
The old wancfg utility is called wancfg_adv.

631
Setup

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,10 @@
# Copyright (c) 1995-2000 Sangoma Technologies Inc. All Rights Reserved.
# ============================================================================
SYSINC=$(shell if [ -f ../.sysinclude ]; then cat ../.sysinclude; else echo ""; fi)
ifeq "$(SYSINC)" ""
SYSINC=/usr/src/linux/include
endif
APIINC=/etc/wanpipe/api/include
####### RULES ################################################################

View File

@ -10,8 +10,10 @@
OS_TYPE = __LINUX__
DEBUG = 2
# Project file paths.
SYSINC = /usr/src/linux/include
SYSINC=$(shell if [ -f ../../.sysinclude ]; then cat ../../.sysinclude; else echo ""; fi)
ifeq "$(SYSINC)" ""
SYSINC=/usr/src/linux/include
endif
# Tools options.
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I../lib -I$(SYSINC) -I$(APIINC)

View File

@ -10,24 +10,34 @@
OS_TYPE = __LINUX__
DEBUG = 2
# Project file paths.
SYSINC = /usr/src/linux/include
SYSINC=$(shell if [ -f ../../.sysinclude ]; then cat ../../.sysinclude; else echo ""; fi)
ifeq "$(SYSINC)" ""
SYSINC=/usr/src/linux/include
endif
VPATH = $(SYSINC)
# Tools options.
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I../lib -I$(SYSINC)
TARGETS=aft_api
TARGETS+= aft_api_ss7
TARGETS+= aft_api_check
####### RULES ################################################################
all: aft_api aft_api_rbs
all: $(TARGETS)
@echo "Ok."
aft_api: aft_api.c ../lib/lib_api.c
$(CC) $(CFLAGS) -o $@ $^
aft_api_rbs: aft_api_rbs.c ../lib/lib_api.c
aft_api_check: aft_api_check.c ../lib/lib_api.c
$(CC) $(CFLAGS) -o $@ $^
aft_api_ss7: aft_api_ss7.c ../lib/lib_api.c
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f aft_api
rm -f aft_api_rbs
rm -f $(TARGETS)

View File

@ -102,6 +102,63 @@ int MakeConnection(void)
}
int sangoma_read_socket(int sock, void *data, int len, int flag)
{
return recv(sock,data,len,flag);
}
int sangoma_readmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
{
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
printf("RECVMSG: \n");
return recvmsg(sock,&msg,flag);
}
int sangoma_send_socket(int sock, void *data, int len, int flag)
{
return send(sock,data,len,flag);
}
int sangoma_sendmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
{
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
printf("SENDMSG: \n");
return sendmsg(sock,&msg,flag);
}
/***************************************************
* HANDLE SOCKET
*
@ -137,8 +194,9 @@ void handle_socket(void)
fd_set ready,write,oob;
int err,i;
int rlen;
#if 0
int stream_sync=0;
#endif
Rx_count = 0;
Tx_count = 0;
Tx_length = tx_size;
@ -264,105 +322,119 @@ void handle_socket(void)
* 3. Check error_flag:
* CRC,Abort..etc
*/
err = recv(sock, Rx_data, MAX_RX_DATA, 0);
memset(Rx_data, 0, sizeof(Rx_data));
#if 1
err = sangoma_readmsg_socket(sock,
Rx_data,16,
&Rx_data[16], MAX_RX_DATA-16,
0);
#else
err = sangoma_read_socket(sock, Rx_data, MAX_RX_DATA, 0);
#endif
if (!read_enable){
goto bitstrm_skip_read;
}
/* err indicates bytes received */
if(err > 0) {
api_rx_el = (api_rx_element_t*)&Rx_data[0];
/* Check the packet length */
Rx_lgth = err - sizeof(api_rx_hdr_t);
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
if (api_rx_el->api_rx_hdr.error_flag){
printf("Data: ");
for(i=0;i<20; i ++) {
printf("0x%02X ", Rx_data[i]);
}
printf("\n");
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_FIFO_ERROR_BIT)){
printf("\nPacket with fifo overflow err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_CRC_ERROR_BIT)){
printf("\nPacket with invalid crc! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_ABORT_ERROR_BIT)){
printf("\nPacket with abort! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
#if 0
if (api_rx_el->data[0] == tx_data && api_rx_el->data[1] == (tx_data+1)){
if (!stream_sync){
printf("GOT SYNC %x\n",api_rx_el->data[0]);
}
stream_sync=1;
}else{
if (stream_sync){
printf("OUT OF SYNC: %x\n",api_rx_el->data[0]);
}
}
#endif
if ((files_used & RX_FILE_USED) && rx_fd){
fwrite((void*)&Rx_data[sizeof(api_rx_hdr_t)],
sizeof(char),
Rx_lgth,
rx_fd);
}
++Rx_count;
if (verbose){
printf("Received %i Olen=%i Length = %i\n",
Rx_count, err,Rx_lgth);
#if 1
printf("Data: ");
for(i=0;i<Rx_lgth; i ++) {
printf("0x%02X ", api_rx_el->data[i]);
}
printf("\n");
#endif
}else{
//putchar('R');
}
if (rx_cnt > 0 && Rx_count >= rx_cnt){
break;
}
} else {
if(err <= 0) {
printf("\nError receiving data\n");
break;
}
bitstrm_skip_read:
api_rx_el = (api_rx_element_t*)&Rx_data[0];
/* Check the packet length */
Rx_lgth = err - sizeof(api_rx_hdr_t);
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
if (api_rx_el->api_rx_hdr.error_flag){
printf("Data: ");
for(i=0;i<Rx_lgth; i ++) {
printf("0x%02X ", Rx_data[i+16]);
}
printf("\n");
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_FIFO_ERROR_BIT)){
printf("\nPacket with fifo overflow err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_CRC_ERROR_BIT)){
printf("\nPacket with invalid crc! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_ABORT_ERROR_BIT)){
printf("\nPacket with abort! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
#if 0
if (api_rx_el->data[0] == tx_data && api_rx_el->data[1] == (tx_data+1)){
if (!stream_sync){
printf("GOT SYNC %x\n",api_rx_el->data[0]);
}
stream_sync=1;
}else{
if (stream_sync){
printf("OUT OF SYNC: %x\n",api_rx_el->data[0]);
}
}
#endif
if ((files_used & RX_FILE_USED) && rx_fd){
fwrite((void*)&Rx_data[sizeof(api_rx_hdr_t)],
sizeof(char),
Rx_lgth,
rx_fd);
}
++Rx_count;
if (verbose){
printf("Received %i Olen=%i Length = %i\n",
Rx_count, err,Rx_lgth);
#if 1
printf("Data: ");
for(i=0;i<Rx_lgth; i ++) {
printf("0x%02X ", api_rx_el->data[i]);
}
printf("\n");
#endif
}else{
//putchar('R');
}
if (rx_cnt > 0 && Rx_count >= rx_cnt){
break;
}
bitstrm_skip_read:
;
}
if (FD_ISSET(sock,&write)){
err = send(sock,Tx_data, Tx_length + sizeof(api_tx_hdr_t), 0);
#if 1
err = sangoma_sendmsg_socket(sock,
Tx_data,16,
&Tx_data[16], Tx_length,
0);
#else
err = sangoma_send_socket(sock,Tx_data,
Tx_length + sizeof(api_tx_hdr_t), 0);
#endif
if (err <= 0){
if (errno == EBUSY){
if (verbose){
@ -485,3 +557,5 @@ void sig_end(int sigid)
exit(1);
}

View File

@ -1,475 +0,0 @@
/*****************************************************************************
* aft_api.c AFT T1/E1: HDLC API Sample Code
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 2003-2004 Sangoma Technologies Inc.
*
* 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.
* ============================================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if_wanpipe.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <signal.h>
#include <linux/if.h>
#include <linux/wanpipe.h>
#include <linux/sdla_xilinx.h>
#include "lib_api.h"
#define MAX_TX_DATA 5000 /* Size of tx data */
#define MAX_FRAMES 5000 /* Number of frames to transmit */
#define MAX_RX_DATA 5000
unsigned short Rx_lgth;
unsigned char Rx_data[MAX_RX_DATA];
unsigned char Tx_data[MAX_TX_DATA + sizeof(api_tx_hdr_t)];
/* Prototypes */
int MakeConnection(void);
void handle_socket( void);
void sig_end(int sigid);
int sock;
FILE *tx_fd=NULL,*rx_fd=NULL;
/***************************************************
* MakeConnection
*
* o Create a Socket
* o Bind a socket to a wanpipe network interface
* (Interface name is supplied by the user)
*/
int MakeConnection(void)
{
struct wan_sockaddr_ll sa;
memset(&sa,0,sizeof(struct wan_sockaddr_ll));
errno = 0;
sock = socket(AF_WANPIPE, SOCK_RAW, 0);
if( sock < 0 ) {
perror("Socket");
return( WAN_FALSE );
} /* if */
printf("\nConnecting to card %s, interface %s prot %x\n", card_name, if_name,htons(PVC_PROT));
strcpy( sa.sll_device, if_name);
strcpy( sa.sll_card, card_name);
sa.sll_protocol = htons(PVC_PROT);
sa.sll_family=AF_WANPIPE;
if(bind(sock, (struct sockaddr *)&sa, sizeof(struct wan_sockaddr_ll)) < 0){
perror("bind");
printf("Failed to bind a socket to %s interface\n",if_name);
exit(0);
}
{
unsigned int customer_id;
int err = ioctl(sock,SIOC_AFT_CUSTOMER_ID,&customer_id);
if (err){
perror("Customer ID: ");
}else{
printf("Customer ID 0x%X\n",customer_id);
}
}
printf("Socket bound to %s\n\n",if_name);
return( WAN_TRUE );
}
/***************************************************
* HANDLE SOCKET
*
* o Read a socket
* o Cast data received to api_rx_element_t data type
* o The received packet contains 16 bytes header
*
* ------------------------------------------
* | 16 bytes | X bytes ...
* ------------------------------------------
* Header Data
*
* o Data structures:
*
* typedef struct {
* unsigned char error_flag;
* unsigned short time_stamp;
* unsigned char reserved[13];
* } api_rx_hdr_t;
*
* typedef struct {
* api_rx_hdr_t api_rx_hdr;
* unsigned char data[1];
* } api_rx_element_t;
*
*/
void handle_socket(void)
{
unsigned int Rx_count,Tx_count,Tx_length;
api_rx_element_t* api_rx_el;
api_tx_element_t * api_tx_el;
fd_set ready,write,oob;
int err,i;
int rlen;
Rx_count = 0;
Tx_count = 0;
Tx_length = tx_size;
printf("\n\nSocket Handler: Rx=%d Tx=%i TxCnt=%i TxLen=%i TxDelay=%i\n",
read_enable,write_enable,tx_cnt,tx_size,tx_delay);
/* Initialize the Tx Data buffer */
memset(&Tx_data[0],0,MAX_TX_DATA + sizeof(api_tx_hdr_t));
/* If rx file is specified, open
* it and prepare it for writing */
if (files_used & RX_FILE_USED){
rx_fd=fopen(rx_file,"wb");
if (!rx_fd){
printf("Failed to open file %s\n",rx_file);
perror("File: ");
return;
}
printf("Opening %s rx file\n",rx_file);
}
/* Cast the Tx data packet with the tx element
* structure. We must insert a 16 byte
* driver header, which driver will remove
* before passing packet out the physical port */
api_tx_el = (api_tx_element_t*)&Tx_data[0];
if (files_used & TX_FILE_USED){
/* TX file is used to transmit data */
tx_fd=fopen(tx_file,"rb");
if (!tx_fd){
printf("Failed to open file %s\n",tx_file);
perror("File: ");
return;
}
printf("Opening %s tx file\n",rx_file);
rlen=fread((void*)&Tx_data[sizeof(api_tx_hdr_t)],
sizeof(char),
Tx_length,tx_fd);
if (!rlen){
printf("%s: File empty!\n",
tx_file);
return;
}
}else{
/* Create a Tx packet based on user info, or
* by deafult incrementing number starting from 0 */
for (i=0;i<Tx_length;i++){
if (tx_data == -1){
api_tx_el->data[i] = (unsigned char)i;
}else{
api_tx_el->data[i] = (unsigned char)tx_data;
}
}
}
/* Main Rx Tx OOB routine */
for(;;) {
/* Initialize all select() descriptors */
FD_ZERO(&ready);
FD_ZERO(&write);
FD_ZERO(&oob);
FD_SET(sock,&oob);
FD_SET(sock,&ready);
if (write_enable){
FD_SET(sock,&write);
}
/* Select will block, until:
* 1: OOB event, link level change
* 2: Rx data available
* 3: Interface able to Tx */
if(select(sock + 1,&ready, &write, &oob, NULL)){
fflush(stdout);
if (FD_ISSET(sock,&oob)){
/* An OOB event is pending, usually indicating
* a link level change */
err = recv(sock, Rx_data, MAX_RX_DATA, MSG_OOB);
api_rx_el = (api_rx_element_t*)&Rx_data[0];
if(err < 0 ) {
printf("Failed to receive OOB %i , %i\n", Rx_count, err);
err = ioctl(sock,SIOC_WANPIPE_SOCK_STATE,0);
printf("Sock state is %s\n",
(err == 0) ? "CONNECTED" :
(err == 1) ? "DISCONNECTED" :
"CONNECTING");
break;
}else{
printf("GOT OOB EXCEPTION: Timeslot=%i Status=0x%X: A=%d B=%d C=%d D=%d\n",
api_rx_el->api_rx_hdr.channel,api_rx_el->data[0],
api_rx_el->data[0]&WAN_RBS_SIG_A?1:0,
api_rx_el->data[0]&WAN_RBS_SIG_B?1:0,
api_rx_el->data[0]&WAN_RBS_SIG_C?1:0,
api_rx_el->data[0]&WAN_RBS_SIG_D?1:0);
continue;
}
break;
}
if (FD_ISSET(sock,&ready)){
/* An Rx packet is pending
* 1: Read the rx packet into the Rx_data
* buffer. Confirm len > 0
*
* 2: Cast Rx_data to the api_rx_element.
* Thus, removing a 16 byte header
* attached by the driver.
*
* 3. Check error_flag:
* CRC,Abort..etc
*/
err = recv(sock, Rx_data, MAX_RX_DATA, 0);
if (!read_enable){
goto bitstrm_skip_read;
}
/* err indicates bytes received */
if(err > 0) {
api_rx_el = (api_rx_element_t*)&Rx_data[0];
/* Check the packet length */
Rx_lgth = err - sizeof(api_rx_hdr_t);
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
if (api_rx_el->api_rx_hdr.error_flag){
printf("Data: ");
for(i=0;i<20; i ++) {
printf("0x%02X ", Rx_data[i]);
}
printf("\n");
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_FIFO_ERROR_BIT)){
printf("\nPacket with fifo overflow err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_CRC_ERROR_BIT)){
printf("\nPacket with invalid crc! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if (api_rx_el->api_rx_hdr.error_flag & (1<<WP_ABORT_ERROR_BIT)){
printf("\nPacket with abort! err=0x%X len=%i\n",
api_rx_el->api_rx_hdr.error_flag,Rx_lgth);
continue;
}
if ((files_used & RX_FILE_USED) && rx_fd){
fwrite((void*)&Rx_data[sizeof(api_rx_hdr_t)],
sizeof(char),
Rx_lgth,
rx_fd);
}
++Rx_count;
if (verbose){
printf("Received %i Olen=%i Length = %i\n",
Rx_count, err,Rx_lgth);
#if 1
printf("Data: ");
for(i=0;i<Rx_lgth; i ++) {
printf("0x%02X ", api_rx_el->data[i]);
}
printf("\n");
#endif
}else{
//putchar('R');
}
if (rx_cnt > 0 && Rx_count >= rx_cnt){
break;
}
} else {
printf("\nError receiving data\n");
break;
}
bitstrm_skip_read:
}
if (FD_ISSET(sock,&write)){
err = send(sock,Tx_data, Tx_length + sizeof(api_tx_hdr_t), 0);
if (err <= 0){
if (errno == EBUSY){
if (verbose){
printf("Sock busy try again!\n");
}
/* Socket busy try sending again !*/
}else{
/* Check socket state */
err = ioctl(sock,SIOC_WANPIPE_SOCK_STATE,0);
printf("Sock state is %s\n",
(err == 0) ? "CONNECTED" :
(err == 1) ? "DISCONNECTED" :
"CONNECTING");
printf("Faild to send %i \n",errno);
perror("Send: ");
break;
}
}else{
++Tx_count;
if (verbose){
printf("Packet sent: Sent %i : %i\n",
err,Tx_count);
}else{
//putchar('T');
}
if ((files_used & TX_FILE_USED) && tx_fd){
rlen=fread((void*)&Tx_data[sizeof(api_tx_hdr_t)],
sizeof(char),
Tx_length,tx_fd);
if (!rlen){
printf("\nTx of file %s is done!\n",
tx_file);
break;
}
if (Tx_length != rlen){
Tx_length = rlen;
}
}
}
}
if (tx_delay){
usleep(tx_delay);
}
if (tx_cnt && tx_size && Tx_count >= tx_cnt && !(files_used & TX_FILE_USED)){
write_enable=0;
if (rx_cnt > 0){
/* Dont break let rx finish */
}else{
break;
}
}
}
}
if (tx_fd){
fclose(tx_fd);
}
if (rx_fd){
fclose(rx_fd);
}
close (sock);
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_socket() to read the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int proceed;
proceed=init_args(argc,argv);
if (proceed != WAN_TRUE){
usage(argv[0]);
return -1;
}
signal(SIGINT,&sig_end);
proceed = MakeConnection();
if( proceed == WAN_TRUE){
handle_socket();
return 0;
}
return 0;
};
void sig_end(int sigid)
{
printf("Got Signal %i\n",sigid);
if (tx_fd){
fclose(tx_fd);
}
if (rx_fd){
fclose(rx_fd);
}
if (sock){
close (sock);
}
exit(1);
}

29
api/asyhdlc/Makefile Normal file
View File

@ -0,0 +1,29 @@
# ============================================================================
# Makefile Make script for building Linux WAN router utilities.
# ----------------------------------------------------------------------------
# Copyright (c) 1995-1998 Sangoma Technologies Inc. All Rights Reserved.
# ============================================================================
####### MACROS ###############################################################
# Build options.
OS_TYPE = __LINUX__
DEBUG = 2
# Project file paths.
SYSINC = /usr/src/linux/include
APIINC = /usr/src/linux/include
# Tools options.
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I../lib -I$(SYSINC) -I$(APIINC)
####### RULES ################################################################
all: asyhdlc_api
@echo "Ok."
asyhdlc_api: asyhdlc_api.c ../lib/lib_api.c
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f asyhdlc_api

22
api/asyhdlc/README Normal file
View File

@ -0,0 +1,22 @@
CHDLC API Package
=================
Author: Nenad Corbic
Date: Jan 18, 2002
The chdlc package contains the sample client and server
program that should be used in user application
development.
Contents of the API Package
---------------------------
1) chdlc_api.c : Client application that sends and receives data.
To disable sending of data, comment out a WRITE definition.
2) chdlc_rts_cts.c: Client application that should be used when
driver has been configured for switched RTS CTS or
idle mark.

462
api/asyhdlc/asyhdlc_api.c Normal file
View File

@ -0,0 +1,462 @@
/*****************************************************************************
* chdlc_api.c CHDLC API: Receive Module
*
* Author(s): Gideon Hack & Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2001 Sangoma Technologies Inc.
*
* 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.
* ============================================================================
* Description:
*
* The chdlc_api.c utility will bind to a socket to a chdlc network
* interface, and continously tx and rx packets to an from the sockets.
*
* This example has been written for a single interface in mind,
* where the same process handles tx and rx data.
*
* A real world example, should use different processes to handle
* tx and rx spearately.
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if_wanpipe.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <linux/wanpipe.h>
#include <linux/sdla_asyhdlc.h>
#include "lib_api.h"
#define FALSE 0
#define TRUE 1
#define LGTH_CRC_BYTES 0
#define MAX_TX_DATA 5000 /* Size of tx data */
#define MAX_RX_DATA MAX_TX_DATA
FILE *tx_fd=NULL,*rx_fd=NULL;
/*===================================================
* Golobal data
*==================================================*/
unsigned short no_CRC_bytes_Rx;
unsigned char HDLC_streaming = FALSE;
unsigned short Rx_lgth;
unsigned char Rx_data[MAX_RX_DATA];
unsigned char Tx_data[MAX_TX_DATA];
int sock;
/*===================================================
* Function Prototypes
*==================================================*/
int MakeConnection(void);
void handle_socket( void);
/*===================================================
* MakeConnection
*
* o Create a Socket
* o Bind a socket to a wanpipe network interface
* (Interface name is supplied by the user)
*==================================================*/
int MakeConnection(void)
{
struct wan_sockaddr_ll sa;
memset(&sa,0,sizeof(struct wan_sockaddr_ll));
errno = 0;
sock = socket(AF_WANPIPE, SOCK_RAW, 0);
if( sock < 0 ) {
perror("Socket");
return(FALSE);
} /* if */
printf("\nConnecting to router %s, interface %s\n", card_name, if_name);
strcpy( sa.sll_device, if_name);
strcpy( sa.sll_card, card_name);
sa.sll_protocol = htons(PVC_PROT);
sa.sll_family=AF_WANPIPE;
if(bind(sock, (struct sockaddr *)&sa, sizeof(struct wan_sockaddr_ll)) < 0){
perror("bind");
printf("Failed to bind a socket to %s interface\n",if_name);
exit(0);
}
printf("Socket bound to %s\n\n",if_name);
return(TRUE);
}
/*===========================================================
* handle_socket
*
* o Tx/Rx data to and from the socket
* o Cast received data to an api_rx_element_t data type
* o The received packet contains 16 bytes header
*
* ------------------------------------------
* | 16 bytes | X bytes ...
* ------------------------------------------
* Header Data
*
* RX DATA:
* --------
* Each rx data packet contains the 16 byte header!
*
* o Rx 16 byte data structure:
*
* typedef struct {
* unsigned char error_flag PACKED;
* unsigned short time_stamp PACKED;
* unsigned char reserved[13] PACKED;
* } api_rx_hdr_t;
*
* typedef struct {
* api_rx_hdr_t api_rx_hdr PACKED;
* void * data PACKED;
* } api_rx_element_t;
*
* error_flag:
* bit 0: incoming frame was aborted
* bit 1: incoming frame has a CRC error
* bit 2: incoming frame has an overrun eror
*
* time_stamp:
* absolute time value in ms.
*
* TX_DATA:
* --------
* Each tx data packet MUST contain a 16 byte header!
*
* o Tx 16 byte data structure
*
* typedef struct {
* unsigned char attr PACKED;
* unsigned char reserved[15] PACKED;
* } api_tx_hdr_t;
*
* typedef struct {
* api_tx_hdr_t api_tx_hdr PACKED;
* void * data PACKED;
* } api_tx_element_t;
*
* Currently the chdlc device driver doesn't use any of
* the above fields. Thus, the user can set the 16 bytes
* to ZERO.
*
*/
void handle_socket(void)
{
unsigned int Rx_count,Tx_count,Tx_length;
api_rx_element_t* api_rx_el;
api_tx_element_t * api_tx_el;
fd_set ready,write,oob;
int err,i;
int rlen;
int ferr;
int txfile_bytes=0;
void *pRx_data,*pTx_data;
int no_CRC_bytes_Rx = LGTH_CRC_BYTES;
pRx_data = (void*)&Rx_data[sizeof(api_rx_hdr_t)];
pTx_data = (void*)&Tx_data[sizeof(api_tx_hdr_t)];
Rx_count = 0;
Tx_count = 0;
Tx_length = tx_size;
printf("\n\nSocket Handler: Rx=%d Tx=%i TxCnt=%i TxLen=%i TxDelay=%i RxCnt=%i\n",
read_enable,write_enable,tx_cnt,tx_size,tx_delay,rx_cnt);
/* If running HDLC_STREAMING then the received CRC bytes
* will be passed to the application as part of the
* received data.
*/
memset(&Tx_data[0],0,MAX_TX_DATA);
if (files_used & RX_FILE_USED){
rx_fd=fopen(rx_file,"wb");
if (!rx_fd){
printf("Failed to open file %s\n",rx_file);
perror("File: ");
return;
}
printf("Opening %s rx file\n",rx_file);
}
if (files_used & TX_FILE_USED){
tx_fd=fopen(tx_file,"rb");
if (!tx_fd){
printf("Failed to open file %s\n",tx_file);
perror("File: ");
return;
}
printf("Opening %s tx file\n",tx_file);
rlen=fread(pTx_data,
sizeof(char),
Tx_length,tx_fd);
if (!rlen){
printf("%s: File empty!\n",
tx_file);
return;
}
}else{
api_tx_el = (api_tx_element_t*)&Tx_data[0];
for (i=0;i<Tx_length;i++){
if (tx_data == -1){
api_tx_el->data[i] = (unsigned char)i;
}else{
api_tx_el->data[i] = (unsigned char)tx_data;
}
}
}
for(;;) {
FD_ZERO(&ready);
FD_ZERO(&write);
FD_ZERO(&oob);
FD_SET(sock,&oob);
FD_SET(sock,&ready);
if (write_enable){
FD_SET(sock,&write);
}
fflush(stdout);
if(select(sock + 1,&ready, &write, &oob, NULL)){
if (FD_ISSET(sock,&oob)){
err = recv(sock, Rx_data, MAX_RX_DATA, MSG_OOB);
if(err < 0 ) {
printf("Failed to receive OOB %i , %i\n", Rx_count, err);
err = ioctl(sock,SIOC_WANPIPE_SOCK_STATE,0);
printf("Sock state is %s\n",
(err == 0) ? "CONNECTED" :
(err == 1) ? "DISCONNECTED" :
"CONNECTING");
break;
}
printf("Got OOB exception: Link Down !\n");
break;
}
if (FD_ISSET(sock,&ready)){
err = recv(sock, Rx_data, MAX_RX_DATA, 0);
if (!read_enable){
goto bitstrm_skip_read;
}
/* err indicates bytes received */
if (err > 0){
api_rx_el = (api_rx_element_t*)&Rx_data[0];
/* Check the packet length */
Rx_lgth = err - sizeof(api_rx_hdr_t)-no_CRC_bytes_Rx;
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
if ((files_used & RX_FILE_USED) && rx_fd){
ferr=fwrite(pRx_data,
sizeof(char),
Rx_lgth,
rx_fd);
if (ferr != Rx_lgth){
printf("Error: fwrite failed: written=%i should have %i\n",
ferr,Rx_lgth);
}
}
++Rx_count;
if (verbose){
printf("Received %i Olen=%i Length = %i\n",
Rx_count, err,Rx_lgth);
}else{
putchar('R');
}
#if 1
if (verbose){
printf("Data: ");
for(i=0;(i<Rx_lgth)&&(i<32); i ++) {
printf("0x%02X ", api_rx_el->data[i]);
}
printf("\n");
}
#endif
if (rx_cnt == Rx_count){
printf("Rxcnt %i == RxCount=%i\n",rx_cnt,Rx_count);
break;
}
} else {
printf("\nError receiving data\n");
break;
}
}
bitstrm_skip_read:
if (FD_ISSET(sock,&write)){
err = send(sock,Tx_data, Tx_length + sizeof(api_tx_hdr_t), 0);
if (err <= 0){
if (errno == EBUSY){
if (verbose){
printf("Sock busy try again!\n");
}
/* Socket busy try sending again !*/
}else{
/* Check socket state */
err = ioctl(sock,SIOC_WANPIPE_SOCK_STATE,0);
printf("Sock state is %s\n",
(err == 0) ? "CONNECTED" :
(err == 1) ? "DISCONNECTED" :
"CONNECTING");
printf("Failed to send %i \n",errno);
perror("Send: ");
break;
}
}else{
++Tx_count;
if (verbose){
printf("Packet sent: Sent %i : %i\n",
err,Tx_count);
}else{
//putchar('T');
}
txfile_bytes+=Tx_length;
if ((files_used & TX_FILE_USED) && tx_fd){
rlen=fread(pTx_data,
sizeof(char),
Tx_length,tx_fd);
if (!rlen){
printf("\nTx of file %s is done %i bytes!\n",
tx_file,txfile_bytes);
break;
}
if (Tx_length != rlen){
Tx_length = rlen;
}
}
}
/* Check if rx data is pending
* Return Codes:
* HDLC_RX_IN_PROCESS - Rx data is pending
* NO_HDLC_RX_IN_PROCESS - No Rx data is pending */
err = ioctl(sock,SIOC_GET_HDLC_RECEIVER_STATUS,0);
switch (err){
case HDLC_RX_IN_PROCESS:
printf("HDLC Status: Pending \n");
break;
case NO_HDLC_RX_IN_PROCESS:
printf("HDLC Status: No Pending \n");
break;
default:
printf("HDLC Status: Error HDLC Get Status Failed\n");
break;
}
}
if (tx_delay){
sleep(tx_delay);
}
if (tx_size && Tx_count == tx_cnt && !(files_used & TX_FILE_USED)){
write_enable=0;
if (!rx_cnt){
break;
}
}
}
}
if (tx_fd){
fclose(tx_fd);
}
if (rx_fd){
fclose(rx_fd);
}
close (sock);
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_socket() to read/write the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int proceed;
proceed=init_args(argc,argv);
if (proceed != WAN_TRUE){
usage(argv[0]);
return -1;
}
proceed = MakeConnection();
if(proceed == WAN_TRUE){
handle_socket();
return 0;
}
return 1;
};

3
api/asyhdlc/tx.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
./asyhdlc_api -i wp1_chdlc -c wanpipe1 -r -rxcnt 10 -w -txsize 10 -txcnt 9 -verbose

Binary file not shown.

View File

@ -47,6 +47,8 @@ int rx_cnt=0;
int tx_size=10;
int tx_delay=0;
int tx_data=-1;
int tx_ss7_type=0;
int rx_ss7_timer=0;
unsigned char card_name[WAN_IFNAME_SZ];
unsigned char if_name[WAN_IFNAME_SZ];
@ -201,6 +203,33 @@ int init_args(int argc, char *argv[])
printf("ERROR: Invalid tx data, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-tx_ss7_type")){
if (i+1 > argc-1){
printf("ERROR: Invalid tx ss7 type!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_ss7_type = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-rx_ss7_timer")){
if (i+1 > argc-1){
printf("ERROR: Invalid rx ss7 timer!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
rx_ss7_timer = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx ss7 type, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txfile")){
if (i+1 > argc-1){
@ -395,6 +424,10 @@ static unsigned char api_usage[]="\n"
" -txfile <file> #Use file to tx instead\n"
" -rxfile <file> #Save all rx data to a file\n"
" \n"
"\n"
" -tx_ss7_type <digit> # 1=FISU 2=LSSU (repeating)\n"
" -rx_ss7_timer <digit> #Force receive timeout value \n"
"\n"
" -rxcnt <digit> #number of rx packets before exit\n"
" #this number overwrites the txcnt\n"
" #Thus, app will only exit after it\n"

View File

@ -21,6 +21,8 @@ extern int rx_cnt;
extern int tx_size;
extern int tx_delay;
extern int tx_data;
extern int tx_ss7_type;
extern int rx_ss7_timer;
extern int files_used;
extern int verbose;
extern int ds_prot;

14
api/libsangoma/Makefile Normal file
View File

@ -0,0 +1,14 @@
CC=gcc
INCLUDES=-I/usr/src/libpri -I/usr/src/linux/include -I. -I./msu/libmsu
CFLAGS=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -O6 -march=i686
CCFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes -g
all: libsangoma.o
libsangoma.o: libsangoma.c libsangoma.h
$(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -O2 -D_DEBUG_=2 -D_GNUC_ -I../lib -I/usr/src/linux/include -c -o libsangoma.o libsangoma.c
clean:
rm -fr *.o *.so *~ *core* *.so* *.a
@echo OK

198
api/libsangoma/libsangoma.c Normal file
View File

@ -0,0 +1,198 @@
/*****************************************************************************
* libsangoma.c AFT T1/E1: HDLC API Code Library
*
* Author(s): Anthony Minessale II <anthmct@yahoo.com>
* Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 2005 Anthony Minessale II
*
* 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.
* ============================================================================
*/
#include "libsangoma.h"
#if 1
/* Enable Sangoma Scatter Gather Socket Calls */
#define SANGOMA_SC_SOCKET 1
#else
/* Disable Sangoma Scatter Gather Socket Calls */
#undef SANGOMA_SC_SOCKET
#endif
int sangoma_create_socket_intr(int span, int intr)
{
struct wan_sockaddr_ll sa;
int sock=-1;
memset(&sa, 0, sizeof(struct wan_sockaddr_ll));
sock = socket(AF_WANPIPE, SOCK_RAW, 0);
if ( sock >= 0 ) {
sprintf(sa.sll_device, "w%dg%d", span, intr);
strcpy( sa.sll_card, "wanpipe1");
sa.sll_protocol = htons(PVC_PROT);
sa.sll_family=AF_WANPIPE;
if (bind(sock, (struct sockaddr *)&sa, sizeof(struct wan_sockaddr_ll)) < 0) {
close(sock);
sock = -1;
printf("Fail %d %s [%s]\n", sock, sa.sll_device, strerror(errno));
}
}
return sock;
}
int sangoma_create_socket(int span)
{
int sock=-1;
int i;
for (i=1; i<32; i++) {
if (i == 16 || i == 24) {
continue;
}
if ((sock=sangoma_create_socket_intr(span, i) >= 0)) {
break;
}
}
return sock;
}
int sangoma_write_socket(int sock, void *data, int len)
{
return send(sock,data,len,0);
}
/*==============================================================
* sangoma_readmsg_socket
*
* Transmits wanpipe header and data using two separate buffers
*
* INPUTS:
*
* hdrbuf = header buffer must be size of sizeof(api_rx_hdr_t) 16bytes
* hdrlen = lenght of the header buffer sizeof(api_rx_hdr_t) 16bytes
*
* databuf = data buffer that will contain the actual payload
* datalen = length of the data buffer. Always set it to MAX value.
*
* OUTPUT:
*
* hdrbuf = will contain Sangoma 16 byte header
* databuf = will contain data payload
*
* Function returns length of received databuf WITHOUT the header.
*
*/
int sangoma_sendmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
{
int bsent;
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
bsent = sendmsg(sock,&msg,flag);
if (bsent > 0){
bsent-=sizeof(sangoma_api_hdr_t);
}
return bsent;
}
int sangoma_read_socket(int sock, void *data, int len)
{
api_rx_element_t *api_rx_el;
int rx_len = recv(sock,data,len,0);
if (rx_len <= sizeof(api_rx_hdr_t)){
return -EINVAL;
}
api_rx_el = (api_rx_element_t*)data;
if (api_rx_el->api_rx_hdr.error_flag){
return -EINVAL;
}
return rx_len;
}
/*==============================================================
* sangoma_readmsg_socket
*
* Receives wanpipe header and data in two separate buffers
*
* INPUTS:
*
* hdrbuf = header buffer must be size of sizeof(api_rx_hdr_t) 16bytes
* hdrlen = lenght of the header buffer sizeof(api_rx_hdr_t) 16bytes
*
* databuf = data buffer that will contain the actual payload
* datalen = length of the data buffer. Always set it to MAX value.
*
* OUTPUT:
*
* hdrbuf = will contain Sangoma 16 byte header
* databuf = will contain data payload
*
* Function returns length of received databuf WITHOUT the header.
*
*/
int sangoma_readmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag)
{
int rx_len;
struct msghdr msg;
struct iovec iov[2];
memset(&msg,0,sizeof(struct msghdr));
iov[0].iov_len=hdrlen;
iov[0].iov_base=hdrbuf;
iov[1].iov_len=datalen;
iov[1].iov_base=databuf;
msg.msg_iovlen=2;
msg.msg_iov=iov;
rx_len = recvmsg(sock,&msg,flag);
if (rx_len <= sizeof(sangoma_api_hdr_t)){
return -EINVAL;
}
rx_len-=sizeof(sangoma_api_hdr_t);
return rx_len;
}

View File

@ -0,0 +1,40 @@
/*****************************************************************************
* libsangoma.c AFT T1/E1: HDLC API Code Library
*
* Author(s): Anthony Minessale II <anthmct@yahoo.com>
* Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 2005 Anthony Minessale II
*
* 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.
* ============================================================================
*/
#ifndef _LIBSNAGOMA_H
#define _LIBSNAGOMA_H
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/if_wanpipe.h>
#include <linux/wanpipe_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <linux/sdla_aft_te1.h>
typedef api_rx_hdr_t sangoma_api_hdr_t;
int sangoma_create_socket(int span);
int sangoma_create_socket_intr(int span, int intr);
int sangoma_write_socket(int sock, void *data, int len);
int sangoma_read_socket(int sock, void *data, int len);
int sangoma_sendmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
int sangoma_readmsg_socket(int sock, void *hdrbuf, int hdrlen, void *databuf, int datalen, int flag);
#endif

1
api/libsangoma/version Normal file
View File

@ -0,0 +1 @@
v1.0.0

View File

@ -10,8 +10,10 @@
OS_TYPE = __LINUX__
DEBUG = 2
# Project file paths.
SYSINC = /usr/src/linux/include
SYSINC=$(shell if [ -f ../../.sysinclude ]; then cat ../../.sysinclude; else echo ""; fi)
ifeq "$(SYSINC)" ""
SYSINC=/usr/src/linux/include
endif
APIINC = /usr/src/linux/include
# Tools options.

View File

@ -52,46 +52,4 @@ Contents of the API Package
to your interface names and re-make
the application.
XDLC API CALLS
==============
SIOCS_XDLC_GET_CONF
SIOCS_XDLC_SET_CONF
SIOCS_XDLC_START
SIOCS_XDLC_STOP
SIOCS_XDLC_ENABLE_IFRAMES
SIOCS_XDLC_DISABLE_IFRAMES
SIOCS_XDLC_CLEAR_POLL_TMR
SIOCS_XDLC_FLUSH_TX_BUF
SIOCS_XDLC_GET_STATS
SIOCS_XDLC_FLUSH_STATS
XDLC OOB EXCEPTOINS
===================
EXCEP_LINK_CONNECTED
EXCEP_LINK_CONNECTING,
EXCEP_LINK_DISCONNECTED,
EXCEP_LINK_DISCONNECTING,
EXCEP_OOB_EXCEPTIONS,
EXCEP_NO_RESPONSE_COUNTER,
EXCEP_FRM_RETRANS_COUNTER,
EXCEP_RNR_COUNTER,
EXCEP_SEC_NRM_TIMEOUT,
EXCEP_PRI_RD_FRAME_RECEIVED,
EXCEP_FRM_DM_FRAME_RECEIVED,
EXCEP_SEC_SNRM_FRAME_RECEIVED,
EXCEP_SEC_DISC_FRAME_RECEIVED,
EXCEP_FRMR_FRAME_RECEIVED,
EXCEP_FRMR_FRAME_TRANSMITTED

View File

@ -1,5 +1,5 @@
Package: wanpipe
Version: 2.3.2-7
Version: 2.3.3-7
Section: networking
Priority: optional
Architecture: all

View File

File diff suppressed because it is too large Load Diff

406
doc/README.asterisk.bak Normal file
View File

@ -0,0 +1,406 @@
Asterisk Open PBC/IVR Project using the Sangoma A101 and A102 cards
===================================================================
Alex Feldman: Mar 2005
Nenad Corbic:
WANPIPE supports the Asterisk Open PBX/IVR project through an interface
of the Zaptel family of hardware devices. These devices share a common
driver suite, called the ZAPATA Telephony Driver Suite (zaptel).
IMPORTANT
---------
Please read the APPENDIX for IMPORTANT INFO
ASTERISK / ZAPTEL Installation
-------------------------------
First install:
zaptel, zapata, libpri and asterisk
software on your system.
The Asterisk distributions can be found at http://www.asterisk.org.
1. Download the LATEST sources from http://www.asterisk.org;
2. Untar zaptel, libpri and asterisk source
in /usr/src directory
3. Proceed with ASTERISK/ZAPTEL installation as per
Asterisk instructions
Note:
Zaptel kernel drivers must compiled and
installed BEFORE loading WANPIPE drivers.
WANPIPE Releases
----------------
2.3.3: Latest Wanpipe Release
All the NEW features are for A104 Card ONLY
o New channelized TDMV Driver for A104 Card
Voice data is channelized and grouped into
8 byte chunks in HARDWARE. Each voice
channel is then DMAed directly into the ZAPTEL
buffers. Thus there is ZERO copy from HARDWARE
to ZAPTEL, resulting in better performance and
scalability.
o New DCHAN PRI Hardware HDLC support
Instead of using ZAPTEL HDLC engines in software,
WANPIPE drivers use HARDWARE HDLC engine to
handle PRI traffic. The HDLC frames are
then passed directly into the LIBPRI, resulting
in better performance and scalability.
o New TDMV API
Customers that develop Voice Applications in User Space, can now develop using Channelized TDMV API.
The TDMV API works in the same way as standard HDLC API.
Application creates a socket to a network interface and
uses standard system calls to read and write.
However, data received from the TDMV API socket, will be
in 8,16,32 or 63 byte CHUNKS for each configured timeslot.
Thus for full T1 1-23 voice channels the rx data would
look like:
__________________________________
| 8bytes | 8 | | ... | 8 |
----------------------------------
Slot 1 2 3 23
The DCHAN PRI HDLC frames would be received as OOB messages
on the same socket.
OR
The DCHAN PRI HDLC frames could be received using another
socket that is connected to a network interface that is
bound to channel 24.
2.3.2: Stable Wanpipe TDMV Release
o The ORIGINAL TDMV driver for both A101/2 and A104 cards.
TDMV Driver has been optimized for best Echo cancel
performance.
This driver has been fully tested in the field and is
considered stable.
WANPIPE Installation for Asterisk
---------------------------------
1. Download the LATEST Wanpipe 2.3.2 Release or Greater!
Note: Wanpipe does not support Asterisk in releases
LOWER than 2.3.2!
ftp.sangoma.com/linux/current_wanpipe
2. Untar wanpipe release in /usr/src/ directory
eg: tar xvfz wanpipe-beta3-2.3.2.tgz
3. Run ./Setup install
Proceed with installation choose YES for each option.
IMPORTANT:
Under compilation mode: select CUSTOM
Then select: DEF :for default protocols
TDM :for TDM Voice asterisk support
Enable TDMV_DCHAN option for Hardware HDLC for
DCHAN PRI.
This option will also PATCH the ZAPTEL driver.
Thus, ZAPTEL MUST be recompiled and installed
after the ./Setup is completed.
Proceed to compile wanpipe drivers.
4. To confirm successful installation run:
wanrouter hwprobe
Confirm that Sangoma cards have been found.
Note:
Zaptel kernel drivers must compiled and
installed BEFORE loading WANPIPE drivers.
WANPIPE Configuration for the A100 series of cards
--------------------------------------------------
You can use the A101 or A102 cards for both data and voice. The
following describes how to configure the Asterisk system for
voice, with an auxiliary data interface, if needed.
1. Run the configuration utility wancfg.
/usr/sbin/wancfg
Hardware Setup:
Select Hardware: AFT
T1/E1 CSU/DSU Setup can be configured via
"Advanced Physical Medium Config"
If all the 24 (T1) or 30 (E1) timeslots will
be used by Asterisk then there is no need to
configure the T1/E1 Channelization.
If less than the full span is used by Asterisk,
set the channel span in
"Advanced Timeslot Groups Configuration"
Protocol Setup:
Select Protocol: TDM VOICE
No other options
Interface Setup:
Select SPAN Number: 1-24
The SPAN usually starts with 1
No other options
2. DCHAN Configuration (A104 Card Only):
Release : beta1-2.3.3 or greater.
Firmware Version: V.10
Currently DCHAN is not supported in wancfg,
thus one has to add it manually to wanpipe#.conf file.
Add it under the SPAN configuration.
.
.
TDMV_SPAN=1
TDMV_DCHAN=24
.
.
Note: TDMV_DCHAN value is ALWAYS from (1-24).
(Don't confuse with Asterisk configuration
that uses values greater than 24 for DCHAN
specification)
3. A102 TE1 Clock Synchronization (A102 Card Only):
Release : beta7-2.3.2 or greater.
Firmware Version: V.24
This option is NOT supported in wancfg, thus
one has to add it manually to wanpipe#.conf file.
TE1 Clock synchronization is used to propagate
a single clock source throughout the
TE1 network.
wanpipe1->Port A-> Normal Mode: Receives T1 Clock from Telco
wanpipe2->Port B-> Master Mode: Transmits the SAME T1
Clock as a master source.
In order to enable this option on wanpipe2:
Add FE_REF_CLOCK option under the "TE_CLOCK" option.
.
.
TE_CLOCK = MASTER
FE_REF_CLOCK = LINE
.
.
Note: That TE_CLOCK must be set as MASTER
The Clock source is the Port A LINE.
Channelization Notes:
--------------------
If you re using PRI mode, channel 24 must be included in the
"Timeslots in Group" list for the Asterisk T1 span, and channel
16 for the Asterisk E1 span.
For the non-Asterisk data channels, if any, configure
the interface as standard WANPIPE interface,
running: Frame Relay, PPP, Cisco HDLC or X.25 with IP or API
access.
Zaptel configuration
--------------------
Download the documentation how to configure Zaptel driver from
(http://www.digium.com/downloads/configuring_zaptel.pdf).
When configuring the Zaptel driver (/etc/zaptel.conf)
1) Select the same span configurations as you used for WANPIPE
(i.e. LBO, framing, coding parameters).
Otherwise the Zaptel configuration is completely
standard, except that if there are data channels that
will be handled by WANPIPE, those channels should be ignored,
and not configured as 'nethdlc'.
2) If you are using multiple WANPIPE devices for Asterisk
For example, an A102 card might be configured as:
wanpipe1 and wanpipe2
then you need to set your starting scripts to start
the wanpipes in the same sequence as defined in zaptel.conf.
Run: wanrouter wanrc
to set the wanpipe startup order.
3) If you are using some channels for DATA
You don't need to set the channel list for this
interface under /etc/zaptel.conf because all data will go
through the separate WANPIPE driver to the kernel.
APPENDIX
========
-------------------------------------------------------------
1)HOTPLUG Conflicts with WANPIPE
===============================
The HOTPLUG Service should be disabled because it
conflicts with Wanpipe interface startup.
The HOTPLUG can conflict with startup of TDMV drivers.
Possible Solutions:
1) Insert wanpipe interface name into the hotplug
interface list, and restart hotplug.
vi /etc/hotplug/net.agent
Insert wanpipe interface name into
the ignore list:
...ppp*|lo*|w*)
Where w* relates to all wanpipe interfaces
starting with letter "w"
Restart hotplug agent:
/etc/init.d/hotplug restart
2) Remove the Hotplug RPM
rpm -qa | grep hotplug
rpm -e <hotplug name>
3) Stop hotplug:
/etc/init.d/hotplug stop
However, you must do this each
time you boot up. Thus insert this
command in rc.local.
-------------------------------------------------------------------
2) Exec "ztcfg" after wanrouter start
==================================
The "ztcfg" tool must be executed before starting
asterisk. WANPIPE "wanrouter" script has the capability
to execute an external script after "wanrouter start"
command is complted.
The wanrouter looks to /etc/wanpipe/scritps directory
for any configured bash scripts.
1) Create a file called "start" (lower case)
vi start
----------Cut Here----------------
#!/bin/sh
ztcvf -vvvv
----------Cut Here----------------
2) Copy the file "start" into /etc/wanpipe/scripts directory.
(Note: the file doesn't have to have exec privilages)
The script "start" will execute each time the "wanrouter start"
command executes.
Please Refer to README.external_scripts for more info about
wanrouter and external scritps.
------------------------------------------------------------
2) Updating FLASH on AFT Cards
===========================
The AFT FLASH update utility is located in:
wanpipe/util/wan_aftup directory.
The same directory contains the latest AFT
FLASH Firmware BIN files since the release
of the driver.
The latest AFT Firmware bins are located in
ftp.sangoma.com/linux/current_wanpipe/firmware.
To update flash on ANY AFT card do the following:
1) Make sure you have the latest AFT Firmware BIN
The latest file necessary for the current release
will be in the wan_aftup/ directory.
One can also check the ftp site above.
The AFT Binary file must reside in wan_aftup/ directory.
2) Make sure that wanpipe drivers are NOT Loaded
lsmod | grep wanpipe
3) Run ./update_aft_firm.sh
Specify interface name that corresponds to the
AFT card.
Specify the latest AFT Firmware version
Once the flashing is done, select Y to reload firmware.
(This step only reloads flash, not your machine!)
4) Card is ready for normal operation. (No reboot needed)

199
doc/README.asyhdlc_api Normal file
View File

@ -0,0 +1,199 @@
WANPIPE ASYNC HDLC STREAMING API Support
=========================================
Author: Nenad Corbic <ncorbic@sangoma.com>
Pre requisites
--------------
1. A Linux kernel source must be available.
Usually in /usr/src/linux directory.
Furthermore, the linux source version must
match the currently running image.
i.e. Output of 'uname -r'
must match the source version
number in /usr/src/linux/Makefile.
Note: The Setup installation script checks
for this condition and will take
appropriate steps to resolve the
name mismatch.
Installing WANPIPE with ASYNC HDLC support
----------------------------------------
The ASYNC HDLC API support IS NOT installed by default
during WANPIPE installation process.
Use the CUSTOM driver compilation
option in:
./Setup install
Custom Compilation Mode
Enable DEF for default protocols and
Enable ASYHDLC protocol.
After successful installation proceed to
configure you ASYNC HDLC card using
MANUAL configuration files located in samples/
directory.
wanpipe1.asyhdlc_pri
wanpipe2.asyhdlc_sec
Note: wancfg GUI configurator doesn't support
Async HDLC API.
Installation Verification
-------------------------
Run wanpipe hardware probe to
make sure that the kernel modules
are working fine:
Run: wanrouter hwprobe
In case of error:
-----------------
Please contact Sangoma Tech Support
Tel. 905 474 1990 ex118
Email: techdesk@sangoma.com
Configuring ASYNC HDLC API
--------------------------
After successful installation proceed to
configure you ASYNC HDLC card using
MANUAL configuration files located in
wanpipe/samples/ directory.
wanpipe1.asyhdlc_pri
wanpipe2.asyhdlc_sec
1. Change dir to wanpipe/samples directory
2. Copy wanpipe1.asyhdlc_pri to /etc/wanpipe/wanpipe1.conf
Card: S514 PRI Port
PCI: Autodetect
The wanpipe1.conf is configured to autdetect
the S514 card. If running more than one S514
card, please edit wanpipe1.conf and disable AUTO_PCISLOT
option, and specify the actual PCI SLOT and BUS
numbers.
Run: "wanrouter hwprobe" to obtain PCI info.
3. Save and Exit
Start Async HDLC Streaming protocol
----------------------------------
Run: wanrouter start
In case of errors:
------------------
Run: wanrouter messages
It will display kernel error
messages.
Please contact Sangoma Tech Support
Tel. 905 474 1990 ex118
Email: techdesk@sangoma.com
Startup Confirmation
--------------------
Run: wanrouter messages
Make sure no error messages are dispalyed.
Confirm the state of Front End (T1/E1/V35)
Confirm the Link state
Check for any error events.
Custom API Application
======================
A sample API application exists in
/etc/wanpipe/api/asyhdlc directory.
To compile it run: make
Run: ./asyhdlc_api
API ./asyhdlc_api USAGE:
./asyhdlc_api <options> <extra options>
<options>:
-i <ifname> #interface name
-c <card name> #card name
-r #read enable
-w #write eable
<extra options>
-txcnt <digit> #number of tx packets (Dflt: 1)
-txsize <digit> #tx packet size (Dflt: 10)
-txdelay <digit> #delay in sec after each tx packet (Dflt: 0)
-txdata <digit> #data to tx <1-255>
-txfile <file> #Use file to tx instead
-rxfile <file> #Save all rx data to a file
-rxcnt <digit> #number of rx packets before exit
#this number overwrites the txcnt
#Thus, app will only exit after it
#receives the rxcnt number of packets.
-verbose #Enable verbose mode
eg: To enable read:
./asyhdlc_api -i wp1chdlc -c wanpipe1 -r -verbose
eg: To enable read and write:
./asyhdlc_api -i wp1chdlc -c wanpipe1 -r -w -txsize 100 -txcnt 10 -verbose

View File

@ -39,7 +39,13 @@ option in
script to enable CHDLC.
After successful installation proceed to
configure you RAW HDLC card using /usr/sbin/wancfg
configure you RAW HDLC card using:
For AFT cards:
/usr/sbin/wancfg
For Legacy S514 cards:
/usr/sbin/wancfg_legacy
GUI configurator.
@ -62,10 +68,44 @@ Run: wanrouter hwprobe
Configuring RAW HDLC API
------------------------
Run: /usr/sbin/wancfg
Configuring RAW HDLC API : AFT cards
------------------------------------
Run /usr/sbin/wancfg
1. Select card from Hardware Probe
2. Configure for T1 or E1 (Default T1)
3. Select HDLC Streaming Protocol
4. Under Interface Section
Selcect API operation mode.
5. Save exit
NOTE:
To Disable HDLC engine per interface
one can manually change HDLC_STREAMING NO option
to NO under interface section in /etc/wanpipe/
wanpip#.conf config file.
This MODE is called TRANSPARENT.
IMPORTANT: When configuring for Transparent mode (HDLC Disabled)
The MTU/MRU must be in multiples of channel numbers
eg: T1 = 24 channels: 24*50 MTU/MRU=1200
E1 = 31 channels: 31*40 MTU/MRU=1240
Configuring RAW HDLC API : Legacy S514
--------------------------------------
Run: /usr/sbin/wancfg_legacy
1. Create new device
@ -128,6 +168,7 @@ Run: wanrouter messages
Check for any error events.
Ethereal Tracing
================
@ -154,24 +195,30 @@ Note: No Custom API application is necessary for
Custom API Application
======================
A sample API application exists in
/etc/wanpipe/api/chdlc directory.
/etc/wanpipe/api directory.
To compile it run: make
Run: ./chdlc_api
For AFT Cards:
Run: /etc/wanpipe/api/aft/aft_api
For S514 Cards:
Run: /etc/wanpipe/api/chdlc/chdlc_api
API aft_api or chdlc_api USAGE:
API ./chdlc_api USAGE:
./aft_api <options> <extra options>
./chdlc_api <options> <extra options>
<options>:
-i <ifname> #interface name
-c <card name> #card name
@ -197,11 +244,13 @@ API ./chdlc_api USAGE:
eg: To enable read:
./aft_api -i w1g1 -c wanpipe1 -r -verbose
./chdlc_api -i wp1chdlc -c wanpipe1 -r -verbose
eg: To enable read and write:
./aft_api -i w1g1 -c wanpipe1 -r -w -txsize 100 -txcnt 10 -verbose
./chdlc_api -i wp1chdlc -c wanpipe1 -r -w -txsize 100 -txcnt 10 -verbose

View File

@ -28,26 +28,22 @@ Pre requisites
Installing WANPIPE with MPAPI X25 support
-----------------------------------------
----------------------------------------
The MPAPI X25 API is NOT distributed with standard
wanpipe release. One has the request the MPAPI
wanpipe release. One has to request the MPAPI
binary or source from Sangoma Technologies.
1. Untar latest wanpipe release located at
ftp.sangoma.com/linux/current_wanpipe
2. Untar the MPAPI release obtained from Sangoma
in the same directory as wanpipe release.
The MPAPI X25 API support IS NOT installed by default
during WANPIPE installation process.
Untar the wanpipe-2.3.2-mpapi.tgz release in
the same directory as current wanpipe source.
eg: cp wanpipe-2.3.2.tgz /tmp
cp wanpipe-2.3.3-mpapi.tgz /tmp
Untar wanpipe-2.3.2.tgz first
Untar wanpipe-2.3.2-mpapi.tgz second
Use the CUSTOM driver compilation
option in

View File

@ -322,6 +322,15 @@ multilink
lcp-echo-interval 5
lcp-echo-failure 12
nodeflate #Do not use compression
nobsdcomp #Do not use bsd compression
noccp #Disable CCP (Compression Control Protocol)
noaccomp #Disable Address/Control compression
nopcomp #Disable protocol field compres.
novj #Disable Van Jacobson TCP/IP header compres.
novjccomp #Disable the connection-ID compression
nopredictor1 #Do not accept or agree to Predictor-1 compres.
#On some CISCO routers we must
#be in silent mode

View File

@ -77,7 +77,7 @@ Run: wanrouter hwprobe
Configuring SS7 API
--------------------
Run: /usr/sbin/wancfg
Run: /usr/sbin/wancfg_legacy
1. Create new device
@ -181,6 +181,44 @@ Use this app as a building block for you custom
APP.
SS7 Commands
------------
/* SS7-level interface commands */
#define READ_SS7_CODE_VERSION 0x20 /* read the SS7 code version */
#define L2_READ_EXCEPTION_CONDITION 0x21 /* L2 - read an exception condition from the adapter */
#define L2_SET_CONFIGURATION 0x22 /* L2 - set the operational configuration */
#define L2_READ_CONFIGURATION 0x23 /* L2 - read the current configuration */
#define L2_READ_LINK_STATUS 0x24 /* L2 - read the link status */
#define L2_READ_OPERATIONAL_STATS 0x25 /* L2 - retrieve the operational statistics */
#define L2_FLUSH_OPERATIONAL_STATS 0x26 /* L2 - flush the operational statistics */
#define L2_READ_HISTORY_TABLE 0x27 /* L2 - read the history table */
#define L2_FLUSH_HISTORY_TABLE 0x28 /* L2 - flush the history table */
#define L2_SET_INTERRUPT_TRIGGERS 0x30 /* L2 - set the application interrupt triggers */
#define L2_READ_INTERRUPT_TRIGGERS 0x31 /* L2 - read the application interrupt trigger configuration */
#define L2_POWER_ON 0x40 /* L2 - power on */
#define L2_EMERGENCY 0x41 /* L2 - emergency */
#define L2_EMERGENCY_CEASES 0x42 /* L2 - emergency ceases */
#define L2_START 0x43 /* L2 - start */
#define L2_STOP 0x44 /* L2 - stop */
#define L2_RESUME 0x45 /* L2 - resume (ANSI) / local processor recovered (ITU) */
#define L2_RETRIEVE_BSNT 0x46 /* L2 - retrieve BSNT */
#define L2_RETRIEVAL_REQ_AND_FSNC 0x47 /* L2 - retrieval request and FSNC */
#define L2_CLEAR_BUFFERS 0x48 /* L2 - clear buffers (ANSI) / flush buffers (ITU) */
#define L2_CLEAR_RTB 0x49 /* L2 - clear RTB */
#define L2_LOCAL_PROCESSOR_OUTAGE 0x4A /* L2 - local processor outage */
#define L2_CONTINUE 0x4B /* L2 - continue (ITU) */
#define L2_SET_TX_CONG_CFG 0x50 /* L2 - set the transmission congestion configuration */
#define L2_READ_TX_CONG_STATUS 0x51 /* L2 - read the transmission congestion status */
#define L2_SET_RX_CONG_CFG 0x52 /* L2 - set the receive congestion configuration */
#define L2_READ_RX_CONG_STATUS 0x53 /* L2 - read the receive congestion status */
#define L2_DEBUG 0x5F /* L2 - debug */
Further Info
------------

461
doc/README.tdmv_api Normal file
View File

@ -0,0 +1,461 @@
WANPIPE TDMV API
================
Installation
============
Please read README.asterisk
Configuration
=============
Please refer to the APPENDIX Config File
TMDV API Sample Code
====================
"libsangoma" Package
APPENDIX
========
A104 - TDMV API Config File
A101/2 - TDMV API Config File
Save the config file below into: /etc/wanpipe/wanpipe1.conf
********************CUT HERE************************************
#================================================
# WANPIPE1 Configuration File
#================================================
[devices]
wanpipe1 = WAN_AFT_TE1, Comment #WAN_AFT_TE1 - Indicates A104 card
#WAN_AFT - Indicates A101/2 card
[interfaces]
#-------- DRIVER INTERFACE DEFINITIONS --------------------------------
w1g1 = wanpipe1, , API, Comment
w1g2 = wanpipe1, , API, Comment
w1g3 = wanpipe1, , API, Comment
w1g4 = wanpipe1, , API, Comment
w1g5 = wanpipe1, , API, Comment
w1g6 = wanpipe1, , API, Comment
w1g7 = wanpipe1, , API, Comment
w1g8 = wanpipe1, , API, Comment
w1g9 = wanpipe1, , API, Comment
w1g10 = wanpipe1, , API, Comment
w1g11 = wanpipe1, , API, Comment
w1g12 = wanpipe1, , API, Comment
w1g13 = wanpipe1, , API, Comment
w1g14 = wanpipe1, , API, Comment
w1g15 = wanpipe1, , API, Comment
w1g16 = wanpipe1, , API, Comment
w1g17 = wanpipe1, , API, Comment
w1g18 = wanpipe1, , API, Comment
w1g19 = wanpipe1, , API, Comment
w1g20 = wanpipe1, , API, Comment
w1g21 = wanpipe1, , API, Comment
w1g22 = wanpipe1, , API, Comment
w1g23 = wanpipe1, , API, Comment
w1g24 = wanpipe1, , API, Comment
[wanpipe1]
#-------- DEVICE / DRIVER BINDING ----------------------------------
CARD_TYPE = AFT #AFT: Same for all aft cards must
#This value must be hardcoed to AFT for all
#aft cards.
S514CPU = A #Used by A101/2 driver to determine T1/E1 port
#A - port 1
#B - port 2
#For A104 driver: Always set this value to A!
AUTO_PCISLOT = YES #Auto detect PCI/BUS info for this card type
#NO - disable this option
#YES- enable this option
# if enabled bottom two options
# PCISLOT and PCIBUS will not be used.
# Therefore one can set the to arbitrary value
# or remove them all together.
PCISLOT = 2 #PCI SLOT Number:
#Valid values = any number
PCIBUS = 2 #PCI BUS Number:
#Valid values = any number
#--------------FRONT END SETUP -----------------------------------
FE_MEDIA = T1 #Front End Type:
#T1 - set front end for T1 mode
#E1 - set front end for E1 mode
FE_LCODE = B8ZS #Front End Line Coding
#If T1: B8ZS or AMI
# E1: HDB3 or AMI
FE_FRAME = ESF #Front End Framing
#If T1: ESF or D4
# E1: CRC4 or NCRC4
FE_LINE = 1 #Front End Line number.
#Used by A104 driver to determine T1/E1 port
#Valid values are: 1-4
#
#The A101/2 driver doesn't use this option
#so one should hardcode it to 1 or
#remove it all together.
TE_CLOCK = NORMAL #T1/E1 Clock Source
#NORMAL - slave clock, clock is received from telco
# This is always the DEFAULT
#MASTER - master clcok, use hw oscillator clock
# Only used in back to back mode or
# when specified by telco.
TE_REF_CLOCK = 0 #T1/E1 Reference Clock Source
#This option allows one to use the incoming clock
#from a different port as a clock source to this
#port. FOR THIS OPTION TO WORK: TE_CLOCK=MASTER
#Valid options: 0 - disable
# 1-4 - use clock from particular port
ACTIVE_CH = ALL #Specify T1/E1 Active channels (timeslots)
#Since AFT cards support channelization this
#option MUST BE HARDCODED TO: ALL!
TE_HIGHIMPEDANCE = NO #Set the Front Ent chip in High Impedance mode
#used for datascoping:
#NO - Disable high impedance mode (DEFAULT)
#YES - Enable hight impedance mode
# (only if you know what you are doing)
LBO = 0DB #Front End Line Buildout
# 0db (Default)
# 7.5dB
# 15dB
# 22.5dB
# 0-110ft
# 110-220ft
# 220-330ft
# 330-440ft
# 440-550ft
# 550-660ft
FE_TXTRISTATE = NO #Front End Tri-State Mode
#Disable front end chip TX mode
#Used for datascoping or connecting multiple ports
#together where one port is operating normally and others
#are tristated, thus only receiving.
#NO - Disable tristae mode
#YES- Enable tristate mode
#------------ MISC DRIVER OPTIONS --------------------------
MTU = 1500 #Global MTU Value
#Note: This value is overwritten by the
# interface MTU value below if it exists.
#Values: any number [ suggested 128 - 4086 ]
IGNORE_FRONT_END = NO #Ignore Fronte End State
#NO - Do not ignore front end state,
# therefore if state changes, change the
# state of the above protocol.
#YES- Igonore front end state
# Thus if front end goes down, the protocol
# will not know.
#------------ VOICE INTERFACE CONFIG --------------------------
#Each interface corresponds to a specific T1/E1 timeslot
#For T1: Interface 24 must be configured for PRI
#For E1: Interface 16 must be configured for PRI
[w1g1]
PROTOCOL = HDLC #Protocol: HDLC : Hardcoded Value
HDLC_STREAMING = NO #HDLC Engine Control
#NO: Disable HDLC Engine: Transparet (VOICE) mode
#YES: Enable HDLC Engine: PRI mode
ACTIVE_CH = 1 #Hardware Timeslot Number
#For T1: 1-24
#For E1: 1-31
IDLE_FLAG = 0x7E #Idle Flag to be transmitted
#in Tx underrun condition.
MTU = 80 #Maximum Tx Size
#API will/must transmit in MTU chunks
#1ms = 8
#10ms = 80 (Default)
MRU = 80 #Maximum Rx Size
#API will receive data in MRU chunks
#1ms = 8
#10ms = 80 (Default)
[w1g2]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 2
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g3]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 3
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g4]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 4
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g5]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 5
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g6]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 6
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g7]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 7
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g8]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 8
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g9]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 9
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g10]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 10
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g11]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 11
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g12]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 12
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g13]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 13
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g14]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 14
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g15]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 15
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g16]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 16
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g17]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 17
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g18]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 18
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g19]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 19
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g20]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 20
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g21]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 21
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g22]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 22
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
[w1g23]
PROTOCOL = HDLC
HDLC_STREAMING = NO
ACTIVE_CH = 23
IDLE_FLAG = 0x7E
MTU = 80
MRU = 80
#--------------- PRI/DCHAN CONFIGURATION ---------------
[w1g24]
PROTOCOL = HDLC #Protocol: HDLC : Hardcoded Value
HDLC_STREAMING = YES #HDLC Engine Control
#NO: Disable HDLC Engine: Transparet (VOICE) mode
#YES: Enable HDLC Engine: PRI mode
ACTIVE_CH = 24 #Hardware PRI Timeslot Number
#For T1: 24
#For E1: 16
IDLE_FLAG = 0x7E #Idle Flag to be transmitted
#in Tx underrun condition.
#Used in VOICE mode only.
MTU = 1500 #Maximum Tx Size
#Corresponds to maximum TX HDLC packet size
MRU = 1500 #Maximum Rx Size
#Corresponds to maximum RX HDLC packet size
********************CUT HERE************************************

View File

@ -0,0 +1,78 @@
Channelized WANPIPE TDMV Driver
===========================
ftp.sangoma.com/linux/current_wanpipe directory.
Release: wanpipe-beta7-2.3.3.tgz
Pleases read README.asterisk for detailed explanation of config options.
To install it follow the recipe below:
1) ./Setup install
Custom compile:
choose TDM (DEF will be set by default)
If you want DCHAN option select yes for it.
This will enable Hardware HDLC for DCHAN PRI.
This option will also PATCH Zaptel driver.
Thus, Zaptel driver MUST be recompiled after
./Setup is finished.
2) Once wanpipe is installed go ahead and recompile
zaptel and install it.
cd ..zaptel/
make clean
make
make install
3) Then make sure wanpipe is unloaded:
lsmod | grep wanpipe
4) The new TDMV Channelized Driver works for both
A104 and A102 Cards.
The new TDMV A104 drivers will fail to load if
firmware version is less then V.11.
How to check your AFT Firmware Version:
1) wanrouter hwprobe
2) grep "HDLC.*rev" /var/log/messages
Note the (HDLC rev.11) message for each card.
If you card has old firmware, proceed to upgrade to
new AFT 104 firmware:
cd wanpipe/utils/wan_aftup
Make sure wanpipe modules are NOT loaded
wanrouter modules
wanrouter stop
Run ./update_aft_firm.sh
Specify interface name for A104 card
Select version 10
Select Y to restart FLASH firmware.
(This will not reboot your computer!)
5) Create config file:
wancfg -> Protocol: TDMV Protocol
-> Interface:
Specify SPAN number
Specify DCHAN PRI Timeslot
Please read README.asterisk for more info.
Save and Exit

64
doc/dfiff Normal file
View File

@ -0,0 +1,64 @@
--- /usr/sbin/wanrouter 2005-08-11 14:31:28.757973744 -0400
+++ /common/wantools/scripts/wanrouter 2005-05-27 12:37:47.000000000 -0400
@@ -3,34 +3,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
# wanrouter WANPIPE WAN Router Initialization Script.
#
# copyright (c) 1999-2002, Sangoma Technologies Inc.
@@ -1755,7 +1727,7 @@
LINEPROBE_PATH=/usr/sbin/lineprobe
if [ $OSYSTEM = "Linux" ]; then
- ROUTER_VERSION=beta13-2.3.3
+ ROUTER_VERSION=beta6-2.3.3
IFCONFIG_LIST=ifconfig
MODULE_STAT=lsmod
WAN_DRIVERS="wanpipe"
@@ -1780,7 +1752,7 @@
MOD5=/lib/modules/af_wanpipe.o
if [ -d /lib/modules/$(uname -r) ]; then
- uname -r | grep "^2.4.*" > /dev/null
+ uname -r | grep "2.4.*" > /dev/null
if [ $? -eq 0 ]; then
if [ -d /lib/modules/$(uname -r)/kernel ]; then
MOD1=/lib/modules/$(uname -r)/kernel/drivers/net/wan/sdladrv.o
@@ -1796,7 +1768,7 @@
fi
else
- uname -r | grep "^2.6.*" > /dev/null
+ uname -r | grep "2.6.*" > /dev/null
if [ $? -eq 0 ]; then
if [ -d /lib/modules/$(uname -r)/kernel ]; then
MOD1=/lib/modules/$(uname -r)/kernel/drivers/net/wan/sdladrv.ko

881
edac/ed_asterisk.patch Normal file
View File

@ -0,0 +1,881 @@
diff -dur asterisk-1.0.7_original/channels/chan_zap.c asterisk-1.0.7_echomaster_v11/channels/chan_zap.c
--- asterisk-1.0.7_original/channels/chan_zap.c 2005-02-25 18:11:41.000000000 +0000
+++ asterisk-1.0.7_echomaster_v11/channels/chan_zap.c 2005-07-26 15:17:50.789354032 +0000
@@ -153,6 +153,134 @@
#define DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP)
+////////////////////////////////////////////////////////////////////////
+
+#define TDMV_SAMPLE_STATE_DECODE(state) \
+ ((state == ECHO_PRESENT) ? "On" : \
+ (state == ECHO_ABSENT) ? "Off" : \
+ (state == INDETERMINATE) ? "?" : "Invalid")
+
+#define TMP_BUFF_LEN 512
+
+static unsigned short u2s[] = {
+ /* negative */
+ 0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84,
+ 0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
+ 0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84,
+ 0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
+ 0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804,
+ 0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
+ 0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444,
+ 0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
+ 0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64,
+ 0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
+ 0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74,
+ 0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
+ 0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC,
+ 0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
+ 0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0,
+ 0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
+ /* positive */
+ 0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C,
+ 0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
+ 0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C,
+ 0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
+ 0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC,
+ 0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
+ 0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC,
+ 0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
+ 0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C,
+ 0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
+ 0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C,
+ 0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
+ 0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104,
+ 0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
+ 0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040,
+ 0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
+};
+
+#if 1
+//ZAPTEL table
+static unsigned short a2s[] = {
+
+0xEB00, 0xEC00, 0xE900, 0xEA00, 0xEF00, 0xF000, 0xED00, 0xEE00,
+0xE300, 0xE400, 0xE100, 0xE200, 0xE700, 0xE800, 0xE500, 0xE600,
+0xF580, 0xF600, 0xF480, 0xF500, 0xF780, 0xF800, 0xF680, 0xF700,
+0xF180, 0xF200, 0xF080, 0xF100, 0xF380, 0xF400, 0xF280, 0xF300,
+0xAC00, 0xB000, 0xA400, 0xA800, 0xBC00, 0xC000, 0xB400, 0xB800,
+0x8C00, 0x9000, 0x8400, 0x8800, 0x9C00, 0xA000, 0x9400, 0x9800,
+0xD600, 0xD800, 0xD200, 0xD400, 0xDE00, 0xE000, 0xDA00, 0xDC00,
+0xC600, 0xC800, 0xC200, 0xC400, 0xCE00, 0xD000, 0xCA00, 0xCC00,
+0xFEB0, 0xFEC0, 0xFE90, 0xFEA0, 0xFEF0, 0xFF00, 0xFED0, 0xFEE0,
+0xFE30, 0xFE40, 0xFE10, 0xFE20, 0xFE70, 0xFE80, 0xFE50, 0xFE60,
+0xFFB0, 0xFFC0, 0xFF90, 0xFFA0, 0xFFF0, 0x0000, 0xFFD0, 0xFFE0,
+0xFF30, 0xFF40, 0xFF10, 0xFF20, 0xFF70, 0xFF80, 0xFF50, 0xFF60,
+0xFAC0, 0xFB00, 0xFA40, 0xFA80, 0xFBC0, 0xFC00, 0xFB40, 0xFB80,
+0xF8C0, 0xF900, 0xF840, 0xF880, 0xF9C0, 0xFA00, 0xF940, 0xF980,
+0xFD60, 0xFD80, 0xFD20, 0xFD40, 0xFDE0, 0xFE00, 0xFDA0, 0xFDC0,
+0xFC60, 0xFC80, 0xFC20, 0xFC40, 0xFCE0, 0xFD00, 0xFCA0, 0xFCC0,
+
+0x1500, 0x1400, 0x1700, 0x1600, 0x1100, 0x1000, 0x1300, 0x1200,
+0x1D00, 0x1C00, 0x1F00, 0x1E00, 0x1900, 0x1800, 0x1B00, 0x1A00,
+0x0A80, 0x0A00, 0x0B80, 0x0B00, 0x0880, 0x0800, 0x0980, 0x0900,
+0x0E80, 0x0E00, 0x0F80, 0x0F00, 0x0C80, 0x0C00, 0x0D80, 0x0D00,
+0x5400, 0x5000, 0x5C00, 0x5800, 0x4400, 0x4000, 0x4C00, 0x4800,
+0x7400, 0x7000, 0x7C00, 0x7800, 0x6400, 0x6000, 0x6C00, 0x6800,
+0x2A00, 0x2800, 0x2E00, 0x2C00, 0x2200, 0x2000, 0x2600, 0x2400,
+0x3A00, 0x3800, 0x3E00, 0x3C00, 0x3200, 0x3000, 0x3600, 0x3400,
+0x0150, 0x0140, 0x0170, 0x0160, 0x0110, 0x0100, 0x0130, 0x0120,
+0x01D0, 0x01C0, 0x01F0, 0x01E0, 0x0190, 0x0180, 0x01B0, 0x01A0,
+0x0050, 0x0040, 0x0070, 0x0060, 0x0010, 0x0000, 0x0030, 0x0020,
+0x00D0, 0x00C0, 0x00F0, 0x00E0, 0x0090, 0x0080, 0x00B0, 0x00A0,
+0x0540, 0x0500, 0x05C0, 0x0580, 0x0440, 0x0400, 0x04C0, 0x0480,
+0x0740, 0x0700, 0x07C0, 0x0780, 0x0640, 0x0600, 0x06C0, 0x0680,
+0x02A0, 0x0280, 0x02E0, 0x02C0, 0x0220, 0x0200, 0x0260, 0x0240,
+0x03A0, 0x0380, 0x03E0, 0x03C0, 0x0320, 0x0300, 0x0360, 0x0340
+};
+#endif
+
+#if 0
+//YATE table
+static unsigned short a2s[] = {
+ /* negative */
+ 0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80,
+ 0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
+ 0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0,
+ 0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
+ 0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600,
+ 0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
+ 0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00,
+ 0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
+ 0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8,
+ 0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
+ 0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8,
+ 0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
+ 0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60,
+ 0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
+ 0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0,
+ 0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
+ /* positive */
+ 0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280,
+ 0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
+ 0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940,
+ 0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
+ 0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00,
+ 0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
+ 0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500,
+ 0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
+ 0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128,
+ 0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
+ 0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028,
+ 0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
+ 0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0,
+ 0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
+ 0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250,
+ 0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
+};
+#endif
+
+////////////////////////////////////////////////////////////////////////
+
#define zt_close(fd) if(fd > 0) close(fd);
static char context[AST_MAX_EXTENSION] = "default";
@@ -439,6 +567,13 @@
struct zt_subchannel subs[3]; /* Sub-channels */
struct zt_confinfo saveconf; /* Saved conference info */
+ int echo_detection_state;
+ pthread_t polling_thread_id;
+ int is_call_active;
+ int ed_enabled;
+ unsigned int num_of_echo_absent_calls;
+ unsigned int num_of_echo_present_calls;
+
struct zt_pvt *slaves[MAX_SLAVES]; /* Slave to us (follows our conferencing) */
struct zt_pvt *master; /* Master to us (we follow their conferencing) */
int inconference; /* If our real should be in the conference */
@@ -575,6 +710,32 @@
#define GET_CHANNEL(p) ((p)->channel)
#endif
+static int sangoma_get_echo_state(struct zt_pvt* pvt, echo_detect_struct_t * ioctl_result);
+static int sangoma_write_call_started_str(struct zt_pvt *pvt);
+static int sangoma_write_call_ended_str(struct zt_pvt *pvt);
+static char* sangoma_get_date_and_time(void);
+static void sangoma_ed_control(int fd, struct zt_pvt *tmp, int control_code);
+static void sangoma_linearize_spike_buffer(int fd, unsigned char *spike_buff, int *linearized_buff, int law);
+static int sangoma_write_spike_buffer_to_file(struct zt_pvt *pvt, int *linearized_buff, int fd);
+static int sangoma_write_buffer_to_file(char * full_file_path, char* string);
+static void sangoma_summary_of_linear_spike_buffer(int fd, int *linearized_buff, struct zt_pvt *tmp);
+static void sangoma_analyze_db_loss(int fd, struct zt_pvt *tmp);
+
+#define INITIAL_LINEAR_TX_SPIKE 16384
+#define NO 0
+#define YES 1
+#define DB_LOSS_THRESHOLD -45.00//-50.00//-60.00
+#define DB_SILENCE 80.00
+
+typedef struct{
+ float db_loss;
+ short linear_power_value;
+}db_sample_t;
+
+db_sample_t db_loss[SANGOMA_SPIKE_SAMPLE_LEN];
+
+void proc_sample(unsigned short, int);
+
struct zt_pvt *round_robin[32];
#ifdef ZAPATA_PRI
@@ -1217,6 +1378,12 @@
}
x = p->echocancel;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
+
+ if(p->ed_enabled == 1 && p->is_call_active == 0){
+ p->is_call_active = 1;
+ sangoma_write_call_started_str(p);
+ }
+
if (res)
ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel);
else {
@@ -1247,9 +1414,42 @@
{
int x;
int res;
+
+ echo_detect_struct_t ioctl_result;
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+
if (p->echocancel) {
x = 0;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
+
+ if(p->is_call_active == 1){
+ /* This function is called twice, without obvious reason,
+ but end of call should be recorded only once.
+ */
+ p->is_call_active = 0;
+
+ if(!sangoma_get_echo_state(p, &ioctl_result)){
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", p->span, p->channel);
+
+ //if(ioctl_result.echo_state != INDETERMINATE){
+ snprintf(log_str_buff, TMP_BUFF_LEN,
+ " %-3s ", TDMV_SAMPLE_STATE_DECODE(ioctl_result.echo_state));
+ sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+ //}
+
+ if(ioctl_result.echo_state == ECHO_ABSENT){
+ p->num_of_echo_absent_calls++;
+ }if(ioctl_result.echo_state == ECHO_PRESENT){
+ p->num_of_echo_present_calls++;
+ }
+ }//if()
+ sangoma_write_call_ended_str(p);
+ }//if(p->is_call_active == 1)
+
if (res)
ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
else
@@ -1299,11 +1499,167 @@
g.txgain[j] = j;
}
}
-
- /* set 'em */
+
+ /* set 'em */
return(ioctl(fd,ZT_SETGAINS,&g));
}
+int usecsleep(int sec, int usecs)
+{
+ struct timeval tv;
+
+ tv.tv_sec = sec;
+ tv.tv_usec = usecs;
+
+ return select(0, NULL, NULL, NULL, &tv);
+}
+
+static char* sangoma_get_date_and_time()
+{
+ struct timeval tv;
+ struct timezone tz;
+ time_t now;
+ static char tmp_str[TMP_BUFF_LEN];
+ int ind;
+
+ gettimeofday(&tv, &tz);
+ now = tv.tv_sec;
+
+ snprintf(tmp_str, TMP_BUFF_LEN, ctime(&now));
+ /* replace 'new line' with 'null' */
+ for(ind = 0; ind < TMP_BUFF_LEN; ind++){
+ if(tmp_str[ind] == '\n'){
+ tmp_str[ind] = '\0';
+ }
+ }
+
+ return tmp_str;
+}
+
+#define MAX_LOG_FILE_SIZE 500000 // 500 Kb is the maximum
+
+int sangoma_write_buffer_to_file(char * full_file_path, char* string)
+{
+ FILE * file;
+ struct stat statbuf;
+
+ file = fopen(full_file_path, "a");
+ if(file == NULL){
+ ast_log(LOG_WARNING, "Failed to open %s file for writing!\n", full_file_path);
+ return 1;
+ }
+
+ //file exist, let's make sure it's not too big
+ if(lstat(full_file_path, &statbuf)){
+ ast_log(LOG_WARNING, "Failed to get file size ! File: %s.\n", full_file_path);
+ return 2;
+ }
+
+ if(statbuf.st_size > MAX_LOG_FILE_SIZE){
+ ast_log(LOG_WARNING, "File %s reached maximum size!\n", full_file_path);
+ return 3;
+ }
+
+ fputs(string, file);
+ fclose(file);
+ return 0;
+}
+
+static int sangoma_write_spike_buffer_to_file(struct zt_pvt *pvt, int *linearized_buff, int fd)
+{
+ FILE *file;
+ int ind;
+ char strbuff[50];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.spike", pvt->span, pvt->channel);
+
+ /* trancate and open the file for writing */
+ file = fopen(log_file_name_buff, "w");
+ if(file == NULL){
+ ast_log(LOG_WARNING, "Failed to open %s file for writing!\n", log_file_name_buff);
+ return 1;
+ }
+
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+ snprintf(strbuff, 50, "%d\n", linearized_buff[ind]);
+ fputs(strbuff, file);
+ }/* for() */
+ fclose(file);
+
+ ast_cli(fd, "Echo spike was written to '%s' file.\n", log_file_name_buff);
+
+ return 0;
+}
+
+static int sangoma_do_echo_detect_ioctl(int zfd, int echo_detect_ioctl, int * ioctl_result)
+{
+ if (ioctl(zfd, echo_detect_ioctl, ioctl_result)){
+ perror("sangoma_do_echo_detect_ioctl():\n");
+ return 1;
+ }else{
+ return 0;
+ }
+}
+
+static int sangoma_get_echo_state(struct zt_pvt* pvt, echo_detect_struct_t* ioctl_result)
+{
+ if(pvt == NULL){
+ ast_log(LOG_WARNING, "%s():pvt is NULL!!!\n", __FUNCTION__);
+ return 1;
+ }
+
+// ast_log(LOG_WARNING, "span: %d, channel: %d\n", pvt->span, pvt->channel);
+// ast_log(LOG_WARNING, "zdf: %d\n", pvt->subs[SUB_REAL].zfd);
+
+ if(!sangoma_do_echo_detect_ioctl(pvt->subs[SUB_REAL].zfd, SANGOMA_GET_ED_STATE, (int*)ioctl_result)){
+ return 0;
+ }else{
+ return 3;
+ }
+}
+
+static int sangoma_write_call_started_str(struct zt_pvt *pvt)
+{
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", pvt->span, pvt->channel);
+
+ snprintf(log_str_buff, TMP_BUFF_LEN, "START: [%-24s]",
+ sangoma_get_date_and_time());
+ sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+
+ if(pvt->owner){
+ snprintf(log_str_buff, TMP_BUFF_LEN, "[exten:%s, callerid:%s]",
+ (pvt->owner->exten == NULL ? "----" : pvt->owner->exten),
+ (pvt->owner->callerid == NULL? "----" : pvt->owner->callerid));
+ }else{
+ snprintf(log_str_buff, TMP_BUFF_LEN, "[context:%s, exten:%s, callerid:%s]",
+ "----", "----", "----");
+ }
+
+ return sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+}
+
+static int sangoma_write_call_ended_str(struct zt_pvt *pvt)
+{
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", pvt->span, pvt->channel);
+
+ snprintf(log_str_buff, TMP_BUFF_LEN, "END: [%s][eabs:%u,epres:%u]\n",
+ sangoma_get_date_and_time(),
+ pvt->num_of_echo_absent_calls,
+ pvt->num_of_echo_present_calls);
+
+ return sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+}
+
static inline int zt_set_hook(int fd, int hs)
{
int x, res;
@@ -8622,6 +8978,382 @@
return RESULT_FAILURE;
}
+static int sangoma_show_channels_func(int fd, int argc, char **argv)
+{
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ echo_detect_struct_t ioctl_result;
+ int active_chans_counter;
+
+ lock = &iflock;
+ start = iflist;
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ ast_cli(fd, "\nSpan\tChannel\t\tEcho\tContext\t\tExtension\tCallerID\n");
+
+ active_chans_counter = 0;
+ while (tmp){
+ if(tmp->channel < 0 ||
+ sangoma_get_echo_state(tmp, &ioctl_result) ||
+ ioctl_result.echo_detection_state != ECHO_DETECT_ON){/* show only active channels*/
+ tmp = tmp->next;
+ continue;
+ }
+
+ active_chans_counter++;
+
+ ast_cli(fd, "%02d\t%02d\t\t%-5s\t%-10s\t%-10s\t%-10s\n",
+ tmp->span,
+ tmp->channel,
+ TDMV_SAMPLE_STATE_DECODE(ioctl_result.echo_state),
+
+ (tmp->owner->context == NULL ? "----" : tmp->owner->context),
+ (tmp->owner->exten == NULL ? "----" : tmp->owner->exten),
+ (tmp->owner->callerid == NULL? "----" : tmp->owner->callerid)
+ );
+
+ tmp = tmp->next;
+ }/* while() */
+ ast_cli(fd, "%d active channel(s)\n", active_chans_counter);
+
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+}
+
+static int sangoma_dbg_channel(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ /* The ED algorithm can be enabled/disabled on all channels or
+ for an individual channel.
+ */
+ if(!strcmp(argv[3], "all")){
+ while (tmp) {
+ if(tmp->channel > 0){
+ if(!strcmp(argv[1], "enable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_ENABLE_ED);
+ }else if(!strcmp(argv[1], "disable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_DISABLE_ED);
+ }else{
+ ast_cli(fd, "%s(): Invalid command switch: %s!\n",
+ argv[2], __FUNCTION__);
+ }
+ }
+ tmp = tmp->next;
+ }/* while() */
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }else{
+ while (tmp) {
+ if (tmp->channel == channel) {
+
+ if(!strcmp(argv[1], "enable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_ENABLE_ED);
+ }else if(!strcmp(argv[1], "disable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_DISABLE_ED);
+ }else{
+ ast_cli(fd, "%s(): Invalid command switch: %s!\n",
+ argv[2], __FUNCTION__);
+ }
+
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+ }/* if() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static void sangoma_ed_control(int fd, struct zt_pvt *tmp, int control_code)
+{
+ echo_detect_struct_t ioctl_result;
+
+ switch(control_code)
+ {
+ case SANGOMA_ENABLE_ED:
+ ast_cli(fd,
+ "Enabling Sangoma ED on Span: %d, Channel: %d, File Descriptor: %d.\n",
+ tmp->span, tmp->channel, tmp->subs[SUB_REAL].zfd);
+ tmp->ed_enabled = 1;
+
+ sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd, SANGOMA_ENABLE_ED,
+ (int*)&ioctl_result);
+ break;
+
+ case SANGOMA_DISABLE_ED:
+ ast_cli(fd,
+ "Disabling Sangoma ED on Span: %d, Channel: %d, File Descriptor: %d.\n",
+ tmp->span, tmp->channel, tmp->subs[SUB_REAL].zfd);
+ tmp->ed_enabled = 0;
+
+ sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd, SANGOMA_DISABLE_ED,
+ (int*)&ioctl_result);
+ break;
+ default:
+ ast_cli(fd, "%s(): invalid IOCTL code.\n", __FUNCTION__);
+ }
+}
+
+static int sangoma_send_echo_spike(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ unsigned char spike_buff[sizeof(echo_spike_struct_t)];
+ echo_spike_struct_t *echo_spike_struct_ptr = (echo_spike_struct_t *)spike_buff;
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ while (tmp) {
+ if (tmp->channel == channel) {
+ if(sangoma_do_echo_detect_ioctl( tmp->subs[SUB_REAL].zfd,
+ SANGOMA_SEND_SPIKE,
+ (int*)spike_buff) != 0){
+ ast_cli(fd,
+ "Command failed on channel %d! Please check kernel messages log.\n",
+ channel);
+ }else if(echo_spike_struct_ptr->return_code == SANGOMA_NO_ACTIVE_CALL_OR_EC_OFF){
+ ast_cli(fd,
+ "Command failed on channel %d! \
+ Possible reasons: 1. the 'echocancel' is set to 'no' 2. call is not up.\n", channel);
+ }else{
+ ;/* no error. do nothing. */
+ }
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static int sangoma_get_echo_spike(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ static unsigned char spike_buff[sizeof(echo_spike_struct_t) + SANGOMA_SPIKE_SAMPLE_LEN];
+ echo_spike_struct_t *echo_spike_struct_ptr = (echo_spike_struct_t *)spike_buff;
+ unsigned char *spike_sample_buff_ptr = &spike_buff[sizeof(echo_spike_struct_t)];
+ int linearized_buff[SANGOMA_SPIKE_SAMPLE_LEN];
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ while (tmp) {
+ if (tmp->channel == channel) {
+ if(sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd,
+ SANGOMA_GET_ECHO_SPIKE_SAMPLE,
+ (int*)spike_buff) == 0){
+ if(echo_spike_struct_ptr->return_code == SANGOMA_OK){
+ /*
+ int ind;
+ ast_cli(fd, "SANGOMA_SPIKE_SAMPLE_LEN:%d\n", SANGOMA_SPIKE_SAMPLE_LEN);
+ ast_cli(fd, "NOT liniarized buffer:\n");
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+ ast_cli(fd, "0x%02X\n", spike_sample_buff_ptr[ind]);
+ }
+ */
+ sangoma_linearize_spike_buffer(fd, spike_sample_buff_ptr, linearized_buff,
+ tmp->law);
+
+ sangoma_write_spike_buffer_to_file(tmp, linearized_buff, fd);
+
+ sangoma_summary_of_linear_spike_buffer(fd, linearized_buff, tmp);
+ }else{
+ ast_cli(fd,
+ "Command failed on channel %d! \
+ Possible reasons: 1. the 'echocancel' is set to 'no' 2. call is not up.\n", channel);
+ }
+ }
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static void sangoma_linearize_spike_buffer(int fd, unsigned char *spike_buff, int *linearized_buff, int law)
+{
+ int ind;
+ unsigned short *linear_table;
+
+ if(law == ZT_LAW_MULAW){
+ ast_cli(fd, "Using MULAW table...\n");
+ linear_table = u2s;
+ }else{
+ ast_cli(fd, "Using ALAW table...\n");
+ linear_table = a2s;
+ }
+
+ memset(linearized_buff, 0x00, SANGOMA_SPIKE_SAMPLE_LEN);
+
+ //ast_cli(fd, "linearized buffer (v2 len: %d)\n", SANGOMA_SPIKE_SAMPLE_LEN);
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+
+ if(linear_table[spike_buff[ind]] == 0){
+ linearized_buff[ind] = 0;
+ }else if(spike_buff[ind] < 128){
+ /* make it negative */
+ linearized_buff[ind] = -65535 + linear_table[spike_buff[ind]];
+ }else{
+ linearized_buff[ind] = linear_table[spike_buff[ind]];
+ }
+ //ast_cli(fd, "%d\n", linearized_buff[ind]);
+ }/* for() */
+}
+
+static void sangoma_summary_of_linear_spike_buffer(int fd, int *linearized_buff, struct zt_pvt *tmp)
+{
+ int i;
+
+ for(i = 0; i < SANGOMA_SPIKE_SAMPLE_LEN; i ++) {
+ proc_sample(linearized_buff[i], i);
+ }
+ sangoma_analyze_db_loss(fd, tmp);
+}
+
+void proc_sample(unsigned short linear, int sample_no)
+{
+ unsigned short val;
+ float d;
+ float db;
+ int neg_voltage = NO;
+
+ db_loss[sample_no].linear_power_value = linear;
+
+ if(linear & 0xF000) {
+ neg_voltage = YES;
+ val = linear ^ 0xFFFF;
+ } else {
+ val = linear;
+ }
+
+ val = val >> 3;
+ val &= 0x0FFF;
+ d = (float)val / (float)(INITIAL_LINEAR_TX_SPIKE >> 3);
+
+ if(d != 0.00) {
+ db = 20 * log10(d);
+ } else {
+ db = -DB_SILENCE;
+ }
+
+ db_loss[sample_no].db_loss = db;
+
+// printf("sample[%04d]%2.5f\n", sample_no, db);
+ return;
+}
+
+static void sangoma_analyze_db_loss(int fd, struct zt_pvt *tmp)
+{
+ float min_db_loss = -DB_SILENCE;
+ int min_db_loss_sample_no=0;
+ float first_db_loss_th;
+ int sample_no_first_db_loss_th = 0xFFFF;
+ float last_db_loss_th;
+ int sample_no_last_db_loss_th = 0xFFFF;
+ int i;
+
+ for(i = 0; i < SANGOMA_SPIKE_SAMPLE_LEN; i ++) {
+ if(db_loss[i].db_loss > min_db_loss) {
+ min_db_loss = db_loss[i].db_loss;
+ min_db_loss_sample_no = i;
+ }
+ if(sample_no_first_db_loss_th == 0xFFFF) {
+ if(db_loss[i].db_loss > DB_LOSS_THRESHOLD) {
+ sample_no_first_db_loss_th = i;
+ first_db_loss_th = db_loss[i].db_loss;
+ }
+ }
+ if(db_loss[i].db_loss > DB_LOSS_THRESHOLD) {
+ last_db_loss_th = db_loss[i].db_loss;
+ sample_no_last_db_loss_th = i;
+ }
+ }
+
+ if(min_db_loss == -DB_SILENCE) {
+ ast_cli(fd, "The line is silent. No conclusion can be made.\n");
+ } else {
+ ast_cli(fd, "\nEcho Spike reached it's maximum at sample %d, linear power is %d\n",
+ min_db_loss_sample_no + 1,
+ db_loss[min_db_loss_sample_no].linear_power_value);
+
+ ast_cli(fd, "First sample containing Echo Spike is %d, linear power is %d\n",
+ sample_no_first_db_loss_th + 1,
+ db_loss[sample_no_first_db_loss_th].linear_power_value);
+
+ ast_cli(fd, "Last sample containing Echo Spike is %d, linear power is %d\n",
+ sample_no_last_db_loss_th + 1,
+ db_loss[sample_no_last_db_loss_th].linear_power_value);
+
+ //suggest something depending on number of Echo Cancellor taps
+ ast_cli(fd, "\nYour Echo Cancellor set to use %d taps.\n", tmp->echocancel);
+ if(tmp->echocancel < sample_no_first_db_loss_th + 1){
+ ast_cli(fd, "It can not cancel the echo because delay is longer than %d taps.\n",
+ tmp->echocancel);
+
+ }else if(tmp->echocancel > sample_no_first_db_loss_th + 1 &&
+ tmp->echocancel < sample_no_last_db_loss_th + 1){
+ ast_cli(fd, "Echo starts WITHIN %d taps, but ends AFTER %d taps, it means\n\
+echo can not be cancelled completely.\n", tmp->echocancel, tmp->echocancel);
+ }else{
+ ast_cli(fd, "Echo starts and ends WITHIN %d taps, it should be cancelled properly.\n",
+ tmp->echocancel);
+ }
+ }
+}
+
static char zap_show_cadences_help[] =
"Usage: zap show cadences\n"
" Shows all cadences currently defined\n";
@@ -8674,6 +9406,58 @@
static struct ast_cli_entry cli_show_channel = {
{"zap", "show", "channel", NULL}, zap_show_channel, "Show information on a channel", show_channel_usage, NULL };
+/////////////////////////////////////////////////////////////////////////////////////////
+static char sangoma_show_channels_usage[] = "Usage: sangoma show channels\n";
+
+static struct ast_cli_entry sangoma_show_channels = {
+ {"sangoma", "show", "channels", NULL},
+ sangoma_show_channels_func,
+ "Show Sangoma channels. Only shows channels with ED enabled and a call up.",
+ sangoma_show_channels_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_show_chan_debug_usage[] = "Usage: sangoma enable edchannel <chan num> OR <all>\n";
+
+static struct ast_cli_entry sangoma_debug_chan = {
+ {"sangoma", "enable", "edchannel", NULL},
+ sangoma_dbg_channel,
+ "Enable ED algorithm on Sangoma channel(s)",
+ sangoma_show_chan_debug_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_show_chan_nodebug_usage[] = "Usage: sangoma disable edchannel <chan num> OR <all>\n";
+
+static struct ast_cli_entry sangoma_nodebug_chan = {
+ {"sangoma", "disable", "edchannel", NULL},
+ sangoma_dbg_channel,
+ "Disable ED algorithm on Sangoma channel(s)",
+ sangoma_show_chan_nodebug_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_get_echo_spike_sample_usage[] = "Usage: sangoma get espike <chan num>\n";
+
+static struct ast_cli_entry sangoma_get_echo_spike_chan = {
+ {"sangoma", "get", "espike", NULL},
+ sangoma_get_echo_spike,
+ "Get Echo spike sample buffer for a channel",
+ sangoma_get_echo_spike_sample_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_send_echo_spike_usage[] = "Usage: sangoma send espike <chan num>\n";
+
+static struct ast_cli_entry sangoma_send_echo_spike_chan = {
+ {"sangoma", "send", "espike", NULL},
+ sangoma_send_echo_spike,
+ "Send Echo spike on a channel",
+ sangoma_send_echo_spike_usage,
+ NULL };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static struct ast_cli_entry cli_destroy_channel = {
{"zap", "destroy", "channel", NULL}, zap_destroy_channel, "Destroy a channel", destroy_channel_usage, NULL };
@@ -8891,6 +9675,12 @@
#endif
ast_cli_unregister(&cli_show_channels);
ast_cli_unregister(&cli_show_channel);
+ ast_cli_unregister(&sangoma_show_channels);
+ ast_cli_unregister(&sangoma_debug_chan);
+ ast_cli_unregister(&sangoma_nodebug_chan);
+ ast_cli_unregister(&sangoma_get_echo_spike_chan);
+ ast_cli_unregister(&sangoma_send_echo_spike_chan);
+
ast_cli_unregister(&cli_destroy_channel);
ast_cli_unregister(&zap_show_cadences_cli);
ast_manager_unregister( "ZapDialOffhook" );
@@ -9694,9 +10484,13 @@
#endif
ast_cli_register(&cli_show_channels);
ast_cli_register(&cli_show_channel);
+ ast_cli_register(&sangoma_show_channels);
+ ast_cli_register(&sangoma_debug_chan);
+ ast_cli_register(&sangoma_nodebug_chan);
+ ast_cli_register(&sangoma_get_echo_spike_chan);
+ ast_cli_register(&sangoma_send_echo_spike_chan);
ast_cli_register(&cli_destroy_channel);
ast_cli_register(&zap_show_cadences_cli);
-
ast_register_application(app_callingpres, change_callingpres, synopsis_callingpres, descrip_callingpres);
memset(round_robin, 0, sizeof(round_robin));
ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );

896
edac/ed_asterisk_cvs.patch Normal file
View File

@ -0,0 +1,896 @@
--- asterisk/channels/chan_zap.c.orig 2005-08-17 14:21:29.109149424 -0400
+++ asterisk/channels/chan_zap.c 2005-08-17 15:06:12.820163336 -0400
@@ -166,6 +166,138 @@
#define DCHAN_AVAILABLE (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP)
+
+////////////////////////////////////////////////////////////////////////
+
+#define TDMV_SAMPLE_STATE_DECODE(state) \
+ ((state == ECHO_PRESENT) ? "On" : \
+ (state == ECHO_ABSENT) ? "Off" : \
+ (state == INDETERMINATE) ? "?" : "Invalid")
+
+#define TMP_BUFF_LEN 512
+
+static unsigned short u2s[] = {
+ /* negative */
+0x8284, 0x8684, 0x8A84, 0x8E84, 0x9284, 0x9684, 0x9A84, 0x9E84,
+0xA284, 0xA684, 0xAA84, 0xAE84, 0xB284, 0xB684, 0xBA84, 0xBE84,
+0xC184, 0xC384, 0xC584, 0xC784, 0xC984, 0xCB84, 0xCD84, 0xCF84,
+0xD184, 0xD384, 0xD584, 0xD784, 0xD984, 0xDB84, 0xDD84, 0xDF84,
+0xE104, 0xE204, 0xE304, 0xE404, 0xE504, 0xE604, 0xE704, 0xE804,
+0xE904, 0xEA04, 0xEB04, 0xEC04, 0xED04, 0xEE04, 0xEF04, 0xF004,
+0xF0C4, 0xF144, 0xF1C4, 0xF244, 0xF2C4, 0xF344, 0xF3C4, 0xF444,
+0xF4C4, 0xF544, 0xF5C4, 0xF644, 0xF6C4, 0xF744, 0xF7C4, 0xF844,
+0xF8A4, 0xF8E4, 0xF924, 0xF964, 0xF9A4, 0xF9E4, 0xFA24, 0xFA64,
+0xFAA4, 0xFAE4, 0xFB24, 0xFB64, 0xFBA4, 0xFBE4, 0xFC24, 0xFC64,
+0xFC94, 0xFCB4, 0xFCD4, 0xFCF4, 0xFD14, 0xFD34, 0xFD54, 0xFD74,
+0xFD94, 0xFDB4, 0xFDD4, 0xFDF4, 0xFE14, 0xFE34, 0xFE54, 0xFE74,
+0xFE8C, 0xFE9C, 0xFEAC, 0xFEBC, 0xFECC, 0xFEDC, 0xFEEC, 0xFEFC,
+0xFF0C, 0xFF1C, 0xFF2C, 0xFF3C, 0xFF4C, 0xFF5C, 0xFF6C, 0xFF7C,
+0xFF88, 0xFF90, 0xFF98, 0xFFA0, 0xFFA8, 0xFFB0, 0xFFB8, 0xFFC0,
+0xFFC8, 0xFFD0, 0xFFD8, 0xFFE0, 0xFFE8, 0xFFF0, 0xFFF8, 0x0000,
+/* positive */
+0x7D7C, 0x797C, 0x757C, 0x717C, 0x6D7C, 0x697C, 0x657C, 0x617C,
+0x5D7C, 0x597C, 0x557C, 0x517C, 0x4D7C, 0x497C, 0x457C, 0x417C,
+0x3E7C, 0x3C7C, 0x3A7C, 0x387C, 0x367C, 0x347C, 0x327C, 0x307C,
+0x2E7C, 0x2C7C, 0x2A7C, 0x287C, 0x267C, 0x247C, 0x227C, 0x207C,
+0x1EFC, 0x1DFC, 0x1CFC, 0x1BFC, 0x1AFC, 0x19FC, 0x18FC, 0x17FC,
+0x16FC, 0x15FC, 0x14FC, 0x13FC, 0x12FC, 0x11FC, 0x10FC, 0x0FFC,
+0x0F3C, 0x0EBC, 0x0E3C, 0x0DBC, 0x0D3C, 0x0CBC, 0x0C3C, 0x0BBC,
+0x0B3C, 0x0ABC, 0x0A3C, 0x09BC, 0x093C, 0x08BC, 0x083C, 0x07BC,
+0x075C, 0x071C, 0x06DC, 0x069C, 0x065C, 0x061C, 0x05DC, 0x059C,
+0x055C, 0x051C, 0x04DC, 0x049C, 0x045C, 0x041C, 0x03DC, 0x039C,
+0x036C, 0x034C, 0x032C, 0x030C, 0x02EC, 0x02CC, 0x02AC, 0x028C,
+0x026C, 0x024C, 0x022C, 0x020C, 0x01EC, 0x01CC, 0x01AC, 0x018C,
+0x0174, 0x0164, 0x0154, 0x0144, 0x0134, 0x0124, 0x0114, 0x0104,
+0x00F4, 0x00E4, 0x00D4, 0x00C4, 0x00B4, 0x00A4, 0x0094, 0x0084,
+0x0078, 0x0070, 0x0068, 0x0060, 0x0058, 0x0050, 0x0048, 0x0040,
+0x0038, 0x0030, 0x0028, 0x0020, 0x0018, 0x0010, 0x0008, 0x0000
+};
+
+#if 1
+//ZAPTEL table
+static unsigned short a2s[] = {
+
+0xEB00, 0xEC00, 0xE900, 0xEA00, 0xEF00, 0xF000, 0xED00, 0xEE00,
+0xE300, 0xE400, 0xE100, 0xE200, 0xE700, 0xE800, 0xE500, 0xE600,
+0xF580, 0xF600, 0xF480, 0xF500, 0xF780, 0xF800, 0xF680, 0xF700,
+0xF180, 0xF200, 0xF080, 0xF100, 0xF380, 0xF400, 0xF280, 0xF300,
+0xAC00, 0xB000, 0xA400, 0xA800, 0xBC00, 0xC000, 0xB400, 0xB800,
+0x8C00, 0x9000, 0x8400, 0x8800, 0x9C00, 0xA000, 0x9400, 0x9800,
+0xD600, 0xD800, 0xD200, 0xD400, 0xDE00, 0xE000, 0xDA00, 0xDC00,
+0xC600, 0xC800, 0xC200, 0xC400, 0xCE00, 0xD000, 0xCA00, 0xCC00,
+0xFEB0, 0xFEC0, 0xFE90, 0xFEA0, 0xFEF0, 0xFF00, 0xFED0, 0xFEE0,
+0xFE30, 0xFE40, 0xFE10, 0xFE20, 0xFE70, 0xFE80, 0xFE50, 0xFE60,
+0xFFB0, 0xFFC0, 0xFF90, 0xFFA0, 0xFFF0, 0x0000, 0xFFD0, 0xFFE0,
+0xFF30, 0xFF40, 0xFF10, 0xFF20, 0xFF70, 0xFF80, 0xFF50, 0xFF60,
+0xFAC0, 0xFB00, 0xFA40, 0xFA80, 0xFBC0, 0xFC00, 0xFB40, 0xFB80,
+0xF8C0, 0xF900, 0xF840, 0xF880, 0xF9C0, 0xFA00, 0xF940, 0xF980,
+0xFD60, 0xFD80, 0xFD20, 0xFD40, 0xFDE0, 0xFE00, 0xFDA0, 0xFDC0,
+0xFC60, 0xFC80, 0xFC20, 0xFC40, 0xFCE0, 0xFD00, 0xFCA0, 0xFCC0,
+
+0x1500, 0x1400, 0x1700, 0x1600, 0x1100, 0x1000, 0x1300, 0x1200,
+0x1D00, 0x1C00, 0x1F00, 0x1E00, 0x1900, 0x1800, 0x1B00, 0x1A00,
+0x0A80, 0x0A00, 0x0B80, 0x0B00, 0x0880, 0x0800, 0x0980, 0x0900,
+0x0E80, 0x0E00, 0x0F80, 0x0F00, 0x0C80, 0x0C00, 0x0D80, 0x0D00,
+0x5400, 0x5000, 0x5C00, 0x5800, 0x4400, 0x4000, 0x4C00, 0x4800,
+0x7400, 0x7000, 0x7C00, 0x7800, 0x6400, 0x6000, 0x6C00, 0x6800,
+0x2A00, 0x2800, 0x2E00, 0x2C00, 0x2200, 0x2000, 0x2600, 0x2400,
+0x3A00, 0x3800, 0x3E00, 0x3C00, 0x3200, 0x3000, 0x3600, 0x3400,
+0x0150, 0x0140, 0x0170, 0x0160, 0x0110, 0x0100, 0x0130, 0x0120,
+0x01D0, 0x01C0, 0x01F0, 0x01E0, 0x0190, 0x0180, 0x01B0, 0x01A0,
+0x0050, 0x0040, 0x0070, 0x0060, 0x0010, 0x0000, 0x0030, 0x0020,
+0x00D0, 0x00C0, 0x00F0, 0x00E0, 0x0090, 0x0080, 0x00B0, 0x00A0,
+0x0540, 0x0500, 0x05C0, 0x0580, 0x0440, 0x0400, 0x04C0, 0x0480,
+0x0740, 0x0700, 0x07C0, 0x0780, 0x0640, 0x0600, 0x06C0, 0x0680,
+0x02A0, 0x0280, 0x02E0, 0x02C0, 0x0220, 0x0200, 0x0260, 0x0240,
+0x03A0, 0x0380, 0x03E0, 0x03C0, 0x0320, 0x0300, 0x0360, 0x0340
+};
+#endif
+
+#if 0
+//YATE table
+static unsigned short a2s[] = {
+/* negative */
+0xEA80, 0xEB80, 0xE880, 0xE980, 0xEE80, 0xEF80, 0xEC80, 0xED80,
+0xE280, 0xE380, 0xE080, 0xE180, 0xE680, 0xE780, 0xE480, 0xE580,
+0xF540, 0xF5C0, 0xF440, 0xF4C0, 0xF740, 0xF7C0, 0xF640, 0xF6C0,
+0xF140, 0xF1C0, 0xF040, 0xF0C0, 0xF340, 0xF3C0, 0xF240, 0xF2C0,
+0xAA00, 0xAE00, 0xA200, 0xA600, 0xBA00, 0xBE00, 0xB200, 0xB600,
+0x8A00, 0x8E00, 0x8200, 0x8600, 0x9A00, 0x9E00, 0x9200, 0x9600,
+0xD500, 0xD700, 0xD100, 0xD300, 0xDD00, 0xDF00, 0xD900, 0xDB00,
+0xC500, 0xC700, 0xC100, 0xC300, 0xCD00, 0xCF00, 0xC900, 0xCB00,
+0xFEA8, 0xFEB8, 0xFE88, 0xFE98, 0xFEE8, 0xFEF8, 0xFEC8, 0xFED8,
+0xFE28, 0xFE38, 0xFE08, 0xFE18, 0xFE68, 0xFE78, 0xFE48, 0xFE58,
+0xFFA8, 0xFFB8, 0xFF88, 0xFF98, 0xFFE8, 0xFFF8, 0xFFC8, 0xFFD8,
+0xFF28, 0xFF38, 0xFF08, 0xFF18, 0xFF68, 0xFF78, 0xFF48, 0xFF58,
+0xFAA0, 0xFAE0, 0xFA20, 0xFA60, 0xFBA0, 0xFBE0, 0xFB20, 0xFB60,
+0xF8A0, 0xF8E0, 0xF820, 0xF860, 0xF9A0, 0xF9E0, 0xF920, 0xF960,
+0xFD50, 0xFD70, 0xFD10, 0xFD30, 0xFDD0, 0xFDF0, 0xFD90, 0xFDB0,
+0xFC50, 0xFC70, 0xFC10, 0xFC30, 0xFCD0, 0xFCF0, 0xFC90, 0xFCB0,
+/* positive */
+0x1580, 0x1480, 0x1780, 0x1680, 0x1180, 0x1080, 0x1380, 0x1280,
+0x1D80, 0x1C80, 0x1F80, 0x1E80, 0x1980, 0x1880, 0x1B80, 0x1A80,
+0x0AC0, 0x0A40, 0x0BC0, 0x0B40, 0x08C0, 0x0840, 0x09C0, 0x0940,
+0x0EC0, 0x0E40, 0x0FC0, 0x0F40, 0x0CC0, 0x0C40, 0x0DC0, 0x0D40,
+0x5600, 0x5200, 0x5E00, 0x5A00, 0x4600, 0x4200, 0x4E00, 0x4A00,
+0x7600, 0x7200, 0x7E00, 0x7A00, 0x6600, 0x6200, 0x6E00, 0x6A00,
+0x2B00, 0x2900, 0x2F00, 0x2D00, 0x2300, 0x2100, 0x2700, 0x2500,
+0x3B00, 0x3900, 0x3F00, 0x3D00, 0x3300, 0x3100, 0x3700, 0x3500,
+0x0158, 0x0148, 0x0178, 0x0168, 0x0118, 0x0108, 0x0138, 0x0128,
+0x01D8, 0x01C8, 0x01F8, 0x01E8, 0x0198, 0x0188, 0x01B8, 0x01A8,
+0x0058, 0x0048, 0x0078, 0x0068, 0x0018, 0x0008, 0x0038, 0x0028,
+0x00D8, 0x00C8, 0x00F8, 0x00E8, 0x0098, 0x0088, 0x00B8, 0x00A8,
+0x0560, 0x0520, 0x05E0, 0x05A0, 0x0460, 0x0420, 0x04E0, 0x04A0,
+0x0760, 0x0720, 0x07E0, 0x07A0, 0x0660, 0x0620, 0x06E0, 0x06A0,
+0x02B0, 0x0290, 0x02F0, 0x02D0, 0x0230, 0x0210, 0x0270, 0x0250,
+0x03B0, 0x0390, 0x03F0, 0x03D0, 0x0330, 0x0310, 0x0370, 0x0350
+};
+#endif
+
+////////////////////////////////////////////////////////////////////////
+
+
+
+
static int cur_emdigitwait = 250; /* Wait time in ms for digits on EM channel */
static char context[AST_MAX_CONTEXT] = "default";
@@ -654,6 +786,13 @@
#endif
int polarity;
+ int echo_detection_state;
+ pthread_t polling_thread_id;
+ int is_call_active;
+ int ed_enabled;
+ unsigned int num_of_echo_absent_calls;
+ unsigned int num_of_echo_present_calls;
+
} *iflist = NULL, *ifend = NULL;
static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
@@ -694,6 +833,32 @@
#define GET_CHANNEL(p) ((p)->channel)
#endif
+static int sangoma_get_echo_state(struct zt_pvt* pvt, echo_detect_struct_t * ioctl_result);
+static int sangoma_write_call_started_str(struct zt_pvt *pvt);
+static int sangoma_write_call_ended_str(struct zt_pvt *pvt);
+static char* sangoma_get_date_and_time(void);
+static void sangoma_ed_control(int fd, struct zt_pvt *tmp, int control_code);
+static void sangoma_linearize_spike_buffer(int fd, unsigned char *spike_buff, int *linearized_buff, int law);
+static int sangoma_write_spike_buffer_to_file(struct zt_pvt *pvt, int *linearized_buff, int fd);
+static int sangoma_write_buffer_to_file(char * full_file_path, char* string);
+static void sangoma_summary_of_linear_spike_buffer(int fd, int *linearized_buff, struct zt_pvt *tmp);
+static void sangoma_analyze_db_loss(int fd, struct zt_pvt *tmp);
+
+#define INITIAL_LINEAR_TX_SPIKE 16384
+#define NO 0
+#define YES 1
+#define DB_LOSS_THRESHOLD -45.00//-50.00//-60.00
+#define DB_SILENCE 80.00
+
+typedef struct{
+ float db_loss;
+ short linear_power_value;
+}db_sample_t;
+
+db_sample_t db_loss[SANGOMA_SPIKE_SAMPLE_LEN];
+
+void proc_sample(unsigned short, int);
+
struct zt_pvt *round_robin[32];
#ifdef ZAPATA_PRI
@@ -1364,6 +1529,12 @@
}
x = p->echocancel;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
+
+ if(p->ed_enabled == 1 && p->is_call_active == 0){
+ p->is_call_active = 1;
+ sangoma_write_call_started_str(p);
+ }
+
if (res)
ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d\n", p->channel);
else {
@@ -1394,9 +1565,42 @@
{
int x;
int res;
+
+ echo_detect_struct_t ioctl_result;
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+
if (p->echocancel) {
x = 0;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
+
+ if(p->is_call_active == 1){
+ /* This function is called twice, without obvious reason,
+ but end of call should be recorded only once.
+ */
+ p->is_call_active = 0;
+
+ if(!sangoma_get_echo_state(p, &ioctl_result)){
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", p->span, p->channel);
+
+ //if(ioctl_result.echo_state != INDETERMINATE){
+ snprintf(log_str_buff, TMP_BUFF_LEN,
+ " %-3s ", TDMV_SAMPLE_STATE_DECODE(ioctl_result.echo_state));
+ sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+ //}
+
+ if(ioctl_result.echo_state == ECHO_ABSENT){
+ p->num_of_echo_absent_calls++;
+ }if(ioctl_result.echo_state == ECHO_PRESENT){
+ p->num_of_echo_present_calls++;
+ }
+ }//if()
+ sangoma_write_call_ended_str(p);
+ }//if(p->is_call_active == 1)
+
if (res)
ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
else
@@ -1446,11 +1650,167 @@
g.txgain[j] = j;
}
}
-
- /* set 'em */
+
+ /* set 'em */
return(ioctl(fd,ZT_SETGAINS,&g));
}
+int usecsleep(int sec, int usecs)
+{
+ struct timeval tv;
+
+ tv.tv_sec = sec;
+ tv.tv_usec = usecs;
+
+ return select(0, NULL, NULL, NULL, &tv);
+}
+
+static char* sangoma_get_date_and_time()
+{
+ struct timeval tv;
+ struct timezone tz;
+ time_t now;
+ static char tmp_str[TMP_BUFF_LEN];
+ int ind;
+
+ gettimeofday(&tv, &tz);
+ now = tv.tv_sec;
+
+ snprintf(tmp_str, TMP_BUFF_LEN, ctime(&now));
+ /* replace 'new line' with 'null' */
+ for(ind = 0; ind < TMP_BUFF_LEN; ind++){
+ if(tmp_str[ind] == '\n'){
+ tmp_str[ind] = '\0';
+ }
+ }
+
+ return tmp_str;
+}
+
+#define MAX_LOG_FILE_SIZE 500000 // 500 Kb is the maximum
+
+int sangoma_write_buffer_to_file(char * full_file_path, char* string)
+{
+ FILE * file;
+ struct stat statbuf;
+
+ file = fopen(full_file_path, "a");
+ if(file == NULL){
+ ast_log(LOG_WARNING, "Failed to open %s file for writing!\n", full_file_path);
+ return 1;
+ }
+
+ //file exist, let's make sure it's not too big
+ if(lstat(full_file_path, &statbuf)){
+ ast_log(LOG_WARNING, "Failed to get file size ! File: %s.\n", full_file_path);
+ return 2;
+ }
+
+ if(statbuf.st_size > MAX_LOG_FILE_SIZE){
+ ast_log(LOG_WARNING, "File %s reached maximum size!\n", full_file_path);
+ return 3;
+ }
+
+ fputs(string, file);
+ fclose(file);
+ return 0;
+}
+
+static int sangoma_write_spike_buffer_to_file(struct zt_pvt *pvt, int *linearized_buff, int fd)
+{
+ FILE *file;
+ int ind;
+ char strbuff[50];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.spike", pvt->span, pvt->channel);
+
+ /* trancate and open the file for writing */
+ file = fopen(log_file_name_buff, "w");
+ if(file == NULL){
+ ast_log(LOG_WARNING, "Failed to open %s file for writing!\n", log_file_name_buff);
+ return 1;
+ }
+
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+ snprintf(strbuff, 50, "%d\n", linearized_buff[ind]);
+ fputs(strbuff, file);
+ }/* for() */
+ fclose(file);
+
+ ast_cli(fd, "Echo spike was written to '%s' file.\n", log_file_name_buff);
+
+ return 0;
+}
+
+static int sangoma_do_echo_detect_ioctl(int zfd, int echo_detect_ioctl, int * ioctl_result)
+{
+ if (ioctl(zfd, echo_detect_ioctl, ioctl_result)){
+ perror("sangoma_do_echo_detect_ioctl():\n");
+ return 1;
+ }else{
+ return 0;
+ }
+}
+
+static int sangoma_get_echo_state(struct zt_pvt* pvt, echo_detect_struct_t* ioctl_result)
+{
+ if(pvt == NULL){
+ ast_log(LOG_WARNING, "%s():pvt is NULL!!!\n", __FUNCTION__);
+ return 1;
+ }
+
+// ast_log(LOG_WARNING, "span: %d, channel: %d\n", pvt->span, pvt->channel);
+// ast_log(LOG_WARNING, "zdf: %d\n", pvt->subs[SUB_REAL].zfd);
+
+ if(!sangoma_do_echo_detect_ioctl(pvt->subs[SUB_REAL].zfd, SANGOMA_GET_ED_STATE, (int*)ioctl_result)){
+ return 0;
+ }else{
+ return 3;
+ }
+}
+
+static int sangoma_write_call_started_str(struct zt_pvt *pvt)
+{
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", pvt->span, pvt->channel);
+
+ snprintf(log_str_buff, TMP_BUFF_LEN, "START: [%-24s]",
+ sangoma_get_date_and_time());
+ sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+
+ if(pvt->owner){
+ snprintf(log_str_buff, TMP_BUFF_LEN, "[exten:%s, callerid:%s]",
+ (pvt->owner->exten == NULL ? "----" : pvt->owner->exten),
+ (pvt->owner->callerid == NULL? "----" : pvt->owner->callerid));
+ }else{
+ snprintf(log_str_buff, TMP_BUFF_LEN, "[context:%s, exten:%s, callerid:%s]",
+ "----", "----", "----");
+ }
+
+ return sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+}
+
+static int sangoma_write_call_ended_str(struct zt_pvt *pvt)
+{
+ char log_str_buff[TMP_BUFF_LEN];
+ char log_file_name_buff[TMP_BUFF_LEN];
+
+ snprintf(log_file_name_buff, TMP_BUFF_LEN,
+ "/etc/wanpipe/span_%d_chan_%d.log", pvt->span, pvt->channel);
+
+ snprintf(log_str_buff, TMP_BUFF_LEN, "END: [%s][eabs:%u,epres:%u]\n",
+ sangoma_get_date_and_time(),
+ pvt->num_of_echo_absent_calls,
+ pvt->num_of_echo_present_calls);
+
+ return sangoma_write_buffer_to_file(log_file_name_buff, log_str_buff);
+}
+
static inline int zt_set_hook(int fd, int hs)
{
int x, res;
@@ -9442,6 +9802,382 @@
return RESULT_FAILURE;
}
+static int sangoma_show_channels_func(int fd, int argc, char **argv)
+{
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ echo_detect_struct_t ioctl_result;
+ int active_chans_counter;
+
+ lock = &iflock;
+ start = iflist;
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ ast_cli(fd, "\nSpan\tChannel\t\tEcho\tContext\t\tExtension\tCallerID\n");
+
+ active_chans_counter = 0;
+ while (tmp){
+ if(tmp->channel < 0 ||
+ sangoma_get_echo_state(tmp, &ioctl_result) ||
+ ioctl_result.echo_detection_state != ECHO_DETECT_ON){/* show only active channels*/
+ tmp = tmp->next;
+ continue;
+ }
+
+ active_chans_counter++;
+
+ ast_cli(fd, "%02d\t%02d\t\t%-5s\t%-10s\t%-10s\t%-10s\n",
+ tmp->span,
+ tmp->channel,
+ TDMV_SAMPLE_STATE_DECODE(ioctl_result.echo_state),
+
+ (tmp->owner->context == NULL ? "----" : tmp->owner->context),
+ (tmp->owner->exten == NULL ? "----" : tmp->owner->exten),
+ (tmp->owner->callerid == NULL? "----" : tmp->owner->callerid)
+ );
+
+ tmp = tmp->next;
+ }/* while() */
+ ast_cli(fd, "%d active channel(s)\n", active_chans_counter);
+
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+}
+
+static int sangoma_dbg_channel(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ /* The ED algorithm can be enabled/disabled on all channels or
+ for an individual channel.
+ */
+ if(!strcmp(argv[3], "all")){
+ while (tmp) {
+ if(tmp->channel > 0){
+ if(!strcmp(argv[1], "enable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_ENABLE_ED);
+ }else if(!strcmp(argv[1], "disable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_DISABLE_ED);
+ }else{
+ ast_cli(fd, "%s(): Invalid command switch: %s!\n",
+ argv[2], __FUNCTION__);
+ }
+ }
+ tmp = tmp->next;
+ }/* while() */
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }else{
+ while (tmp) {
+ if (tmp->channel == channel) {
+
+ if(!strcmp(argv[1], "enable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_ENABLE_ED);
+ }else if(!strcmp(argv[1], "disable")){
+ sangoma_ed_control(fd, tmp, SANGOMA_DISABLE_ED);
+ }else{
+ ast_cli(fd, "%s(): Invalid command switch: %s!\n",
+ argv[2], __FUNCTION__);
+ }
+
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+ }/* if() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static void sangoma_ed_control(int fd, struct zt_pvt *tmp, int control_code)
+{
+ echo_detect_struct_t ioctl_result;
+
+ switch(control_code)
+ {
+ case SANGOMA_ENABLE_ED:
+ ast_cli(fd,
+ "Enabling Sangoma ED on Span: %d, Channel: %d, File Descriptor: %d.\n",
+ tmp->span, tmp->channel, tmp->subs[SUB_REAL].zfd);
+ tmp->ed_enabled = 1;
+
+ sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd, SANGOMA_ENABLE_ED,
+ (int*)&ioctl_result);
+ break;
+
+ case SANGOMA_DISABLE_ED:
+ ast_cli(fd,
+ "Disabling Sangoma ED on Span: %d, Channel: %d, File Descriptor: %d.\n",
+ tmp->span, tmp->channel, tmp->subs[SUB_REAL].zfd);
+ tmp->ed_enabled = 0;
+
+ sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd, SANGOMA_DISABLE_ED,
+ (int*)&ioctl_result);
+ break;
+ default:
+ ast_cli(fd, "%s(): invalid IOCTL code.\n", __FUNCTION__);
+ }
+}
+
+static int sangoma_send_echo_spike(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ unsigned char spike_buff[sizeof(echo_spike_struct_t)];
+ echo_spike_struct_t *echo_spike_struct_ptr = (echo_spike_struct_t *)spike_buff;
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ while (tmp) {
+ if (tmp->channel == channel) {
+ if(sangoma_do_echo_detect_ioctl( tmp->subs[SUB_REAL].zfd,
+ SANGOMA_SEND_SPIKE,
+ (int*)spike_buff) != 0){
+ ast_cli(fd,
+ "Command failed on channel %d! Please check kernel messages log.\n",
+ channel);
+ }else if(echo_spike_struct_ptr->return_code == SANGOMA_NO_ACTIVE_CALL_OR_EC_OFF){
+ ast_cli(fd,
+ "Command failed on channel %d! \
+ Possible reasons: 1. the 'echocancel' is set to 'no' 2. call is not up.\n", channel);
+ }else{
+ ;/* no error. do nothing. */
+ }
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static int sangoma_get_echo_spike(int fd, int argc, char **argv)
+{
+ int channel;
+ struct zt_pvt *tmp = NULL;
+ ast_mutex_t *lock;
+ struct zt_pvt *start;
+ static unsigned char spike_buff[sizeof(echo_spike_struct_t) + SANGOMA_SPIKE_SAMPLE_LEN];
+ echo_spike_struct_t *echo_spike_struct_ptr = (echo_spike_struct_t *)spike_buff;
+ unsigned char *spike_sample_buff_ptr = &spike_buff[sizeof(echo_spike_struct_t)];
+ int linearized_buff[SANGOMA_SPIKE_SAMPLE_LEN];
+
+ lock = &iflock;
+ start = iflist;
+
+ if (argc != 4){
+ return RESULT_SHOWUSAGE;
+ }
+
+ channel = atoi(argv[3]);
+
+ ast_mutex_lock(lock);
+ tmp = start;
+
+ while (tmp) {
+ if (tmp->channel == channel) {
+ if(sangoma_do_echo_detect_ioctl(tmp->subs[SUB_REAL].zfd,
+ SANGOMA_GET_ECHO_SPIKE_SAMPLE,
+ (int*)spike_buff) == 0){
+ if(echo_spike_struct_ptr->return_code == SANGOMA_OK){
+ /*
+ int ind;
+ ast_cli(fd, "SANGOMA_SPIKE_SAMPLE_LEN:%d\n", SANGOMA_SPIKE_SAMPLE_LEN);
+ ast_cli(fd, "NOT liniarized buffer:\n");
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+ ast_cli(fd, "0x%02X\n", spike_sample_buff_ptr[ind]);
+ }
+ */
+ sangoma_linearize_spike_buffer(fd, spike_sample_buff_ptr, linearized_buff,
+ tmp->law);
+
+ sangoma_write_spike_buffer_to_file(tmp, linearized_buff, fd);
+
+ sangoma_summary_of_linear_spike_buffer(fd, linearized_buff, tmp);
+ }else{
+ ast_cli(fd,
+ "Command failed on channel %d! \
+ Possible reasons: 1. the 'echocancel' is set to 'no' 2. call is not up.\n", channel);
+ }
+ }
+ ast_mutex_unlock(lock);
+ return RESULT_SUCCESS;
+ }
+ tmp = tmp->next;
+ }/* while() */
+
+ ast_cli(fd, "Unable to find given channel %d\n", channel);
+ ast_mutex_unlock(lock);
+ return RESULT_FAILURE;
+}
+
+static void sangoma_linearize_spike_buffer(int fd, unsigned char *spike_buff, int *linearized_buff, int law)
+{
+ int ind;
+ unsigned short *linear_table;
+
+ if(law == ZT_LAW_MULAW){
+ ast_cli(fd, "Using MULAW table...\n");
+ linear_table = u2s;
+ }else{
+ ast_cli(fd, "Using ALAW table...\n");
+ linear_table = a2s;
+ }
+
+ memset(linearized_buff, 0x00, SANGOMA_SPIKE_SAMPLE_LEN);
+
+ //ast_cli(fd, "linearized buffer (v2 len: %d)\n", SANGOMA_SPIKE_SAMPLE_LEN);
+ for(ind = 0; ind < SANGOMA_SPIKE_SAMPLE_LEN; ind++){
+
+ if(linear_table[spike_buff[ind]] == 0){
+ linearized_buff[ind] = 0;
+ }else if(spike_buff[ind] < 128){
+ /* make it negative */
+ linearized_buff[ind] = -65535 + linear_table[spike_buff[ind]];
+ }else{
+ linearized_buff[ind] = linear_table[spike_buff[ind]];
+ }
+ //ast_cli(fd, "%d\n", linearized_buff[ind]);
+ }/* for() */
+}
+
+static void sangoma_summary_of_linear_spike_buffer(int fd, int *linearized_buff, struct zt_pvt *tmp)
+{
+ int i;
+
+ for(i = 0; i < SANGOMA_SPIKE_SAMPLE_LEN; i ++) {
+ proc_sample(linearized_buff[i], i);
+ }
+ sangoma_analyze_db_loss(fd, tmp);
+}
+
+void proc_sample(unsigned short linear, int sample_no)
+{
+ unsigned short val;
+ float d;
+ float db;
+ int neg_voltage = NO;
+
+ db_loss[sample_no].linear_power_value = linear;
+
+ if(linear & 0xF000) {
+ neg_voltage = YES;
+ val = linear ^ 0xFFFF;
+ } else {
+ val = linear;
+ }
+
+ val = val >> 3;
+ val &= 0x0FFF;
+ d = (float)val / (float)(INITIAL_LINEAR_TX_SPIKE >> 3);
+
+ if(d != 0.00) {
+ db = 20 * log10(d);
+ } else {
+ db = -DB_SILENCE;
+ }
+
+ db_loss[sample_no].db_loss = db;
+
+// printf("sample[%04d]%2.5f\n", sample_no, db);
+ return;
+}
+
+static void sangoma_analyze_db_loss(int fd, struct zt_pvt *tmp)
+{
+ float min_db_loss = -DB_SILENCE;
+ int min_db_loss_sample_no=0;
+ float first_db_loss_th;
+ int sample_no_first_db_loss_th = 0xFFFF;
+ float last_db_loss_th;
+ int sample_no_last_db_loss_th = 0xFFFF;
+ int i;
+
+ for(i = 0; i < SANGOMA_SPIKE_SAMPLE_LEN; i ++) {
+ if(db_loss[i].db_loss > min_db_loss) {
+ min_db_loss = db_loss[i].db_loss;
+ min_db_loss_sample_no = i;
+ }
+ if(sample_no_first_db_loss_th == 0xFFFF) {
+ if(db_loss[i].db_loss > DB_LOSS_THRESHOLD) {
+ sample_no_first_db_loss_th = i;
+ first_db_loss_th = db_loss[i].db_loss;
+ }
+ }
+ if(db_loss[i].db_loss > DB_LOSS_THRESHOLD) {
+ last_db_loss_th = db_loss[i].db_loss;
+ sample_no_last_db_loss_th = i;
+ }
+ }
+
+ if(min_db_loss == -DB_SILENCE) {
+ ast_cli(fd, "The line is silent. No conclusion can be made.\n");
+ } else {
+ ast_cli(fd, "\nEcho Spike reached it's maximum at sample %d, linear power is %d\n",
+ min_db_loss_sample_no + 1,
+ db_loss[min_db_loss_sample_no].linear_power_value);
+
+ ast_cli(fd, "First sample containing Echo Spike is %d, linear power is %d\n",
+ sample_no_first_db_loss_th + 1,
+ db_loss[sample_no_first_db_loss_th].linear_power_value);
+
+ ast_cli(fd, "Last sample containing Echo Spike is %d, linear power is %d\n",
+ sample_no_last_db_loss_th + 1,
+ db_loss[sample_no_last_db_loss_th].linear_power_value);
+
+ //suggest something depending on number of Echo Cancellor taps
+ ast_cli(fd, "\nYour Echo Cancellor set to use %d taps.\n", tmp->echocancel);
+ if(tmp->echocancel < sample_no_first_db_loss_th + 1){
+ ast_cli(fd, "It can not cancel the echo because delay is longer than %d taps.\n",
+ tmp->echocancel);
+
+ }else if(tmp->echocancel > sample_no_first_db_loss_th + 1 &&
+ tmp->echocancel < sample_no_last_db_loss_th + 1){
+ ast_cli(fd, "Echo starts WITHIN %d taps, but ends AFTER %d taps, it means\n\
+echo can not be cancelled completely.\n", tmp->echocancel, tmp->echocancel);
+ }else{
+ ast_cli(fd, "Echo starts and ends WITHIN %d taps, it should be cancelled properly.\n",
+ tmp->echocancel);
+ }
+ }
+}
+
static char zap_show_cadences_help[] =
"Usage: zap show cadences\n"
" Shows all cadences currently defined\n";
@@ -9563,6 +10299,61 @@
"Show all Zaptel cards status", zap_show_status_usage },
};
+
+/////////////////////////////////////////////////////////////////////////////////////////
+static char sangoma_show_channels_usage[] = "Usage: sangoma show channels\n";
+
+static struct ast_cli_entry sangoma_show_channels = {
+ {"sangoma", "show", "channels", NULL},
+ sangoma_show_channels_func,
+ "Show Sangoma channels. Only shows channels with ED enabled and a call up.",
+ sangoma_show_channels_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_show_chan_debug_usage[] = "Usage: sangoma enable edchannel <chan num> OR <all>\n";
+
+static struct ast_cli_entry sangoma_debug_chan = {
+ {"sangoma", "enable", "edchannel", NULL},
+ sangoma_dbg_channel,
+ "Enable ED algorithm on Sangoma channel(s)",
+ sangoma_show_chan_debug_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_show_chan_nodebug_usage[] = "Usage: sangoma disable edchannel <chan num> OR <all>\n";
+
+static struct ast_cli_entry sangoma_nodebug_chan = {
+ {"sangoma", "disable", "edchannel", NULL},
+ sangoma_dbg_channel,
+ "Disable ED algorithm on Sangoma channel(s)",
+ sangoma_show_chan_nodebug_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_get_echo_spike_sample_usage[] = "Usage: sangoma get espike <chan num>\n";
+
+static struct ast_cli_entry sangoma_get_echo_spike_chan = {
+ {"sangoma", "get", "espike", NULL},
+ sangoma_get_echo_spike,
+ "Get Echo spike sample buffer for a channel",
+ sangoma_get_echo_spike_sample_usage,
+ NULL };
+
+//--------------------------------------------------------------------------------------
+static char sangoma_send_echo_spike_usage[] = "Usage: sangoma send espike <chan num>\n";
+
+static struct ast_cli_entry sangoma_send_echo_spike_chan = {
+ {"sangoma", "send", "espike", NULL},
+ sangoma_send_echo_spike,
+ "Send Echo spike on a channel",
+ sangoma_send_echo_spike_usage,
+ NULL };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+
+
#define TRANSFER 0
#define HANGUP 1
@@ -9760,6 +10551,18 @@
ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
#endif
ast_cli_unregister_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
+
+ ast_cli_unregister_multiple(sangoma_show_channels,
+ sizeof(sangoma_show_channels)/sizeof(sangoma_show_channels[0]);
+ ast_cli_unregister_multiple(sangoma_debug_chan,
+ sizeof(sangoma_debug_chan)/sizeof(sangoma_debug_chan[0]));
+ ast_cli_unregister_multiple(sangoma_nodebug_chan,
+ sizeof(sangoma_nodebug_chan)/sizeof(sangoma_nodebug_chan[0]));
+ ast_cli_unregister_multiple(sangoma_get_echo_spike_chan,
+ sizeof(sangoma_get_echo_spike_chan)/sizeof(sangoma_get_echo_spike_chan[0]));
+ ast_cli_unregister_multiple(sangoma_send_echo_spike_chan,
+ sizeof(sangoma_send_echo_spike_chan)/sizeof(sangoma_send_echo_spike_chan[0]));
+
ast_manager_unregister( "ZapDialOffhook" );
ast_manager_unregister( "ZapHangup" );
ast_manager_unregister( "ZapTransfer" );
@@ -10660,6 +11463,17 @@
ast_cli_register_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
#endif
ast_cli_register_multiple(zap_cli, sizeof(zap_cli) / sizeof(zap_cli[0]));
+
+ ast_cli_register_multiple(sangoma_show_channels,
+ sizeof(sangoma_show_channels)/sizeof(sangoma_show_channels[0]);
+ ast_cli_register_multiple(sangoma_debug_chan,
+ sizeof(sangoma_debug_chan)/sizeof(sangoma_debug_chan[0]));
+ ast_cli_register_multiple(sangoma_nodebug_chan,
+ sizeof(sangoma_nodebug_chan)/sizeof(sangoma_nodebug_chan[0]));
+ ast_cli_register_multiple(sangoma_get_echo_spike_chan,
+ sizeof(sangoma_get_echo_spike_chan)/sizeof(sangoma_get_echo_spike_chan[0]));
+ ast_cli_register_multiple(sangoma_send_echo_spike_chan,
+ sizeof(sangoma_send_echo_spike_chan)/sizeof(sangoma_send_echo_spike_chan[0]));
memset(round_robin, 0, sizeof(round_robin));
ast_manager_register( "ZapTransfer", 0, action_transfer, "Transfer Zap Channel" );

286
edac/ed_zaptel.patch Normal file
View File

@ -0,0 +1,286 @@
diff -dur zaptel-1.0.9.1_original/zaptel.c zaptel/zaptel.c
--- zaptel-1.0.9.1_original/zaptel.c 2005-08-16 16:27:17.491862664 +0000
+++ zaptel/zaptel.c 2005-08-16 17:21:24.896182168 +0000
@@ -289,6 +289,8 @@
static int zt_chan_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long data, int unit);
+static void sang_zt_ec_chunk_spike_store(struct zt_chan *ss, unsigned char *rxchunk);
+
#if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP)
/* XXX kernel_fpu_begin() is NOT exported properly (in 2.4), so we have to make
a local version. Somebody fix this! XXX */
@@ -4113,6 +4115,11 @@
chan->echostate = ECHO_STATE_IDLE;
chan->echolastupdate = 0;
chan->echotimer = 0;
+ chan->echo_spike_struct.state_bits = SANGOMA_INITIAL_STATE;
+ chan->echo_spike_struct.sample_len_counter = 0;
+ if(chan->echo_detect_struct.ed_enabled == 1){
+ chan->echo_detect_struct.echo_detection_state = ECHO_DETECT_ON;
+ }
echo_can_disable_detector_init(&chan->txecdis);
echo_can_disable_detector_init(&chan->rxecdis);
}
@@ -4127,6 +4134,7 @@
chan->echostate = ECHO_STATE_IDLE;
chan->echolastupdate = 0;
chan->echotimer = 0;
+ chan->echo_detect_struct.echo_detection_state = ECHO_DETECT_OFF;
/* Attempt hardware native echo can */
if (chan->span && chan->span->echocan)
chan->span->echocan(chan, 0);
@@ -4270,6 +4278,92 @@
return -EINVAL;
break;
#endif
+ case SANGOMA_GET_ED_STATE:
+ if(chan->span->ioctl != NULL){
+ if (chan->span->ioctl(chan, cmd, 0) != 0){
+ return -EINVAL;
+ }
+ copy_to_user((echo_detect_struct_t*)data, &chan->echo_detect_struct,
+ sizeof(echo_detect_struct_t));
+ }else{
+ printk(KERN_INFO "SANGOMA_GET_ED_STATE: channo: %d : chan->span->ioctl == NULL !!\n",
+ chan->channo);
+ return -EINVAL;
+ }
+ break;
+
+ case SANGOMA_ENABLE_ED:
+ chan->echo_detect_struct.ed_enabled = 1;
+ break;
+
+ case SANGOMA_DISABLE_ED:
+ chan->echo_detect_struct.ed_enabled = 0;
+ break;
+
+ case SANGOMA_GET_ECHO_SPIKE_SAMPLE:
+ if(chan->echo_spike_struct.sample_buffer){
+ unsigned char *tmp_ptr = (unsigned char*)data;
+
+ chan->echo_spike_struct.return_code = SANGOMA_OK;
+
+ /* first copy the 'echo_spike_struct_t' structure */
+ copy_to_user(tmp_ptr, &chan->echo_spike_struct, sizeof(echo_spike_struct_t));
+
+ /* second copy the data AFTER the 'echo_spike_struct_t' structure */
+ copy_to_user (&tmp_ptr[sizeof(echo_spike_struct_t)],
+ chan->echo_spike_struct.sample_buffer,
+ SANGOMA_SPIKE_SAMPLE_LEN);
+
+ /* free the sample buffer */
+ kfree(chan->echo_spike_struct.sample_buffer);
+ chan->echo_spike_struct.sample_buffer = NULL;
+
+ chan->echo_spike_struct.state_bits = SANGOMA_INITIAL_STATE;
+ chan->echo_spike_struct.sample_len_counter = 0;
+ }else{
+ unsigned char *tmp_ptr = (unsigned char*)data;
+
+ chan->echo_spike_struct.return_code = SANGOMA_NO_ACTIVE_CALL_OR_EC_OFF;
+ /* copy the 'echo_spike_struct_t' structure */
+ copy_to_user(tmp_ptr, &chan->echo_spike_struct, sizeof(echo_spike_struct_t));
+ }
+ break;
+
+ case SANGOMA_SEND_SPIKE:
+ /* allocate EchoTest buffer */
+ chan->echo_spike_struct.sample_buffer = kmalloc(SANGOMA_SPIKE_SAMPLE_LEN, GFP_KERNEL);
+ if (chan->echo_spike_struct.sample_buffer == NULL) {
+ printk(KERN_INFO "channo: %d: Failed to allocate %d bytes for EchoTest storage!!!\n",
+ chan->channo, SANGOMA_SPIKE_SAMPLE_LEN);
+ return -ENOMEM;
+ }
+
+ spin_lock_irqsave(&chan->lock, flags);
+ /* send echo spike */
+ if (chan->ec) {
+ chan->echo_spike_struct.state_bits = SANGOMA_INITIAL_STATE;
+ chan->echo_spike_struct.sample_len_counter = 0;
+ /* these two lines will make zaptel to send the spike: */
+ chan->echostate = ECHO_STATE_PRETRAINING;
+ chan->echotimer = 2048; /*Number of silence bytes to transmit before the spike.
+ It makes the line clean from noise, so spike is easy
+ to detect on return.*/
+ /* must unlock here!! */
+ spin_unlock_irqrestore(&chan->lock, flags);
+ }else{
+ unsigned char *tmp_ptr = (unsigned char*)data;
+
+ chan->echo_spike_struct.return_code = SANGOMA_NO_ACTIVE_CALL_OR_EC_OFF;
+
+ /* Must unlock here, BEFORE copy_to_user() call.
+ Or will get warnings from the kernel. */
+ spin_unlock_irqrestore(&chan->lock, flags);
+
+ /* copy the 'echo_spike_struct_t' structure */
+ copy_to_user(tmp_ptr, &chan->echo_spike_struct, sizeof(echo_spike_struct_t));
+ }
+ break;
+
default:
return zt_chanandpseudo_ioctl(inode, file, cmd, data, unit);
}
@@ -5325,7 +5419,13 @@
short rxlin, txlin;
int x;
unsigned long flags;
+ unsigned char rxchunk_backup[ZT_CHUNKSIZE];
+
spin_lock_irqsave(&ss->lock, flags);
+
+ //original rxchank is modyfied, make a backup copy for future use.
+ memcpy(rxchunk_backup, rxchunk, ZT_CHUNKSIZE);
+
/* Perform echo cancellation on a chunk if necessary */
if (ss->ec) {
#if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP)
@@ -5345,12 +5445,30 @@
if ((ss->echostate == ECHO_STATE_AWAITINGECHO) && (txlin > 8000)) {
ss->echolastupdate = 0;
ss->echostate = ECHO_STATE_TRAINING;
+
+ //printk(KERN_INFO "ss->echostate == ECHO_STATE_AWAITINGECHO\n");
+
+ if(ss->echo_spike_struct.state_bits == SANGOMA_INITIAL_STATE){
+ ss->echo_spike_struct.state_bits = SANGOMA_BUSY_COLLECTING_SAMPLE;
+ ss->echo_spike_struct.sample_len_counter = 0;
+ }
}
if (ss->echostate == ECHO_STATE_TRAINING) {
+ //printk(KERN_INFO "rxchunk[%d]: 0x%02X\n", x, rxchunk[x]);
+
if (echo_can_traintap(ss->ec, ss->echolastupdate++, rxlin)) {
#if 0
printk("Finished training (%d taps trained)!\n", ss->echolastupdate);
#endif
+ /*
+ //sang
+ printk(KERN_INFO
+ "span:%d,chan:%d:Finished training (%d taps trained)!\n",
+ (ss->span ? ss->span->spanno : 0),
+ ss->channo,
+ ss->echolastupdate);
+ */
+
ss->echostate = ECHO_STATE_ACTIVE;
}
}
@@ -5364,6 +5482,9 @@
rxchunk[x] = ZT_LIN2X((int)rxlin, ss);
}
}
+
+ sang_zt_ec_chunk_spike_store(ss, rxchunk_backup);
+
#if defined(CONFIG_ZAPTEL_MMX) || defined(ECHO_CAN_FP)
kernel_fpu_end();
#endif
@@ -6500,3 +6621,60 @@
module_init(zt_init);
module_exit(zt_cleanup);
+
+
+static void sang_zt_ec_chunk_spike_store(struct zt_chan *ss, unsigned char *rxchunk)
+{
+ int x;
+
+ if(ss->echo_spike_struct.state_bits != SANGOMA_BUSY_COLLECTING_SAMPLE ||
+ ss->echo_spike_struct.sample_buffer == NULL){
+ return;
+ }
+
+ //check input values
+ if(ss->echo_spike_struct.sample_len_counter >= SANGOMA_SPIKE_SAMPLE_LEN){
+ printk(KERN_INFO "chan: %d: Invalid sample_len_counter! (%d)\n",
+ ss->channo, ss->echo_spike_struct.sample_len_counter);
+ return;
+ }
+
+ if(ss->echo_spike_struct.state_bits == SANGOMA_BUSY_COLLECTING_SAMPLE){
+
+ for (x = 0; x < ZT_CHUNKSIZE; x++) {
+ ss->echo_spike_struct.sample_buffer[ss->echo_spike_struct.sample_len_counter]
+ = rxchunk[x];
+
+ ss->echo_spike_struct.sample_len_counter++;
+
+ if(ss->echo_spike_struct.sample_len_counter >= SANGOMA_SPIKE_SAMPLE_LEN){
+ //finished collecting the sample
+ ss->echo_spike_struct.state_bits = SANGOMA_FINISHED_COLLECTING_SAMPLE;
+ break;
+ }//if()
+ }//for()
+ }//if()
+
+#if 0
+ if(ss->echo_spike_struct.state_bits == SANGOMA_FINISHED_COLLECTING_SAMPLE){
+
+ printk(KERN_INFO "chan: %d: spike sample buffer(len:%d):\n",
+ ss->channo, SANGOMA_SPIKE_SAMPLE_LEN);
+ //print out the sample buffer
+ for (x = 0; x < SANGOMA_SPIKE_SAMPLE_LEN; x++) {
+ printk(KERN_INFO "0x%02X\n", ss->echo_spike_struct.sample_buffer[x]);
+ }
+ printk(KERN_INFO "end of spike sample buffer\n");
+
+ printk(KERN_INFO "chan: %d: LINEAR (ALAW) spike sample buffer(len:%d):\n",
+ ss->channo, SANGOMA_SPIKE_SAMPLE_LEN);
+ //print out the sample buffer
+ for (x = 0; x < SANGOMA_SPIKE_SAMPLE_LEN; x++) {
+ printk(KERN_INFO "0x%04X\n",
+ ZT_ALAW(ss->echo_spike_struct.sample_buffer[x]) & 0xFFFF);
+ }
+ printk(KERN_INFO "end of spike sample buffer\n");
+ }
+#endif
+}
+
diff -dur zaptel-1.0.9.1_original/zaptel.h zaptel/zaptel.h
--- zaptel-1.0.9.1_original/zaptel.h 2005-08-16 16:27:17.503860840 +0000
+++ zaptel/zaptel.h 2005-08-16 17:22:11.279130888 +0000
@@ -61,6 +61,8 @@
#endif /* CONFIG_DEVFS_FS */
#include <linux/ioctl.h>
+#include <linux/wanpipe_edac_iface.h>
+
#ifndef ELAST
#define ELAST 500
#endif
@@ -608,6 +610,21 @@
* 80-85 are reserved for dynamic span stuff
*/
+
+
+
+
+
+
+
+
+
+#define SANGOMA_GET_ED_STATE _IOR (ZT_CODE, 61, int)
+#define SANGOMA_ENABLE_ED _IOR (ZT_CODE, 62, int)
+#define SANGOMA_DISABLE_ED _IOR (ZT_CODE, 63, int)
+#define SANGOMA_GET_ECHO_SPIKE_SAMPLE _IOR (ZT_CODE, 64, int)
+#define SANGOMA_SEND_SPIKE _IOR (ZT_CODE, 65, int)
+
/*
* Create a dynamic span
*/
@@ -1150,6 +1167,10 @@
devfs_handle_t fhandle; /* File handle in devfs for the channel */
devfs_handle_t fhandle_symlink;
#endif /* CONFIG_DEVFS_FS */
+
+ //SANGOMA
+ echo_detect_struct_t echo_detect_struct;
+ echo_spike_struct_t echo_spike_struct;
};
/* defines for transmit signalling */

BIN
firmware/asy514.sfm Normal file

Binary file not shown.

BIN
firmware/cdual514asy.sfm Executable file

Binary file not shown.

View File

@ -26,9 +26,10 @@ obj-m := $(MODULE_NAME).o
else
KVER ?= $(shell uname -r)
PWD := $(shell pwd)
KBUILD_VERBOSE=
all:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) CC=$(CC) KBUILD_VERBOSE=$(KBUILD_VERBOSE) modules
clean:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean

View File

@ -150,10 +150,15 @@ enum {
SIOC_WANPIPE_SNMP,
SIOC_WANPIPE_SNMP_IFSPEED,
#if 0
SIOC_WANPIPE_DEVICE, /* GENERIC */
SIOC_WANPIPE_DUMP, /* GENERIC */
#endif
SIOC_WAN_DEVEL_IOCTL, /* uses wan_cmd_api_t */
# if defined(CONFIG_PRODUCT_WANPIPE_TDMV_EC)
SIOC_WAN_OCT6100_IOCTL,
#endif
SIOC_WANAPI_DEVPRIVATE = SIOCDEVPRIVATE + 20,
@ -318,7 +323,7 @@ typedef struct wanpipe_parent
unsigned char hdlc_enabled;
rwlock_t lock;
char time_slots;
signed char time_slots;
char media;
unsigned char seven_bit_hdlc;

View File

@ -92,7 +92,9 @@ typedef struct {
wan_timer_t dev_timer;
unsigned int protocol;
void *lip;
unsigned int lip_prot;
#endif
int is_netdev;
wanpipe_common_iface_t iface;
@ -143,6 +145,16 @@ static __inline int wan_set_lip_ptr(netdevice_t *dev, void *lipreg)
return -ENODEV;
}
static __inline int wan_set_lip_prot(netdevice_t *dev, int protocol)
{
if (wan_netif_priv(dev)){
((wanpipe_common_t*)wan_netif_priv(dev))->lip_prot = protocol;
return 0;
}
return -ENODEV;
}
static __inline int wan_api_rx(void *chan_ptr,netskb_t *skb)
{
#if defined(__LINUX__)

View File

@ -22,7 +22,7 @@
DEFINES AND MACROS
******************************************************************************/
#define IS_56K_CARD(card) IS_56K_MEDIA(card->fe.fe_cfg.media)
#define IS_56K_CARD(card) IS_56K_FEMEDIA(&(card)->fe)
#define RRA(alarm) ((alarm>>8)&0xFF)
#define RRC(alarm) ((alarm)&0xFF)

View File

@ -37,15 +37,13 @@
#define AFT_CHIP_CFG_REG 0x40
/* Moved to sdlasfm.h #define AFT_MCPU_INTERFACE 0x44 */
#define AFT_MCPU_INTERFACE_RW 0x54
/* Moved to sdlasfm.h #define AFT_MCPU_INTERFACE_ADDR 0x46 */
#define AFT_WDT_CTRL_REG 0x48
#define AFT_DATA_MUX_REG 0x4C
#define AFT_FIFO_MARK_REG 0x50
# define AFT_CHIPCFG_TE1_CFG_BIT 0
# define AFT_CHIPCFG_SFR_EX_BIT 1
@ -55,6 +53,11 @@
# define AFT_CHIPCFG_RAM_READY_BIT 7
# define AFT_CHIPCFG_HDLC_CTRL_RDY_BIT 8
# define AFT_CHIPCFG_P1_TDMV_INTR_BIT 14
# define AFT_CHIPCFG_P2_TDMV_INTR_BIT 15
# define AFT_CHIPCFG_P3_TDMV_INTR_BIT 16
# define AFT_CHIPCFG_P4_TDMV_INTR_BIT 17
# define AFT_CHIPCFG_P1_WDT_INTR_BIT 18
# define AFT_CHIPCFG_P2_WDT_INTR_BIT 19
# define AFT_CHIPCFG_P3_WDT_INTR_BIT 20
@ -72,6 +75,9 @@
# define AFT_CHIPCFG_WDT_INTR_MASK 0x0F
# define AFT_CHIPCFG_WDT_INTR_SHIFT 18
# define AFT_CHIPCFG_TDMV_INTR_MASK 0x0F
# define AFT_CHIPCFG_TDMV_INTR_SHIFT 14
# define AFT_CHIPCFG_WDT_FE_INTR_STAT 0
# define AFT_CHIPCFG_WDT_TX_INTR_STAT 1
# define AFT_CHIPCFG_WDT_RX_INTR_STAT 2
@ -99,6 +105,15 @@ aft_chipcfg_get_wdt_intr_stats(u32 reg)
return reg;
}
static __inline u32
aft_chipcfg_get_tdmv_intr_stats(u32 reg)
{
reg=reg>>AFT_CHIPCFG_TDMV_INTR_SHIFT;
reg&=AFT_CHIPCFG_TDMV_INTR_MASK;
return reg;
}
# define AFT_WDTCTRL_MASK 0xFF
# define AFT_WDTCTRL_TIMEOUT 75 /* ms */
@ -116,6 +131,33 @@ aft_wdt_ctrl_set(u8 *reg, u8 timeout)
}
#define AFT_FIFO_MARK_32_MASK 0x3F
#define AFT_FIFO_MARK_32_SHIFT 0
#define AFT_FIFO_MARK_64_MASK 0x3F
#define AFT_FIFO_MARK_64_SHIFT 6
#define AFT_FIFO_MARK_128_MASK 0x3F
#define AFT_FIFO_MARK_128_SHIFT 12
#define AFT_FIFO_MARK_256_MASK 0x3F
#define AFT_FIFO_MARK_256_SHIFT 18
#define AFT_FIFO_MARK_512_MASK 0x3F
#define AFT_FIFO_MARK_512_SHIFT 24
static __inline void
aft_fifo_mark_gset(u32 *reg, u8 mark)
{
mark&=AFT_FIFO_MARK_32_MASK;
*reg=0;
*reg=(mark<<AFT_FIFO_MARK_32_SHIFT)|
(mark<<AFT_FIFO_MARK_64_SHIFT)|
(mark<<AFT_FIFO_MARK_128_SHIFT)|
(mark<<AFT_FIFO_MARK_256_SHIFT)|
(mark<<AFT_FIFO_MARK_512_SHIFT);
}
/*======================================================
@ -151,12 +193,50 @@ aft_wdt_ctrl_set(u8 *reg, u8 timeout)
# define AFT_LCFG_DMA_INTR_BIT 8
# define AFT_LCFG_FIFO_INTR_BIT 9
# define AFT_LCFG_SYNC_ENABLE_BIT 10
# define AFT_LCFG_TDMV_CH_NUM_MASK 0x1F
# define AFT_LCFG_TDMV_CH_NUM_SHIFT 10
# define AFT_LCFG_TDMV_INTR_BIT 15
# define AFT_LCFG_FE_CLK_ROUTE_BIT 27
# define AFT_LCFG_FE_CLK_SOURCE_MASK 0x03
# define AFT_LCFG_FE_CLK_SOURCE_SHIFT 28
# define AFT_LCFG_GREEN_LED_BIT 30
# define AFT_LCFG_RED_LED_BIT 31
static __inline void
aft_lcfg_fe_clk_source(u32 *reg, u32 src)
{
*reg&=~(AFT_LCFG_FE_CLK_SOURCE_MASK<<AFT_LCFG_FE_CLK_SOURCE_SHIFT);
*reg|=(src&AFT_LCFG_FE_CLK_SOURCE_MASK)<<AFT_LCFG_FE_CLK_SOURCE_SHIFT;
}
static __inline void
aft_lcfg_tdmv_cnt_inc(u32 *reg)
{
u32 cnt = (*reg>>AFT_LCFG_TDMV_CH_NUM_SHIFT)&AFT_LCFG_TDMV_CH_NUM_MASK;
if (cnt < 32){
cnt++;
}
*reg&=~(AFT_LCFG_TDMV_CH_NUM_MASK<<AFT_LCFG_TDMV_CH_NUM_SHIFT);
*reg|=(cnt&AFT_LCFG_TDMV_CH_NUM_MASK)<<AFT_LCFG_TDMV_CH_NUM_SHIFT;
}
static __inline void
aft_lcfg_tdmv_cnt_dec(u32 *reg)
{
u32 cnt = (*reg>>AFT_LCFG_TDMV_CH_NUM_SHIFT)&AFT_LCFG_TDMV_CH_NUM_MASK;
if (cnt > 0){
cnt--;
}
*reg&=~(AFT_LCFG_TDMV_CH_NUM_MASK<<AFT_LCFG_TDMV_CH_NUM_SHIFT);
*reg|=(cnt&AFT_LCFG_TDMV_CH_NUM_MASK)<<AFT_LCFG_TDMV_CH_NUM_SHIFT;
}
/* SS7 LCFG MODE
* 0: 128
* 1: 4096
@ -202,6 +282,8 @@ aft_lcfg_ss7_mode4096_cfg(u32 *reg, int lssu_size)
#define AFT_RX_DMA_CTRL_REG 0x208
# define AFT_DMACTRL_TDMV_RX_TOGGLE 14
# define AFT_DMACTRL_TDMV_TX_TOGGLE 15
# define AFT_DMACTRL_MAX_LOGIC_CH_SHIFT 16
# define AFT_DMACTRL_MAX_LOGIC_CH_MASK 0x1F
@ -216,7 +298,6 @@ aft_dmactrl_set_max_logic_ch(u32 *reg, int max_logic_ch)
*reg|=(max_logic_ch<<AFT_DMACTRL_MAX_LOGIC_CH_SHIFT);
}
/*======================================================
* PER PORT
*
@ -240,12 +321,14 @@ aft_dmactrl_set_max_logic_ch(u32 *reg, int max_logic_ch)
# define AFT_CTRLRAM_SS7_ENABLE_BIT 12
# define AFT_CTRLRAM_DATA_MUX_ENABLE_BIT 13
# define AFT_CTRLRAM_SS7_FORCE_RX_BIT 14
# define AFT_CTRLRAM_FIFO_SIZE_SHIFT 16
# define AFT_CTRLRAM_FIFO_SIZE_MASK 0x1F
# define AFT_CTRLRAM_FIFO_SIZE_SHIFT 16
# define AFT_CTRLRAM_FIFO_SIZE_MASK 0x1F
# define AFT_CTRLRAM_FIFO_BASE_SHIFT 24
# define AFT_CTRLRAM_FIFO_BASE_MASK 0x1F
# define AFT_CTRLRAM_FIFO_BASE_SHIFT 24
# define AFT_CTRLRAM_FIFO_BASE_MASK 0x1F
static __inline void
aft_ctrlram_set_logic_ch(u32 *reg, int logic_ch)
@ -290,9 +373,22 @@ aft_ctrlram_set_fifo_base(u32 *reg, int base)
# define AFT_DMACHAIN_FIFO_SIZE_MASK 0x1F
# define AFT_DMACHAIN_FIFO_SIZE_SHIFT 16
/* AFT_DMACHAIN_TDMV_SIZE Bit Map
* 00= 8byte size
* 01= 16byte size
* 10= 32byte size
* 11= 64byte size
*/
# define AFT_DMACHAIN_TDMV_SIZE_MASK 0x03
# define AFT_DMACHAIN_TDMV_SIZE_SHIFT 21
# define AFT_DMACHAIN_TDMV_ENABLE_BIT 23
# define AFT_DMACHAIN_FIFO_BASE_MASK 0x1F
# define AFT_DMACHAIN_FIFO_BASE_SHIFT 24
# define AFT_DMACHAIN_SS7_FORCE_RX 29
# define AFT_DMACHAIN_SS7_ENABLE_BIT 30
# define AFT_DMACHAIN_RX_SYNC_BIT 31
@ -321,6 +417,8 @@ aft_dmachain_get_rx_dma_addr(u32 reg)
reg&=AFT_DMACHAIN_RX_ADDR_CNT_MASK;
return reg;
}
static __inline void
aft_dmachain_set_rx_dma_addr(u32 *reg, int addr)
{
@ -346,6 +444,35 @@ aft_dmachain_set_fifo_base(u32 *reg, int base)
*reg|=(base<<AFT_DMACHAIN_FIFO_BASE_SHIFT);
}
static __inline void
aft_dmachain_enable_tdmv_and_mtu_size(u32 *reg, int size)
{
*reg&=~(AFT_DMACHAIN_TDMV_SIZE_MASK<<AFT_DMACHAIN_TDMV_SIZE_SHIFT);
switch(size){
case 8:
size=0x00;
break;
case 16:
size=0x01;
break;
case 32:
size=0x02;
break;
case 64:
size=0x03;
break;
default:
size=0x00;
break;
}
size&=AFT_DMACHAIN_TDMV_SIZE_MASK;
*reg|=(size<<AFT_DMACHAIN_TDMV_SIZE_SHIFT);
wan_set_bit(AFT_DMACHAIN_TDMV_ENABLE_BIT,reg);
}
/*======================================================
* PER PORT
@ -670,6 +797,20 @@ aft_set_led(unsigned int color, int led_pos, int on, u32 *reg)
}
}
static __inline int
aft_get_num_of_slots(u32 total_slots, u32 chan_slots)
{
int num_of_slots=0;
int i;
for (i=0;i<total_slots;i++){
if (wan_test_bit(i,&chan_slots)){
num_of_slots++;
}
}
return num_of_slots;
}
#endif /* WAN_KERNEL */
/*================================================================
@ -743,7 +884,8 @@ typedef struct aft_config
#if defined(__LINUX__)
enum {
SIOC_AFT_CUSTOMER_ID = SIOC_WANPIPE_DEVPRIVATE
SIOC_AFT_CUSTOMER_ID = SIOC_WANPIPE_DEVPRIVATE,
SIOC_AFT_SS7_FORCE_RX
};
#endif

View File

@ -911,6 +911,21 @@ get_current_tx_dma_ptr(u32 reg)
{
return ((reg & AFT_TE3_CRNT_TX_DMA_MASK));
}
static __inline void
set_current_rx_dma_ptr(u32 *reg, u32 val)
{
*reg &= ~AFT_TE3_CRNT_RX_DMA_MASK;
*reg |= (val << AFT_TE3_CRNT_RX_DMA_SHIFT) & AFT_TE3_CRNT_RX_DMA_MASK;
}
static __inline void
set_current_tx_dma_ptr(u32 *reg, u32 val)
{
*reg &= ~AFT_TE3_CRNT_TX_DMA_MASK;
*reg |= val & AFT_TE3_CRNT_TX_DMA_MASK;
}
#endif
/*=======================================
@ -1172,10 +1187,10 @@ typedef struct {
typedef struct wp_rx_element
{
unsigned long dma_addr;
unsigned int dma_addr;
unsigned int reg;
unsigned int align;
unsigned char pkt_error;
unsigned char pkt_error;
}wp_rx_element_t;

View File

@ -0,0 +1,579 @@
/*
***********************************************************************************
* *
* ASYAPI.H - the 'C' header file for the Sangoma S508/S514 asynchronous code API. *
* *
***********************************************************************************
*/
#ifndef _SDLA_ASYHDLC_H_
#define _SDLA_ASYHDLC_H_
#pragma pack(1)
/* ----------------------------------------------------------------------------
* Constants defining the shared memory control block (mailbox)
* --------------------------------------------------------------------------*/
#define PRI_BASE_ADDR_MB_STRUCT 0xE000 /* the base address of the mailbox structure (primary port) */
#define SEC_BASE_ADDR_MB_STRUCT 0xE800 /* the base address of the mailbox structure (secondary port) */
#define NUMBER_MB_RESERVED_BYTES 0x0B /* the number of reserved bytes in the mailbox header area */
#define SIZEOF_MB_DATA_BFR 2032 /* the size of the actual mailbox data area */
/* the control block mailbox structure */
typedef struct {
unsigned char opp_flag; /* the opp flag */
unsigned char command; /* the user command */
unsigned short buffer_length; /* the data length */
unsigned char return_code; /* the return code */
char MB_reserved[NUMBER_MB_RESERVED_BYTES]; /* reserved for later use */
char data[SIZEOF_MB_DATA_BFR]; /* the data area */
} ASY_MAILBOX_STRUCT;
/* ----------------------------------------------------------------------------
* Interface commands
* --------------------------------------------------------------------------*/
/* interface commands */
#define READ_GLOBAL_EXCEPTION_CONDITION 0x01 /* read a global exception condition from the adapter */
#define SET_GLOBAL_CONFIGURATION 0x02 /* set the global operational configuration */
#define READ_GLOBAL_CONFIGURATION 0x03 /* read the global configuration */
#define READ_GLOBAL_STATISTICS 0x04 /* retrieve the global statistics */
#define FLUSH_GLOBAL_STATISTICS 0x05 /* flush the global statistics */
#define SET_MODEM_STATUS 0x06 /* set the status of DTR and/or RTS */
#define READ_MODEM_STATUS 0x07 /* read the current status of CTS and DCD */
#define READ_COMMS_ERROR_STATS 0x08 /* read the communication error statistics */
#define FLUSH_COMMS_ERROR_STATS 0x09 /* flush the communication error statistics */
#define READ_ASY_CODE_VERSION 0x20 /* read the code version */
#define SET_ASY_INTERRUPT_TRIGGERS 0x30 /* set the application interrupt triggers */
#define READ_ASY_INTERRUPT_TRIGGERS 0x31 /* read the application interrupt trigger configuration */
#define SET_ASY_CONFIGURATION 0xE2 /* set the asychronous operational configuration */
#define READ_ASY_CONFIGURATION 0xE3 /* read the current asychronous operational configuration */
#define ENABLE_ASY_COMMUNICATIONS 0xE4 /* enable asychronous communications */
#define DISABLE_ASY_COMMUNICATIONS 0xE5 /* disable asychronous communications */
#define READ_ASY_OPERATIONAL_STATS 0xE7 /* retrieve the asychronous operational statistics */
#define FLUSH_ASY_OPERATIONAL_STATS 0xE8 /* flush the asychronous operational statistics */
#define TRANSMIT_ASY_BREAK_SIGNAL 0xEC /* transmit an asychronous break signal */
/* ----------------------------------------------------------------------------
* Return codes from interface commands
* --------------------------------------------------------------------------*/
#define OK 0x00 /* the interface command was successful */
#define COMMAND_OK 0x00 /* the interface command was successful */
/* return codes from global interface commands */
#define NO_GLOBAL_EXCEP_COND_TO_REPORT 0x01 /* there is no global exception condition to report */
#define LGTH_GLOBAL_CFG_DATA_INVALID 0x01 /* the length of the passed global configuration data is invalid */
#define IRQ_TIMEOUT_VALUE_INVALID 0x02 /* an invalid application IRQ timeout value was selected */
#define ADAPTER_OPERATING_FREQ_INVALID 0x03 /* an invalid adapter operating frequency was selected */
#define TRANSMIT_TIMEOUT_INVALID 0x04 /* the frame transmit timeout is invalid */
/* return codes from command READ_GLOBAL_EXCEPTION_CONDITION */
#define EXCEP_MODEM_STATUS_CHANGE 0x10 /* a modem status change occurred */
#define EXCEP_APP_IRQ_TIMEOUT 0x12 /* an application IRQ timeout has occurred */
#define EXCEP_ASY_BREAK_RECEIVED 0x17 /* a break sequence has been received (asynchronous mode only) */
/* return codes from interface commands */
#define xxxCOMMS_DISABLED 0x21 /* communications are not currently enabled */
#define xxxCOMMS_ENABLED 0x21 /* communications are currently enabled */
#define LGTH_INT_TRIGGERS_DATA_INVALID 0x22 /* the length of the passed interrupt trigger data is invalid */
#define INVALID_IRQ_SELECTED 0x23 /* an invalid IRQ was selected in the SET_ASY_INTERRUPT_TRIGGERS */
#define IRQ_TMR_VALUE_INVALID 0x24 /* an invalid application IRQ timer value was selected */
#define DISABLE_ASY_COMMS_BEFORE_CFG 0xE1 /* communications must be disabled before setting the configuration */
#define ASY_COMMS_ENABLED 0xE1 /* communications are currently enabled */
#define ASY_COMMS_DISABLED 0xE1 /* communications are currently disabled */
#define ASY_CFG_BEFORE_COMMS_ENABLED 0xE2 /* perform a SET_ASY_CONFIGURATION before enabling comms */
#define LGTH_ASY_CFG_DATA_INVALID 0xE2 /* the length of the passed configuration data is invalid */
#define INVALID_ASY_CFG_DATA 0xE3 /* the passed configuration data is invalid */
#define ASY_BREAK_SIGNAL_BUSY 0xEC /* a break signal is being transmitted */
#define INVALID_COMMAND 0xFF /* the defined interface command is invalid */
/* ----------------------------------------------------------------------------
* Constants for the READ_GLOBAL_EXCEPTION_CONDITION command
* --------------------------------------------------------------------------*/
/* the global exception condition structure for handling a modem status change */
typedef struct {
unsigned char modem_status_change; /* the modem status change */
} GLOBAL_EX_MODEM_STRUCT;
/* settings for the 'modem_status_change' */
#define CHANGE_IN_DCD 0x04 /* a change in DCD occured */
#define CHANGE_IN_CTS 0x10 /* a change in CTS occured */
/* ----------------------------------------------------------------------------
* Constants for the SET_GLOBAL_CONFIGURATION/READ_GLOBAL_CONFIGURATION commands
* --------------------------------------------------------------------------*/
/* the global configuration structure */
typedef struct {
unsigned short adapter_config_options; /* adapter configuration options */
unsigned short app_IRQ_timeout; /* application IRQ timeout */
unsigned long adapter_operating_frequency; /* adapter operating frequency */
unsigned short frame_transmit_timeout; /* frame transmission timeout */
} GLOBAL_CONFIGURATION_STRUCT;
/* settings for the 'adapter_config_options' */
#define ADPTR_CFG_S514 0x0001 /* S514 adapter */
/* settings for the 'app_IRQ_timeout' */
#define MAX_APP_IRQ_TIMEOUT_VALUE 5000 /* the maximum permitted IRQ timeout */
/* ----------------------------------------------------------------------------
* Constants for the READ_GLOBAL_STATISTICS command
* --------------------------------------------------------------------------*/
/* the global statistics structure */
typedef struct {
unsigned short app_IRQ_timeout_count; /* application IRQ timeout count */
unsigned short FT1_INS_alarm_count; /* FT1 in-service/alarm condition count */
} GLOBAL_STATS_STRUCT;
/* ----------------------------------------------------------------------------
* Constants for the SET_MODEM_STATUS command
* --------------------------------------------------------------------------*/
/* the set modem status structure */
typedef struct {
unsigned char output_modem_status; /* the output modem status */
} SET_MODEM_STATUS_STRUCT;
/* settings for the 'output_modem_status' */
#define SET_DTR_HIGH 0x01 /* set DTR high */
#define SET_RTS_HIGH 0x02 /* set RTS high */
/* ----------------------------------------------------------------------------
* Constants for the READ_MODEM_STATUS command
* --------------------------------------------------------------------------*/
/* the read modem status structure */
typedef struct {
unsigned char input_modem_status; /* the input modem status */
} READ_MODEM_STATUS_STRUCT;
/* settings for the 'input_modem_status' */
#define DCD_HIGH 0x08 /* DCD is high */
#define CTS_HIGH 0x20 /* CTS is high */
/* ----------------------------------------------------------------------------
* Constants for the READ_COMMS_ERROR_STATS command
* --------------------------------------------------------------------------*/
/* the communications error statistics structure */
typedef struct {
unsigned short Rx_overrun_err_count; /* receiver overrun error count */
unsigned short Rx_parity_err_count; /* receiver parity error count */
unsigned short Rx_framing_err_count; /* framing errors received count */
unsigned short DCD_state_change_count; /* DCD state change count */
unsigned short CTS_state_change_count; /* CTS state change count */
} COMMS_ERROR_STATS_STRUCT;
/* ----------------------------------------------------------------------------
* Constants for using application interrupts
* --------------------------------------------------------------------------*/
/* the structure used for the SET_ASY_INTERRUPT_TRIGGERS/READ_ASY_INTERRUPT_TRIGGERS command */
typedef struct {
unsigned char interrupt_triggers; /* interrupt trigger configuration */
unsigned char IRQ; /* IRQ to be used */
unsigned short interrupt_timer; /* interrupt timer */
unsigned short misc_interrupt_bits; /* miscellaneous interrupt bits */
} ASY_INT_TRIGGERS_STRUCT;
/* 'interrupt_triggers' bit settings */
#define APP_INT_ON_RX 0x01 /* interrupt on reception */
#define APP_INT_ON_RX_FRAME APP_INT_ON_RX
#define APP_INT_ON_TX 0x02 /* interrupt when data may be transmitted */
#define APP_INT_ON_COMMAND_COMPLETE 0x04 /* interrupt when an interface command is complete */
#define APP_INT_ON_TIMER 0x08 /* interrupt on a defined millisecond timeout */
#define APP_INT_ON_GLOBAL_EXCEP_COND 0x10 /* interrupt on a global exception condition */
/* 'interrupt_timer' limitation */
#define MAX_INTERRUPT_TIMER_VALUE 60000 /* the maximum permitted timer interrupt value */
/* interrupt types indicated at 'interrupt_type' byte of the INTERRUPT_INFORMATION_STRUCT */
#define NO_APP_INTS_PEND 0x00 /* no interrups are pending */
#define RX_APP_INT_PEND 0x01 /* a receive interrupt is pending */
#define TX_APP_INT_PEND 0x02 /* a transmit interrupt is pending */
#define COMMAND_COMPLETE_APP_INT_PEND 0x04 /* a 'command complete' interrupt is pending */
#define TIMER_APP_INT_PEND 0x08 /* a timer interrupt is pending */
#define GLOBAL_EXCEP_COND_APP_INT_PEND 0x10 /* a global exception condition interrupt is pending */
/* ----------------------------------------------------------------------------
* Constants for the SET_ASY_CONFIGURATION/READ_ASY_CONFIGURATION command
* --------------------------------------------------------------------------*/
/* the asynchronous configuration structure */
typedef struct {
unsigned long baud_rate; /* the baud rate */
unsigned short line_config_options; /* line configuration options */
unsigned short modem_config_options; /* modem configuration options */
unsigned short API_options; /* asynchronous API options */
unsigned short protocol_options; /* asynchronous protocol options */
unsigned short Tx_bits_per_char; /* number of bits per transmitted character */
unsigned short Rx_bits_per_char; /* number of bits per received character */
unsigned short stop_bits; /* number of stop bits per character */
unsigned short parity; /* parity definition */
unsigned short break_timer; /* the break signal timer */
unsigned short Rx_inter_char_timer; /* the receive inter-character timer */
unsigned short Rx_complete_length; /* the receive 'buffer complete' length */
unsigned short XON_char; /* the XON character */
unsigned short XOFF_char; /* the XOFF character */
unsigned short statistics_options; /* operational statistics options */
unsigned long ptr_shared_mem_info_struct; /* a pointer to the shared memory area information structure */
unsigned long ptr_asy_Tx_stat_el_cfg_struct; /* a pointer to the transmit status element configuration structure */
unsigned long ptr_asy_Rx_stat_el_cfg_struct; /* a pointer to the receive status element configuration structure */
} ASY_CONFIGURATION_STRUCT;
/* settings for the 'line_config_options' */
#define INTERFACE_LEVEL_V35 0x0000 /* V.35 interface level */
#define INTERFACE_LEVEL_RS232 0x0001 /* RS-232 interface level */
/* settings for the 'modem_config_options' */
#define DONT_RAISE_DTR_RTS_ON_EN_COMMS 0x0001 /* don't automatically raise DTR and RTS when performing an */
/* ENABLE_ASY_COMMUNICATIONS command */
#define DONT_REPORT_CHG_IN_MODEM_STAT 0x0002 /* don't report changes in modem status to the application */
/* settings for the 'asy_statistics_options' */
#define ASY_TX_THROUGHPUT_STAT 0x0004 /* compute the transmit throughput */
#define ASY_RX_THROUGHPUT_STAT 0x0008 /* compute the receive throughput */
/* permitted minimum and maximum values for setting the asynchronous configuration */
#define MIN_ASY_BAUD_RATE 50 /* maximum baud rate */
#define MAX_ASY_BAUD_RATE 250000 /* minimum baud rate */
#define MIN_ASY_BITS_PER_CHAR 5 /* minimum number of bits per character */
#define MAX_ASY_BITS_PER_CHAR 8 /* maximum number of bits per character */
#define MAX_BREAK_TMR_VAL 5000 /* maximum break signal timer */
#define MAX_ASY_RX_INTER_CHAR_TMR 30000 /* maximum receive inter-character timer */
#define MAX_ASY_RX_CPLT_LENGTH 2000 /* maximum receive 'length complete' value */
/* bit settings for the 'asy_API_options' */
#define ASY_RX_DATA_TRANSPARENT 0x0001 /* do not strip parity and unused bits from received characters */
/* bit settings for the 'asy_protocol_options' */
#define ASY_RTS_HS_FOR_RX 0x0001 /* RTS handshaking is used for reception control */
#define ASY_XON_XOFF_HS_FOR_RX 0x0002 /* XON/XOFF handshaking is used for reception control */
#define ASY_XON_XOFF_HS_FOR_TX 0x0004 /* XON/XOFF handshaking is used for transmission control */
#define ASY_DCD_HS_FOR_TX 0x0008 /* DCD handshaking is used for transmission control */
#define ASY_CTS_HS_FOR_TX 0x0020 /* CTS handshaking is used for transmission control */
#define ASY_HDLC_FRAMING 0x0100 /* use HDLC framing */
#define ASY_HDLC_PASS_RX_CRC_TO_APP 0x0200 /* pass received HDLC CRC bytes to the application */
#define ASY_HDLC_PASS_RX_BAD_TO_APP 0x0400 /* pass received bad frames to the application */
#define ASY_DIS_RX_WHEN_TX 0x1000 /* disable the receiver when transmitting */
/* bit settings for the 'stop_bits' definition */
#define ONE_STOP_BIT 1 /* representation for 1 stop bit */
#define TWO_STOP_BITS 2 /* representation for 2 stop bits */
#define ONE_AND_A_HALF_STOP_BITS 3 /* representation for 1.5 stop bits */
/* bit settings for the 'parity' definition */
#define NO_PARITY 0 /* representation for no parity */
#define ODD_PARITY 1 /* representation for odd parity */
#define EVEN_PARITY 2 /* representation for even parity */
/* ----------------------------------------------------------------------------
* Constants for the READ_COMMS_ERROR_STATS command (asynchronous mode)
* --------------------------------------------------------------------------*/
/* the communications error statistics structure */
typedef struct {
unsigned short Rx_overrun_err_count; /* receiver overrun error count */
unsigned short Rx_parity_err_count; /* parity errors received count */
unsigned short Rx_framing_err_count; /* framing errors received count */
unsigned short DCD_state_change_count; /* DCD state change count */
unsigned short CTS_state_change_count; /* CTS state change count */
} ASY_COMMS_ERROR_STATS_STRUCT;
/* ----------------------------------------------------------------------------
* Constants for the READ_ASY_OPERATIONAL_STATS command
* --------------------------------------------------------------------------*/
/* the asynchronous operational statistics structure */
typedef struct {
/* transmission statistics */
unsigned long blocks_Tx_count; /* number of blocks transmitted */
unsigned long bytes_Tx_count; /* number of bytes transmitted */
unsigned long Tx_throughput; /* transmit throughput */
unsigned long no_ms_for_Tx_thruput_comp; /* millisecond time used for the Tx throughput computation */
unsigned long Tx_block_discard_lgth_err_count;/* number of blocks discarded (length error) */
/* reception statistics */
unsigned long blocks_Rx_count; /* number of blocks received */
unsigned long bytes_Rx_count; /* number of bytes received */
unsigned long Rx_throughput; /* receive throughput */
unsigned long no_ms_for_Rx_thruput_comp; /* millisecond time used for the Rx throughput computation */
unsigned long Rx_bytes_discard_count; /* received Data bytes discarded */
/* handshaking protocol statistics */
unsigned short XON_chars_Tx_count; /* number of XON characters transmitted */
unsigned short XOFF_chars_Tx_count; /* number of XOFF characters transmitted */
unsigned short XON_chars_Rx_count; /* number of XON characters received */
unsigned short XOFF_chars_Rx_count; /* number of XOFF characters received */
unsigned short Tx_halt_modem_low_count; /* number of times Tx halted (modem line low) */
unsigned short Rx_halt_RTS_low_count; /* number of times Rx halted by setting RTS low */
/* break statistics */
unsigned short break_Tx_count; /* number of break sequences transmitted */
unsigned short break_Rx_count; /* number of break sequences received */
} ASY_OPERATIONAL_STATS_STRUCT;
/* ----------------------------------------------------------------------------
* Constants for data transmission
* --------------------------------------------------------------------------*/
/* the data block transmit status element configuration structure */
typedef struct {
unsigned short number_Tx_status_elements; /* number of transmit status elements */
unsigned long base_addr_Tx_status_elements; /* base address of the transmit element list */
unsigned long next_Tx_status_element_to_use; /* pointer to the next transmit element to be used */
} ASY_TX_STATUS_EL_CFG_STRUCT;
/* the data block transmit status element structure */
typedef struct {
unsigned char opp_flag; /* opp flag */
unsigned short data_length; /* length of the block to be transmitted */
unsigned char misc_bits; /* miscellaneous transmit bits */
unsigned char reserved[8]; /* reserved for internal use */
unsigned long ptr_data_bfr; /* pointer to the data area */
} ASY_DATA_TX_STATUS_EL_STRUCT;
/* ----------------------------------------------------------------------------
* Constants for data reception
* --------------------------------------------------------------------------*/
/* the data block receive status element configuration structure */
typedef struct {
unsigned short number_Rx_status_elements; /* number of receive status elements */
unsigned long base_addr_Rx_status_elements; /* base address of the receive element list */
unsigned long next_Rx_status_element_to_use; /* pointer to the next receive element to be used */
unsigned long base_addr_Rx_buffer; /* base address of the receive data buffer */
unsigned long end_addr_Rx_buffer; /* end address of the receive data buffer */
} ASY_RX_STATUS_EL_CFG_STRUCT;
/* the data block receive status element structure */
typedef struct {
unsigned char opp_flag; /* opp flag */
unsigned short data_length; /* length of the received data block */
unsigned char misc_bits; /* miscellaneous receive bits */
unsigned short time_stamp; /* receive time stamp (HDLC_STREAMING_MODE) */
unsigned short data_buffered; /* the number of data bytes still buffered */
unsigned char reserved[4]; /* reserved for internal use */
unsigned long ptr_data_bfr; /* pointer to the data area */
} ASY_DATA_RX_STATUS_EL_STRUCT;
/* settings for the 'misc_bits' */
#define RX_HDLC_FRM_ABORT 0x01 /* the incoming frame was aborted */
#define RX_HDLC_FRM_CRC_ERROR 0x02 /* the incoming frame has a CRC error */
#define RX_FRM_OVERRUN_ERROR 0x04 /* the incoming frame has an overrun error */
#define RX_HDLC_FRM_SHORT_ERROR 0x10 /* the incoming frame was too short */
#define RX_HDLC_FRM_LONG_ERROR 0x20 /* the incoming frame was too long */
/* ----------------------------------------------------------------------------
* Constants defining the shared memory information area
* --------------------------------------------------------------------------*/
/* the global information structure */
typedef struct {
unsigned char global_status; /* global status */
unsigned char modem_status; /* current modem status */
unsigned char global_excep_conditions; /* global exception conditions */
unsigned char glob_info_reserved[5]; /* reserved */
unsigned char code_name[4]; /* code name */
unsigned char code_version[4]; /* code version */
} GLOBAL_INFORMATION_STRUCT;
/* the ASY information structure */
typedef struct {
unsigned char asy_rx_avail;
unsigned char asy_info_reserved[15]; /* reserved */
} ASY_INFORMATION_STRUCT;
/* the interrupt information structure */
typedef struct {
unsigned char interrupt_type; /* type of interrupt triggered */
unsigned char interrupt_permission; /* interrupt permission mask */
unsigned char int_info_reserved[14]; /* reserved */
} INTERRUPT_INFORMATION_STRUCT;
/* the FT1 information structure */
typedef struct {
unsigned char parallel_port_A_input; /* input - parallel port A */
unsigned char parallel_port_B_input; /* input - parallel port B */
unsigned char FT1_INS_alarm_condition; /* the current FT1 in-service/alarm condition */
unsigned char FT1_info_reserved[13]; /* reserved */
} FT1_INFORMATION_STRUCT;
/* the shared memory area information structure */
typedef struct {
GLOBAL_INFORMATION_STRUCT global_info_struct; /* the global information structure */
ASY_INFORMATION_STRUCT async_info_struct; /* the asynchronous information structure */
INTERRUPT_INFORMATION_STRUCT interrupt_info_struct;/* the interrupt information structure */
FT1_INFORMATION_STRUCT FT1_info_struct; /* the FT1 information structure */
} SHARED_MEMORY_INFO_STRUCT;
#define MAX_LGTH_HDLC_FRAME 2048 /* the maximum permitted length of an HDLC frame */
/* ----------------------------------------------------------------------------
* HDLC Interface commands
* --------------------------------------------------------------------------*/
#define READ_HDLC_OPERATIONAL_STATS 0xF0 /* retrieve the HDLC operational statistics */
#define FLUSH_HDLC_OPERATIONAL_STATS 0xF1 /* flush the HDLC operational statistics */
/* the HDLC operational statistics structure (returned on READ_HDLC_OPERATIONAL_STATS command) */
typedef struct {
/* frame transmission statistics */
unsigned long frames_Tx_count; /* number of frames transmitted */
unsigned long bytes_Tx_count; /* number of bytes transmitted */
unsigned long Tx_frame_discard_lgth_err_count;/* number of frames discarded (length error) */
/* frame reception statistics */
unsigned long frames_Rx_count; /* number of frames received */
unsigned long bytes_Rx_count; /* number of bytes received */
unsigned long Rx_frame_short_count; /* received frames too short */
unsigned long Rx_frame_long_count; /* received frames too long */
unsigned long Rx_frame_discard_full_count; /* received frames discarded (buffer full) */
unsigned long CRC_error_count; /* receiver CRC error count */
unsigned long Rx_abort_count; /* abort frames received count */
} HDLC_OPERATIONAL_STATS_STRUCT;
#pragma pack()
#define UDPMGMT_SIGNATURE "CTPIPEAB"
#define UDPMGMT_SIGNATURE_LEN 8
/* UDP/IP packet (for UDP management) layout */
/*
typedef struct {
unsigned char reserved[2] PACKED;
unsigned short ip_length PACKED;
unsigned char reserved2[4] PACKED;
unsigned char ip_ttl PACKED;
unsigned char ip_protocol PACKED;
unsigned short ip_checksum PACKED;
unsigned long ip_src_address PACKED;
unsigned long ip_dst_address PACKED;
unsigned short udp_src_port PACKED;
unsigned short udp_dst_port PACKED;
unsigned short udp_length PACKED;
unsigned short udp_checksum PACKED;
udp_management_packet_t um_packet PACKED;
} ip_packet_t;
*/
/* valid ip_protocol for UDP management */
#define UDPMGMT_UDP_PROTOCOL 0x11
#if 0
typedef struct {
unsigned char status PACKED;
unsigned char data_avail PACKED;
unsigned short real_length PACKED;
unsigned short time_stamp PACKED;
unsigned char data[1] PACKED;
} trace_pkt_t;
#endif
typedef struct {
unsigned char error_flag PACKED;
unsigned short time_stamp PACKED;
unsigned char reserved[13] PACKED;
} api_rx_hdr_t;
typedef struct {
api_rx_hdr_t api_rx_hdr PACKED;
unsigned char data[1] PACKED;
} api_rx_element_t;
typedef struct {
unsigned char attr PACKED;
unsigned char misc_Tx_bits PACKED;
unsigned char reserved[14] PACKED;
} api_tx_hdr_t;
typedef struct {
api_tx_hdr_t api_tx_hdr PACKED;
unsigned char data[1] PACKED;
} api_tx_element_t;
/* Special UDP drivers management commands */
#define CPIPE_ENABLE_TRACING 0x50
#define CPIPE_DISABLE_TRACING 0x51
#define CPIPE_GET_TRACE_INFO 0x52
#define CPIPE_GET_IBA_DATA 0x53
#define CPIPE_FT1_READ_STATUS 0x54
#define CPIPE_DRIVER_STAT_IFSEND 0x55
#define CPIPE_DRIVER_STAT_INTR 0x56
#define CPIPE_DRIVER_STAT_GEN 0x57
#define CPIPE_FLUSH_DRIVER_STATS 0x58
#define CPIPE_ROUTER_UP_TIME 0x59
#if 0
#define CPIPE_MPPP_TRACE_ENABLE 0x60
#define CPIPE_MPPP_TRACE_DISABLE 0x61
#define CPIPE_TE1_56K_STAT 0x62 /* TE1_56K */
#define CPIPE_GET_MEDIA_TYPE 0x63 /* TE1_56K */
#define CPIPE_FLUSH_TE1_PMON 0x64 /* TE1 */
#define CPIPE_READ_REGISTER 0x65 /* TE1_56K */
#define CPIPE_TE1_CFG 0x66 /* TE1 */
#endif
/* Driver specific commands for API */
#define CHDLC_READ_TRACE_DATA 0xE4 /* read trace data */
#define TRACE_ALL 0x00
#define TRACE_PROT 0x01
#define TRACE_DATA 0x02
#define SIOC_ASYHDLC_RX_AVAIL_CMD SIOC_WANPIPE_DEVPRIVATE
#define SIOC_GET_HDLC_RECEIVER_STATUS SIOC_ASYHDLC_RX_AVAIL_CMD
/* Return codes for SIOC_GET_HDLC_RECEIVER_STATUS cmd */
enum {
HDLC_RX_IN_PROCESS,
NO_HDLC_RX_IN_PROCESS
};
#endif

View File

@ -50,47 +50,83 @@
#define WAN_FE_SET_LB_MODE (WAN_FE_UDP_CMD_START + 1)
#define WAN_FE_FLUSH_PMON (WAN_FE_UDP_CMD_START + 2)
#define WAN_FE_GET_CFG (WAN_FE_UDP_CMD_START + 3)
#define WAN_FE_SET_DEBUG_MODE (WAN_FE_UDP_CMD_START + 4)
#define WAN_FE_TX_MODE (WAN_FE_UDP_CMD_START + 5)
#define IS_T1_MEDIA(media) ((media) == WAN_MEDIA_T1)
#define IS_E1_MEDIA(media) ((media) == WAN_MEDIA_E1)
#define IS_J1_MEDIA(media) ((media) == WAN_MEDIA_J1)
#define IS_TE1_MEDIA(media) ((media) == WAN_MEDIA_T1 || \
(media) == WAN_MEDIA_E1 || \
(media) == WAN_MEDIA_J1)
#define IS_56K_MEDIA(media) ((media) == WAN_MEDIA_56K)
#define IS_TE1_56K_MEDIA(media) ((media) == WAN_MEDIA_T1 || \
(media) == WAN_MEDIA_E1 || \
(media) == WAN_MEDIA_J1 || \
(media) == WAN_MEDIA_56K)
#define IS_DS3_MEDIA(media) ((media) == WAN_MEDIA_DS3)
#define IS_E3_MEDIA(media) ((media) == WAN_MEDIA_E3)
/* Front-End DEBUG flags */
#define WAN_FE_DEBUG_RBS_RX_ENABLE 0x01
#define WAN_FE_DEBUG_RBS_TX_ENABLE 0x02
#define WAN_FE_DEBUG_RBS_RX_DISABLE 0x04
#define WAN_FE_DEBUG_RBS_TX_DISABLE 0x08
#define WAN_FE_DEBUG_RBS_READ 0x10
#define IS_TE1_56K(te_cfg) ((te_cfg).media == WAN_MEDIA_T1 || \
(te_cfg).media == WAN_MEDIA_E1 || \
(te_cfg).media == WAN_MEDIA_J1 || \
(te_cfg).media == WAN_MEDIA_56K)?1:0
#define WAN_FE_DEBUG_ALARM_AIS_ENABLE 0x01
#define WAN_FE_DEBUG_ALARM_AIS_DISABLE 0x02
#define MEDIA_DECODE(media) ((media) == WAN_MEDIA_T1) ? "T1" : \
((media) == WAN_MEDIA_E1) ? "E1" : \
((media) == WAN_MEDIA_J1) ? "J1" : \
((media) == WAN_MEDIA_56K) ? "56K" : \
((media) == WAN_MEDIA_DS3) ? "DS3" : \
((media) == WAN_MEDIA_E3) ? "E3" : "Unknown"
#define WAN_FE_DEBUG_NONE 0x00
#define WAN_FE_DEBUG_RBS 0x01
#define WAN_FE_DEBUG_ALARM 0x02
#define LCODE_DECODE(lcode) ((lcode) == WAN_LCODE_AMI) ? "AMI" : \
((lcode) == WAN_LCODE_B8ZS) ? "B8ZS" : \
((lcode) == WAN_LCODE_HDB3) ? "HDB3" : \
((lcode) == WAN_LCODE_B3ZS) ? "B3ZS" : "Unknown"
/* Front-End TX tri-state mode flags */
#define WAN_FE_TXMODE_ENABLE 0x01
#define WAN_FE_TXMODE_DISABLE 0x02
/* Read alarm flag */
#define WAN_FE_ALARM_NONE 0x00
#define WAN_FE_ALARM_READ 0x01
#define WAN_FE_ALARM_PRINT 0x02
#define IS_FE_ALARM_READ(action) ((action) & WAN_FE_ALARM_READ)
#define IS_FE_ALARM_PRINT(action) ((action) & WAN_FE_ALARM_PRINT)
#define FE_MEDIA(fe_cfg) ((fe_cfg)->media)
#define FE_SUBMEDIA(fe_cfg) ((fe_cfg)->sub_media)
#define FE_LCODE(fe_cfg) ((fe_cfg)->lcode)
#define FE_FRAME(fe_cfg) ((fe_cfg)->frame)
#define FE_LINENO(fe_cfg) ((fe_cfg)->line_no)
#define FE_TXTRISTATE(fe_cfg) ((fe_cfg)->tx_tristate_mode)
#define IS_T1_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_T1)
#define IS_E1_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_E1)
#define IS_J1_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_T1 && \
FE_SUBMEDIA(fe_cfg) == WAN_MEDIA_J1)
#define IS_TE1_MEDIA(fe_cfg) (IS_T1_MEDIA(fe_cfg) || \
IS_E1_MEDIA(fe_cfg) || \
IS_J1_MEDIA(fe_cfg))
#define IS_56K_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_56K)
#define IS_TE1_56K_MEDIA(fe_cfg)(IS_TE1_MEDIA(fe_cfg) || \
IS_56K_MEDIA(fe_cfg)
#define IS_DS3_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_DS3)
#define IS_E3_MEDIA(fe_cfg) (FE_MEDIA(fe_cfg) == WAN_MEDIA_E3)
#define IS_TXTRISTATE(fe_cfg) (FE_TXTRISTATE(fe_cfg) == WANOPT_YES)
#define MEDIA_DECODE(fe_cfg) \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_T1 && \
FE_SUBMEDIA(fe_cfg)==WAN_MEDIA_J1)?"J1" :\
(FE_MEDIA(fe_cfg) == WAN_MEDIA_T1) ? "T1" : \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_E1) ? "E1" : \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_J1) ? "J1" : \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_56K) ? "56K" : \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_DS3) ? "DS3" : \
(FE_MEDIA(fe_cfg) == WAN_MEDIA_E3) ? "E3" : "Unknown"
#define LCODE_DECODE(fe_cfg) \
(FE_LCODE(fe_cfg) == WAN_LCODE_AMI) ? "AMI" : \
(FE_LCODE(fe_cfg) == WAN_LCODE_B8ZS) ? "B8ZS" : \
(FE_LCODE(fe_cfg) == WAN_LCODE_HDB3) ? "HDB3" : \
(FE_LCODE(fe_cfg) == WAN_LCODE_B3ZS) ? "B3ZS" : "Unknown"
#define FRAME_DECODE(fe_cfg) \
(FE_FRAME(fe_cfg) == WAN_FR_ESF) ? "ESF" : \
(FE_FRAME(fe_cfg) == WAN_FR_D4) ? "D4" : \
(FE_FRAME(fe_cfg) == WAN_FR_CRC4) ? "CRC4" : \
(FE_FRAME(fe_cfg) == WAN_FR_NCRC4) ? "non-CRC4" : \
(FE_FRAME(fe_cfg) == WAN_FR_UNFRAMED) ? "Unframed" : \
(FE_FRAME(fe_cfg) == WAN_FR_E3_G751) ? "G.751" : \
(FE_FRAME(fe_cfg) == WAN_FR_E3_G832) ? "G.832" : \
(FE_FRAME(fe_cfg) == WAN_FR_DS3_Cbit) ? "C-bit" : \
(FE_FRAME(fe_cfg) == WAN_FR_DS3_M13) ? "M13" : "Unknown"
#define FRAME_DECODE(frame) ((frame) == WAN_FR_ESF) ? "ESF" : \
((frame) == WAN_FR_D4) ? "D4" : \
((frame) == WAN_FR_CRC4) ? "CRC4" : \
((frame) == WAN_FR_NCRC4) ? "non-CRC4" : \
((frame) == WAN_FR_UNFRAMED) ? "Unframed" : \
((frame) == WAN_FR_E3_G751) ? "G.751" : \
((frame) == WAN_FR_E3_G832) ? "G.832" : \
((frame) == WAN_FR_DS3_Cbit) ? "C-bit" : \
((frame) == WAN_FR_DS3_M13) ? "M13" : "Unknown"
/* front-end configuration and access interface commands */
@ -106,6 +142,7 @@ typedef struct {
unsigned char lcode;
unsigned char frame;
unsigned int line_no;
unsigned char tx_tristate_mode;
union {
sdla_te_cfg_t te_cfg;
sdla_te3_cfg_t te3_cfg;
@ -129,6 +166,23 @@ typedef struct {
#define WAN_FECALL(dev, func, x) \
((dev)->fe_iface.func) ? (dev)->fe_iface.func x : -EINVAL
#define IS_T1_FEMEDIA(fe) IS_T1_MEDIA(&((fe)->fe_cfg))
#define IS_E1_FEMEDIA(fe) IS_E1_MEDIA(&((fe)->fe_cfg))
#define IS_TE1_FEMEDIA(fe) IS_TE1_MEDIA(&((fe)->fe_cfg))
#define IS_56K_FEMEDIA(fe) IS_56K_MEDIA(&((fe)->fe_cfg))
#define IS_J1_FEMEDIA(fe) IS_J1_MEDIA(&((fe)->fe_cfg))
#define IS_FE_TXTRISTATE(fe) IS_TXTRISTATE(&((fe)->fe_cfg))
#define WAN_FE_MEDIA(fe) FE_MEDIA(&((fe)->fe_cfg))
#define WAN_FE_LCODE(fe) FE_LCODE(&((fe)->fe_cfg))
#define WAN_FE_FRAME(fe) FE_FRAME(&((fe)->fe_cfg))
#define WAN_FE_LINENO(fe) FE_LINENO(&((fe)->fe_cfg))
#define WAN_FE_TXTRISTATE(fe) FE_TXTRISTATE(&((fe)->fe_cfg))
#define FE_MEDIA_DECODE(fe) MEDIA_DECODE(&((fe)->fe_cfg))
#define FE_LCODE_DECODE(fe) LCODE_DECODE(&((fe)->fe_cfg))
#define FE_FRAME_DECODE(fe) FRAME_DECODE(&((fe)->fe_cfg))
/* Front-End status */
#if 0
enum fe_status {
@ -178,14 +232,27 @@ enum fe_status {
#define READ_REG(reg) card->wandev.read_front_end_reg(card, reg)
#define WRITE_REG(reg, value) card->wandev.write_front_end_reg(card, reg, (unsigned char)(value))
#endif
#define WRITE_REG(reg,val) \
fe->write_fe_reg(fe->card, reg + (fe->fe_cfg.line_no*PMC4_LINE_DELTA), (unsigned char)val)
#define WRITE_REG_LINE(fe_line_no, reg,val) \
fe->write_fe_reg(fe->card, reg + fe_line_no*PMC4_LINE_DELTA, (unsigned char)val)
#define READ_REG(reg) \
fe->read_fe_reg(fe->card, reg + (fe->fe_cfg.line_no*PMC4_LINE_DELTA))
#define READ_REG_LINE(fe_line_no, reg) \
fe->read_fe_reg(fe->card, reg + fe_line_no*PMC4_LINE_DELTA)
#define WRITE_REG(reg,val) \
fe->write_fe_reg( \
fe->card, \
(unsigned short)((reg) + (fe->fe_cfg.line_no*PMC4_LINE_DELTA)), \
(unsigned char)(val))
#define WRITE_REG_LINE(fe_line_no, reg,val) \
fe->write_fe_reg( \
fe->card, \
(unsigned short)((reg) + (fe_line_no)*PMC4_LINE_DELTA), \
(unsigned char)(val))
#define READ_REG(reg) \
fe->read_fe_reg( \
fe->card, \
(unsigned short)((reg) + (fe->fe_cfg.line_no*PMC4_LINE_DELTA)))
#define READ_REG_LINE(fe_line_no, reg) \
fe->read_fe_reg( \
fe->card, \
(unsigned short)((reg) + (fe_line_no)*PMC4_LINE_DELTA))
/* the structure used for the SET_FE_RX_DISC_TX_IDLE_CFG/READ_FE_RX_DISC_TX_IDLE_CFG command */
#pragma pack(1)
@ -274,6 +341,8 @@ typedef struct {
/* FIXME: Remove the following parameters from wandev_t */
unsigned char fe_status;
unsigned long fe_alarm;
unsigned char fe_chip_id;
unsigned char fe_debug;
/* ^^^ */
union {
sdla_te_param_t te_param;
@ -314,13 +383,13 @@ typedef struct {
int (*polling)(sdla_fe_t *fe);
int (*isr)(sdla_fe_t *fe);
int (*process_udp)(sdla_fe_t *fe, void*, unsigned char*);
unsigned long (*read_alarm)(sdla_fe_t *fe, int);
unsigned long (*read_alarm)(sdla_fe_t *fe, int);
int (*read_pmon)(sdla_fe_t *fe);
int (*flush_pmon)(sdla_fe_t *fe);
/* Set Front-End alarm (T1/E1) */
int (*set_fe_alarm)(sdla_fe_t *fe, unsigned long);
/* Set extra interrupt type (after link get connected)) */
int (*set_fe_sigcfg)(sdla_fe_t*, unsigned long);
int (*set_fe_sigctrl)(sdla_fe_t*, int);
/* Print Front-End alarm (T1/E1/56K) */
char* (*print_fe_act_channels)(sdla_fe_t*);
/* Print Front-End alarm (T1/E1/56K) */
@ -339,14 +408,24 @@ typedef struct {
int (*update_pmon_info)(sdla_fe_t*, struct seq_file* m, int* stop_cnt);
/* AFT T1/E1 cards only */
int (*led_ctrl)(sdla_fe_t*, int mode);
/* Check RBS bits (T1/E1 cards) */
int (*check_rbsbits)(sdla_fe_t*, int, unsigned long, int);
/* Read RBS bits (T1/E1 cards) */
int (*read_rbsbits)(sdla_fe_t*, int);
unsigned char (*read_rbsbits)(sdla_fe_t*, int, int);
/* Set RBS bits (T1/E1 cards, voice) */
int (*set_rbsbits)(sdla_fe_t*, int, unsigned char);
/* Report RBS bits (T1/E1 cards) */
int (*report_rbsbits)(sdla_fe_t*);
/* Get Front-End SNMP data */
int (*get_snmp_data)(sdla_fe_t*, void*, void*);
/* Check if the interrupt is for this port */
int (*check_isr)(sdla_fe_t *fe);
#if defined(__WINDOWS__)
/* Enable TE1 poll timer (WINDOWS ONLY) */
void (*enable_timer)(sdla_fe_t*, unsigned char, unsigned long);
#endif
/* Set extra T1/E1 configuration */
int (*post_config)(sdla_fe_t*);
} sdla_fe_iface_t;
#endif /* WAN_KERNEL */

View File

@ -0,0 +1,92 @@
/*******************************************************************************
** sdla_remora.h
**
** Author: Alex Feldman <al.feldman@sangoma.com>
**
** Copyright: (c) 2005 Sangoma Technologies Inc.
**
** 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.
** ============================================================================
** Oct 6, 2005 Alex Feldman Initial version.
*******************************************************************************/
#ifndef __SDLA_REMORA_H
# define __SDLA_REMORA_H
#ifdef __SDLA_REMORA_SRC
# define EXTERN
#else
# define EXTERN extern
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# include <net/sdla_remora_proslic.h>
#else
# include <linux/sdla_remora_proslic.h>
#endif
/*******************************************************************************
** DEFINES and MACROS
*******************************************************************************/
#define FXOFXS_CHANNEL_RANGE(fe) 16
/*******************************************************************************
** TYPEDEF STRUCTURE
*******************************************************************************/
typedef struct sdla_remora_cfg_ {
int not_used;
int fxo_opermode;
// int tdmv_law; /* WAN_TDMV_ALAW or WAN_TDMV_MULAW */
int reversepolarity;
} sdla_remora_cfg_t;
#if defined(WAN_KERNEL)
#define MAX_REMORA_MODULES 16
enum proslic_power_warn {
PROSLIC_POWER_UNKNOWN = 0,
PROSLIC_POWER_ON,
PROSLIC_POWER_WARNED,
};
typedef struct {
int ready;
} fxo_t;
typedef struct {
int ready;
int idletxhookstate;
enum proslic_power_warn proslic_power;
} fxs_t;
typedef struct sdla_remora_param {
int not_used;
union {
fxo_t fxo;
fxs_t fxs;
} mod[MAX_REMORA_MODULES];
int type[MAX_REMORA_MODULES];
int chain[MAX_REMORA_MODULES];
unsigned long module_map; /* Map of available module */
} sdla_remora_param_t;
#endif /* WAN_KERNEL */
/*******************************************************************************
** FUNCTION PROTOTYPES
*******************************************************************************/
extern int wp_remora_config(void *, void*);
extern int wp_remora_unconfig(void *);
#undef EXTERN
#endif /* __SDLA_REMORA_H */

View File

@ -0,0 +1,190 @@
// ProSlic Header File
typedef struct {
unsigned char address;
unsigned char altaddr;
char *name;
unsigned short initial;
} alpha;
typedef struct {
unsigned char chip_number;
unsigned char DTMF_digit;
unsigned char interrupt_line;
unsigned char hook_status;
unsigned long half_pulses[20]; // Contains the time stamps of incomming half pulses.
unsigned char half_pulses_detected; // Contains the number of half pulses detected.
unsigned char Pulse_digit;
unsigned long On_Hook_time;
unsigned long Off_Hook_time;
} chipStruct;
// Defines
#define LPT 0X378
#define IDA_LO 28
#define IDA_HI 29
#define IAA 30
#define ID_ACCES_STATUS 31
#define IAS_BIT 1
#define I_STATUS 31
#define SPI_MODE 0
#define PCM_MODE 1
#define PCM_XMIT_START_COUNT_LSB 2
#define PCM_XMIT_START_COUNT_MSB 3
#define PCM_RCV_START_COUNT_LSB 4
#define PCM_RCV_START_COUNT_MSB 5
#define DIO 6
#define AUDIO_LOOPBACK 8
#define AUDIO_GAIN 9
#define LINE_IMPEDANCE 10
#define HYBRID 11
#define RESERVED12 12
#define RESERVED13 13
#define PWR_DOWN1 14
#define PWR_DOWN2 15
#define RESERVED16 16
#define RESERVED17 17
#define INTRPT_STATUS1 18
#define INTRPT_STATUS2 19
#define INTRPT_STATUS3 20
#define INTRPT_MASK1 21
#define INTRPT_MASK2 22
#define INTRPT_MASK3 23
#define DTMF_DIGIT 24
#define RESERVED25 25
#define RESERVED26 26
#define RESERVED27 27
#define I_DATA_LOW 28
#define I_DATA_HIGH 29
#define I_ADDRESS 30
#define I_STATUS 31
#define OSC1 32
#define OSC2 33
#define RING_OSC_CTL 34
#define PULSE_OSC 35
#define OSC1_ON__LO 36
#define OSC1_ON_HI 37
#define OSC1_OFF_LO 38
#define OSC1_OFF_HI 39
#define OSC2_ON__LO 40
#define OSC2_ON_HI 41
#define OSC2_OFF_LO 42
#define OSC2_OFF_HI 43
#define PULSE_ON__LO 44
#define PULSE_ON_HI 45
#define PULSE_OFF_LO 46
#define PULSE_OFF_HI 47
#define RING_ON__LO 48
#define RING_ON_HI 49
#define RING_OFF_LO 50
#define RING_OFF_HI 51
#define RESERVED52 52
#define RESERVED53 53
#define RESERVED54 54
#define RESERVED55 55
#define RESERVED56 56
#define RESERVED57 57
#define RESERVED58 58
#define RESERVED59 59
#define RESERVED60 60
#define RESERVED61 61
#define RESERVED62 62
#define RESERVED63 63
#define LINE_STATE 64
#define ACTIVATE_LINE 0x11
#define RING_LINE 0x44
#define BIAS_SQUELCH 65
#define BAT_FEED 66
#define AUTO_STATE 67
#define LOOP_STAT 68
#define LOOP_DEBOUCE 69
#define RT_DEBOUCE 70
#define LOOP_I_LIMIT 71
#define OFF_HOOK_V 72
#define COMMON_V 73
#define BAT_V_HI 74
#define BAT_V_LO 75
#define PWR_STAT_DEV 76
#define PWR_STAT 77
#define LOOP_V_SENSE 78
#define LOOP_I_SENSE 79
#define TIP_V_SENSE 80
#define RING_V_SENSE 81
#define BAT_V_HI_SENSE 82
#define BAT_V_LO_SENSE 83
#define IQ1 84
#define IQ2 85
#define IQ3 86
#define IQ4 87
#define IQ5 88
#define IQ6 89
#define RESERVED90 90
#define RESERVED91 91
#define DCDC_PWM_OFF 92
#define DCDC 93
#define DCDC_PW_OFF 94
#define RESERVED95 95
#define CALIBR1 96
#define CALIBRATE_LINE 0x78
#define NORMAL_CALIBRATION_COMPLETE 0x20
#define CALIBR2 97
#define RING_GAIN_CAL 98
#define TIP_GAIN_CAL 99
#define DIFF_I_CAL 100
#define COMMON_I_CAL 101
#define I_LIMIT_GAIN_CAL 102
#define ADC_OFFSET_CAL 103
#define DAC_ADC_OFFSET 104
#define DAC_OFFSET_CAL 105
#define COMMON_BAL_CAL 106
#define DC_PEAK_CAL 107
// Indirect Register (decimal)
#define DTMF_ROW_0_PEAK 0
#define DTMF_ROW_1_PEAK 1
#define DTMF_ROW2_PEAK 2
#define DTMF_ROW3_PEAK 3
#define DTMF_COL1_PEAK 4
#define DTMF_FWD_TWIST 5
#define DTMF_RVS_TWIST 6
#define DTMF_ROW_RATIO_THRESH 7
#define DTMF_COL_RATIO_THRESH 8
#define DTMF_ROW_2ND_HARM 9
#define DTMF_COL_2ND_HARM 10
#define DTMF_PWR_MIN_THRESH 11
#define DTMF_HOT_LIM_THRESH 12
#define OSC1_COEF 13
#define OSC1X 14
#define OSC1Y 15
#define OSC2_COEF 16
#define OSC2X 17
#define OSC2Y 18
#define RING_V_OFF 19
#define RING_OSC_COEF 20
#define RING_X 21
#define RING_Y 22
#define PULSE_ENVEL 23
#define PULSE_X 24
#define PULSE_Y 25
#define RECV_DIGITAL_GAIN 26
#define XMIT_DIGITAL_GAIN 27
#define LOOP_CLOSE_THRESH 28
#define RING_TRIP_THRESH 29
#define COMMON_MIN_THRESH 30
#define COMMON_MAX_THRESH 31
#define PWR_ALARM_Q1Q2 32
#define PWR_ALARM_Q3Q4 33
#define PWR_ALARM_Q5Q6 34
#define LOOP_CLOSURE_FILTER 35
#define RING_TRIP_FILTER 36
#define THERM_LP_POLE_Q1Q2 37
#define THERM_LP_POLE_Q3Q4 38
#define THERM_LP_POLE_Q5Q6 39
#define CM_BIAS_RINGING 40
#define DCDC_MIN_V 41
#define DCDC_XTRA 42

View File

@ -22,6 +22,7 @@
# define EXTERN extern
#endif
#include <linux/wanpipe_edac_iface.h>
/*
*******************************************************************************
@ -35,11 +36,17 @@
** TYPEDEF STRUCTURE
*******************************************************************************
*/
typedef struct wan_tdmv_ {
void *sc;
int max_tx_len;
int max_timeslots;
int brt_enable;
int spanno;
wan_tdmv_rxtx_pwr_t chan_pwr[31];
WAN_LIST_ENTRY(wan_tdmv_) next;
} wan_tdmv_t;
/*
@ -47,15 +54,40 @@ typedef struct wan_tdmv_ {
** FUNCTION PROTOTYPES
*******************************************************************************
*/
EXTERN int wp_tdmv_check_mtu(void*, unsigned long);
EXTERN int wp_tdmv_init(void*, wanif_conf_t*);
EXTERN int wp_tdmv_check_mtu(void*, unsigned long);
EXTERN int wp_tdmv_init(void*, wanif_conf_t*);
EXTERN void wp_tdmv_free(wan_tdmv_t*);
EXTERN int wp_tdmv_remove(void*);
EXTERN int wp_tdmv_running(void*);
EXTERN int wp_tdmv_software_init(wan_tdmv_t*);
EXTERN void wp_tdmv_state(void*, int);
EXTERN int wp_tdmv_rx_tx(void*, netskb_t*);
EXTERN int wp_tdmv_running(void*);
EXTERN int wp_tdmv_rx_tx(void*, netskb_t*);
EXTERN void wp_tdmv_report_rbsbits(void*, int, unsigned char);
EXTERN void wp_tdmv_report_alarms(void*, unsigned long);
EXTERN int wp_tdmv_create(void* pcard, wandev_conf_t *conf);
EXTERN int wp_tdmv_reg(void*, wanif_conf_t*, netdevice_t*);
EXTERN int wp_tdmv_unreg(void* pcard, unsigned long ts_map);
EXTERN int wp_tdmv_remove(void* pcard);
EXTERN int wp_tdmv_rx_chan(wan_tdmv_t *wan_tdmv, int channo,
unsigned char *rxbuf, unsigned char *txbuf);
#if defined(CONFIG_PRODUCT_WANPIPE_TDM_VOICE_DCHAN)
EXTERN int wp_tdmv_rx_dchan(wan_tdmv_t *wan_tdmv, int channo,
unsigned char *rxbuf, unsigned int len);
#endif
EXTERN int wp_tdmv_rx_tx_span(void *pcard);
#ifdef CONFIG_PRODUCT_WANPIPE_TDM_VOICE_ECHOMASTER
EXTERN int wp_tdmv_echo_check(wan_tdmv_t *wan_tdmv, void *current_ztchan, int channo);
#endif
EXTERN int wanpipe_codec_convert_2s(u8 *data, int len, netskb_t *nskb,
u16 *power_ptr, int is_alaw);
EXTERN int wanpipe_codec_convert_s2ulaw(netskb_t *skb, netskb_t *nskb, int is_alaw);
EXTERN int wp_tdmv_is_rbsbits(wan_tdmv_t *);
EXTERN int wp_tdmv_rbsbits_poll(wan_tdmv_t *, void*);
#undef EXTERN
#endif /* __SDLA_VOIP_H */

View File

@ -29,7 +29,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: sdla_te1.h,v 1.17 2005/01/24 20:16:42 sangoma Exp $
* $Id: sdla_te1.h,v 1.29 2005/09/08 17:30:53 sangoma Exp $
*/
/*****************************************************************************
@ -75,6 +75,9 @@
#define E1_FRAMING_TIMESLOT 0
#define E1_SIGNALING_TIMESLOT 16
#define WAN_TE_SIG_POLL 0x01
#define WAN_TE_SIG_INTR 0x02
/* Alram bit mask */
#define WAN_TE_BIT_ALOS_ALARM 0x0001
#define WAN_TE_BIT_LOS_ALARM 0x0002
@ -100,20 +103,24 @@
#define lcv pmon4 /* E1/T1 */
/* For T1 only */
#define WAN_T1_LBO_0_DB 0x01
#define WAN_T1_LBO_75_DB 0x02
#define WAN_T1_LBO_15_DB 0x03
#define WAN_T1_LBO_225_DB 0x04
#define WAN_T1_0_110 0x05
#define WAN_T1_110_220 0x06
#define WAN_T1_220_330 0x07
#define WAN_T1_330_440 0x08
#define WAN_T1_440_550 0x09
#define WAN_T1_550_660 0x0A
#define WAN_T1_LBO_0_DB 0x01
#define WAN_T1_LBO_75_DB 0x02
#define WAN_T1_LBO_15_DB 0x03
#define WAN_T1_LBO_225_DB 0x04
#define WAN_T1_0_110 0x05
#define WAN_T1_110_220 0x06
#define WAN_T1_220_330 0x07
#define WAN_T1_330_440 0x08
#define WAN_T1_440_550 0x09
#define WAN_T1_550_660 0x0A
/* For E1 only */
#define WAN_E1_120 0x0B
#define WAN_E1_75 0x0C
#define WAN_E1_120 0x0B
#define WAN_E1_75 0x0C
/* For T1 only (long or short haul) */
#define WAN_T1_LONG_HAUL 0x01
#define WAN_T1_SHORT_HAUL 0x02
/* Line loopback modes */
#define WAN_TE1_LINELB_MODE 0x01
@ -125,6 +132,17 @@
#define WAN_TE1_ACTIVATE_LB 0x01
#define WAN_TE1_DEACTIVATE_LB 0x02
/* T1/E1 front end Master clock source */
#define WAN_TE1_REFCLK_OSC 0x00
#define WAN_TE1_REFCLK_LINE1 0x01
#define WAN_TE1_REFCLK_LINE2 0x02
#define WAN_TE1_REFCLK_LINE3 0x03
#define WAN_TE1_REFCLK_LINE4 0x04
/* E1 signalling insertion mode */
#define WAN_TE1_SIG_CCS 0x00 /* default */
#define WAN_TE1_SIG_CAS 0x01
/* Loopback commands (T1.107-1995 p.44) */
#define LINELB_TE1_TIMER 40 /* 40ms */
#define LINELB_CODE_CNT 10 /* no. of repetitions for lb_code */
@ -161,6 +179,7 @@
#define LINELB_DS1LINE_27 0x3B
#define LINELB_DS1LINE_28 0x3C
#define LINELB_DS1LINE_ALL 0x13
#define LINELB_DS1LINE_DISABLE 0x3F
#define LINELB_DS1LINE_MASK 0x1F
/* Interrupt polling delay */
@ -186,22 +205,29 @@
#define TE_LINELB_TIMER 0x01
#define TE_LINKDOWN_TIMER 0x02
#define TE_SET_INTR 0x03
#define TE_ABCD_UPDATE 0x04
#define TE_RBS_READ 0x04
#define TE_LINKUP_TIMER 0x05
/* TE1 T1/E1 interrupt setting delay */
#define INTR_TE1_TIMER 150 /* 50 ms */
#define IS_T1_CARD(card) IS_T1_MEDIA(card->fe.fe_cfg.media)
#define IS_E1_CARD(card) IS_E1_MEDIA(card->fe.fe_cfg.media)
#define IS_TE1_CARD(card) IS_TE1_MEDIA(card->fe.fe_cfg.media)
#define IS_T1_CARD(card) IS_T1_FEMEDIA(&(card)->fe)
#define IS_E1_CARD(card) IS_E1_FEMEDIA(&(card)->fe)
#define IS_TE1_CARD(card) IS_TE1_FEMEDIA(&(card)->fe)
#define FE_LBO(fe_cfg) (fe_cfg)->cfg.te_cfg.lbo
#define FE_CLK(fe_cfg) (fe_cfg)->cfg.te_cfg.te_clock
#define FE_REFCLK(fe_cfg) (fe_cfg)->cfg.te_cfg.te_ref_clock
#define HIMPEDANCE_MODE(fe_cfg) (fe_cfg)->cfg.te_cfg.high_impedance_mode
#define FE_ACTIVE_CH(fe_cfg) (fe_cfg)->cfg.te_cfg.active_ch
#define FE_SIG_MODE(fe_cfg) (fe_cfg)->cfg.te_cfg.sig_mode
#define IS_TE1_UNFRAMED(fe) \
(((sdla_fe_t*)(fe))->fe_cfg.frame == WAN_FR_UNFRAMED)
#define GET_TE_CHANNEL_RANGE(fe) \
(IS_T1_MEDIA(((sdla_fe_t*)(fe))->fe_cfg.media) ? NUM_OF_T1_CHANNELS :\
IS_E1_MEDIA(((sdla_fe_t*)(fe))->fe_cfg.media) ? NUM_OF_E1_CHANNELS :0)
(IS_T1_FEMEDIA(fe) ? NUM_OF_T1_CHANNELS :\
IS_E1_FEMEDIA(fe) ? NUM_OF_E1_CHANNELS :0)
#define WAN_TE_ALARM(alarm, bit) ((alarm) & (bit)) ? "ON" : "OFF"
@ -217,21 +243,21 @@
#define WAN_TE_RAI_ALARM(alarm) WAN_TE_ALARM(alarm, WAN_TE_BIT_RAI_ALARM)
#define WAN_TE_YEL_ALARM(alarm) WAN_TE_ALARM(alarm, WAN_TE_BIT_YEL_ALARM)
#define TECLK_DECODE(val) \
(val == WAN_NORMAL_CLK) ? "Normal" : \
(val == WAN_MASTER_CLK) ? "Master" : "Unknown"
#define TECLK_DECODE(fe_cfg) \
(FE_CLK(fe_cfg) == WAN_NORMAL_CLK) ? "Normal" : \
(FE_CLK(fe_cfg) == WAN_MASTER_CLK) ? "Master" : "Unknown"
#define LBO_DECODE(val) \
(val == WAN_T1_LBO_0_DB) ? "0db" : \
(val == WAN_T1_LBO_75_DB) ? "7.5db" : \
(val == WAN_T1_LBO_15_DB) ? "15dB" : \
(val == WAN_T1_LBO_225_DB) ? "22.5dB" : \
(val == WAN_T1_0_110) ? "0-110ft" : \
(val == WAN_T1_110_220) ? "110-220ft" : \
(val == WAN_T1_220_330) ? "220-330ft" : \
(val == WAN_T1_330_440) ? "330-440ft" : \
(val == WAN_T1_440_550) ? "440-550ft" : \
(val == WAN_T1_550_660) ? "550-660ft" : "Unknown"
#define LBO_DECODE(fe_cfg) \
(FE_LBO(fe_cfg) == WAN_T1_LBO_0_DB) ? "0db" : \
(FE_LBO(fe_cfg) == WAN_T1_LBO_75_DB) ? "7.5db" : \
(FE_LBO(fe_cfg) == WAN_T1_LBO_15_DB) ? "15dB" : \
(FE_LBO(fe_cfg) == WAN_T1_LBO_225_DB) ? "22.5dB" : \
(FE_LBO(fe_cfg) == WAN_T1_0_110) ? "0-110ft" : \
(FE_LBO(fe_cfg) == WAN_T1_110_220) ? "110-220ft" : \
(FE_LBO(fe_cfg) == WAN_T1_220_330) ? "220-330ft" : \
(FE_LBO(fe_cfg) == WAN_T1_330_440) ? "330-440ft" : \
(FE_LBO(fe_cfg) == WAN_T1_440_550) ? "440-550ft" : \
(FE_LBO(fe_cfg) == WAN_T1_550_660) ? "550-660ft" : "Unknown"
/*----------------------------------------------------------------------------
@ -243,6 +269,8 @@ typedef struct sdla_te_cfg {
unsigned long active_ch;
unsigned long te_rbs_ch;
unsigned char high_impedance_mode;
unsigned char te_ref_clock;
unsigned char sig_mode;
} sdla_te_cfg_t;
/* Performamce monitor counters */
@ -262,6 +290,15 @@ typedef struct {
#ifdef WAN_KERNEL
#define WAN_TE1_LBO(fe) FE_LBO(&((fe)->fe_cfg))
#define WAN_TE1_CLK(fe) FE_CLK(&((fe)->fe_cfg))
#define WAN_TE1_REFCLK(fe) FE_REFCLK(&((fe)->fe_cfg))
#define WAN_TE1_HI_MODE(fe) HIMPEDANCE_MODE(&((fe)->fe_cfg))
#define WAN_TE1_ACTIVE_CH(fe) FE_ACTIVE_CH(&((fe)->fe_cfg))
#define WAN_TE1_SIG_MODE(fe) FE_SIG_MODE(&((fe)->fe_cfg))
#define TE_LBO_DECODE(fe) LBO_DECODE(&((fe)->fe_cfg))
#define TE_CLK_DECODE(fe) TECLK_DECODE(&((fe)->fe_cfg))
/* -----------------------------------------------------------------------------
* Constants for the SET_T1_E1_SIGNALING_CFG/READ_T1_E1_SIGNALING_CFG commands
@ -313,6 +350,8 @@ typedef struct {
unsigned char lb_tx_cmd;
unsigned long lb_tx_cnt;
unsigned char lb_rx_code;
unsigned char critical;
wan_timer_t timer;
unsigned char timer_cmd;
@ -326,8 +365,28 @@ typedef struct {
unsigned long ptr_te_Rx_sig_off;
unsigned long ptr_te_Tx_sig_off;
} sdla_te_param_t;
unsigned char intr_src1;
unsigned char intr_src2;
unsigned char intr_src3;
unsigned int max_channels;
unsigned long rx_rbs_status;
unsigned char rx_rbs[32];
unsigned char tx_rbs[32];
unsigned long tx_rbs_A;
unsigned long tx_rbs_B;
unsigned long tx_rbs_C;
unsigned long tx_rbs_D;
unsigned long rx_rbs_A;
unsigned long rx_rbs_B;
unsigned long rx_rbs_C;
unsigned long rx_rbs_D;
unsigned char xlpg_scale;
} sdla_te_param_t;
/*

View File

@ -29,7 +29,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: sdla_te1_def.h,v 1.24 2005/02/09 21:55:54 sangoma Exp $
* $Id: sdla_te1_def.h,v 1.36 2005/07/19 16:06:49 sangoma Exp $
*/
/*****************************************************************************
@ -60,6 +60,11 @@
#define REG_RECEIVE_OPT 0x02
#define BIT_RECEIVE_OPT_UNF 0x40
#define REG_TX_LINE_CONF 0x04
#define BIT_TX_LINE_CONF_TJATBYP 0x80
#define BIT_TX_LINE_CONF_TAISEN 0x40
#define BIT_TX_LINE_CONF_TAUXP 0x20
#define REG_TX_TIMING_OPT 0x06
#define BIT_TX_PLLREF1 0x08
#define BIT_TX_PLLREF0 0x04
@ -71,6 +76,12 @@
#define BIT_MASTER_DIAG_DDLB 0x04
#define REG_REVISION_CHIP_ID 0x0D
#define MASK_CHIP_ID 0xE0
#define CHIP_ID_COMET_QUAD 0x40
#define CHIP_ID_COMET 0x20
#define DECODE_CHIPID(chip_id) \
(chip_id == CHIP_ID_COMET_QUAD) ? "COMET-QUAD" : \
(chip_id == CHIP_ID_COMET) ? "COMET" : "Unknown"
#define REG_RESET 0x0E
#define BIT_RESET 0x01
@ -133,7 +144,8 @@
#define BIT_BRIF_ROHM 0x08
#define REG_BRIF_DATA_CFG 0x32
#define BIT_BRIF_DATA_TRI_0 0x01
#define BIT_BRIF_DATA_TRI_0 0x01 /* PMC4351 */
#define BIT_BRIF_DATA_TRI 0x01 /* PMC4354 */
#define REG_BTIF_CFG 0x40
#define BIT_BTIF_NXDS0_1 0x80
@ -172,18 +184,37 @@
#define BIT_SIGX_PCCE 0x01
#define BIT_SIGX_SIGE 0x20
#define BIT_SIGX_COSS 0x40
#define REG_SIGX_CHG_30_25 0x50
#define MASK_SIGX_COSS_30_25 0x3F
#define REG_SIGX_CHG_24_17 0x51
#define REG_SIGX_CHG_16_9 0x52
#define REG_SIGX_CHG_8_1 0x53
#define REG_SIGX_TIMESLOT_IND_STATUS 0x51
#define BIT_SIGX_BUSY 0x80
#define REG_SIGX_TIMESLOT_IND_ACCESS 0x52
#define BIT_SIGX_TS_IND_ACCESS_READ 0x80
#define REG_SIGX_TIMESLOT_IND_DATA_BUFFER 0x53
#define REG_SIGX_SIGDATA 0x20
#define BIT_SIGX_SIGDATA_A 0x08
#define BIT_SIGX_SIGDATA_B 0x04
#define BIT_SIGX_SIGDATA_C 0x02
#define BIT_SIGX_SIGDATA_D 0x01
#define REG_SIGX_CURRENT 0x10
#define BIT_SIGX_CURRENT_A_N 0x80
#define BIT_SIGX_CURRENT_B_N 0x40
#define BIT_SIGX_CURRENT_C_N 0x20
#define BIT_SIGX_CURRENT_D_N 0x10
#define BIT_SIGX_CURRENT_A_N16 0x08
#define BIT_SIGX_CURRENT_B_N16 0x04
#define BIT_SIGX_CURRENT_C_N16 0x02
#define BIT_SIGX_CURRENT_D_N16 0x01
#define BIT_SIGX_A 0x08
#define BIT_SIGX_B 0x04
#define BIT_SIGX_C 0x02
#define BIT_SIGX_D 0x01
#define REG_SIGX_DELAYED_SIGDATA 0x20
#define BIT_SIGX_DELAYED_SIGDATA_A 0x08
#define BIT_SIGX_DELAYED_SIGDATA_B 0x04
#define BIT_SIGX_DELAYED_SIGDATA_C 0x02
#define BIT_SIGX_DELAYED_SIGDATA_D 0x01
#define REG_SIGX_CHANCFG 0x40
#define BIT_SIGX_CHANCFG_RINV1 0x08
@ -195,6 +226,7 @@
#define REG_T1_XBAS_CFG 0x54
#define BIT_T1_XBAS_ZCS0 0x01
#define BIT_T1_XBAS_ZCS1 0x02
#define BIT_T1_XBAS_JPN 0x40
#define BIT_T1_XBAS_B8ZS 0x20
#define BIT_T1_XBAS_ESF 0x10
@ -233,6 +265,7 @@
/* T1 XBOC Code */
#define REG_T1_XBOC_CODE 0x67
#define BITS_T1_XBOC_DISABLE 0x3F
#define MASK_T1_XBOC_CODE 0x3F
/* T1 RBOC Enable */
@ -274,13 +307,14 @@
#define BIT_TPSC_E1_CTRL_BYTE_B 0x04
#define BIT_TPSC_E1_CTRL_BYTE_C 0x02
#define BIT_TPSC_E1_CTRL_BYTE_D 0x01
#define BIT_TPSC_SIGNALING_BYTE_SIGC_0 0x80
#define BIT_TPSC_SIGNALING_BYTE_SIGC_1 0x40
#define BIT_TPSC_SIGNALING_BYTE_DS1 0x20
#define BIT_TPSC_SIGNALING_BYTE_A 0x08
#define BIT_TPSC_SIGNALING_BYTE_B 0x04
#define BIT_TPSC_SIGNALING_BYTE_C 0x02
#define BIT_TPSC_SIGNALING_BYTE_D 0x01
#define BIT_TPSC_SIGBYTE_SIGC_0 0x80
#define BIT_TPSC_SIGBYTE_SIGC_1 0x40
#define BIT_TPSC_SIGBYTE_DS1 0x20
#define BIT_TPSC_SIGBYTE_SIGSRC 0x10
#define BIT_TPSC_SIGBYTE_A 0x08
#define BIT_TPSC_SIGBYTE_B 0x04
#define BIT_TPSC_SIGBYTE_C 0x02
#define BIT_TPSC_SIGBYTE_D 0x01
/* RPSC Indirect Register Access */
#define REG_RPSC_CFG 0x70
@ -296,20 +330,47 @@
#define BIT_RPSC_DATA_CTRL_BYTE_DTRKC 0x40
#define BIT_RPSC_DATA_CTRL_BYTE_SIGNINV 0x04
#define REG_RPSC_DATA_COND_BYTE 0x40
#define REG_RPSC_SIGNALING_BYTE 0x60
#define BIT_RPSC_SIGNALING_BYTE_A 0x08
#define BIT_RPSC_SIGNALING_BYTE_B 0x04
#define BIT_RPSC_SIGNALING_BYTE_C 0x02
#define BIT_RPSC_SIGNALING_BYTE_D 0x01
#define REG_RPSC_SIGBYTE 0x60
#define BIT_RPSC_SIGBYTE_A 0x08
#define BIT_RPSC_SIGBYTE_B 0x04
#define BIT_RPSC_SIGBYTE_C 0x02
#define BIT_RPSC_SIGBYTE_D 0x01
#define REG_E1_TRAN_CFG 0x80
#define BIT_E1_TRAN_AMI 0x80
#define BIT_E1_TRAN_SIGEN 0x40
#define BIT_E1_TRAN_DLEN 0x20
#define BIT_E1_TRAN_GENCRC 0x10
#define BIT_E1_TRAN_FDIS 0x08
#define BIT_E1_TRAN_FEBEDIS 0x04
#define BIT_E1_TRAN_INDIS 0x02
#define BIT_E1_TRAN_XDIS 0x01
#define REG_E1_TRAN_TX_ALARM_CTRL 0x81
#define BIT_E1_TRAN_TX_ALARM_RAI 0x08
#define BIT_E1_TRAN_TX_ALARM_YBIT 0x04
#define BIT_E1_TRAN_TX_ALARM_AIS 0x01
#define REG_E1_TRAN_NATB_CODESEL 0x86
#define BIT_E1_TRAN_NATB_CODESEL_SaSEL2 0x80
#define BIT_E1_TRAN_NATB_CODESEL_SaSEL1 0x40
#define BIT_E1_TRAN_NATB_CODESEL_SaSEL0 0x20
#define BIT_E1_TRAN_NATB_CODESEL_Sa4 0x60
#define BIT_E1_TRAN_NATB_CODESEL_Sa5 0x80
#define BIT_E1_TRAN_NATB_CODESEL_Sa6 0xA0
#define BIT_E1_TRAN_NATB_CODESEL_Sa7 0xC0
#define BIT_E1_TRAN_NATB_CODESEL_Sa8 0xE0
#define REG_E1_TRAN_NATB_CODE 0x87
#define BIT_E1_TRAN_NATB_CODE_SaXEN1 0x80
#define BIT_E1_TRAN_NATB_CODE_SaXEN2 0x40
#define BIT_E1_TRAN_NATB_CODE_SaXEN3 0x20
#define BIT_E1_TRAN_NATB_CODE_SaXEN4 0x10
#define BIT_E1_TRAN_NATB_CODE_SaX1 0x08
#define BIT_E1_TRAN_NATB_CODE_SaX2 0x04
#define BIT_E1_TRAN_NATB_CODE_SaX3 0x02
#define BIT_E1_TRAN_NATB_CODE_SaX4 0x01
#define REG_E1_FRMR_CFG 0x90
#define BIT_E1_FRMR_CRCEN 0x80
#define BIT_E1_FRMR_CASDIS 0x40
@ -378,9 +439,9 @@
/* RLPS Equalization Indirect Data (LSB) */
#define REG_RLPS_IND_DATA_4 0xDB
#define REG_EQ_VREF 0xDC
#define REG_EQ_VREF 0xDC
#define REG_RLPS_FUSE_CTRL_STAT 0xDD
#define REG_RLPS_FUSE_CTRL_STAT 0xDD
#define REG_PRGD_INT_STATUS_EN 0xE1
#define BIT_PRGD_INT_STATUS_EN_SYNCE 0x80
@ -423,6 +484,7 @@
#define BIT_RLPS_CFG_STATUS_ALOSI 0x80
#define BIT_RLPS_CFG_STATUS_ALOSV 0x40
#define BIT_RLPS_CFG_STATUS_ALOSE 0x20
#define BIT_RLPS_CFG_STATUS_SQUELCHE 0x10
#define BIT_RLPS_CFG_STATUS_LONGE 0x01
#define REG_RLPS_ALOS_DET_CLR_THR 0xF9
@ -469,6 +531,9 @@
#define BIT_RLPS_EQ_FREQ_1 0x02 /* PMC4351 */
#define BIT_RLPS_EQ_FREQ_0 0x01 /* PMC4351 */
#define BIT_RLPS_EQ_EQEN 0x08 /* PMC4354 */
#define BIT_RLPS_EQ_RESERVED_3 0x04 /* PMC4354 */
#define BIT_RLPS_EQ_RESERVED_1 0x03 /* PMC4354 */
#define BIT_RLPS_EQ_RESERVED_0 0x01 /* PMC4354 */
/********************************************/
/************ Interrupt Register ************/

View File

@ -29,7 +29,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: sdladrv.h,v 1.36 2005/02/09 21:55:54 sangoma Exp $
* $Id: sdladrv.h,v 1.47 2005/11/10 18:02:32 sangoma Exp $
*/
/*****************************************************************************
@ -92,6 +92,7 @@
#define SDLA_BASEADDR 0x10
#define SDLA_COREREV 0x11
#define SDLA_USEDCNT 0x12
#define SDLA_ADAPTERSUBTYPE 0x13
#define SDLA_MAX_CPUS 2
@ -114,22 +115,31 @@
typedef void* sdla_mem_handle_t;
# if (__FreeBSD_version < 400000)
typedef bus_addr_t sdla_base_addr_t;
typedef bus_addr_t sdla_dma_addr_t;
typedef pcici_t sdla_pci_dev_t;
# else
typedef uint32_t sdla_base_addr_t;
typedef uint32_t sdla_dma_addr_t;
typedef struct device* sdla_pci_dev_t;
# endif
#elif defined(__OpenBSD__)
typedef bus_space_handle_t sdla_mem_handle_t;
typedef bus_addr_t sdla_base_addr_t;
typedef bus_addr_t sdla_dma_addr_t;
typedef struct pci_attach_args* sdla_pci_dev_t;
#elif defined(__NetBSD__)
typedef bus_space_handle_t sdla_mem_handle_t;
typedef bus_addr_t sdla_base_addr_t;
typedef bus_addr_t sdla_dma_addr_t;
typedef struct pci_attach_args* sdla_pci_dev_t;
#elif defined(__LINUX__)
typedef unsigned long sdla_mem_handle_t;
typedef u32 sdla_base_addr_t;
#if defined(__iomem)
typedef void __iomem* sdla_mem_handle_t;
#else
typedef void * sdla_mem_handle_t;
#endif
typedef unsigned long sdla_base_addr_t;
typedef dma_addr_t sdla_dma_addr_t;
typedef struct pci_dev* sdla_pci_dev_t;
#else
# warning "Undefined types sdla_mem_handle_t/sdla_base_addr_t!"
@ -189,8 +199,11 @@ typedef struct sdla_hw_probe {
typedef struct sdlahw_card {
int used;
unsigned int hw_type; /* ISA/PCI */
unsigned int type; /* S50x/S514/ADSL/XILINX */
unsigned int adapter_type; /* SubVendor ID */
unsigned int type; /* S50x/S514/ADSL/SDLA_AFT */
unsigned char cfg_type; /* Config card type WANOPT_XXX */
unsigned int adptr_type; /* Adapter type (subvendor ID) */
unsigned char adptr_subtype; /* Adapter Subtype (Normal|Shark) */
unsigned char adptr_name[SDLA_NAME_SIZE];
unsigned char core_id; /* SubSystem ID [0..7] */
unsigned char core_rev; /* SubSystem ID [8..15] */
unsigned char pci_extra_ver;
@ -206,10 +219,9 @@ typedef struct sdlahw_card {
#endif
sdla_pci_dev_t pci_dev; /* PCI config header info */
#endif
unsigned char cfg_type; /* Card type */
wan_spinlock_t pcard_lock; /* lock per physical card */
wan_smp_flag_t fe_rw_flag;
unsigned char adptr_security; /* Adapter security (AFT cards) */
unsigned char adptr_name[SDLA_NAME_SIZE];
WAN_LIST_ENTRY(sdlahw_card) next;
} sdlahw_card_t;
@ -239,8 +251,8 @@ typedef struct sdlahw
bus_dma_tag_t dmat;
#endif
int irq; /* interrupt request level */
#if (__FreeBSD_version >= 450000)
void* irqh;
#if (defined(__FreeBSD__) && __FreeBSD_version >= 450000)
void* irqh[SDLA_MAX_PORTS];
#endif
unsigned int cpu_no; /* PCI CPU Number */
unsigned int line_no; /* PCI CPU Number */
@ -250,7 +262,7 @@ typedef struct sdlahw
unsigned dpmsize; /* dual-port memory size */
unsigned pclk; /* CPU clock rate, kHz */
unsigned long memory; /* memory size */
sdla_mem_handle_t vector; /* local offset of the DPM window */
sdla_mem_handle_t vector; /* local offset of the DPM window */
unsigned io_range; /* I/O port range */
unsigned char regs[SDLA_MAXIORANGE]; /* was written to registers */
@ -273,7 +285,7 @@ typedef struct sdlahw_iface
int (*load)(void*,void*, unsigned);
int (*down)(void*);
int (*start)(sdlahw_t* hw, unsigned addr);
int (*halt)(void*);
int (*hw_halt)(void*);
int (*intack)(void*, uint32_t);
int (*read_int_stat)(void*, uint32_t*);
int (*mapmem)(void*, unsigned long);
@ -301,8 +313,8 @@ typedef struct sdlahw_iface
int (*poke_byte)(void*,unsigned long, u8);
int (*set_bit)(void*,unsigned long, u8);
int (*clear_bit)(void*,unsigned long,u8);
int (*set_intrhand)(void*, void (*isr_func)(void*), void*);
int (*restore_intrhand)(void*);
int (*set_intrhand)(void*, void (*isr_func)(void*), void*,int);
int (*restore_intrhand)(void*,int);
int (*is_te1)(void*);
int (*is_56k)(void*);
int (*get_hwcard)(void*, void**);
@ -310,6 +322,10 @@ typedef struct sdlahw_iface
int (*hw_unlock)(void *phw, wan_smp_flag_t *flag);
int (*hw_lock)(void *phw, wan_smp_flag_t *flag);
int (*hw_same)(void *phw1, void *phw2);
int (*fe_test_and_set_bit)(void *phw);
int (*fe_clear_bit)(void *phw);
sdla_dma_addr_t (*pci_map_dma)(void *phw, void *buf, int len, int ctrl);
int (*pci_unmap_dma)(void *phw, sdla_dma_addr_t buf, int len, int ctrl);
} sdlahw_iface_t;
typedef struct sdla_hw_type_cnt
@ -320,6 +336,7 @@ typedef struct sdla_hw_type_cnt
unsigned char aft101_adapters;
unsigned char aft104_adapters;
unsigned char aft300_adapters;
unsigned char aft_analog_adapters;
}sdla_hw_type_cnt_t;
/****** Function Prototypes *************************************************/
@ -434,7 +451,7 @@ sdla_bus_set_region_1(sdlahw_t* hw, unsigned int offset, unsigned char val, unsi
}
static __inline int
sdla_request_mem_region(sdlahw_t* hw, unsigned long base_addr, unsigned int len, unsigned char* name, void** pres)
sdla_request_mem_region(sdlahw_t* hw, sdla_base_addr_t base_addr, unsigned int len, unsigned char* name, void** pres)
{
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
/* We don't need for BSD */
@ -453,7 +470,7 @@ sdla_request_mem_region(sdlahw_t* hw, unsigned long base_addr, unsigned int len,
}
static __inline void
sdla_release_mem_region(sdlahw_t* hw, unsigned long base_addr, unsigned int len)
sdla_release_mem_region(sdlahw_t* hw, sdla_base_addr_t base_addr, unsigned int len)
{
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return;
@ -482,6 +499,27 @@ sdla_pci_enable_device(sdlahw_t* hw)
#endif
}
static __inline int
sdla_pci_disable_device(sdlahw_t* hw)
{
sdlahw_card_t* card;
WAN_ASSERT(hw == NULL);
WAN_ASSERT(hw->hwcard == NULL);
card = hw->hwcard;
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return 0;
#elif defined(__LINUX__)
pci_disable_device(card->pci_dev);
return 0;
#else
# warning "sdla_release_mem_region: Not supported yet!"
return -EINVAL;
#endif
}
static __inline void
sdla_pci_set_master(sdlahw_t* hw)
{
@ -499,6 +537,38 @@ sdla_pci_set_master(sdlahw_t* hw)
#endif
}
static __inline void
sdla_get_pci_base_resource_addr(sdlahw_t* hw, int pci_offset, sdla_base_addr_t *base_addr)
{
sdlahw_card_t* card;
WAN_ASSERT1(hw == NULL);
WAN_ASSERT1(hw->hwcard == NULL);
card = hw->hwcard;
#if defined(__FreeBSD__)
# if (__FreeBSD_version > 400000)
*base_addr = (sdla_base_addr_t)pci_read_config(card->pci_dev, pci_offset, 4);
# else
*base_addr = (sdla_base_addr_t)ci_cfgread(card->pci_dev, pci_offset, 4);
# endif
#elif defined(__NetBSD__) || defined(__OpenBSD__)
*base_addr = (sdla_base_addr_t)pci_conf_read(card->pci_dev->pa_pc, card->pci_dev->pa_tag, pci_offset);
#elif defined(__LINUX__)
if (pci_offset == PCI_IO_BASE_DWORD){
*base_addr = (sdla_base_addr_t)pci_resource_start(card->pci_dev,0);
}else{
*base_addr = (sdla_base_addr_t)pci_resource_start(card->pci_dev,1);
}
#else
# warning "sdla_get_pci_base_resource_addr: Not supported yet!"
#endif
}
#endif /* __SDLADRV__ */

View File

@ -37,12 +37,27 @@
#define A300_UTE3_SUBSYS_VENDOR 0xA020 /* A300 with T3/E3 (unchannelized) */
#define A305_CT3_SUBSYS_VENDOR 0xA030 /* A305 with T3 (channelized) */
#define A104_1TE1_SHARK_SUBSYS_VENDOR 0xA111 /* A101-SHARK T1/E1 1 lines */
#define A104_2TE1_SHARK_SUBSYS_VENDOR 0xA112 /* A102-SHARK T1/E1 2 lines */
#define A104_4TE1_SHARK_SUBSYS_VENDOR 0xA113 /* A104-SHARK T1/E1 4 lines */
#define A104_8TE1_SHARK_SUBSYS_VENDOR 0xA114 /* A108-SHARK T1/E1 8 lines */
#define A300_UTE3_SHARK_SUBSYS_VENDOR 0xA115 /* A300-SHARK with T3/E3 (unchannelized) */
#define A305_CTE3_SHARK_SUBSYS_VENDOR 0xA116 /* A305-SHARK with T3 (channelized) */
#define A200_REMORA_SHARK_SUBSYS_VENDOR 0xA200 /* AFT-REMORA SHARK analog board */
#define AFT_CORE_ID_MASK 0x00FF
#define AFT_CORE_REV_MASK 0xFF00
#define AFT_HDLC_CORE_ID 0x00 /* HDLC core */
#define AFT_ATM_CORE_ID 0x01 /* ATM core */
#define AFT_SS7_CORE_ID 0x02 /* SS7 core */
#define AFT_CHIP_UNKNOWN 0x0000
#define AFT_CHIP_OLD_X300 0x0300
#define AFT_CHIP_OLD_X400 0x0400
#define AFT_CHIP_X300 0x0030
#define AFT_CHIP_X400 0x0040
#define AFT_CHIP_X1000 0x0100
#define AFT_PCI_MEM_SIZE 0x2FF
#define XILINX_PCI_LATENCY 0x0000FF00
@ -54,6 +69,7 @@
/* Local PCI register offsets */
#define PCI_VENDOR_ID_WORD 0x00 /* vendor ID */
#define PCI_DEVICE_ID_WORD 0x02 /* device ID */
#define PCI_REVISION_ID_BYTE 0x08 /* revision ID */
#define PCI_SUBCLASS_ID_BYTE 0x0a /* subclass ID byte */
#define PCI_IO_BASE_DWORD 0x10 /* IO base */
#define PCI_MEM_BASE0_DWORD 0x14 /* memory base - apperture 0 */

View File

@ -134,19 +134,34 @@ typedef struct sfm /* SDLA firmware file structire */
#define A104_ADPTR_TE1_MASK 0x0080 /* Quad T1/E1 type mask */
#define A104_ADPTR_4TE1 0x0081 /* Quad line T1/E1 */
#define A108_ADPTR_TE1_MASK 0x0200 /* 8 Channels T1/E1 type mask */
#define A108_ADPTR_8TE1 0x0201 /* 8 Channels T1/E1 */
#define A100_ADPTR_T3E3_MASK 0x0100 /* T3/E3 type mask */
#define A100_ADPTR_U_1TE3 0x0101 /* 1 Channel T3/E3 (Proto) */
#define A300_ADPTR_U_1TE3 0x0102 /* 1 Channel T3/E3 */
#define A300_ADPTR_U_1TE3 0x0102 /* 1 Channel T3/E3 (unchannelized) */
#define A305_ADPTR_C_1TE3 0x0104 /* 1 Channel T3/E3 (channelized) */
#define A200_ADPTR_ANALOG_MASK 0x0400 /* AFT-REMORA analog board mask */
#define A200_ADPTR_ANALOG 0x0401 /* AFT-REMORA analog board */
#define OPERATE_T1E1_AS_SERIAL 0x8000 /* For bitstreaming only
* Allow the applicatoin to
* E1 front end */
/* settings for the 'adapter_subtype' */
#define AFT_SUBTYPE_NORMAL 0x00
#define AFT_SUBTYPE_SHARK 0x01
/* settings for the 'adapter_security' */
#define AFT_SECURITY_NONE 0x00
#define AFT_SECURITY_CHAN 0x01
#define AFT_SECURITY_UNCHAN 0x02
/* settings for the 'adptr_subtype' */
#define AFT_SUBTYPE_SHIFT 8
#define AFT_SUBTYPE_MASK 0x0F
/* CPLD definitions */
#define AFT_SECURITY_1LINE_UNCH 0x00
#define AFT_SECURITY_1LINE_CH 0x01
@ -175,7 +190,8 @@ typedef struct sfm /* SDLA firmware file structire */
(adapter_type == A101_ADPTR_1TE1) ? "AFT-A101" : \
(adapter_type == A101_ADPTR_2TE1) ? "AFT-A102" : \
(adapter_type == A104_ADPTR_4TE1) ? "AFT-A104" : \
(adapter_type == A300_ADPTR_U_1TE3) ? "AFT-A300" : \
(adapter_type == A300_ADPTR_U_1TE3) ? "AFT-A301" : \
(adapter_type == A200_ADPTR_ANALOG) ? "AFT-A200" : \
"UNKNOWN"
#if 0
@ -190,20 +206,28 @@ typedef struct sfm /* SDLA firmware file structire */
(adapter_type == A101_ADPTR_1TE1) ? "AFT-A101 " : \
(adapter_type == A101_ADPTR_2TE1) ? "AFT-A102 " : \
(adapter_type == A104_ADPTR_4TE1) ? "AFT-A104 " : \
(adapter_type == A300_ADPTR_U_1TE3) ? "AFT-A300 " : \
(adapter_type == A300_ADPTR_U_1TE3) ? "AFT-A301 " : \
"UNKNOWN "
#endif
#define AFT_GET_SECURITY(security) \
#define AFT_GET_SECURITY(security) \
((security >> AFT_SECURITY_CPLD_SHIFT) & AFT_SECURITY_CPLD_MASK)
#define AFT_SECURITY(adapter_security) \
(adapter_security == AFT_SECURITY_CHAN) ? "c" : \
(adapter_security == AFT_SECURITY_CHAN) ? "c" : \
(adapter_security == AFT_SECURITY_UNCHAN) ? "u" : ""
#define AFT_SECURITY_DECODE(adapter_security) \
#define AFT_SECURITY_DECODE(adapter_security) \
(adapter_security == AFT_SECURITY_CHAN) ? "Channelized" : \
(adapter_security == AFT_SECURITY_UNCHAN) ? "Unchannelized" : ""
#define AFT_SUBTYPE(adptr_subtype) \
(adptr_subtype == AFT_SUBTYPE_NORMAL) ? "" : \
(adptr_subtype == AFT_SUBTYPE_SHARK) ? "-SH" : ""
#define AFT_SUBTYPE_DECODE(adptr_subtype) \
(adptr_subtype == AFT_SUBTYPE_NORMAL) ? "" : \
(adptr_subtype == AFT_SUBTYPE_SHARK) ? "SHARK" : ""
#endif /* _SDLASFM_H */

View File

@ -141,6 +141,7 @@ enum {
*/
#define DYN_OPT_ON 0x00
#define DEV_DOWN 0x01
#define WAN_DEV_READY 0x02
/*
* Data structures for IOCTL calls.
@ -206,37 +207,6 @@ typedef struct global_stats
} global_stats_t;
#if ALEX
typedef struct{
unsigned short udp_src_port PACKED;
unsigned short udp_dst_port PACKED;
unsigned short udp_length PACKED;
unsigned short udp_checksum PACKED;
} udp_pkt_t;
typedef struct {
unsigned char ver_inet_hdr_length PACKED;
unsigned char service_type PACKED;
unsigned short total_length PACKED;
unsigned short identifier PACKED;
unsigned short flags_frag_offset PACKED;
unsigned char ttl PACKED;
unsigned char protocol PACKED;
unsigned short hdr_checksum PACKED;
unsigned long ip_src_address PACKED;
unsigned long ip_dst_address PACKED;
} ip_pkt_t;
typedef struct {
unsigned char signature[8] PACKED;
unsigned char request_reply PACKED;
unsigned char id PACKED;
unsigned char reserved[6] PACKED;
} wp_mgmt_t;
#endif
/*************************************************************************
Data Structure for if_send statistics
*************************************************************************/
@ -288,7 +258,7 @@ typedef struct {
struct sk_buff *skb;
} bh_data_t, cmd_data_t;
#define MAX_LGTH_UDP_MGNT_PKT 2000
#define MAX_LGTH_UDP_MGNT_PKT WAN_MAX_DATA_SIZE
/* This is used for interrupt testing */
@ -339,7 +309,10 @@ typedef struct {
#endif
#define MAX_E1_CHANNELS 32
#define MAX_FR_CHANNELS (991+1)
#define MAX_FR_CHANNELS (1007+1)
#define WAN_ENABLE 0x01
#define WAN_DISABLE 0x02
#ifndef min
#define min(a,b) (((a)<(b))?(a):(b))
@ -731,7 +704,21 @@ typedef struct
unsigned int security_cnt;
unsigned char firm_ver;
unsigned int chip_security_cnt;
unsigned int comm_enabled;
unsigned long rx_timeout,gtimeout;
unsigned int comm_enabled;
unsigned int lcfg_reg;
unsigned int tdmv_master_if_up;
unsigned int tdmv_mtu;
unsigned int tdmv_zaptel_cfg;
netskb_t *tdmv_api_rx;
netskb_t *tdmv_api_tx;
wan_skb_queue_t tdmv_api_tx_list;
unsigned int tdmv_dchan_cfg_on_master;
unsigned int tdmv_chan;
unsigned int tdmv_dchan_active_ch;
void *tdmv_chan_ptr;
unsigned char led_ctrl;
} sdla_xilinx_t;
typedef struct
@ -829,6 +816,7 @@ typedef struct sdla
/*Should be in wandev */
unsigned int type; /* card type */
unsigned int adptr_type; /* adapter type */
unsigned char adptr_subtype; /* adapter subtype */
wan_tasklet_t debug_task;
wan_timer_t debug_timer;
unsigned long debug_running;
@ -868,6 +856,10 @@ typedef struct sdla
struct sdla* same_card;
#endif
#if defined(CONFIG_PRODUCT_WANPIPE_TDMV_EC)
void *oct6100;
#endif
#if defined(__FreeBSD__)
# if defined(NETGRAPH)
int running; /* something is attached so we are running */
@ -914,6 +906,7 @@ int wpx_init (sdla_t* card, wandev_conf_t* conf); /* wpx.c */
int wpf_init (sdla_t* card, wandev_conf_t* conf); /* wpf.c */
int wpp_init (sdla_t* card, wandev_conf_t* conf); /* wpp.c */
int wpc_init (sdla_t* card, wandev_conf_t* conf); /* Cisco HDLC */
int wp_asyhdlc_init (sdla_t* card, wandev_conf_t* conf); /* Async HDLC */
int wpbsc_init (sdla_t* card, wandev_conf_t* conf); /* BSC streaming */
int wph_init(sdla_t* card, wandev_conf_t* conf); /* HDLC support */
int wpft1_init (sdla_t* card, wandev_conf_t* conf); /* FT1 Config support */

View File

@ -52,8 +52,11 @@ extern void* wpabs_skb_dequeue(void *queue);
extern void wpabs_skb_set_dev(void *skb, void *dev);
extern void wpabs_skb_set_raw(void *skb);
extern void wpabs_skb_set_protocol(void *skb, unsigned int prot);
extern void wpabs_skb_set_csum(void *skb_new_ptr, unsigned int csum);
extern unsigned int wpabs_skb_csum(void *skb_new_ptr);
extern void* wpabs_netif_alloc(unsigned char *,int*);
extern void* wpabs_netif_alloc(unsigned char *,int,int*);
extern void wpabs_netif_free(void *);
extern unsigned char* wpabs_netif_name(void *);
extern int wpabs_netif_queue_stopped(void*);
@ -149,9 +152,9 @@ extern int wpabs_strlen(unsigned char *);
extern void wpabs_debug_print_skb(void*,char);
extern void wpabs_decode_ipaddr(unsigned long, unsigned char *);
extern void wpabs_decode_ipaddr(unsigned long, unsigned char *,int);
extern int wpabs_detect_prot_header(unsigned char *,int, char*);
extern int wpabs_detect_prot_header(unsigned char *,int, char*,int);
extern int wpabs_net_ratelimit(void);
extern void wpabs_get_random_bytes(void *ptr, int len);

View File

@ -6,11 +6,13 @@
# include <net/sdla_56k.h>
# include <net/sdla_te1.h>
# include <net/sdla_te3.h>
# include <net/sdla_remora.h>
# include <net/sdla_front_end.h>
#elif defined(__LINUX__)
# include <linux/sdla_56k.h>
# include <linux/sdla_te1.h>
# include <linux/sdla_te3.h>
# include <linux/sdla_remora.h>
# include <linux/sdla_front_end.h>
#else
# error "No OS Defined!"
@ -24,7 +26,7 @@
#define WAN_IFNAME_SZ 15 /* max length of the interface name */
#define WAN_DRVNAME_SZ 15 /* max length of the link driver name */
#define WAN_ADDRESS_SZ 31 /* max length of the WAN media address */
#define USED_BY_FIELD 10 /* max length of the used by field */
#define USED_BY_FIELD 30 /* max length of the used by field */
#define WAN_AUTHNAMELEN 64
@ -62,12 +64,13 @@
#define CRITICAL_INTR_HANDLED 0xB1
/* Card Types */
#define WANOPT_S50X 1
#define WANOPT_S51X 2
#define WANOPT_ADSL 3
#define WANOPT_AFT 4
#define WANOPT_AFT104 5
#define WANOPT_AFT300 6
#define WANOPT_S50X 1
#define WANOPT_S51X 2
#define WANOPT_ADSL 3
#define WANOPT_AFT 4
#define WANOPT_AFT104 5
#define WANOPT_AFT300 6
#define WANOPT_AFT_ANALOG 7
/*
* Configuration options defines.
@ -108,6 +111,7 @@
#define WANOPT_SECONDARY 0
#define WANOPT_PRIMARY 1
/* connection options */
#define WANOPT_PERMANENT 0 /* DTR always active */
#define WANOPT_SWITCHED 1 /* use DTR to setup link (dial-up) */
@ -118,6 +122,10 @@
#define WANOPT_FR_ANSI 1 /* ANSI T1.617 Annex D */
#define WANOPT_FR_Q933 2 /* ITU Q.933A */
#define WANOPT_FR_LMI 3 /* LMI */
#define WANOPT_FR_NO_LMI 4
#define WANOPT_FR_EEK_REQUEST 1
#define WANOPT_FR_EEK_REPLY 2
/* PPP IP Mode Options */
#define WANOPT_PPP_STATIC 0
@ -148,8 +156,8 @@
#define WANOPT_SS7_MODE_128 0
#define WANOPT_SS7_MODE_4096 1
#define WANOPT_SS7_FISU_4096_SZ 6
#define WANOPT_SS7_FISU_128_SZ 3
#define WANOPT_SS7_FISU_4096_SZ 6
/* CHDLC Protocol Options */
@ -190,17 +198,28 @@
#define WANOPT_FE_OSC_CLOCK 0x00
#define WANOPT_FE_LINE_CLOCK 0x01
/* Interface Operation Modes */
#define WANPIPE 0x00
#define API 0x01
#define BRIDGE 0x02
#define BRIDGE_NODE 0x03
#define SWITCH 0x04
#define STACK 0x05
#define ANNEXG 0x06
#define TDM_VOICE 0x07
#define TTY 0x08
enum wan_codec_format{
WP_NONE,
WP_SLINEAR
};
/* Interface Operation Modes */
enum {
WANPIPE,
API,
BRIDGE,
BRIDGE_NODE,
SWITCH,
STACK,
ANNEXG,
TTY,
TDM_VOICE,
TDM_VOICE_DCHAN,
TDM_VOICE_API,
TDM_API
};
/* POS protocols */
enum {
@ -282,7 +301,9 @@ enum {
(card_type == WANOPT_ADSL) ? "ADSL" : \
(card_type == WANOPT_AFT) ? "A101/2" : \
(card_type == WANOPT_AFT104) ? "A104" : \
(card_type == WANOPT_AFT300) ? "A300" : "Unknown"
(card_type == WANOPT_AFT300) ? "A300" : \
(card_type == WANOPT_AFT_ANALOG) ? "A200" : \
"Unknown"
#define COMPORT_DECODE(port) (port == WANOPT_PRI) ? "PRI" : "SEC"
@ -412,6 +433,18 @@ typedef struct wan_atm_conf_if
unsigned char atm_arp;
unsigned char atm_arp_intr;
unsigned short mtu;
unsigned char atm_sync_mode;
unsigned short atm_sync_data;
unsigned char atm_sync_offset;
unsigned short atm_hunt_timer;
unsigned char atm_cell_cfg;
unsigned char atm_cell_pt;
unsigned char atm_cell_clp;
unsigned char atm_cell_payload;
}wan_atm_conf_if_t;
@ -488,6 +521,8 @@ typedef struct wan_fr_conf
unsigned dlci[100]; /* List of all DLCIs */
unsigned char issue_fs_on_startup;
unsigned char station; /* Node or CPE */
unsigned int eek_cfg; /* Cisco End-to-End Keepalive: REQUEST/REPY */
unsigned int eek_timer; /* EEK Timer */
} wan_fr_conf_t;
@ -495,10 +530,13 @@ typedef struct wan_xilinx_conf
{
unsigned short dma_per_ch; /* DMA buffers per logic channel */
unsigned short mru; /* MRU of transparent channels */
unsigned char rbs; /* Robbit signalling support */
unsigned int rbs; /* Robbit signalling support */
unsigned int data_mux_map; /* Data mux map */
unsigned int fe_ref_clock; /* Front End Reference Clock */
unsigned int tdmv_span_no;
unsigned int tdmv_dchan; /* hwHDLC: PRI SIG */
unsigned int rx_crc_bytes;
unsigned char tdmv_hwec; /* Congiure HW EC */
unsigned char tdmv_hwec_map[50]; /* Enable/Disable HW EC */
}wan_xilinx_conf_t;
@ -514,6 +552,7 @@ typedef struct wan_xilinx_conf_if
unsigned char ss7_enable;
unsigned char ss7_mode;
unsigned char ss7_lssu_size;
unsigned char tdmv_master_if;
}wan_xilinx_conf_if_t;
@ -656,6 +695,7 @@ typedef struct wan_chdlc_conf
unsigned keepalive_err_margin; /* keepalive_error_tolerance */
unsigned slarp_timer; /* SLARP request timer */
unsigned char fast_isr; /* Fast interrupt option */
unsigned int protocol_options;
} wan_chdlc_conf_t;
@ -684,7 +724,7 @@ typedef struct lapb_parms_struct {
typedef struct sppp_parms_struct {
unsigned char dynamic_ip;
unsigned char dynamic_ip;/* Static/Host/Peer (the same as ip_mode) */
unsigned int local_ip;
unsigned int remote_ip;
@ -696,9 +736,12 @@ typedef struct sppp_parms_struct {
unsigned char chap;
unsigned char userid[WAN_AUTHNAMELEN];
unsigned char passwd[WAN_AUTHNAMELEN];
#define SYSTEM_NAME_LEN 31
unsigned char sysname[SYSTEM_NAME_LEN];
unsigned int gateway;
unsigned char ppp_prot;
unsigned int keepalive_err_margin;
}wan_sppp_if_conf_t;
@ -866,6 +909,7 @@ typedef struct wandev_conf
unsigned int max_trace_queue;
unsigned int max_rx_queue;
#if 0
/* Bitstreaming options */
unsigned int sync_options;
@ -881,8 +925,6 @@ typedef struct wandev_conf
} wandev_conf_t;
/* 'config_id' definitions */
#define WANCONFIG_X25 101 /* X.25 link */
#define WANCONFIG_FR 102 /* frame relay link */
@ -913,6 +955,11 @@ typedef struct wandev_conf
#define WANCONFIG_XDLC 126 /* LIP XDLC Protocol Support */
#define WANCONFIG_TTY 127 /* LIP TTY Support */
#define WANCONFIG_AFT_TE1 128 /* AFT Quad Hardware Support */
#define WANCONFIG_XMTP2 129 /* LIP XMTP2 Protocol Support */
#define WANCONFIG_ASYHDLC 130 /* S514 ASY HDLC API Support */
#define WANCONFIG_LIP_ATM 131 /* ATM in LIP layer */
#define WANCONFIG_AFT_ANALOG 132 /* AFT Analog Driver */
#define WANCONFIG_ZAP 133 /* Used in wanpipemon when working with Zaptel driver */
/*FIXME: This should be taken out, I just
//used it so I don't break the apps that are
@ -921,6 +968,34 @@ typedef struct wandev_conf
*/
#define WANCONFIG_ETH WANCONFIG_ADSL
#define SDLA_DECODE_PROTOCOL(protocol) \
(protocol == WANCONFIG_X25) ? "X25" : \
(protocol == WANCONFIG_FR) ? "Frame Relay" : \
(protocol == WANCONFIG_PPP) ? "PPP" : \
(protocol == WANCONFIG_CHDLC) ? "CHDLC" : \
(protocol == WANCONFIG_BSC) ? "BiSync Streaming": \
(protocol == WANCONFIG_HDLC) ? "HDLC Streaming": \
(protocol == WANCONFIG_MPPP) ? "PPP": \
(protocol == WANCONFIG_BITSTRM) ? "Bit Stream": \
(protocol == WANCONFIG_EDUKIT) ? "WAN EduKit": \
(protocol == WANCONFIG_SS7) ? "SS7": \
(protocol == WANCONFIG_BSCSTRM) ? "Bisync Streaming Nasdaq": \
(protocol == WANCONFIG_MFR) ? "Frame Relay": \
(protocol == WANCONFIG_ADSL) ? "LLC Ethernet (ADSL)": \
(protocol == WANCONFIG_SDLC) ? "SDLC": \
(protocol == WANCONFIG_ATM) ? "ATM": \
(protocol == WANCONFIG_LIP_ATM)? "LIP_ATM": \
(protocol == WANCONFIG_POS) ? "Point-of-Sale": \
(protocol == WANCONFIG_AFT) ? "AFT": \
(protocol == WANCONFIG_AFT_TE3) ? "AFT TE3": \
(protocol == WANCONFIG_DEBUG) ? "Real Time Debugging": \
(protocol == WANCONFIG_ADCCP) ? "Special HDLC LAPB": \
(protocol == WANCONFIG_MLINK_PPP) ? "Multi-Link PPP": \
(protocol == WANCONFIG_GENERIC) ? "WANPIPE Generic driver": \
(protocol == WANCONFIG_MPCHDLC) ? "CHDLC": \
(protocol == WANCONFIG_TTY) ? "TTY": "Unknown Protocol"
/*----------------------------------------------------------------------------
* WAN interface (logical channel) configuration (for ROUTER_IFNEW IOCTL).
*/
@ -948,7 +1023,7 @@ typedef struct wanif_conf
char local_addr[WAN_ADDRESS_SZ+1];/* local media address, ASCIIZ */
unsigned char port; /* board port */
unsigned char protocol; /* prococol used in this channel (TCPOX25 or X25) */
char pap; /* PAP enabled or disabled */
char pap; /* PAP enabled or disabled */
char chap; /* CHAP enabled or disabled */
#ifdef ENABLE_IPV6
unsigned char chap_userid[WAN_AUTHNAMELEN]; /* List of User Id */
@ -959,7 +1034,7 @@ typedef struct wanif_conf
unsigned char userid[WAN_AUTHNAMELEN]; /* List of User Id */
unsigned char passwd[WAN_AUTHNAMELEN]; /* List of passwords */
#endif
unsigned char sysname[31]; /* Name of the system */
unsigned char sysname[SYSTEM_NAME_LEN]; /* Name of the system */
unsigned char ignore_dcd; /* Protocol options: */
unsigned char ignore_cts; /* Ignore these to determine */
unsigned char ignore_keepalive; /* link status (Yes or No) */
@ -1018,12 +1093,14 @@ typedef struct wanif_conf
unsigned char station;
unsigned char label[WAN_IF_LABEL_SZ+1];
unsigned int spanno; /* TDMV span device number */
unsigned char tdmv_echo_off; /* TDMV echo disable */
unsigned char tdmv_echo_off; /* TDMV echo disable */
unsigned char tdmv_codec; /* TDMV codec */
unsigned char single_tx_buf; /* Used in low latency applications */
unsigned char lip_prot;
union {
wan_atm_conf_if_t atm;
wan_atm_conf_if_t atm; /* per interface configuration */
wan_x25_if_conf_t x25;
wan_lapb_if_conf_t lapb;
wan_dsp_if_conf_t dsp;
@ -1032,6 +1109,7 @@ typedef struct wanif_conf
wan_xilinx_conf_if_t aft;
wan_xdlc_conf_t xdlc;
wan_sppp_if_conf_t ppp;
wan_chdlc_conf_t chdlc;
}u;
} wanif_conf_t;
@ -1102,6 +1180,7 @@ typedef struct wplip_prot_reg
unsigned int,
unsigned int,
unsigned int);
int (*kick_task) (void *);
int mtu;
}wplip_prot_reg_t;
@ -1110,7 +1189,10 @@ enum {
WPLIP_IP,
WPLIP_IPV6,
WPLIP_IPX,
WPLIP_FR_ARP
WPLIP_FR_ARP,
WPLIP_PPP,
WPLIP_FR,
WPLIP_ETH
};
#endif

View File

@ -2,7 +2,7 @@
* Copyright (c) 2002
* Alex Feldman <al.feldman@sangoma.com>. All rights reserved.
*
* $Id: wanpipe_common.h,v 1.122 2005/02/10 18:53:45 sangoma Exp $
* $Id: wanpipe_common.h,v 1.146 2005/11/10 18:02:32 sangoma Exp $
*/
/****************************************************************************
@ -40,6 +40,7 @@ extern atomic_t wan_debug_mem;
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
# define WAN_LIST_HEAD(name, type) LIST_HEAD(name, type)
# define WAN_LIST_HEAD_INITIALIZER(head) LIST_HEAD_INITIALIZER(head)
# define WAN_LIST_ENTRY(type) LIST_ENTRY(type)
@ -53,8 +54,47 @@ extern atomic_t wan_debug_mem;
# define WAN_LIST_NEXT(elm, field) LIST_NEXT(elm, field)
# define WAN_LIST_REMOVE(elm, field) LIST_REMOVE(elm, field)
#elif defined(__SOLARIS__)
/* ********* S O L A R I S *****************/
# define WAN_LIST_HEAD(name, type) struct name { struct type * lh_first; }
# define WAN_LIST_HEAD_INITIALIZER(head) { NULL }
# define WAN_LIST_ENTRY(type) struct { struct type *le_next; struct type **le_prev; }
# define WAN_LIST_FIRST(head) ((head)->lh_first)
# define WAN_LIST_END(head) NULL
# define WAN_LIST_EMPTY(head) (WAN_LIST_FIRST(head) == WAN_LIST_END(head))
# define WAN_LIST_NEXT(elm, field) ((elm)->field.le_next)
# define WAN_LIST_FOREACH(var, head, field) for((var) = WAN_LIST_FIRST(head); \
(var); \
(var) = WAN_LIST_NEXT(var, field))
# define WAN_LIST_INIT(head) do { WAN_LIST_FIRST(head) = NULL;}\
while(0)
#define WAN_LIST_INSERT_HEAD(head, elm, field) do { \
if ((WAN_LIST_NEXT((elm), field) = WAN_LIST_FIRST((head))) != NULL) \
WAN_LIST_FIRST((head))->field.le_prev = &WAN_LIST_NEXT((elm), field);\
WAN_LIST_FIRST((head)) = (elm); \
(elm)->field.le_prev = &WAN_LIST_FIRST((head)); \
} while (0)
#define WAN_LIST_INSERT_AFTER(listelm, elm, field) do { \
if ((WAN_LIST_NEXT((elm), field) = WAN_LIST_NEXT((listelm), field)) != NULL)\
WAN_LIST_NEXT((listelm), field)->field.le_prev = \
&WAN_LIST_NEXT((elm), field); \
WAN_LIST_NEXT((listelm), field) = (elm); \
(elm)->field.le_prev = &WAN_LIST_NEXT((listelm), field); \
} while (0)
#define WAN_LIST_REMOVE(elm, field) do { \
if (WAN_LIST_NEXT((elm), field) != NULL) \
WAN_LIST_NEXT((elm), field)->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = WAN_LIST_NEXT((elm), field); \
} while (0)
#elif defined(__LINUX__)
/* ********* L I N U X *****************/
# define WAN_LIST_HEAD(name, type) struct name { struct type * lh_first; }
# define WAN_LIST_HEAD_INITIALIZER(head) { NULL }
# define WAN_LIST_ENTRY(type) struct { struct type *le_next; struct type **le_prev; }
@ -92,7 +132,6 @@ extern atomic_t wan_debug_mem;
# error "WAN_LISTx macros not supported yet!"
#endif
#if defined(WAN_KERNEL)
#if defined(__FreeBSD__)
@ -105,114 +144,30 @@ extern atomic_t wan_debug_mem;
# define WAN_TAILQ_FIRST(ifp) TAILQ_FIRST(&ifp->if_addrlist)
# define WAN_TAILQ_NEXT(ifa) TAILQ_NEXT(ifa, ifa_list)
#elif defined(__LINUX__)
#elif defined(__SOLARIS__)
#elif defined(__WINDOWS__)
#else
# error "WAN_TAILQ_x macros doesn't supported yet!"
#endif
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# ifndef IFQ_SET_READY
# define WAN_IFQ_SET_READY(ifq) /* nothing */
# define WAN_IFQ_SET_READY IFQ_SET_READY
# define WAN_IFQ_IS_EMPTY IFQ_IS_EMPTY
# define WAN_IFQ_INC_LEN IFQ_INC_LEN
# define WAN_IFQ_DEC_LEN IFQ_DEC_LEN
# define WAN_IFQ_INC_DROPS IFQ_INC_DROPS
# define WAN_IFQ_SET_MAXLEN IFQ_SET_MAXLEN
# define WAN_IFQ_PURGE IFQ_PURGE
# if (__FreeBSD_version > 503000)
# define WAN_IFQ_ENQUEUE(ifq, m, pattr, err) IFQ_ENQUEUE((ifq),(m),(err))
# else
# define WAN_IFQ_SET_READY IFQ_SET_READY
# define WAN_IFQ_ENQUEUE IFQ_ENQUEUE
# endif
# ifndef IFQ_IS_EMPTY
# define WAN_IFQ_IS_EMPTY(ifq) ((ifq)->ifq_len == 0)
# else
# define WAN_IFQ_IS_EMPTY IFQ_IS_EMPTY
# endif
# ifndef IFQ_INC_LEN
# define WAN_IFQ_INC_LEN(ifq) ((ifq)->ifq_len++)
# else
# define WAN_IFQ_INC_LEN IFQ_INC_LEN
# endif
# ifndef IFQ_DEC_LEN
# define WAN_IFQ_DEC_LEN(ifq) (--(ifq)->ifq_len)
# else
# define WAN_IFQ_DEC_LEN IFQ_DEC_LEN
# endif
# ifndef IFQ_INC_DROPS
# define WAN_IFQ_INC_DROPS(ifq) ((ifq)->ifq_drops++)
# else
# define WAN_IFQ_INC_DROPS IFQ_INC_DROPS
# endif
# ifndef IFQ_SET_MAXLEN
# define WAN_IFQ_SET_MAXLEN(ifq, len) ((ifq)->ifq_maxlen = (len))
# else
# define WAN_IFQ_SET_MAXLEN IFQ_SET_MAXLEN
# endif
# if (__FreeBSD_version > 500000)
# define IF_DROP _IF_DROP
# define IF_QFULL _IF_QFULL
# endif
# ifndef IFQ_PURGE
# if (__FreeBSD_version > 500000)
# define WAN_IFQ_PURGE(ifq) IF_DRAIN((ifq))
# else
# define WAN_IFQ_PURGE(ifq) \
while (1) { \
struct mbuf *m0; \
IF_DEQUEUE((ifq), m0); \
if (m0 == NULL) \
break; \
else \
m_freem(m0); \
}
# endif
# else
# define WAN_IFQ_PURGE IFQ_PURGE
# endif
# ifndef IFQ_ENQUEUE
# if (__FreeBSD_version > 500000)
# define WAN_IFQ_ENQUEUE(ifq, m, pattr, err) IF_ENQUEUE((ifq), (m))
# else
# define WAN_IFQ_ENQUEUE(ifq, m, pattr, err) \
do { \
if (IF_QFULL((ifq))) { \
m_freem((m)); \
(err) = ENOBUFS; \
} else { \
IF_ENQUEUE((ifq), (m)); \
(err) = 0; \
} \
if ((err)) \
(ifq)->ifq_drops++; \
} while (0)
# endif
# else
# if (__FreeBSD_version > 503000)
# define WAN_IFQ_ENQUEUE(ifq, m, pattr, err) IFQ_ENQUEUE((ifq),(m),(err))
# else
# define WAN_IFQ_ENQUEUE IFQ_ENQUEUE
# endif
# endif
# ifndef IFQ_DEQUEUE
# define WAN_IFQ_DEQUEUE(ifq, m) IF_DEQUEUE((ifq), (m))
# else
# define WAN_IFQ_DEQUEUE IFQ_DEQUEUE
# endif
# ifndef IFQ_POLL
# define WAN_IFQ_POLL(ifq, m) ((m) = (ifq)->ifq_head)
# else
# define WAN_IFQ_POLL IFQ_POLL
# endif
# ifndef IFQ_CLASSIFY
/*struct altq_pktattr { void* attr; };*/
# define WAN_IFQ_CLASSIFY(ifq, m, sa_family, pktattr) /*(pktattr)->attr = NULL*/
# else
# define WAN_IFQ_CLASSIFY IFQ_CLASSIFY
# endif
# if (__FreeBSD_version > 500000)
# define WAN_IFQ_INIT(ifq, max_pkt) \
WAN_IFQ_SET_MAXLEN((ifq), max_pkt); \
mtx_init(&(ifq)->ifq_mtx, "ifq", "wan", MTX_DEF); \
(ifq)->ifq_len = 0;
# else
# define WAN_IFQ_INIT(ifq, max_pkt) \
WAN_IFQ_SET_MAXLEN((ifq), max_pkt); \
(ifq)->ifq_len = 0;
# endif
# define WAN_IFQ_LEN(ifq) ((ifq)->ifq_len)
# define WAN_IFQ_DEQUEUE IFQ_DEQUEUE
# define WAN_IFQ_POLL IFQ_POLL
# define WAN_IFQ_CLASSIFY IFQ_CLASSIFY
# define WAN_IFQ_INIT IFQ_INIT
# define WAN_IFQ_LEN IFQ_LEN
#elif defined(__LINUX__)
# define WAN_IFQ_INIT(ifq, max_pkt) skb_queue_head_init((ifq))
# define WAN_IFQ_PURGE(ifq) skb_queue_purge((ifq))
@ -233,7 +188,15 @@ extern atomic_t wan_debug_mem;
wan_set_bit(0, &(task)->running); \
(task)->task_func((task)->data, 0); \
}
# define __WAN_TASKLET_SCHEDULE(task) WAN_TASKLET_SCHEDULE(task)
# define WAN_TASKLET_RUNNING(task) \
wan_test_bit(0, &(task)->running)
# define WAN_TASKLET_END(task) wan_clear_bit(0, &(task)->running)
# define WAN_TASKLET_RUNNING(task) \
wan_test_bit(0, &(task)->running)
# define WAN_TASKLET_KILL(task)
# else
# define WAN_TASKLET_INIT(task, priority, func, arg) \
@ -244,6 +207,11 @@ extern atomic_t wan_debug_mem;
wan_set_bit(0, &(task)->running); \
taskqueue_enqueue(taskqueue_swi, &(task)->task_id); \
}
# define __WAN_TASKLET_SCHEDULE(task) WAN_TASKLET_SCHEDULE(task)
# define WAN_TASKLET_RUNNING(task) \
wan_test_bit(0, &(task)->running)
/* taskqueue_run(taskqueue_swi); \*/
# define WAN_TASKLET_END(task) wan_clear_bit(0, &(task)->running)
# define WAN_TASKLET_KILL(task)
@ -257,16 +225,38 @@ extern atomic_t wan_debug_mem;
wan_set_bit(0, &(task)->running); \
(task)->task_func((task)->data, 0); \
}
# define __WAN_TASKLET_SCHEDULE(task) WAN_TASKLET_SCHEDULE(task)
# define WAN_TASKLET_RUNNING(task) \
wan_test_bit(0, &(task)->running)
# define WAN_TASKLET_END(task) wan_clear_bit(0, &(task)->running)
# define WAN_TASKLET_KILL(task)
#elif defined(__LINUX__)
# define WAN_TASKLET_INIT(task, priority, func, arg) \
(task)->running = 0; \
tasklet_init(&(task)->task_id,func,(unsigned long)arg)
# define WAN_TASKLET_SCHEDULE(task) \
tasklet_hi_schedule(&(task)->task_id);
wan_set_bit(0, &(task)->running); \
tasklet_schedule(&(task)->task_id);
#if 0
# define WAN_WP_TASKLET_SCHEDULE_PER_CPU(task,cpu) \
wan_set_bit(0, &(task)->running); \
wp_tasklet_hi_schedule_per_cpu(&(task)->task_id,cpu);
#endif
# define WAN_TASKLET_RUNNING(task) \
wan_test_bit(0, &(task)->running)
# define WAN_TASKLET_END(task) wan_clear_bit(0, &(task)->running)
# define WAN_TASKLET_KILL(task) tasklet_kill(&(task)->task_id)
#elif defined(__WINDOWS__)
#else
# error "Undefined WAN_TASKLET_x macro!"
@ -340,7 +330,17 @@ extern atomic_t wan_debug_mem;
# define WAN_NETIF_CARRIER_ON(dev)
# define WAN_NETIF_CARRIER_OK(dev) 1
# else
# define WAN_NETIF_WAKE_QUEUE(dev) netif_wake_queue(dev)
#if 0
# define WAN_NETIF_WAKE_QUEUE(dev) do{ \
if (((wanpipe_common_t *)dev->priv)->usedby == TDM_VOICE){ \
DEBUG_EVENT("%s: TDM VOICE not waking but starting!!!!\n",dev->name); \
netif_start_queue(dev); \
}else{ \
netif_wake_queue(dev); \
} \
}while(0)
#endif
# define WAN_NETIF_WAKE_QUEUE(dev) netif_wake_queue(dev);
# define WAN_NETIF_START_QUEUE(dev) netif_start_queue(dev)
# define WAN_NETIF_STOP_QUEUE(dev) netif_stop_queue(dev)
# define WAN_NETIF_RUNNING(dev) netif_running(dev)
@ -355,14 +355,14 @@ extern atomic_t wan_debug_mem;
# define WAN_NET_RATELIMIT net_ratelimit
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
# define WAN_NETIF_QUEUE_STOPPED(dev) (dev)->if_flags & IFF_OACTIVE
# define WAN_NETIF_WAKE_QUEUE(dev) (dev)->if_flags &= ~IFF_OACTIVE
# define WAN_NETIF_QUEUE_STOPPED(dev) (dev)->if_flags & IFF_DRV_OACTIVE
# define WAN_NETIF_WAKE_QUEUE(dev) (dev)->if_flags &= ~IFF_DRV_OACTIVE
#if 0
# define WAN_NETIF_STOP_QUEUE(dev)
# define WAN_NETIF_START_QUEUE(dev)
#endif
# define WAN_NETIF_STOP_QUEUE(dev) (dev)->if_flags |= IFF_OACTIVE
# define WAN_NETIF_START_QUEUE(dev) (dev)->if_flags &= ~IFF_OACTIVE
# define WAN_NETIF_STOP_QUEUE(dev) (dev)->if_flags |= IFF_DRV_OACTIVE
# define WAN_NETIF_START_QUEUE(dev) (dev)->if_flags &= ~IFF_DRV_OACTIVE
# define WAN_NETIF_RUNNING(dev) 1
# define WAN_NETIF_UP(dev) ((dev)->if_flags&IFF_UP)
# define WAN_NETDEVICE_STOP(dev)
@ -458,28 +458,13 @@ extern atomic_t wan_debug_mem;
# error "Undefined WAN_SPPP_x macros!"
#endif
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
# ifdef NBPFILTER
# if defined(__FreeBSD__)
# define BPF_ATTACH(ifp,type) bpfattach(ifp, type, 4)
# elif defined(__OpenBSD__)
# define BPF_ATTACH(ifp,type) bpfattach(&ifp->if_bpf, ifp, DLT_NULL, 4)
# elif defined(__NetBSD__)
# define BPF_ATTACH(ifp,type) bpfattach(ifp, type, 4)
# else
# error "BPF_ATTACH macro doesn't supported yet!"
# endif
# else
# define BPF_ATTACH(ifp, type)
# endif
#endif
#define WAN_MAX_TRACE_TIMEOUT (5*HZ)
/****************************************************************************
** T Y P E D E F S
****************************************************************************/
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
# if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
/*
* Ethernet statistics collection data
*/
@ -535,8 +520,7 @@ void wanpipe_debug_timer_init(void*);
void wan_trace_info_init(wan_trace_t *trace, int max_trace_queue);
int wan_trace_purge (wan_trace_t *trace);
int wan_trace_enqueue(wan_trace_t *trace, void *skb_ptr);
int wan_tracing_enabled(wan_trace_t *trace_info);
int wan_tracing_enabled(wan_trace_t *trace_info);
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
void wanpipe_debugging (void* data, int pending);
#else
@ -558,6 +542,8 @@ static __inline void* wan_malloc(int size)
if (ptr){
DEBUG_ADD_MEM(size);
}
#elif defined(__SOLARIS__)
ptr=kmem_alloc(size,KM_NOSLEEP);
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
ptr = malloc(size, M_DEVBUF, M_NOWAIT);
#elif defined(__WINDOWS__)
@ -584,6 +570,9 @@ static __inline void wan_free(void* ptr)
#if defined(__LINUX__)
kfree(ptr);
#elif defined(__SOLARIS__)
kmem_free(ptr,sizeof(*ptr));
DEBUG_EVENT("%s: Feeing Size %i\n",__FUNCTION__,sizeof(*ptr));
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
return free(ptr, M_DEVBUF);
#elif defined(__WINDOWS__)
@ -895,6 +884,8 @@ static __inline unsigned char* wan_skb_data(void* skb)
return ((struct sk_buff*)skb)->data;
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
return mtod((struct mbuf*)skb, caddr_t);
#elif defined(__SOLARIS__)
return ((netskb_t*)mp)->b_rptr;
#else
# error "wan_skb_data() function is not supported yet!"
#endif
@ -910,12 +901,13 @@ static __inline unsigned char* wan_skb_tail(void* skb)
return ((struct sk_buff*)skb)->tail;
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
return mtod((struct mbuf*)skb, caddr_t) + ((struct mbuf*)skb)->m_len;
#elif defined(__SOLARIS__)
return ((netskb_t*)mp)->b_wptr;
#else
# error "wan_skb_tail() function is not supported yet!"
#endif
}
/*
** wan_skb_append() -
** Returns pointer to data.
@ -933,7 +925,8 @@ static __inline void wan_skb_append(void* skbprev, void *skb, void *list)
#else
# error "wan_skb_append() function is not supported yet!"
#endif
}
}
/*
@ -946,6 +939,14 @@ static __inline int wan_skb_len(void* skb)
return ((struct sk_buff*)skb)->len;
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
return ((struct mbuf*)skb)->m_len;
#elif defined(__SOLARIS__)
mblk_t* tmp = skb;
int len = 0;
while(tmp) {
len += (tmp->b_wptr - tmp->b_rptr);
tmp = tmp->b_cont;
}
return len;
#else
# error "wan_skb_len() function is not supported yet!"
#endif
@ -964,6 +965,8 @@ static __inline void wan_skb_free(void* skb)
wan_dev_kfree_skb(skb, FREE_WRITE);
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
m_freem(skb);
#elif defined(__SOLARIS__)
freemsg(skb);
#else
# error "wan_skb_free() function is not supported yet!"
#endif
@ -1052,6 +1055,13 @@ static __inline void* wan_skb_alloc(unsigned int len)
return (void*)new;
}
return NULL;
#elif defined (__SOLARIS__)
mblk_t *mp=allocb(ROUNDUP(len+16, IOC_LINESIZE), BPRI_MED);
if (mp){
caddr_t ptr= (caddr_t) ROUNDUP((long)mp->b_rptr, 1);
mp->b_rptr=(uchar_t *)ptr+16;
}
return mp;
#else
# error "wan_skb_alloc() function is not supported yet!"
#endif
@ -1091,6 +1101,7 @@ static __inline void wan_skb_set_protocol(void* pskb, unsigned int protocol)
mbuf->m_flags |= M_PROTO1;
}
#else
# warning "wan_skb_set_protocol() function is not supported yet!"
#endif
}
@ -1101,6 +1112,7 @@ static __inline void wan_skb_set_raw(void* pskb)
struct sk_buff *skb = (struct sk_buff*)pskb;
if (skb){
skb->mac.raw = skb->data;
skb->nh.raw = skb->data;
}
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#else
@ -1121,14 +1133,15 @@ static __inline void wan_skb_set_csum(void* skb, unsigned int csum)
if (sk){
sk->csum = csum;
}
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#elif defined(__OpenBSD__)
netskb_t* m = (netskb_t*)skb;
if (m){
# if defined(__OpenBSD__)
m->m_pkthdr.csum = csum;
# else
}
#elif defined(__NetBSD__) || defined(__FreeBSD__)
netskb_t* m = (netskb_t*)skb;
if (m){
m->m_pkthdr.csum_data = csum;
# endif
}
#else
# error "wan_skb_set_csum() function is not supported yet!"
@ -1144,13 +1157,12 @@ static __inline unsigned int wan_skb_csum(void* skb)
#if defined(__LINUX__)
struct sk_buff *sk = (struct sk_buff*)skb;
return (sk) ? sk->csum : 0;
#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#elif defined(__NetBSD__) || defined(__FreeBSD__)
netskb_t* m = (netskb_t*)skb;
# if defined(__OpenBSD__)
return (m) ? m->m_pkthdr.csum : 0;
# else
return (m) ? m->m_pkthdr.csum_data : 0;
# endif
#elif defined(__OpenBSD__)
netskb_t* m = (netskb_t*)skb;
return (m) ? m->m_pkthdr.csum : 0;
#else
# error "wan_skb_set_dev() function is not supported yet!"
#endif
@ -1301,6 +1313,17 @@ static __inline void wan_skb_copydata(void* skb, int off, int len, caddr_t cp)
caddr_t data = mtod((struct mbuf*)skb, caddr_t);
bcopy(cp, &data[off], len);
#elif defined(__SOLARIS__)
mblk_t* tmp = (mblk_t*)skb;
unsigned char* ptr = NULL;
unsigned i = 0, num = 0;
while(tmp != NULL) {
ptr = tmp->b_rptr;
num = tmp->b_wptr - tmp->b_rptr;
bcopy(ptr, &cp[i], num);
i += num;
tmp = tmp->b_cont;
}
#else
# error "wan_skb_copydata() function is not supported yet!"
#endif
@ -1411,6 +1434,11 @@ static __inline unsigned char* wan_skb_put(void* skb, int len)
m->m_pkthdr.len = org_len + len;
/*Alex Sep27,2004 last tail but not data pointer return wan_skb_data(skb);*/
return data + org_len;
#elif defined(__SOLARIS__)
mblk_t mp=(mblk_t*)skb;
unsigned char *wptr=mp->b_wptr;
mp->b_wptr += len;
return mp->b_wptr;
#else
# error "wan_skb_put() function is not supported yet!"
#endif
@ -1506,9 +1534,12 @@ static __inline void wan_skb_trim(void* skb, unsigned int len)
skb_trim(skb, len);
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
struct mbuf* m = (struct mbuf*)skb;
#if 0
/* Trim only moves tail to head+len (Oct13) */
if (len == 0){
m->m_data = m->m_ext.ext_buf;
}
#endif
m->m_pkthdr.len = len;
m->m_len = m->m_pkthdr.len;
#else
@ -1516,8 +1547,6 @@ static __inline void wan_skb_trim(void* skb, unsigned int len)
#endif
}
/*
** wan_skb_init() - Setup skb data ptr
**
@ -1529,6 +1558,8 @@ static __inline void wan_skb_init(void* pskb, unsigned int len)
struct sk_buff* skb = (struct sk_buff*)pskb;
skb->data = skb->head + len;
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
struct mbuf* m = (struct mbuf*)pskb;
m->m_data = m->m_ext.ext_buf + len;
#else
# error "wan_skb_init() function is not supported yet!"
#endif
@ -1552,8 +1583,11 @@ static __inline int wan_skb_print(void* skb)
int len = m->m_pkthdr.len, i;
unsigned char *data = wan_skb_data(skb);
if (m->m_type & (M_EXT|M_PKTHDR))
DEBUG_EVENT("M_EXT|M_PKTHDR flag set (%d)!\n",
if (m->m_type & M_PKTHDR)
DEBUG_EVENT("M_PKTHDR flag set (%d)!\n",
m->m_pkthdr.len);
if (m->m_type & M_EXT)
DEBUG_EVENT("M_EXT flag set (%d)!\n",
m->m_pkthdr.len);
DEBUG_EVENT("Packet %d bytes: ", len);
for(i=0;i<len;i++){
@ -1564,6 +1598,16 @@ static __inline int wan_skb_print(void* skb)
return 0;
}
extern unsigned char wp_brt[256];
static __inline void wan_skb_reverse(void *skb)
{
unsigned char *data = wan_skb_data(skb);
int len = wan_skb_len(skb);
int i;
for (i=0; i < len; i++){
data[i]=wp_brt[data[i]];
}
}
/*
** wan_skb_unlink() - Unlink skb from the list
@ -1582,6 +1626,7 @@ static __inline void wan_skb_unlink(void* pskb)
#endif
}
/*
** wan_skb_queue_init() -
**
@ -1949,6 +1994,17 @@ static __inline int wan_netif_set_ticks(netdevice_t* dev, unsigned long ticks)
return 0;
}
static __inline int wan_netif_set_mtu(netdevice_t* dev, unsigned long mtu)
{
#if defined(__LINUX__)
#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
dev->if_mtu = mtu;
#else
# error "wan_netif_set_mtu() function is not supported yet!"
#endif
return 0;
}
static __inline void wan_bpf_report(netdevice_t* dev, void* pkt, int flag)
{
@ -2013,7 +2069,11 @@ static __inline void wan_spin_lock_irq(void *lock, wan_smp_flag_t *flag)
{
#if defined(__LINUX__)
spin_lock_irqsave(((spinlock_t*)lock),*flag);
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#elif defined(__FreeBSD__)
/* Feb 10, 2005 Change splnet to splimp
** (i think it was cause to system crash) */
*flag = splimp();
#elif defined(__OpenBSD__)
*flag = splnet();
#elif defined(__NetBSD__)
# if (__NetBSD_Version__ >= 106000200)
@ -2040,7 +2100,11 @@ static __inline void wan_spin_lock(void *lock)
{
#if defined(__LINUX__)
spin_lock(((spinlock_t*)lock));
#elif defined(__FreeBSD__) || defined(__OpenBSD__)
#elif defined(__FreeBSD__)
/* Feb 10, 2005 Change splnet to splimp
** (i think it was cause to system crash) */
*((wan_spinlock_t*)lock) = splimp();
#elif defined(__OpenBSD__)
*((wan_spinlock_t*)lock) = splnet();
#elif defined(__NetBSD__)
# if (__NetBSD_Version__ >= 106000200)
@ -2063,6 +2127,8 @@ static __inline void wan_spin_unlock(void *lock)
#endif
}
#if 0
static __inline void wan_read_rw_lock(void *lock)
{
@ -2101,5 +2167,5 @@ static __inline void wan_write_rw_unlock_irq(void *lock, unsigned long *flag)
}
#endif
#endif /* WAN_KERNEL */
#endif /* WAN_KERNEL */
#endif /* __WANPIPE_COMMON_H */

View File

@ -19,7 +19,7 @@
************************************************/
#if defined (__KERNEL__) || defined (KERNEL) || defined (_KERNEL)
# ifndef WAN_KERNEL
# define WAN_KERNEL
# define WAN_KERNEL
# endif
#endif
@ -479,8 +479,7 @@ typedef struct {
#pragma pack()
enum {
enum {
SIOC_WAN_READ_REG = 0x01,
SIOC_WAN_WRITE_REG,
SIOC_WAN_HWPROBE,
@ -492,9 +491,9 @@ enum {
SIOC_WAN_COREREV,
SIOC_WAN_GET_CFG,
SIOC_WAN_FE_READ_REG,
SIOC_WAN_FE_WRITE_REG
SIOC_WAN_FE_WRITE_REG,
SIOC_WAN_OCT6100_REG
};
typedef struct wan_cmd_api_
{
unsigned int cmd;
@ -674,7 +673,7 @@ typedef struct wan_udp_hdr{
# define WAN_MODULE_VERSION(module, version)
# define WAN_MODULE_DEPEND(module, mdepend, vmin, vpref, vmax)
# define WAN_MODULE_DEFINE(name,name_str,author,descr,lic,mod_init,mod_exit,devsw)\
int (##name)(struct lkm_table* lkmtp, int cmd, int ver);\
int (name)(struct lkm_table* lkmtp, int cmd, int ver);\
MOD_DEV(name_str, LM_DT_CHAR, -1, (devsw)); \
int load_##name(struct lkm_table* lkm_tp, int cmd){ \
switch(cmd){ \
@ -683,7 +682,7 @@ typedef struct wan_udp_hdr{
} \
return -EINVAL; \
} \
int (##name)(struct lkm_table* lkmtp, int cmd, int ver){\
int (name)(struct lkm_table* lkmtp, int cmd, int ver){\
DISPATCH(lkmtp,cmd,ver,load_##name,load_##name,lkm_nofunc);\
}
#elif defined(__NetBSD__)
@ -718,6 +717,30 @@ typedef struct wan_udp_hdr{
void __exit unload_##name(void){mod_exit(NULL);} \
module_init(load_##name); \
module_exit(unload_##name);
#elif defined(__SOLARIS__)
# define WAN_MODULE_VERSION(module, version)
# define WAN_MODULE_DEPEND(module, mdepend, vmin, vpref, vmax)
# define WAN_MODULE_DEFINE(name,name_str,author,descr,lic,mod_init,mod_exit,devsw)\
int _init(void){\
int err=mod_init(NULL); \
if (err) return err; \
err=mod_install(&modlinkage) \
if (err) cmn_err(CE_CONT, "mod_install: failed\n"); \
return err; \
}\
void _fini(void){ \
int status \
mod_exit(NULL); \
if ((status = mod_remove(&modlinkage)) != 0) \
cmn_err(CE_CONT, "mod_remove: failed\n"); \
return status; \
}\
int _info(struct modinfo* modinfop) \
{ \
dcmn_err((CE_CONT, "Get module info!\n")); \
return (mod_info(&modlinkage, modinfop)); \
}
#endif
/*
@ -753,6 +776,7 @@ typedef struct termios termios_t;
# define vsnprintf(a,b,c,d) vsprintf(a,c,d)
# endif
typedef void* wan_dma_tag_t;
typedef wait_queue_head_t wan_waitq_head_t;
#elif defined(__FreeBSD__)
typedef u_int8_t u8;
typedef u_int16_t u16;
@ -788,6 +812,7 @@ typedef struct proc wan_dev_thread_t;
typedef d_thread_t wan_dev_thread_t;
# endif
typedef bus_dma_tag_t wan_dma_tag_t;
typedef int wan_waitq_head_t;
#elif defined(__OpenBSD__)
typedef u_int8_t u8;
typedef u_int16_t u16;
@ -848,6 +873,10 @@ typedef int wan_spinlock_t;
typedef int wan_smp_flag_t;
typedef int wan_rwlock_t;
typedef int wan_rwlock_flag_t;
#elif defined(__SOLARIS__)
typedef mblk_t netskb_t;
#elif defined(__WINDOWS__)
typedef UCHAR u8;
typedef UINT u16;
@ -938,6 +967,8 @@ typedef struct _wan_tasklet
void* data;
#elif defined(__LINUX__)
struct tasklet_struct task_id;
#elif defined(__SOLARIS__)
#error "wan_tasklet: not defined in solaris"
#endif
} wan_tasklet_t;
@ -952,6 +983,8 @@ typedef struct _wan_taskq
void* data;
#elif defined(__LINUX__)
struct tq_struct tqueue;
#elif defined(__SOLARIS__)
#error "_wan_taskq: not defined in solaris"
#endif
} wan_taskq_t;

View File

@ -0,0 +1,101 @@
#ifndef __WANPIPE_EDAC_IFACE_H
#define __WANPIPE_EDAC_IFACE_H
#define WAN_TDMV_RX 0
#define WAN_TDMV_TX 1
typedef struct wan_tdmv_pwr{
unsigned int sum;
unsigned int tap_depth;
unsigned int tap_debug_counter;
}wan_tdmv_pwr_t;
#define SAMPLE_STATE_HISTORY_LEN 3
typedef struct wan_tdmv_rxtx_pwr{
wan_tdmv_pwr_t direction[2];
/* of type ED_STATE */
int sample_state[SAMPLE_STATE_HISTORY_LEN];
unsigned int current_sample_number;
/* of type ED_STATE */
int current_state;
/* see comment in ED code */
int complete_samples_counter;
/* debugging stuff */
unsigned int total_samples_number;
/* current counters */
unsigned int echo_present_samples_number;
unsigned int echo_absent_samples_number;
/* history counters */
unsigned int echo_present_samples_number_history;
unsigned int echo_absent_samples_number_history;
}wan_tdmv_rxtx_pwr_t;
typedef enum { ECHO_PRESENT, ECHO_ABSENT, INDETERMINATE } ED_STATE;
typedef enum { ECHO_DETECT_OFF, ECHO_DETECT_ON } ED_CONTROL_STATE;
typedef struct _echo_detect_struct{
/* Used for reporting Echo Presence/Absence on a Asterisk CLI request. */
ED_STATE echo_state;
/* Controls start/stop of ED algorithm. */
ED_CONTROL_STATE echo_detection_state;
ED_CONTROL_STATE echo_detection_state_old;
/* if 1 ED algorithm enabled for the channel */
int ed_enabled;
/* debugging stuff */
int echo_absent_samples_number;
int echo_present_samples_number;
unsigned int last_rx_power;
unsigned int last_tx_power;
}echo_detect_struct_t;
#define SANGOMA_SPIKE_SAMPLE_LEN 1024
/* values for 'state_bits' */
#define SANGOMA_INITIAL_STATE 0x00000000
#define SANGOMA_BUSY_COLLECTING_SAMPLE 0x00000001
#define SANGOMA_FINISHED_COLLECTING_SAMPLE 0x00000002
/* values for 'return_code' */
#define SANGOMA_OK 0
#define SANGOMA_NO_ACTIVE_CALL_OR_EC_OFF 1
#define TDMV_SAMPLE_STATE_DECODE(state) \
((state == ECHO_PRESENT) ? "ECHO_PRESENT" : \
(state == ECHO_ABSENT) ? "ECHO_ABSENT" : \
(state == INDETERMINATE) ? "INDETERMINATE" : "Invalid")
typedef struct _echo_spike_struct{
unsigned char return_code;
unsigned int state_bits;
unsigned int sample_len_counter;/* current length of data in sample_buffer */
unsigned char *sample_buffer;
}echo_spike_struct_t;
extern int wp_tdmv_calc_echo (wan_tdmv_rxtx_pwr_t *pwr_rxtx,
int is_mlaw,
int channo,
unsigned char* rxdata, unsigned char *txdata,
int len);
extern void init_ed_state(wan_tdmv_rxtx_pwr_t *pwr_rxtx, int echo_detect_chan);
#endif

View File

@ -91,23 +91,15 @@ struct if_settings
};
#endif
#if 0
typedef struct {
int proto;
int iface;
char hwprobe[100];
sdla_te_cfg_t te_cfg;
wan_dev_conf_t devconf;
union {
cisco_proto cisco;
fr_proto fr;
fr_proto_pvc fr_pvc;
} protocol;
} wanlite_def_t;
#endif
/* WANPIPE Generic function interface */
# if defined(WAN_KERNEL)
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define WAN_IFT_OTHER IFT_OTHER
#elif defined(__LINUX__)
# define WAN_IFT_OTHER 0x00
#endif
typedef struct
{
netdevice_t*(*alloc)(int);
@ -116,20 +108,8 @@ typedef struct
void(*detach)(netdevice_t*, int);
int(*input)(netdevice_t*, netskb_t*);
int(*set_proto)(netdevice_t*, struct ifreq*);
int(*attach_eth)(netdevice_t*, char*, int);
} wan_iface_t;
#if 0
/* ALEX Remove it !!! */
netdevice_t* wan_iface_alloc (int);
void wan_iface_free (netdevice_t* dev);
int wan_iface_attach(netdevice_t*, char*, int);
void wan_iface_detach(netdevice_t*, int);
int wan_iface_open(netdevice_t* dev);
int wan_iface_close(netdevice_t* dev);
int wan_iface_input(netdevice_t*, netskb_t*);
int wan_iface_tx_timeout(netdevice_t*);
int wan_iface_set_proto(netdevice_t* dev, struct ifreq* ifr);
#endif
# endif
#endif /* __WANPIPE_IFACE_H */

View File

@ -13,7 +13,7 @@
#ifndef __WANPIPE_INCLUDES_H
# define __WANPIPE_INCLUDES_H
#if !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined (__OpenBSD__) && !defined(__WINDOWS__) && !defined(__LINUX__)
#if !defined(__NetBSD__) && !defined(__FreeBSD__) && !defined (__OpenBSD__) && !defined(__WINDOWS__) && !defined(__SOLARIS__) && !defined(__LINUX__)
# if defined(__KERNEL__)
# define __LINUX__
# endif
@ -188,7 +188,7 @@
# include <machine/param.h>
# include <machine/cpufunc.h>
# include <machine/bus.h>
# include <machine/stdarg.h>
/*# include <machine/stdarg.h>*/
# include <net/bpf.h>
# include <net/bpfdesc.h>
# include <net/if_dl.h>
@ -278,6 +278,33 @@
# include <net/inet_common.h>
# endif
#endif
#elif defined(__SOLARIS__)
/*
** *** S O L A R I S ***
*/
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/cmn_err.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/strsun.h>
#include <sys/kmem.h>
#include <sys/stat.h>
#include <sys/modctl.h>
#include <sys/dditypes.h>
#include <sys/ddi.h>
#include <sys/conf.h>
#include <sys/ethernet.h>
#include <sys/sunddi.h>
#include <sys/ddidmareq.h>
#include <sys/ddimapreq.h>
#include <sys/ddipropdefs.h>
#include <sys/ddidevmap.h>
#include <sys/devops.h>
#include <sys/pci.h>
#include <sys/dlpi.h>
#include <sys/gld.h>
#elif defined(__WINDOWS__)
/*
** *** W I N D O W S ***
@ -291,6 +318,26 @@
# include <stdarg.h>
# include <stdio.h>
# endif
#elif defined (__SOLARIS__)
# include <sys/types.h>
# include <sys/systm.h>
# include <sys/cmn_err.h>
# include <sys/kmem.h>
# include <sys/stat.h>
# include <sys/modctl.h>
# include <sys/ddi.h>
# include <sys/conf.h>
# include <sys/sunddi.h>
# include <sys/ethernet.h>
# include <sys/dditypes.h>
# include <sys/ddidmareq.h>
# include <sys/ddimapreq.h>
# include <sys/ddipropdefs.h>
# include <sys/ddidevmap.h>
# include <sys/devops.h>
# include <sys/pci.h>
# include <sys/gld.h>
# include <netinet/in.h>
#else
# error "Unsupported Operating System!";
#endif

View File

@ -28,6 +28,16 @@ extern void *wp_register_lapb_prot(void *, char *,
void *,
wplip_prot_reg_t *);
extern int wp_unregister_lapb_prot(void *);
extern void *wp_register_lapb_chan_prot(void *callback_dev_ptr,
void *link_ptr,
char *devname,
void *cfg_ptr,
unsigned char type);
extern int wp_unregister_lapb_chan_prot(void *dev_ptr);
extern int wp_lapb_open(void *lapb_ptr);
extern int wp_lapb_close(void *lapb_ptr);
extern int wp_lapb_rx(void *lapb_ptr, void *skb);

View File

@ -1,4 +1,4 @@
/* $Header: /usr/local/cvsroot/wanpipe_common/include/wanpipe_lip.h,v 1.25 2005/02/10 18:53:45 sangoma Exp $ */
/* $Header: /usr/local/cvsroot/wanpipe_common/include/wanpipe_lip.h,v 1.33 2005/11/10 18:02:32 sangoma Exp $ */
#ifndef _WANPIPE_LIP_HEADER_
#define _WANPIPE_LIP_HEADER_
@ -39,6 +39,7 @@
# include <linux/if_wanpipe.h>
# include <linux/if_wanpipe_common.h>
# include <linux/wanpipe_fr_iface.h>
# include <linux/wanpipe_lip_atm_iface.h>
# include <linux/wanpipe_sppp_iface.h>
# if defined(CONFIG_PRODUCT_WANPIPE_LAPB)
# include <linux/wanpipe_lapb_iface.h>
@ -46,6 +47,9 @@
# if defined(CONFIG_PRODUCT_WANPIPE_XDLC)
# include <linux/wanpipe_xdlc_iface.h>
# endif
# if defined(CONFIG_PRODUCT_WANPIPE_XMTP2)
# include <linux/wanpipe_xmtp2_iface.h>
# endif
# include <linux/wanpipe_lip_kernel.h>
# include <linux/wanpipe_iface.h>
@ -88,6 +92,25 @@
#define MAX_LINK_RX_Q_LEN 10
#define MAX_TAIL_ROOM 16
#define MAX_LIP_LINKS 255
#if 0
/* This option defaults the inital network
* interface state to STOPPED/DISABLED.
*
* In this case, all traffic will be blocked
* and data pushed back up the protocol stack.
* This can cause memory starvation if there are
* many interfaces running, because each interface
* queue can be up to 100 packets, and fames will
* only be dropped once the queue is overfilled
*
* By disabling this option, all packets received
* by the interface in disconnected state, will be
* silently discarded with carrier stat incremented.
*/
#define WANPIPE_LIP_IFNET_QUEUE_POLICY_INIT_OFF
#endif
/* BH flags */
enum{
WPLIP_BH_RUNNING,
@ -138,7 +161,9 @@ enum {
#define MAX_PROC_EVENT_SIZE X25_CALL_STR_SZ+200+1
/*#define MAX_TX_BUF 10*/
#define MAX_TX_BUF 10
#define MAX_ATM_TX_BUF 35
#define MAX_RX_Q 32
#define WPLIP_MAGIC_LINK 0xDAFE1234
@ -239,6 +264,9 @@ typedef struct wplip_link
unsigned char async_mode;
#endif
wan_taskq_t prot_task;
unsigned int latency_qlen;
} wplip_link_t;
@ -281,10 +309,15 @@ typedef struct wplip_dev{
unsigned long ipx_net_num;
unsigned int prot_addr;
unsigned int max_mtu_sz;
unsigned int max_mtu_sz_orig;
atomic_t refcnt;
pid_t pid;
unsigned int interface_down;
wan_taskq_t if_task;
} wplip_dev_t;
@ -330,6 +363,7 @@ typedef struct wplip_prot_iface
int (*timer) (void *prot_ptr, unsigned int *period, unsigned int);
int (*bh) (void *);
int (*snmp) (void *, void *);
int (*task) (void *prot_ptr);
}wplip_prot_iface_t;
@ -377,6 +411,8 @@ extern int wplip_data_rx_up(wplip_dev_t* lip_dev, void *skb);
extern int wplip_data_tx_down(wplip_link_t *lip_link, void *skb);
extern int wplip_callback_tx_down(void *lip_dev, void *skb);
extern int wplip_link_callback_tx_down(void *lip_link, void *skb);
extern int wplip_callback_kick_prot_task(void *lip_link);
extern int wplip_set_hw_idle_frame (void *liplink_ptr, unsigned char *data, int len);
/* wanpipe_lip_sub.c */
extern wplip_link_t* wplip_create_link(char *devname);
@ -384,6 +420,7 @@ extern void wplip_remove_link(wplip_link_t *lip_link);
extern void wplip_insert_link(wplip_link_t *lip_link);
extern int wplip_link_exists(wplip_link_t *lip_link);
extern void wplip_free_link(wplip_link_t *lip_link);
extern int wplip_lipdev_latency_change(wplip_link_t *lip_link);
#if 1
@ -406,6 +443,8 @@ extern int wplip_stop_dev(netdevice_t *dev);
extern struct net_device_stats * wplip_ifstats (netdevice_t *dev);
extern int wplip_if_send (netskb_t *skb, netdevice_t *dev);
extern int wplip_if_init(netdevice_t *dev);
extern void wplip_kick(void *wplip_id,int reason);
# ifdef WPLIP_TTY_SUPPORT
/* wanpipe_lip_tty.c */
@ -452,6 +491,7 @@ extern int wplip_set_ipv4_addr (void *wplip_id,
unsigned int,
unsigned int);
extern void wplip_add_gateway(void *wplip_id);
extern void wplip_trigger_if_task(wplip_dev_t *lip_dev);
void wplip_ipxwan_switch_net_num(unsigned char *sendpacket,
unsigned long network_number,
@ -506,11 +546,12 @@ static __inline int wplip_kick_trigger_bh(wplip_link_t *lip_link)
return 0;
}
static __inline int wplip_decode_protocol(void *ptr)
static __inline int wplip_decode_protocol(wplip_dev_t *lip_dev, void *ptr)
{
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
struct sockaddr *sa = (struct sockaddr *)ptr;
switch (sa->sa_family){
case AF_INET:
@ -525,7 +566,24 @@ static __inline int wplip_decode_protocol(void *ptr)
#elif defined(__LINUX__)
struct sk_buff *skb=(struct sk_buff*)ptr;
if (lip_dev->common.usedby == BRIDGE ||
lip_dev->common.usedby == BRIDGE_NODE){
return WPLIP_ETH;
}
if (lip_dev->common.usedby == STACK){
switch (lip_dev->common.lip_prot){
case WANCONFIG_PPP:
case WANCONFIG_TTY:
return WPLIP_PPP;
case WANCONFIG_FR:
return WPLIP_FR;
}
/* Break out down */
}
switch (htons(skb->protocol)){
case ETH_P_IP:
@ -535,7 +593,7 @@ static __inline int wplip_decode_protocol(void *ptr)
case ETH_P_IPX:
return WPLIP_IPX;
}
return WPLIP_IP;
#else
# error ("wplip_decode_protocol: Unknown Protocol!\n");
@ -543,6 +601,24 @@ static __inline int wplip_decode_protocol(void *ptr)
}
#if defined(__LINUX__)
static __inline void wp_lip_config_bridge_mode(wplip_dev_t *lip_dev)
{
netdevice_t * dev = lip_dev->common.dev;
/* Setup the interface for Bridging */
int hw_addr=0;
ether_setup(dev);
/* Use a random number to generate the MAC address */
memcpy(dev->dev_addr, "\xFE\xFC\x00\x00\x00\x00", 6);
get_random_bytes(&hw_addr, sizeof(hw_addr));
*(int *)(dev->dev_addr + 2) += hw_addr;
}
#endif
/*__KERNEL__*/
#endif

View File

@ -0,0 +1,69 @@
/*****************************************************************************
* wanpipe_lip_atm_iface.h WANPIPE(tm) ATM ALL5 SAR Interface Header
*
* Authors: David Rokhvarg <davidr@sangoma.com>
*
* Copyright: (c) 2003 Sangoma Technologies Inc.
*
* 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.
* ============================================================================
* September 15, 2005 David Rokhvarg Initial Version
*****************************************************************************/
#ifndef _WANPIPE_LIP_ATM_IFACE_H
#define _WANPIPE_LIP_ATM_IFACE_H
#include <linux/wanpipe_cfg.h>
#define wplist_insert_dev(dev, list) do{\
dev->next = list;\
list = dev;\
}while(0)
#define wplist_remove_dev(dev,cur,prev,list)\
do{\
if ((cur=list) == dev){\
list=cur->next;\
break;\
}else{\
while (cur!=NULL && cur->next!=NULL){\
prev=cur;\
cur=cur->next;\
if (cur==dev){\
prev->next=cur->next;\
break;\
}\
}\
}\
}while(0)
extern void *wp_register_atm_prot(void *link_ptr,
char *devname,
void *cfg,
wplip_prot_reg_t *atm_reg);
extern int wp_unregister_atm_prot(void *prot_ptr);
extern void *wp_register_atm_chan(void *if_ptr,
void *prot_ptr,
char *devname,
void *cfg,
unsigned char type);
extern int wp_unregister_atm_chan(void *chan_ptr);
extern int wp_atm_open_chan (void *chan_ptr);
extern int wp_atm_close_chan(void *chan_ptr);
extern int wp_atm_ioctl (void *chan_ptr, int cmd, void *arg);
extern int wp_atm_rx (void * prot_ptr, void *rx_pkt);
extern int wp_atm_timer (void *prot_ptr, unsigned int *period, unsigned int carrier_reliable);
extern int wp_atm_tx (void * chan_ptr, void *skb, int type);
extern int wp_atm_pipemon(void *chan, int cmd, int dlci, unsigned char* data, unsigned int *len);
extern int wp_atm_snmp(void* chan_ptr, void* data);
#endif

View File

@ -18,7 +18,7 @@
#define WANPIPE_SNMP_VERSION "1.0.4"
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined (__OpenBSD__)
# define SIOC_WANPIPE_SNMP _IOWR('i', 100, struct ifreq)
# define SIOC_WANPIPE_SNMP _IOWR('i', 100, struct ifreq)
# define SIOC_WANPIPE_SNMP_IFSPEED _IOWR('i', 101, struct ifreq)
#else
//# include <linux/if_wanpipe.h>

View File

@ -40,6 +40,7 @@ extern int wp_sppp_bh(void *sppp_ptr);
extern int wp_sppp_tx(void *sppp_ptr, void *skb, int type);
extern int wp_sppp_timer(void *sppp_ptr, unsigned int *period, unsigned int carrier_reliable);
extern int wp_sppp_pipemon(void *sppp, int cmd, int addr, unsigned char* data, unsigned int *len);
extern int wp_sppp_task(void *sppp_ptr);
#endif
@ -57,6 +58,7 @@ extern int wp_sppp_pipemon(void *sppp, int cmd, int addr, unsigned char* data, u
#define PPP_SET_INBOUND_AUTH 0x30
#define PPP_SET_OUTBOUND_AUTH 0x31
#define PPP_GET_CONNECTION_INFO 0x32
#define PPP_GET_LINK_STATUS 0x34
#define PPP_COMM_ENABLE 0x03 /* operational commands */
#define PPP_COMM_DISABLE 0x04

View File

@ -2,24 +2,24 @@
#define __WANPIPE_VERSION__
#define WANPIPE_COPYRIGHT_DATES "(c) 1994-2005"
#define WANPIPE_COPYRIGHT_DATES "(c) 1994-2006"
#define WANPIPE_COMPANY "Sangoma Technologies Inc"
/********** LINUX **********/
#define WANPIPE_VERSION "2.3.2"
#define WANPIPE_VERSION "2.3.3"
#define WANPIPE_SUB_VERSION "7"
#define WANPIPE_VERSION_BETA 0
#define WANPIPE_VERSION_BETA 0
#define WANPIPE_LITE_VERSION "1.1.1"
/********** FreeBSD **********/
#define WANPIPE_VERSION_FreeBSD "2.7.5"
#define WANPIPE_SUB_VERSION_FreeBSD "12"
#define WANPIPE_VERSION_FreeBSD "2.8.2"
#define WANPIPE_SUB_VERSION_FreeBSD "1"
#define WANPIPE_VERSION_BETA_FreeBSD 1
#define WANPIPE_LITE_VERSION_FreeBSD "1.1.1"
/********** OpenBSD **********/
#define WANPIPE_VERSION_OpenBSD "1.6.1"
#define WANPIPE_SUB_VERSION_OpenBSD "8"
#define WANPIPE_VERSION_OpenBSD "1.6.2"
#define WANPIPE_SUB_VERSION_OpenBSD "1"
#define WANPIPE_VERSION_BETA_OpenBSD 1
#define WANPIPE_LITE_VERSION_OpenBSD "1.1.1"

View File

@ -87,48 +87,9 @@ int wandev_get_info(char* buf, char** start, off_t offs, int len);
int interfaces_get_info(char* buf, char** start, off_t offs, int len);
int wanproc_active_dev(char* buf, char** start, off_t offs, int len);
#endif
extern int proc_add_line(struct seq_file* m, char* frm, ...);
#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
static int proc_add_line(struct seq_file* m, char* frm, ...)
#else
static inline int proc_add_line(struct seq_file* m, char* frm, ...)
#endif
{
#if defined(LINUX_2_6)
return 0;
#else
char tmp[400];
int ret = PROC_BUF_CONT;
int size = 0;
va_list arg;
va_start(arg, frm);
if (m->count && m->stop_cnt){
va_end(arg);
return PROC_BUF_EXIT;
}
size = vsprintf(tmp, frm, arg);
if (m->stop_cnt){
if (m->stop_cnt < size){
DEBUG_EVENT("!!! Error in writting in proc buffer !!!\n");
m->stop_cnt = size;
}
m->stop_cnt -= size;
}else{
if (size < m->size - m->count){
/*vsprintf(&m->buf[m->count], frm, arg);*/
memcpy(&m->buf[m->count], tmp, size);
m->count += size;
/* *cnt += vsprintf(&buf[*cnt], frm, arg); */
}else{
m->stop_cnt = m->from + m->count;
ret = PROC_BUF_EXIT;
}
}
va_end(arg);
return ret;
#endif
}
/*
* ******************************************************************

View File

@ -73,19 +73,12 @@
# define ROUTER_USER_MAX _IOW(ROUTER_IOCTL, 31, u_int)
# define SIOC_WANPIPE_PIPEMON _IOWR('i', 150, struct ifreq) /* get monitor statistics */
# define SIOC_WANPIPE_DEVICE _IOWR('i', 151, struct ifreq) /* set generic device */
# define SIOC_WAN_HWPROBE _IOWR('i', 152, struct ifreq) /* get hwprobe string */
# define SIOC_WAN_DEVEL_IOCTL _IOWR('i', 152, struct ifreq) /* get hwprobe string */
# define SIOC_WANPIPE_DUMP _IOWR('i', 153, struct ifreq) /* get memdump string (GENERIC) */
# define SIOC_AFT_CUSTOMER_ID _IOWR('i', 154, struct ifreq) /* get AFT customer ID */
# define SIOC_WAN_READ_REG _IOWR('i', 155, struct ifreq) /* read AFT register */
# define SIOC_WAN_WRITE_REG _IOWR('i', 156, struct ifreq) /* write AFT register */
# define SIOC_WAN_SET_PCI_BIOS _IOWR('i', 159, struct ifreq) /* set pci BIOS register */
# define SIOC_WAN_ALL_READ_REG _IOWR('i', 157, struct ifreq) /* read register for all AFT cards */
# define SIOC_WAN_ALL_WRITE_REG _IOWR('i', 158, struct ifreq) /* write register to all AFT cards */
# define SIOC_WAN_ALL_SET_PCI_BIOS _IOWR('i', 162, struct ifreq) /* set ALL pci BIOS register */
# define SIOC_WAN_ALL_HWPROBE _IOWR('i', 163, struct ifreq) /* get hwprobe string */
# define SIOC_WAN_GET_CFG _IOWR('i', 160, struct ifreq) /* get configuration */
# define SIOC_WAN_COREREV _IOWR('i', 161, struct ifreq) /* get core revision */
#else
enum router_ioctls
{
ROUTER_SETUP = ROUTER_IOCTL<<8, /* configure device */
@ -212,6 +205,10 @@ typedef struct wan_conf
# include <net/wanpipe_debug.h>
# include <net/wanpipe_cfg.h>
# include <net/wanpipe_common.h>
# ifdef CONFIG_PRODUCT_WANPIPE_TDM_VOICE
# include <net/sdla_tdmv.h>
# endif
#else
//# include <linux/version.h>
# include <linux/wanpipe_includes.h>
@ -383,6 +380,10 @@ typedef struct wan_device
unsigned char macAddr[ETHER_ADDR_LEN];
sdla_fe_iface_t fe_iface;
#if defined(CONFIG_PRODUCT_WANPIPE_TDMV_EC)
unsigned char (*write_ec)(void*, unsigned short, unsigned char);
unsigned char (*read_ec)(void*, unsigned short);
#endif
} wan_device_t;
WAN_LIST_HEAD(wan_devlist_, wan_device);
@ -406,6 +407,7 @@ extern int wanpipe_lip_rx(void *chan, void *sk_id);
extern int wanpipe_lip_connect(void *chan, int );
extern int wanpipe_lip_disconnect(void *chan, int);
extern int wanpipe_lip_kick(void *chan,int);
extern int wanpipe_lip_get_if_status(void *chan, void *m);
#elif defined(__LINUX__)
unsigned short wanrouter_type_trans(struct sk_buff *skb, netdevice_t *dev);
int wanrouter_encapsulate(struct sk_buff *skb, netdevice_t *dev,unsigned short type);

View File

@ -1,343 +0,0 @@
Only in /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/: af_wanpipe_annexg_api.c
diff -dur wanrouter/af_wanpipe.c /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/af_wanpipe.c
--- wanrouter/af_wanpipe.c 2005-05-16 19:23:50.000000000 -0400
+++ /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/af_wanpipe.c 2005-06-14 12:58:17.737815992 -0400
@@ -404,7 +404,7 @@
return -ENODEV;
}
- newsk->sk_zapped=1;
+ wansk_set_zapped(newsk);
newsk->sk_bound_dev_if = dev->ifindex;
dev_hold(dev);
SK_PRIV(newsk)->dev = dev;
@@ -573,7 +573,7 @@
* we go the pointer for skb */
__sock_put(newsk);
- if (newsk->sk_zapped && SK_PRIV(newsk) &&
+ if (wansk_is_zapped(newsk) && SK_PRIV(newsk) &&
(dev = (struct net_device *)SK_PRIV(newsk)->dev)){
if (dev && dev->do_ioctl){
@@ -671,7 +671,7 @@
return -ENODEV;
}
- if (!sk->sk_zapped){
+ if (!wansk_is_zapped(sk)){
return -EINVAL;
}
@@ -828,7 +828,7 @@
WAN_ASSERT_EINVAL(!SK_PRIV(sk));
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -ENETDOWN;
if (sk->sk_state != WANSOCK_CONNECTED)
@@ -954,7 +954,7 @@
WAN_ASSERT_VOID(!SK_PRIV(sk));
sk->sk_state = WANSOCK_DISCONNECTED;
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
sk->sk_bound_dev_if=0;
if (SK_PRIV(sk)->dev){
dev_put(SK_PRIV(sk)->dev);
@@ -1079,7 +1079,7 @@
#ifdef CONFIG_PRODUCT_WANPIPE_SOCK_DATASCOPE
if (SK_PRIV(sk) && DATA_SC(sk) && DATA_SC(sk)->parent_sk != NULL){
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
wanpipe_unbind_sk_from_parent(sk);
}
#endif
@@ -1100,7 +1100,7 @@
}else if ((SK_PRIV(sk)->num == htons(ETH_P_X25) ||
SK_PRIV(sk)->num == htons(WP_X25_PROT) ||
- SK_PRIV(sk)->num == htons(DSP_PROT)) && sk->sk_zapped){
+ SK_PRIV(sk)->num == htons(DSP_PROT)) && wansk_is_zapped(sk)){
netdevice_t *dev = (struct net_device *)SK_PRIV(sk)->dev;
if (dev){
@@ -1114,7 +1114,7 @@
}else{
DEBUG_EVENT("%s: No dev on svc release !\n",__FUNCTION__);
}
- }else if (sk->sk_zapped){
+ }else if (wansk_is_zapped(sk)){
netdevice_t *dev = (struct net_device *)SK_PRIV(sk)->dev;
if (dev){
if(dev->do_ioctl){
@@ -1128,7 +1128,7 @@
}
sk->sk_state = WANSOCK_DISCONNECTED;
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
sk->sk_bound_dev_if=0;
if (SK_PRIV(sk)->dev){
dev_put((struct net_device*)SK_PRIV(sk)->dev);
@@ -1433,7 +1433,7 @@
}
if (!err){
- sk->sk_zapped=1;
+ wansk_set_zapped(sk);
}
// printk(KERN_INFO "11-11 Bind Socket Prot %i, X25=%i Zapped %i, Bind Dev %i Sock %u!\n",
@@ -1468,7 +1468,7 @@
sock->ops = &wanpipe_ops;
sock_init_data(sock,sk);
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
sk->sk_family = AF_WANPIPE;
SK_PRIV(sk)->num = protocol;
sk->sk_state = WANSOCK_UNCONFIGURED;
@@ -1518,7 +1518,7 @@
WAN_ASSERT_EINVAL(!SK_PRIV(sk));
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -ENETDOWN;
/*
@@ -1676,7 +1676,7 @@
sk->sk_state = WANSOCK_DISCONNECTED;
}
sk->sk_bound_dev_if = 0;
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
if (SK_PRIV(sk) && SK_PRIV(sk)->dev){
dev_put((struct net_device *)SK_PRIV(sk)->dev);
@@ -1714,7 +1714,7 @@
return 0;
}
- if (!SK_PRIV(sk) || !sk->sk_zapped){
+ if (!SK_PRIV(sk) || !wansk_is_zapped(sk)){
mask |= POLLPRI;
return mask;
}
@@ -1726,7 +1726,7 @@
/* exceptional events? */
if (!SK_PRIV(sk) ||
- !sk->sk_zapped ||
+ !wansk_is_zapped(sk) ||
sk->sk_err ||
!skb_queue_empty(&sk->sk_error_queue)){
mask |= POLLPRI;
@@ -1781,7 +1781,7 @@
if (sk == NULL || dev == NULL)
return -EINVAL;
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -EINVAL;
DEBUG_TEST("%s: API Connected!\n",__FUNCTION__);
@@ -1796,7 +1796,7 @@
if (sk == NULL || dev == NULL)
return -EINVAL;
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -EINVAL;
DEBUG_TEST("%s: API Connecting!\n",__FUNCTION__);
@@ -1822,7 +1822,7 @@
}
- if (!sk->sk_zapped){
+ if (!wansk_is_zapped(sk)){
return -EINVAL;
}
@@ -1850,7 +1850,7 @@
struct wan_sockaddr_ll *addr = (struct wan_sockaddr_ll*)uaddr;
netdevice_t *dev;
- if (!sk->sk_zapped){ /* Must bind first - autobinding does not work */
+ if (!wansk_is_zapped(sk)){ /* Must bind first - autobinding does not work */
return -EINVAL;
}
@@ -1914,7 +1914,7 @@
static int sk_buf_check (struct sock *sk, int len)
{
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -EINVAL;
if (atomic_read(&sk->sk_rmem_alloc) + len >= (unsigned)sk->sk_rcvbuf)
@@ -1925,7 +1925,7 @@
static int sk_poll_wake (struct sock *sk)
{
- if (!sk->sk_zapped)
+ if (!wansk_is_zapped(sk))
return -EINVAL;
sk->sk_data_ready(sk,0);
diff -dur wanrouter/af_wanpipe_datascope.c /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/af_wanpipe_datascope.c
--- wanrouter/af_wanpipe_datascope.c 2005-05-16 19:23:50.000000000 -0400
+++ /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/af_wanpipe_datascope.c 2005-06-14 12:58:18.223742120 -0400
@@ -220,7 +220,7 @@
wanpipe_sk_parent_rx_bh, (unsigned long)parent_sk);
skb_queue_head_init(&PPRIV(parent_sk)->rx_queue);
- parent_sk->sk_zapped=0;
+ wansk_reset_zapped(parent_sk);
DATA_SC(parent_sk)->parent=1;
if (DATA_SC(sk)->active_ch){
@@ -311,7 +311,7 @@
parent_sk->sk_bound_dev_if = dev->ifindex;
SK_PRIV(parent_sk)->dev = dev;
- parent_sk->sk_zapped=1;
+ wansk_set_zapped(parent_sk);
}else{
if (SK_PRIV(parent_sk)->num != SK_PRIV(sk)->num){
@@ -378,7 +378,7 @@
SK_PRIV(sk)->dev=dev;
sk->sk_bound_dev_if = dev->ifindex;
sk->sk_state = parent_sk->sk_state;
- sk->sk_zapped=1;
+ wansk_set_zapped(sk);
return 0;
}
@@ -447,7 +447,7 @@
}
- sk->sk_zapped=0;
+ wansk_reset_zapped(sk);
wan_free(DATA_SC(sk));
DATA_SC_INIT(sk,NULL);
diff -dur wanrouter/wanmain.c /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/wanmain.c
--- wanrouter/wanmain.c 2005-05-16 19:23:50.000000000 -0400
+++ /root/2.3.3/wanpipe/patches/kdrivers/src/wanrouter/wanmain.c 2005-06-07 13:02:21.000000000 -0400
@@ -181,9 +181,7 @@
*/
static wan_device_t *find_device (char *name);
-static int delete_interface (wan_device_t *wandev, netdevice_t *dev);
-
-
+static int delete_interface (wan_device_t *wandev, netdevice_t *dev, int force);
/*
* Global Data
@@ -742,6 +740,7 @@
wandev_conf_t *conf = NULL;
wan_smp_flag_t smp_flags;
int err=0;
+ int force=0;
if (wandev->state == WAN_UNCONFIGURED){
return 0;
@@ -762,6 +761,9 @@
wan_free(conf);
return -EFAULT;
}
+ }else{
+ /* Module is being unloaded we have no choice here */
+ force=1;
}
printk(KERN_INFO "\n");
@@ -771,7 +773,7 @@
while(devle){
dev = WAN_DEVLE2DEV(devle);
- if ((err=delete_interface(wandev, dev)) != 0){
+ if ((err=delete_interface(wandev, dev, force)) != 0){
return err;
}
@@ -840,7 +842,6 @@
* o make sure there is no interface name conflict
* o register network interface
*/
-
static int wan_device_new_if (wan_device_t *wandev, wanif_conf_t *u_conf)
{
struct wan_dev_le *devle;
@@ -889,13 +890,7 @@
err = -EINVAL;
}else if (dev_get_by_name(dev->name)){
err = -EEXIST; /* name already exists */
- }else{
-
- #ifdef WANDEBUG
- printk(KERN_INFO "%s: registering interface %s...\n",
- modname, dev->name);
- #endif
-
+ }else if (dev->priv){
err = register_netdev(dev);
if (!err) {
wan_smp_flag_t smp_flags=0;
@@ -912,6 +907,7 @@
return 0;
}
}
+
if (wandev->del_if)
wandev->del_if(wandev, dev);
}
@@ -1000,7 +996,7 @@
}
- err = delete_interface(wandev, dev);
+ err = delete_interface(wandev, dev,0);
if (err){
return(err);
}
@@ -1068,18 +1064,17 @@
* sure that opened interfaces are not removed!
*/
-static int delete_interface (wan_device_t *wandev, netdevice_t *dev)
+static int delete_interface (wan_device_t *wandev, netdevice_t *dev, int force)
{
int err;
if (dev == NULL){
return -ENODEV; /* interface not found */
}
-
+
if (netif_running(dev)){
return -EBUSY; /* interface in use */
}
-
/* Unregister the lip interface attached
* to this interace */
err=wan_device_unreg_lip(dev);
@@ -1106,7 +1101,7 @@
}
unregister_netdev(dev);
-
+
DEBUG_SUB_MEM(sizeof(netdevice_t));
#ifdef LINUX_2_2

View File

@ -0,0 +1,261 @@
wanpipe_lip_ipx.o: wanpipe_lip_ipx.c \
/usr/src/linux/include/linux/wanpipe_lip.h \
/usr/src/linux/include/linux/wanpipe_includes.h \
/usr/src/linux/include/linux/init.h \
/usr/src/linux/include/linux/config.h \
/usr/src/linux/include/linux/autoconf.h \
/usr/src/linux/include/linux/compiler.h \
/usr/src/linux/include/linux/compiler-gcc3.h \
/usr/src/linux/include/linux/compiler-gcc.h \
/usr/src/linux/include/linux/version.h \
/usr/src/linux/include/linux/module.h \
/usr/src/linux/include/linux/sched.h /usr/src/linux/include/asm/param.h \
/usr/src/linux/include/linux/capability.h \
/usr/src/linux/include/linux/types.h \
/usr/src/linux/include/linux/posix_types.h \
/usr/src/linux/include/linux/stddef.h \
/usr/src/linux/include/asm/posix_types.h \
/usr/src/linux/include/asm/types.h \
/usr/src/linux/include/linux/spinlock.h \
/usr/src/linux/include/linux/preempt.h \
/usr/src/linux/include/linux/linkage.h \
/usr/src/linux/include/asm/linkage.h \
/usr/src/linux/include/linux/thread_info.h \
/usr/src/linux/include/linux/bitops.h \
/usr/src/linux/include/asm/bitops.h \
/usr/src/linux/include/asm/thread_info.h \
/usr/src/linux/include/asm/page.h \
/usr/src/linux/include/asm/processor.h \
/usr/src/linux/include/asm/vm86.h /usr/src/linux/include/asm/math_emu.h \
/usr/src/linux/include/asm/sigcontext.h \
/usr/src/linux/include/asm/segment.h \
/usr/src/linux/include/asm/cpufeature.h \
/usr/src/linux/include/asm/msr.h /usr/src/linux/include/asm/system.h \
/usr/src/linux/include/linux/kernel.h \
/usr/lib/gcc/i386-redhat-linux/3.4.3/include/stdarg.h \
/usr/src/linux/include/asm/byteorder.h \
/usr/src/linux/include/linux/byteorder/little_endian.h \
/usr/src/linux/include/linux/byteorder/swab.h \
/usr/src/linux/include/linux/byteorder/generic.h \
/usr/src/linux/include/asm/bug.h \
/usr/src/linux/include/asm-generic/bug.h \
/usr/src/linux/include/linux/cache.h /usr/src/linux/include/asm/cache.h \
/usr/src/linux/include/linux/threads.h \
/usr/src/linux/include/linux/stringify.h \
/usr/src/linux/include/asm/spinlock.h \
/usr/src/linux/include/asm/atomic.h /usr/src/linux/include/asm/rwlock.h \
/usr/src/linux/include/linux/timex.h /usr/src/linux/include/asm/timex.h \
/usr/src/linux/include/linux/time.h \
/usr/src/linux/include/linux/seqlock.h \
/usr/src/linux/include/asm/div64.h \
/usr/src/linux/include/linux/jiffies.h \
/usr/src/linux/include/linux/rbtree.h \
/usr/src/linux/include/linux/cpumask.h \
/usr/src/linux/include/linux/bitmap.h \
/usr/src/linux/include/linux/string.h \
/usr/src/linux/include/asm/string.h \
/usr/src/linux/include/asm/semaphore.h \
/usr/src/linux/include/linux/wait.h /usr/src/linux/include/linux/list.h \
/usr/src/linux/include/linux/prefetch.h \
/usr/src/linux/include/linux/rwsem.h /usr/src/linux/include/asm/rwsem.h \
/usr/src/linux/include/asm/ptrace.h /usr/src/linux/include/asm/mmu.h \
/usr/src/linux/include/linux/smp.h /usr/src/linux/include/asm/smp.h \
/usr/src/linux/include/asm/fixmap.h /usr/src/linux/include/asm/acpi.h \
/usr/src/linux/include/asm/apicdef.h \
/usr/src/linux/include/asm/kmap_types.h \
/usr/src/linux/include/asm/mpspec.h \
/usr/src/linux/include/asm/mpspec_def.h \
/usr/src/linux/include/asm-i386/mach-generic/mach_mpspec.h \
/usr/src/linux/include/asm/io_apic.h /usr/src/linux/include/asm/apic.h \
/usr/src/linux/include/linux/pm.h \
/usr/src/linux/include/asm-i386/mach-generic/mach_apicdef.h \
/usr/src/linux/include/asm/genapic.h /usr/src/linux/include/linux/sem.h \
/usr/src/linux/include/linux/ipc.h /usr/src/linux/include/asm/ipcbuf.h \
/usr/src/linux/include/asm/sembuf.h \
/usr/src/linux/include/linux/signal.h \
/usr/src/linux/include/asm/signal.h \
/usr/src/linux/include/asm/siginfo.h \
/usr/src/linux/include/asm-generic/siginfo.h \
/usr/src/linux/include/linux/resource.h \
/usr/src/linux/include/asm/resource.h \
/usr/src/linux/include/linux/securebits.h \
/usr/src/linux/include/linux/fs_struct.h \
/usr/src/linux/include/linux/completion.h \
/usr/src/linux/include/linux/pid.h \
/usr/src/linux/include/linux/percpu.h \
/usr/src/linux/include/linux/slab.h /usr/src/linux/include/linux/gfp.h \
/usr/src/linux/include/linux/mmzone.h \
/usr/src/linux/include/linux/numa.h \
/usr/src/linux/include/linux/topology.h \
/usr/src/linux/include/asm/topology.h \
/usr/src/linux/include/asm-generic/topology.h \
/usr/src/linux/include/linux/kmalloc_sizes.h \
/usr/src/linux/include/asm/percpu.h \
/usr/src/linux/include/asm-generic/percpu.h \
/usr/src/linux/include/linux/param.h \
/usr/src/linux/include/linux/timer.h /usr/src/linux/include/linux/aio.h \
/usr/src/linux/include/linux/workqueue.h \
/usr/src/linux/include/linux/aio_abi.h \
/usr/src/linux/include/asm/current.h \
/usr/src/linux/include/linux/stat.h /usr/src/linux/include/asm/stat.h \
/usr/src/linux/include/linux/kmod.h \
/usr/src/linux/include/linux/errno.h /usr/src/linux/include/asm/errno.h \
/usr/src/linux/include/asm-generic/errno.h \
/usr/src/linux/include/asm-generic/errno-base.h \
/usr/src/linux/include/linux/elf.h /usr/src/linux/include/asm/elf.h \
/usr/src/linux/include/asm/user.h /usr/src/linux/include/asm/desc.h \
/usr/src/linux/include/asm/ldt.h /usr/src/linux/include/linux/utsname.h \
/usr/src/linux/include/linux/kobject.h \
/usr/src/linux/include/linux/sysfs.h \
/usr/src/linux/include/linux/kref.h \
/usr/src/linux/include/linux/moduleparam.h \
/usr/src/linux/include/asm/local.h /usr/src/linux/include/asm/module.h \
/usr/src/linux/include/linux/mm.h \
/usr/src/linux/include/linux/prio_tree.h \
/usr/src/linux/include/linux/fs.h /usr/src/linux/include/linux/limits.h \
/usr/src/linux/include/linux/kdev_t.h \
/usr/src/linux/include/linux/ioctl.h /usr/src/linux/include/asm/ioctl.h \
/usr/src/linux/include/linux/dcache.h \
/usr/src/linux/include/linux/rcupdate.h \
/usr/src/linux/include/linux/radix-tree.h \
/usr/src/linux/include/linux/audit.h \
/usr/src/linux/include/linux/quota.h \
/usr/src/linux/include/linux/dqblk_xfs.h \
/usr/src/linux/include/linux/dqblk_v1.h \
/usr/src/linux/include/linux/dqblk_v2.h \
/usr/src/linux/include/linux/nfs_fs_i.h \
/usr/src/linux/include/linux/nfs.h \
/usr/src/linux/include/linux/sunrpc/msg_prot.h \
/usr/src/linux/include/linux/fcntl.h /usr/src/linux/include/asm/fcntl.h \
/usr/src/linux/include/linux/err.h /usr/src/linux/include/asm/pgtable.h \
/usr/src/linux/include/asm/pgtable-3level-defs.h \
/usr/src/linux/include/asm/pgtable-3level.h \
/usr/src/linux/include/asm-generic/pgtable.h \
/usr/src/linux/include/linux/page-flags.h \
/usr/src/linux/include/linux/ctype.h /usr/src/linux/include/net/ip.h \
/usr/src/linux/include/linux/socket.h \
/usr/src/linux/include/asm/socket.h \
/usr/src/linux/include/asm/sockios.h \
/usr/src/linux/include/linux/sockios.h \
/usr/src/linux/include/linux/uio.h /usr/src/linux/include/linux/ip.h \
/usr/src/linux/include/net/sock.h \
/usr/src/linux/include/linux/netdevice.h \
/usr/src/linux/include/linux/if.h \
/usr/src/linux/include/linux/hdlc/ioctl.h \
/usr/src/linux/include/linux/if_ether.h \
/usr/src/linux/include/linux/skbuff.h \
/usr/src/linux/include/linux/highmem.h \
/usr/src/linux/include/asm/cacheflush.h \
/usr/src/linux/include/asm/highmem.h \
/usr/src/linux/include/linux/interrupt.h \
/usr/src/linux/include/linux/hardirq.h \
/usr/src/linux/include/linux/smp_lock.h \
/usr/src/linux/include/asm/hardirq.h /usr/src/linux/include/linux/irq.h \
/usr/src/linux/include/asm/irq.h \
/usr/src/linux/include/asm-i386/mach-default/irq_vectors.h \
/usr/src/linux/include/asm-i386/mach-default/irq_vectors_limits.h \
/usr/src/linux/include/asm/hw_irq.h \
/usr/src/linux/include/linux/profile.h \
/usr/src/linux/include/asm/sections.h \
/usr/src/linux/include/asm-generic/sections.h \
/usr/src/linux/include/linux/irq_cpustat.h \
/usr/src/linux/include/asm/tlbflush.h \
/usr/src/linux/include/asm/atomic_kmap.h \
/usr/src/linux/include/linux/poll.h /usr/src/linux/include/asm/poll.h \
/usr/src/linux/include/asm/uaccess.h /usr/src/linux/include/linux/net.h \
/usr/src/linux/include/net/checksum.h \
/usr/src/linux/include/asm/checksum.h \
/usr/src/linux/include/linux/in6.h \
/usr/src/linux/include/linux/if_packet.h \
/usr/src/linux/include/linux/device.h \
/usr/src/linux/include/linux/ioport.h \
/usr/src/linux/include/linux/notifier.h \
/usr/src/linux/include/linux/security.h \
/usr/src/linux/include/linux/binfmts.h \
/usr/src/linux/include/linux/sysctl.h \
/usr/src/linux/include/linux/shm.h \
/usr/src/linux/include/asm/shmparam.h \
/usr/src/linux/include/asm/shmbuf.h /usr/src/linux/include/linux/msg.h \
/usr/src/linux/include/asm/msgbuf.h \
/usr/src/linux/include/linux/netlink.h \
/usr/src/linux/include/linux/filter.h /usr/src/linux/include/net/dst.h \
/usr/src/linux/include/linux/rtnetlink.h \
/usr/src/linux/include/net/neighbour.h \
/usr/src/linux/include/linux/seq_file.h \
/usr/src/linux/include/linux/igmp.h /usr/src/linux/include/linux/in.h \
/usr/src/linux/include/net/flow.h \
/usr/src/linux/include/linux/inetdevice.h \
/usr/src/linux/include/linux/in_route.h \
/usr/src/linux/include/net/route.h \
/usr/src/linux/include/net/inetpeer.h \
/usr/src/linux/include/linux/route.h /usr/src/linux/include/net/arp.h \
/usr/src/linux/include/linux/if_arp.h /usr/src/linux/include/net/snmp.h \
/usr/src/linux/include/linux/snmp.h /usr/src/linux/include/linux/ipv6.h \
/usr/src/linux/include/linux/icmpv6.h \
/usr/src/linux/include/net/if_inet6.h \
/usr/src/linux/include/linux/tcp.h /usr/src/linux/include/linux/udp.h \
/usr/src/linux/include/net/protocol.h \
/usr/src/linux/include/linux/wireless.h \
/usr/src/linux/include/linux/inet.h /usr/src/linux/include/asm/io.h \
/usr/src/linux/include/asm-generic/iomap.h \
/usr/src/linux/include/linux/vmalloc.h \
/usr/src/linux/include/asm/delay.h /usr/src/linux/include/linux/pci.h \
/usr/src/linux/include/linux/mod_devicetable.h \
/usr/src/linux/include/linux/pci_ids.h \
/usr/src/linux/include/linux/dmapool.h \
/usr/src/linux/include/asm/scatterlist.h \
/usr/src/linux/include/asm/pci.h \
/usr/src/linux/include/asm-generic/pci-dma-compat.h \
/usr/src/linux/include/linux/dma-mapping.h \
/usr/src/linux/include/asm/dma-mapping.h \
/usr/src/linux/include/asm-generic/pci.h \
/usr/src/linux/include/linux/pkt_sched.h \
/usr/src/linux/include/linux/etherdevice.h \
/usr/src/linux/include/linux/random.h \
/usr/src/linux/include/net/inet_common.h \
/usr/src/linux/include/linux/wanpipe_defines.h \
/usr/src/linux/include/linux/wanpipe_version.h \
/usr/src/linux/include/linux/wanpipe_kernel.h \
/usr/src/linux/include/linux/wanpipe_debug.h \
/usr/src/linux/include/linux/wanpipe_common.h \
/usr/src/linux/include/linux/wanpipe_abstr.h \
/usr/src/linux/include/linux/wanpipe_snmp.h \
/usr/src/linux/include/linux/wanproc.h \
/usr/src/linux/include/linux/wanpipe.h \
/usr/src/linux/include/linux/wanpipe_cfg.h \
/usr/src/linux/include/linux/sdla_56k.h \
/usr/src/linux/include/linux/sdla_te1.h \
/usr/src/linux/include/linux/sdla_te1_def.h \
/usr/src/linux/include/linux/sdla_te3.h \
/usr/src/linux/include/linux/sdla_remora.h \
/usr/src/linux/include/linux/sdla_remora_proslic.h \
/usr/src/linux/include/linux/sdla_front_end.h \
/usr/src/linux/include/linux/wanrouter.h \
/usr/src/linux/include/linux/proc_fs.h \
/usr/src/linux/include/linux/sdlasfm.h \
/usr/src/linux/include/linux/sdladrv.h \
/usr/src/linux/include/linux/serial.h \
/usr/src/linux/include/linux/serialP.h \
/usr/src/linux/include/linux/termios.h \
/usr/src/linux/include/asm/termios.h \
/usr/src/linux/include/asm/termbits.h \
/usr/src/linux/include/asm/ioctls.h \
/usr/src/linux/include/linux/circ_buf.h \
/usr/src/linux/include/linux/serial_reg.h \
/usr/src/linux/include/asm/serial.h /usr/src/linux/include/linux/tty.h \
/usr/src/linux/include/linux/major.h \
/usr/src/linux/include/linux/tty_driver.h \
/usr/src/linux/include/linux/cdev.h \
/usr/src/linux/include/linux/tty_ldisc.h \
/usr/src/linux/include/linux/tty_flip.h \
/usr/src/linux/include/linux/if_wanpipe.h \
/usr/src/linux/include/linux/if_wanpipe_common.h \
/usr/src/linux/include/linux/wanpipe_fr_iface.h \
/usr/src/linux/include/linux/wanpipe_lip_atm_iface.h \
/usr/src/linux/include/linux/wanpipe_sppp_iface.h \
/usr/src/linux/include/linux/wanpipe_lapb_iface.h \
/usr/src/linux/include/linux/wanpipe_xdlc_iface.h \
/usr/src/linux/include/linux/wanpipe_lip_kernel.h \
/usr/src/linux/include/linux/wanpipe_iface.h \
/usr/src/linux/include/linux/hdlc.h \
/usr/src/linux/include/net/syncppp.h

View File

@ -0,0 +1 @@
D

View File

@ -0,0 +1 @@
wanpipe_common/fr/bin

View File

@ -0,0 +1 @@
:pserver:sangoma@homer.sangoma-lab.com:/usr/local/cvsroot

View File

@ -26,9 +26,22 @@ FRDIR = ../fr
LAPBDIR = ../lapb
XDLCDIR = ../xdlc
SPPPDIR = ../sppp
XMTP2DIR= ../xmtp2
X25DIR = ../x25
LIP_ATM_DIR = ../lip_atm
WAN_ROUTER_DIR = /wanpipe/code/router
WAN_TTY_SUPPORT=YES
WAN_TTY_SUPPORT=YES
WAN_FR_SUPPORT=YES
WAN_X25_SUPPORT=NO
WAN_CHDLC_PPP_SUPPORT=YES
WAN_XDLC_SUPPORT=YES
WAN_LAPB_SUPPORT=YES
WAN_XMTP2_SUPPORT=NO
WANPIPE_LIP_ATM=YES
REGPARM=YES
LIP_LINKED_PROTS=
KERN := $(shell grep 2.4 /usr/src/linux/include/linux/version.h)
KERN_V26 := $(shell grep 2.6 /usr/src/linux/include/linux/version.h)
@ -56,16 +69,51 @@ endif
endif
CFLAGS=$(shell cat /wanpipe/GCFLAGS)
CFLAGS+=-DWANLIP_DRIVER
#CFLAGS=-Wp,-MD,.wanpipe_lip.o.d -nostdinc -iwithprefix include -D__KERNEL__ -D__LINUX__ -Iinclude -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=$(ARCH) -I/usr/src/linux/include/asm-i386/mach-default -O2 -DWANLIP_DRIVER -DMODULE
CFLAGS=-Wp,-MD,.wanpipe_lip.o.d -nostdinc -iwithprefix include -D__KERNEL__ -D__LINUX__ -Iinclude -I/usr/src/linux/include -Wall -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -pipe -mpreferred-stack-boundary=2 -march=$(ARCH) -I/usr/src/linux/include/asm-i386/mach-default -O2 -DWANLIP_DRIVER -DMODULE
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_FR -DCONFIG_PRODUCT_WANPIPE_CHDLC -DCONFIG_PRODUCT_WANPIPE_PPP -DCONFIG_PRODUCT_WANPIPE_XDLC -DCONFIG_PRODUCT_WANPIPE_LAPB
#CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_FR -DCONFIG_PRODUCT_WANPIPE_CHDLC -DCONFIG_PRODUCT_WANPIPE_PPP -DCONFIG_PRODUCT_WANPIPE_XDLC -DCONFIG_PRODUCT_WANPIPE_LAPB -DCONFIG_PRODUCT_WANPIPE_XMTP2
ifeq "$(WAN_TTY_SUPPORT)" "YES"
CFLAGS+= -DWPLIP_TTY_SUPPORT
TTY_SUPPORT_FILE=$(TMPDIR)/wanpipe_lip_tty.o
endif
ifeq "$(WAN_FR_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_FR
LIP_LINKED_PROTS+= $(FRDIR)/wanpipe_fr.o
endif
ifeq "${WANPIPE_LIP_ATM}" "YES"
CFLAGS+=-DCONFIG_PRODUCT_WANPIPE_LIP_ATM
LIP_LINKED_PROTS+= $(LIP_ATM_DIR)/wanpipe_lip_atm.o
endif
ifeq "$(WAN_X25_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_X25
LIP_LINKED_PROTS+= $(X25DIR)/wanpipe_x25.o
endif
ifeq "$(WAN_CHDLC_PPP_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_CHDLC -DCONFIG_PRODUCT_WANPIPE_PPP
LIP_LINKED_PROTS+= $(SPPPDIR)/wanpipe_sppp.o
endif
ifeq "$(WAN_XDLC_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_XDLC
LIP_LINKED_PROTS+= $(XDLCDIR)/wanpipe_xdlc.o
endif
ifeq "$(WAN_LAPB_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_LAPB
LIP_LINKED_PROTS+= $(LAPBDIR)/wanpipe_lapb.o
endif
ifeq "$(WAN_XMTP2_SUPPORT)" "YES"
CFLAGS+= -DCONFIG_PRODUCT_WANPIPE_XMTP2
LIP_LINKED_PROTS+= $(XMTP2DIR)/wanpipe_xmtp2.o
endif
####### RULES ################################################################
all: $(OUTDIR)/wanpipe_lip.$(MODTYPE)
@ -84,7 +132,7 @@ $(MODDIR)/wanpipe_lip.mod.o: $(MODDIR)/wanpipe_lip.mod.c
#----------------------------------------------------
$(OUTDIR)/wanpipe_lip.o: $(TMPDIR)/wanpipe_lip_iface.o $(TMPDIR)/wanpipe_lip_sub.o $(TMPDIR)/wanpipe_lip_netdev.o $(TMPDIR)/wanpipe_lip_prot.o $(TMPDIR)/wanpipe_lip_bh.o $(TMPDIR)/wanpipe_lip_ipx.o $(TMPDIR)/wanpipe_abstr.o $(TMPDIR)/wanpipe_linux_iface.o $(TTY_SUPPORT_FILE) $(FRDIR)/wanpipe_fr.o $(LAPBDIR)/wanpipe_lapb.o $(XDLCDIR)/wanpipe_xdlc.o $(SPPPDIR)/wanpipe_sppp.o
$(OUTDIR)/wanpipe_lip.o: $(TMPDIR)/wanpipe_lip_iface.o $(TMPDIR)/wanpipe_lip_sub.o $(TMPDIR)/wanpipe_lip_netdev.o $(TMPDIR)/wanpipe_lip_prot.o $(TMPDIR)/wanpipe_lip_bh.o $(TMPDIR)/wanpipe_lip_ipx.o $(TMPDIR)/wanpipe_abstr.o $(TMPDIR)/wanpipe_linux_iface.o $(TTY_SUPPORT_FILE) $(LIP_LINKED_PROTS)
ld $(LD_ELF) -r -o $@ $^
chmod 664 $@
@ -130,31 +178,45 @@ $(TMPDIR)/wanpipe_linux_iface.o: $(WAN_ROUTER_DIR)/wanpipe_linux_iface.c
$(FRDIR)/wanpipe_fr.o:
make -C $(FRDIR) clean
make -C $(FRDIR) all
make -C $(FRDIR) all REGPARM=$(REGPARM)
$(LIP_ATM_DIR)/wanpipe_lip_atm.o:
make -C $(LIP_ATM_DIR) clean
make -C $(LIP_ATM_DIR) all REGPARM=$(REGPARM)
$(LAPBDIR)/wanpipe_lapb.o:
make -C $(LAPBDIR) clean
make -C $(LAPBDIR) all
make -C $(LAPBDIR) all REGPARM=$(REGPARM)
$(XDLCDIR)/wanpipe_xdlc.o:
make -C $(XDLCDIR) clean
make -C $(XDLCDIR) all
make -C $(XDLCDIR) all REGPARM=$(REGPARM)
$(SPPPDIR)/wanpipe_sppp.o:
make -C $(SPPPDIR) clean
make -C $(SPPPDIR) all
make -C $(SPPPDIR) all REGPARM=$(REGPARM)
$(XMTP2DIR)/wanpipe_xmtp2.o:
make -C $(XMTP2DIR) clean
make -C $(XMTP2DIR) all REGPARM=$(REGPARM)
$(X25DIR)/wanpipe_x25.o:
make -C $(X25DIR) clean
make -C $(X25DIR) all REGPARM=$(REGPARM)
clean:
rm -f wanpipe_lip.$(MODTYPE)
rm -f *.o
rm -f mod/*.o
rm -f tmp/*.o
rm -f modinfo/*.o
rm -f *.o*
rm -f mod/*.*o
rm -f tmp/*.*o
rm -f modinfo/*.*o
make -C ../fr clean
make -C ../lapb clean
make -C ../xdlc clean
make -C $(SPPPDIR) clean
make -C $(XMTP2DIR) clean
make -C ../x25 clean
install:
install -D $(OUTDIR)/wanpipe_lip.${MODTYPE} /lib/modules/$(shell uname -r)/kernel/net/wanrouter/wanpipe_lip.${MODTYPE}

View File

@ -0,0 +1 @@
D

View File

@ -0,0 +1 @@
wanpipe_common/fr/bin

View File

@ -0,0 +1 @@
:pserver:sangoma@homer.sangoma-lab.com:/usr/local/cvsroot

Some files were not shown because too many files have changed in this diff Show More