wanpipe-3.5.24.tgz

This commit is contained in:
Harald Welte 2021-12-29 18:51:11 +01:00
parent d50d536a62
commit 1c0741b1c6
861 changed files with 24393 additions and 311516 deletions

2
.git_info Normal file
View File

@ -0,0 +1,2 @@
wanpipe_linux: git ver fe8b74a
wanpipe_common: git ver 1b884cb

View File

@ -1 +0,0 @@
/usr/src/dahdi

View File

@ -1 +1 @@
wanpipe-3.5.23
wanpipe-3.5.24

View File

@ -1,5 +0,0 @@
URL: http://192.168.1.168/svn/wanpipe/wanpipe_common/branches/unified_release
Revision: 9296
Last Changed Author: dyatsin
Last Changed Rev: 9296
Last Changed Date: 2011-09-08 18:16:34 -0400 (Thu, 08 Sep 2011)

View File

@ -1,5 +0,0 @@
URL: http://192.168.1.168/svn/wanpipe/wanpipe_linux/branches/unified_release
Revision: 9296
Last Changed Author: ncorbic
Last Changed Rev: 9268
Last Changed Date: 2011-08-29 12:32:20 -0400 (Mon, 29 Aug 2011)

View File

@ -2,9 +2,10 @@ Sangoma WANPIPE Package contains GPL, Proprietary and BSD code.
Please refer to each file for License Type.
GPL License Definition
-----------------------
------------------------
GNU GENERAL PUBLIC LICENSE

View File

@ -1 +0,0 @@
ChangeLog.3.5

469
ChangeLog Normal file
View File

@ -0,0 +1,469 @@
------------------------------------------------------------------------------
WANPIPE TDM VOICE - IP/WAN Package
------------------------------------------------------------------------------
Author: Nenad Corbic <ncorbic@sangoma.com>
Copyright (c) 1995-2011 Sangoma Technologies Inc.
For more info visit: http://wiki.sangoma.com
------------------------------------------------------------------------------
* Tue Nov 15 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.24
==================================================================
- Bug fixes in Setup
- Bug fixes in wancfg_dahdi
- Updated scripts for Debian/Ubuntu
- Added MTP1 msu/lssu filter option
- New LINEAR mapping of A108 ports for use with T3Mux
- Updates and fixes to MTP1 engine
- Fix for potential memory leak in proc file system
- Fix for analog dma sync on 64bit kernels
- Dahdi BRI fix: wakeup of powered down line
- Fixed RPM spec for trixbox
* Wed Sep 07 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.23
==================================================================
- Bug fixes in Setup
- Bug fixes in compiling and configufing old deprecated SMG/BRI
- Fixed rpmbuild using Setup
* Wed Aug 24 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.22
==================================================================
- Bug introducted in .21 release for analog card.
Changed the way wanpipe enumerates analog channels
breaks backward compatibility. Reverted to original.
- Setup install script update
Removed old and legacy products out of Setup compile options.
* Tue Aug 23 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.21
==================================================================
- T1 AMI fix
- Fixed for 2.6.39 and 3.0.1 kernels
- Fixed for dahdi 2.5
- Fixed BRI wancfg_dahdi config
- Added HW Echo Cancellation Clock failover.
If EC is using clock from port 1 and that port goes down.
The clock source will be taken from another connected port.
- Minor bug fix in hdlc test sample app
- Bug fix libsangoma: multilple wait object issue
- BRI for DAHDI
- B601 receives timing from analog port when T1 is down.
- Libsangoma ss7 hw config status
- Edge cases bug fixes on multi port restart
- Updated v44 for A104 firmware
- Analog 64bit 8GIG memory issue dma sync fix
- Support for ss7 firmware V44 on A104 only.
- Fixed logger - caused slow prints on some kernels due
to use of vprintk
- Added Global Poll IRQ mode for efficient high density
hdlc tx/rx
- wanpipemon added led blink option to idetnify port
Removed the led on/off
wanpipemon -i w1g1 -c dled_blink -timeout 10 #with timeout
wanpipemon -i w1g1 -c dled_blink #without timeout
- wanpipemon documented performance statatistics
wanpipemon -p aft
- wanpipemon added led ctrl
Used to visually identify a port from software
wanpipemon -p aft for documentation
Added this feature in libsangoma as well.
- Minor updates in wanpipe spec file
- Bug fixes in wancfg legacy
- aftpipemon fixed for 24port analog
- B601 mtu fix for FreeSWITCH
Causes audio issues
- Added performance stats
- Fixed B601 for TDMAPI & FreeSWITCH Dchannel
- Confirmed that B601 works for Asterisk (dahdi hdlc mode)
- Fixed rescan feature
- Libsangoma builds by default now
wanec utilities now depend on libsangoma
- Libsangoma contains the full wanec api
- Libsangoma wanec API for TDM API
- Added libsangoma hwec functions for Linux
- Hwec audio_mem_load added to the api.
* Mon Apr 11 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.20
==================================================================
- Fixed customer id read
- Added hwrescan libsangoma command
- Updated the analog ring debouncing threshold
so that ring is properly debounced
- Fixed AIS alarm clear flag bug
The AIS alarm flag was not being cleared in the driver.
- New Octasic Image 1.6.2
Fix for AGC (Automatic Gain Control)
AGC now meets Microsoft Audio Quality Spec
- Fixed start script for ubuntu
* Fri Mar 1 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.19
==================================================================
- Fixed scripts for Ubuntu
- TDM API updated Tone Event API to include tone type
DTMF, FAX_1100, FAX_2100, FAX_2100_WSPR
- Fixes for latest 2.6.36 linux kernel
- Fixes for TTY Driver for 2.6.32 linux kernel
- BRI default idle set to 0xFF so it does not interfere
with multi-port mode.
- BRI NT & TE activation/deactivation logic update.
- Dahdi Yellow alarm reporting fix
Wanpipe driver did not report yellow alarms properly to dahdi
- T1 Automatic AIS on LOS option now optional
Previoulsy the T1 code enabled automatic AIS on LOS by default.
This is now an option TE_AIS_AUTO_ON_LOS=YES|NO
Default behaviour is to send Yellow alarm on link down.
- Fixed a TE1 startup race condition bug.
It was possible for T1/E1 interrupt to occour before
configuration was completel
- Fixed wanpipe.spec for dahdi RPM build
- Added serial clock recovery feature
* Fri Nov 22 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.18
==================================================================
- BRI Multi-Point fix idle 0xFF
- BRI fix for XEN virtualization
- Fixed front end interrupt issue
- wancfg_fs (fix the little bugs)
- update to support the latest dahdi-linux
- fix dahdi_scan, now reporting the right values instead of showing blank
- new echo canceler image
- fix for the echo canceler for A500 for freetdm mode.
HWEC will turn on when there is a call on the bri line.
- Added SW HDLC into the core. B
- B601 is now supported on FreeTDM/FreeSWITCH and TMDAPI
- Added wan_fxotune utility to utils directory
Used to tune fxo cards under TDM API or FreeSWITCH mode.
* Fri Oct 08 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.17
===================================================================
- Critical Bug fix in WAN mode. Bug introduced in 3.5.16
* Fri Sep 27 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.16
===================================================================
- Dahdi 2.4 Support
- Fixed BRI B500/B700 hwec enable on call start caused in 3.5.12 release.
- Bug fix in voice+data mixed mode where dchan could get stuck due to
dma overruns.
- Bug fix in tdmapi where excessive memory was allocated on pre-allocation buffers.
- Bug fix tdmapi defaults to 20ms chunk size instead of 10ms
- Bug fix broken support for A101/2 legacy EOL cards.
- New XEN Support
TDM Voice will now work properly on xen virtualized machines
- Fix for 64bit 8gig issues
- New rpmbuld spec files.
rpmbuild -tb wanpipe-3.5.16.tgz
rpmbuild -tb wanpipe-3.5.16.tgz --define 'with_dahdi 1' --define 'dahdi_dir /usr/src/dahdi'
* Fri Aug 27 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.15
===================================================================
- Fixed B600 and B601 warning messages introduced in 3.5.14
- New Firmware for A108&A104 V43
Fixes PCI parity errors on new dell,ibm boxes
- Libsangoma added rw fe reg, and rx/tx gains
- Build script does not polute the linux source any more.
- Bug fix in B800 detect code
- Fixed wanfcg_fs for freeswitch
-
* Tue Jun 29 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.14
===================================================================
- Fixes stop script for Asterisk 1.6.2
- Compile fix in legacy api sample code
- Skipped .13 releaes went straight to 14 :)
* Mon Jun 28 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.12
===================================================================
- Fixed Dahdi 2.3 Support
- Fixed FreeSwitch Openzap HardHDLC option for AFT cards
- Fixed wanpipemon support for non aft cards.
- Merged USB FXO code from 3.6 release
- USB FXO bug fix for 2.6.32 kernels
- Support for B800 Analog card
- Fixed alarm reporting in DAHDI/ZAPTEL
- Added Extra EC DSP Configuration Options
HWEC_OPERATION_MODE = OCT_NORMAL # OCT_NORMAL: echo cancelation enabled with nlp (default)
# OCT_SPEECH: improves software tone detection by disabling NLP (echo possible)
# OCT_NO_ECHO:disables echo cancelation but allows VQE/tone functions.
HWEC_DTMF_REMOVAL = NO # NO: default YES: remove dtmf out of incoming media (must have hwdtmf enabled)
HWEC_NOISE_REDUCTION = NO # NO: default YES: reduces noise on the line - could break fax
HWEC_ACUSTIC_ECHO = NO # NO: default YES: enables acustic echo cancelation
HWEC_NLP_DISABLE = NO # NO: default YES: guarantees software tone detection (possible echo)
HWEC_TX_AUTO_GAIN = 0 # 0: disable -40-0: default tx audio level to be maintained (-20 default)
HWEC_RX_AUTO_GAIN = 0 # 0: disable -40-0: default rx audio level to be maintained (-20 default)
HWEC_TX_GAIN = 0 # 0: disable -24-24: db values to be applied to tx signal
HWEC_RX_GAIN = 0 # 0: disable -24-24: db values to be applied to tx signal
- Added AIS BLUE Alarm Maintenance Startup option
Allows a port to be started in BLUE alarm.
TE_AIS_MAINTENANCE = NO #NO: defualt YES: Start port in AIS Blue Alarm and keep line down
#wanpipemon -i w1g1 -c Ttx_ais_off to disable AIS maintenance mode
#wanpipemon -i w1g1 -c Ttx_ais_on to enable AIS maintenance mode
- Fixed Legacy XDLC compile
- Fixed core edge case scenarios where
potential race condition could occour.
* Thu Apr 08 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.11
===================================================================
- Fix for 2.6.31 and higher kernels
- TDM API Analog rx gain feature
- Disabled default NOISE REDUCTION feature in hwec
that was enabled in 3.5.9 release.
- Updates to T1/E1 Loopback and BERT Test
* Wed Jan 11 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.10
===================================================================
- Release cleanup script earsed libsangoma.c during release packaging.
I have update release procedure so this does not happen again.
This release has no functionl differences aside from the missing
file from 3.5.9 release.
* Wed Dec 30 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.9
===================================================================
- New logger dev feature
- Bug fix in tx fifo handler
- Dahdi 2.2 broke wanpipe rbs support.
- Fixed free run interrupt supported on V38 (A108)
- Fixed RBS signalling for E1 channel 31
- Added Front end Reset Detection
-> Support for new A108 Firmware V40
- Fixed RTP TAP bug: Caused high system load on RTP TAP usage.
- Added excessive fifo error sanity check. Fixes random pci dma errors.
- HWEC: Increased EC VQE Delay: Fixes random fax failure due to hwec.
- HWEC: Check state before bypass enable.
- HWEC: Disable bypass on release
- HWEC: Enabled Noise Reduction by default
- HWEC: Enabled Auto Gain Control by default
- HWEC: To disable Noise Reduction and Gain control set
-> HWEC_NOISE_REDUCTION_DISABLE=NO in [wanpipe] section of wanpipe1.conf
To check if Noise Reduction or Gain control are set
-> wan_ec_client wanpipe1 stats 1
* Thu Oct 02 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.8
===================================================================
- Bug fix in sangoma_prid PRI stack for FreeSwitch & Asterisk.
There was a slow memory leak.
* Thu Sep 04 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.7
===================================================================
- New Telesoft PRI Stack Support for FreeSwitch & Asterisk
For Asterisk: The new stack uses the existing Sangoma Media Gateway
architecture currently used by SS7 and BRI.
-> run: wancfg_dahdi or wancfg_zaptel to configure
for sangoma prid stack.
For FreeSwitch: The new stack binds to openzap directly just like
current SS7 and BRI.
-> run: wancfg_fs to configure freeswitch for
sangoma prid, brid, ss7.
- Fixed Tx Tristate
- Updated yellow alarm handling for Dallas maxim cards
(A101/2/4/8)
- Autodetect USB support so that driver will compile
correctly on kernel without USB support
- Added DAHDI Red alarm for Analog
* Thu Aug 20 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.6
===================================================================
- Update to T1 Yellow Alarm handling.
In some cases Yellow alarm did not turn off poperly causing
line to stay down an card startup.
- Update configuration utility
wancfg_fs updated for sangoma_prid configuration. Added wancfg_openzap
for OpenZap Configuration
* Mon Aug 17 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.5
===================================================================
- Dahdi 2.2 Support
- BRI Update - Added T1 timer for NT module
- AFT Core Update - optimized dma ring buffer usage
- TDM API - refractoring and optimization
- Updated for 2.6.30 kernel
- New firmawre feature for A101/2/5/8: Free Run Timer Interrupt
The AFT T1/E1 cards will now provide perfect timing to zatpel/dahdi
even when the ports are not connected. The free run interrupt
will be enabled when all zaptel/dahdi ports are down, or on
inital card start. To test this feature just start a wanpipe
port with zaptel/dahdi and run zttest.
A108 firmare V38
A104/2/1/ firmware V36
- AFT T1/E1 front end update
Added OOF alarm treshold, so that line does not go down
on very first OOF alarm.
- Added module inc cound when zaptel/dahdi starts.
So wanpipe drivers do not crash if one tries to unload
zaptel/dahdi before stopping wanpipe drivers.
* Thu Jul 07 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.8
===================================================================
- Updated for B700 Dchan Critical Timeout
- Fix for FAX detect on PRI
- Updated for 2.6.21 kernel TASK QUEUE REMOVAL caused
unexpected behaviour.
- Updated wancfg_zaptel for fax detect
* Thu Jul 03 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.3
===================================================================
- Added DAHDI 2.2 Support
* Thu Jul 02 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.2
===================================================================
- AFT 64bit update
No need for --64bit_4G flag any more.
The 64bit check is now down in the driver.
- TDM API
Updated the Global TDM Device
This device can be used to read events an all cards configured in
TDM API mode.
- Libsangoma verion 3.1.0
Added a function to check if hwec is supported
* Tue Jun 30 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.1
===================================================================
- Sangoma MGD update v.1.48
Disable hwec on data calls
* Mon Jun 29 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4
===================================================================
- E1 Voice Bug fix introduced in 3.5.3
- Removed NOISE REDUCTION enabled by default.
The noise reduction is disabled by default and should be
enabled using HWEC_NOISE_REDUCTION = YES
- Fixed libsangoma enable dtmf events functionality
* Tue Jun 25 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.3
===================================================================
- New Makefile build system
Note this does not replace Setup. Makefile build system can be
used by power users.
Asterisk
make dahdi DAHDI_DIR=<abs path to dahdi>
make install
make zaptel ZAPDIR=<abs path to zaptel>
make install
FreeSwitch
make openzap
make install
TDM API
make all_src
make install
- Updated libsangoma API
Redesigned wait object for Linux/Windows integration.
- Turned on HWEC Noise Reduction by default
To disable noise reduction specify
HWEC_NOISE_REDUCTION_DISABLE=YES in [wanpipe1] section of wanpipe
config file.
- Regression tested for FreeSwitch+OpenZAP
- Updated dma buffers in ZAPTEL and TDM API mode.
- Bug fixes for Mixed Data + Voice Mode
- Bug fix on TDM API mode.
Flush buffers could interfere with tx/rx data.
- Added BRI DCHAN monitor in case task is not scheduled by the
system. Sanity check.
- Fixed libsangoma stack overflow check that failed on some kernels.
* Fri May 08 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.2
===================================================================
- B700 PCIe cards were being displayed as PCI cards in hwprobe
- Bug fix in wancfg_zaptel
* Thu May 07 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.1
===================================================================
- New Hardware Support
B700 - Mixed BRI & Analog
B600 - Analog 4FXO/FXS
USB-FXO - USB Fxo device
- New Unified API for Linux & Windows
API Library - libsangoma
Unified Voice API for Linux & Windows
-More Info
http://wiki.sangoma.com/wanpipe-api
- SPAN mode API
- CHAN mode API
- Unified driver for Linux & Windows
- Updated BRI Stack and Support
- New BRI A500 & B700 firmware that fixes PCI parity errors.
On some systems A500 & B700 cards can generate parity errors.
- FreeSwitch Tested
- Update for 2.6.26 kernel
Note this is a major release. It has been fully regression
tested and stress tested in the lab and in the field.

View File

@ -1,455 +0,0 @@
------------------------------------------------------------------------------
WANPIPE TDM VOICE - IP/WAN Package
------------------------------------------------------------------------------
Author: Nenad Corbic <ncorbic@sangoma.com>
Copyright (c) 1995-2011 Sangoma Technologies Inc.
For more info visit: http://wiki.sangoma.com
------------------------------------------------------------------------------
* Wed Sep 07 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.23
==================================================================
- Bug fixes in Setup
- Bug fixes in compiling and configufing old deprecated SMG/BRI
- Fixed rpmbuild using Setup
* Wed Aug 24 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.22
==================================================================
- Bug introducted in .21 release for analog card.
Changed the way wanpipe enumerates analog channels
breaks backward compatibility. Reverted to original.
- Setup install script update
Removed old and legacy products out of Setup compile options.
* Tue Aug 23 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.21
==================================================================
- T1 AMI fix
- Fixed for 2.6.39 and 3.0.1 kernels
- Fixed for dahdi 2.5
- Fixed BRI wancfg_dahdi config
- Added HW Echo Cancellation Clock failover.
If EC is using clock from port 1 and that port goes down.
The clock source will be taken from another connected port.
- Minor bug fix in hdlc test sample app
- Bug fix libsangoma: multilple wait object issue
- BRI for DAHDI
- B601 receives timing from analog port when T1 is down.
- Libsangoma ss7 hw config status
- Edge cases bug fixes on multi port restart
- Updated v44 for A104 firmware
- Analog 64bit 8GIG memory issue dma sync fix
- Support for ss7 firmware V44 on A104 only.
- Fixed logger - caused slow prints on some kernels due
to use of vprintk
- Added Global Poll IRQ mode for efficient high density
hdlc tx/rx
- wanpipemon added led blink option to idetnify port
Removed the led on/off
wanpipemon -i w1g1 -c dled_blink -timeout 10 #with timeout
wanpipemon -i w1g1 -c dled_blink #without timeout
- wanpipemon documented performance statatistics
wanpipemon -p aft
- wanpipemon added led ctrl
Used to visually identify a port from software
wanpipemon -p aft for documentation
Added this feature in libsangoma as well.
- Minor updates in wanpipe spec file
- Bug fixes in wancfg legacy
- aftpipemon fixed for 24port analog
- B601 mtu fix for FreeSWITCH
Causes audio issues
- Added performance stats
- Fixed B601 for TDMAPI & FreeSWITCH Dchannel
- Confirmed that B601 works for Asterisk (dahdi hdlc mode)
- Fixed rescan feature
- Libsangoma builds by default now
wanec utilities now depend on libsangoma
- Libsangoma contains the full wanec api
- Libsangoma wanec API for TDM API
- Added libsangoma hwec functions for Linux
- Hwec audio_mem_load added to the api.
* Mon Apr 11 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.20
==================================================================
- Fixed customer id read
- Added hwrescan libsangoma command
- Updated the analog ring debouncing threshold
so that ring is properly debounced
- Fixed AIS alarm clear flag bug
The AIS alarm flag was not being cleared in the driver.
- New Octasic Image 1.6.2
Fix for AGC (Automatic Gain Control)
AGC now meets Microsoft Audio Quality Spec
- Fixed start script for ubuntu
* Fri Mar 1 2011 Nenad Corbic <ncorbic@sangoma.com> - 3.5.19
==================================================================
- Fixed scripts for Ubuntu
- TDM API updated Tone Event API to include tone type
DTMF, FAX_1100, FAX_2100, FAX_2100_WSPR
- Fixes for latest 2.6.36 linux kernel
- Fixes for TTY Driver for 2.6.32 linux kernel
- BRI default idle set to 0xFF so it does not interfere
with multi-port mode.
- BRI NT & TE activation/deactivation logic update.
- Dahdi Yellow alarm reporting fix
Wanpipe driver did not report yellow alarms properly to dahdi
- T1 Automatic AIS on LOS option now optional
Previoulsy the T1 code enabled automatic AIS on LOS by default.
This is now an option TE_AIS_AUTO_ON_LOS=YES|NO
Default behaviour is to send Yellow alarm on link down.
- Fixed a TE1 startup race condition bug.
It was possible for T1/E1 interrupt to occour before
configuration was completel
- Fixed wanpipe.spec for dahdi RPM build
- Added serial clock recovery feature
* Fri Nov 22 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.18
==================================================================
- BRI Multi-Point fix idle 0xFF
- BRI fix for XEN virtualization
- Fixed front end interrupt issue
- wancfg_fs (fix the little bugs)
- update to support the latest dahdi-linux
- fix dahdi_scan, now reporting the right values instead of showing blank
- new echo canceler image
- fix for the echo canceler for A500 for freetdm mode.
HWEC will turn on when there is a call on the bri line.
- Added SW HDLC into the core. B
- B601 is now supported on FreeTDM/FreeSWITCH and TMDAPI
- Added wan_fxotune utility to utils directory
Used to tune fxo cards under TDM API or FreeSWITCH mode.
* Fri Oct 08 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.17
===================================================================
- Critical Bug fix in WAN mode. Bug introduced in 3.5.16
* Fri Sep 27 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.16
===================================================================
- Dahdi 2.4 Support
- Fixed BRI B500/B700 hwec enable on call start caused in 3.5.12 release.
- Bug fix in voice+data mixed mode where dchan could get stuck due to
dma overruns.
- Bug fix in tdmapi where excessive memory was allocated on pre-allocation buffers.
- Bug fix tdmapi defaults to 20ms chunk size instead of 10ms
- Bug fix broken support for A101/2 legacy EOL cards.
- New XEN Support
TDM Voice will now work properly on xen virtualized machines
- Fix for 64bit 8gig issues
- New rpmbuld spec files.
rpmbuild -tb wanpipe-3.5.16.tgz
rpmbuild -tb wanpipe-3.5.16.tgz --define 'with_dahdi 1' --define 'dahdi_dir /usr/src/dahdi'
* Fri Aug 27 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.15
===================================================================
- Fixed B600 and B601 warning messages introduced in 3.5.14
- New Firmware for A108&A104 V43
Fixes PCI parity errors on new dell,ibm boxes
- Libsangoma added rw fe reg, and rx/tx gains
- Build script does not polute the linux source any more.
- Bug fix in B800 detect code
- Fixed wanfcg_fs for freeswitch
-
* Tue Jun 29 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.14
===================================================================
- Fixes stop script for Asterisk 1.6.2
- Compile fix in legacy api sample code
- Skipped .13 releaes went straight to 14 :)
* Mon Jun 28 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.12
===================================================================
- Fixed Dahdi 2.3 Support
- Fixed FreeSwitch Openzap HardHDLC option for AFT cards
- Fixed wanpipemon support for non aft cards.
- Merged USB FXO code from 3.6 release
- USB FXO bug fix for 2.6.32 kernels
- Support for B800 Analog card
- Fixed alarm reporting in DAHDI/ZAPTEL
- Added Extra EC DSP Configuration Options
HWEC_OPERATION_MODE = OCT_NORMAL # OCT_NORMAL: echo cancelation enabled with nlp (default)
# OCT_SPEECH: improves software tone detection by disabling NLP (echo possible)
# OCT_NO_ECHO:disables echo cancelation but allows VQE/tone functions.
HWEC_DTMF_REMOVAL = NO # NO: default YES: remove dtmf out of incoming media (must have hwdtmf enabled)
HWEC_NOISE_REDUCTION = NO # NO: default YES: reduces noise on the line - could break fax
HWEC_ACUSTIC_ECHO = NO # NO: default YES: enables acustic echo cancelation
HWEC_NLP_DISABLE = NO # NO: default YES: guarantees software tone detection (possible echo)
HWEC_TX_AUTO_GAIN = 0 # 0: disable -40-0: default tx audio level to be maintained (-20 default)
HWEC_RX_AUTO_GAIN = 0 # 0: disable -40-0: default rx audio level to be maintained (-20 default)
HWEC_TX_GAIN = 0 # 0: disable -24-24: db values to be applied to tx signal
HWEC_RX_GAIN = 0 # 0: disable -24-24: db values to be applied to tx signal
- Added AIS BLUE Alarm Maintenance Startup option
Allows a port to be started in BLUE alarm.
TE_AIS_MAINTENANCE = NO #NO: defualt YES: Start port in AIS Blue Alarm and keep line down
#wanpipemon -i w1g1 -c Ttx_ais_off to disable AIS maintenance mode
#wanpipemon -i w1g1 -c Ttx_ais_on to enable AIS maintenance mode
- Fixed Legacy XDLC compile
- Fixed core edge case scenarios where
potential race condition could occour.
* Thu Apr 08 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.11
===================================================================
- Fix for 2.6.31 and higher kernels
- TDM API Analog rx gain feature
- Disabled default NOISE REDUCTION feature in hwec
that was enabled in 3.5.9 release.
- Updates to T1/E1 Loopback and BERT Test
* Wed Jan 11 2010 Nenad Corbic <ncorbic@sangoma.com> - 3.5.10
===================================================================
- Release cleanup script earsed libsangoma.c during release packaging.
I have update release procedure so this does not happen again.
This release has no functionl differences aside from the missing
file from 3.5.9 release.
* Wed Dec 30 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.9
===================================================================
- New logger dev feature
- Bug fix in tx fifo handler
- Dahdi 2.2 broke wanpipe rbs support.
- Fixed free run interrupt supported on V38 (A108)
- Fixed RBS signalling for E1 channel 31
- Added Front end Reset Detection
-> Support for new A108 Firmware V40
- Fixed RTP TAP bug: Caused high system load on RTP TAP usage.
- Added excessive fifo error sanity check. Fixes random pci dma errors.
- HWEC: Increased EC VQE Delay: Fixes random fax failure due to hwec.
- HWEC: Check state before bypass enable.
- HWEC: Disable bypass on release
- HWEC: Enabled Noise Reduction by default
- HWEC: Enabled Auto Gain Control by default
- HWEC: To disable Noise Reduction and Gain control set
-> HWEC_NOISE_REDUCTION_DISABLE=NO in [wanpipe] section of wanpipe1.conf
To check if Noise Reduction or Gain control are set
-> wan_ec_client wanpipe1 stats 1
* Thu Oct 02 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.8
===================================================================
- Bug fix in sangoma_prid PRI stack for FreeSwitch & Asterisk.
There was a slow memory leak.
* Thu Sep 04 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.7
===================================================================
- New Telesoft PRI Stack Support for FreeSwitch & Asterisk
For Asterisk: The new stack uses the existing Sangoma Media Gateway
architecture currently used by SS7 and BRI.
-> run: wancfg_dahdi or wancfg_zaptel to configure
for sangoma prid stack.
For FreeSwitch: The new stack binds to openzap directly just like
current SS7 and BRI.
-> run: wancfg_fs to configure freeswitch for
sangoma prid, brid, ss7.
- Fixed Tx Tristate
- Updated yellow alarm handling for Dallas maxim cards
(A101/2/4/8)
- Autodetect USB support so that driver will compile
correctly on kernel without USB support
- Added DAHDI Red alarm for Analog
* Thu Aug 20 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.6
===================================================================
- Update to T1 Yellow Alarm handling.
In some cases Yellow alarm did not turn off poperly causing
line to stay down an card startup.
- Update configuration utility
wancfg_fs updated for sangoma_prid configuration. Added wancfg_openzap
for OpenZap Configuration
* Mon Aug 17 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.5
===================================================================
- Dahdi 2.2 Support
- BRI Update - Added T1 timer for NT module
- AFT Core Update - optimized dma ring buffer usage
- TDM API - refractoring and optimization
- Updated for 2.6.30 kernel
- New firmawre feature for A101/2/5/8: Free Run Timer Interrupt
The AFT T1/E1 cards will now provide perfect timing to zatpel/dahdi
even when the ports are not connected. The free run interrupt
will be enabled when all zaptel/dahdi ports are down, or on
inital card start. To test this feature just start a wanpipe
port with zaptel/dahdi and run zttest.
A108 firmare V38
A104/2/1/ firmware V36
- AFT T1/E1 front end update
Added OOF alarm treshold, so that line does not go down
on very first OOF alarm.
- Added module inc cound when zaptel/dahdi starts.
So wanpipe drivers do not crash if one tries to unload
zaptel/dahdi before stopping wanpipe drivers.
* Thu Jul 07 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.8
===================================================================
- Updated for B700 Dchan Critical Timeout
- Fix for FAX detect on PRI
- Updated for 2.6.21 kernel TASK QUEUE REMOVAL caused
unexpected behaviour.
- Updated wancfg_zaptel for fax detect
* Thu Jul 03 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.3
===================================================================
- Added DAHDI 2.2 Support
* Thu Jul 02 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.2
===================================================================
- AFT 64bit update
No need for --64bit_4G flag any more.
The 64bit check is now down in the driver.
- TDM API
Updated the Global TDM Device
This device can be used to read events an all cards configured in
TDM API mode.
- Libsangoma verion 3.1.0
Added a function to check if hwec is supported
* Tue Jun 30 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4.1
===================================================================
- Sangoma MGD update v.1.48
Disable hwec on data calls
* Mon Jun 29 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.4
===================================================================
- E1 Voice Bug fix introduced in 3.5.3
- Removed NOISE REDUCTION enabled by default.
The noise reduction is disabled by default and should be
enabled using HWEC_NOISE_REDUCTION = YES
- Fixed libsangoma enable dtmf events functionality
* Tue Jun 25 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.3
===================================================================
- New Makefile build system
Note this does not replace Setup. Makefile build system can be
used by power users.
Asterisk
make dahdi DAHDI_DIR=<abs path to dahdi>
make install
make zaptel ZAPDIR=<abs path to zaptel>
make install
FreeSwitch
make openzap
make install
TDM API
make all_src
make install
- Updated libsangoma API
Redesigned wait object for Linux/Windows integration.
- Turned on HWEC Noise Reduction by default
To disable noise reduction specify
HWEC_NOISE_REDUCTION_DISABLE=YES in [wanpipe1] section of wanpipe
config file.
- Regression tested for FreeSwitch+OpenZAP
- Updated dma buffers in ZAPTEL and TDM API mode.
- Bug fixes for Mixed Data + Voice Mode
- Bug fix on TDM API mode.
Flush buffers could interfere with tx/rx data.
- Added BRI DCHAN monitor in case task is not scheduled by the
system. Sanity check.
- Fixed libsangoma stack overflow check that failed on some kernels.
* Fri May 08 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.2
===================================================================
- B700 PCIe cards were being displayed as PCI cards in hwprobe
- Bug fix in wancfg_zaptel
* Thu May 07 2009 Nenad Corbic <ncorbic@sangoma.com> - 3.5.1
===================================================================
- New Hardware Support
B700 - Mixed BRI & Analog
B600 - Analog 4FXO/FXS
USB-FXO - USB Fxo device
- New Unified API for Linux & Windows
API Library - libsangoma
Unified Voice API for Linux & Windows
-More Info
http://wiki.sangoma.com/wanpipe-api
- SPAN mode API
- CHAN mode API
- Unified driver for Linux & Windows
- Updated BRI Stack and Support
- New BRI A500 & B700 firmware that fixes PCI parity errors.
On some systems A500 & B700 cards can generate parity errors.
- FreeSwitch Tested
- Update for 2.6.26 kernel
Note this is a major release. It has been fully regression
tested and stress tested in the lab and in the field.

10
Makefile Normal file → Executable file
View File

@ -239,7 +239,6 @@ clean: cleanup_local clean_util _cleanoldwanpipe
.PHONY: _cleanoldwanpipe
_cleanoldwanpipe: _checksrc
@eval "./patches/build_links.sh"
@eval "./patches/clean_old_wanpipe.sh $(WINCLUDE) $(KDIR)/include/linux"
#Check for linux headers
@ -323,8 +322,10 @@ install: install_etc install_util install_kmod install_inc
@if [ -e .all_lib ] ; then \
$(MAKE) -C api/libsangoma install DESTDIR=$(INSTALLPREFIX); \
$(MAKE) -C api/libstelephony install DESTDIR=$(INSTALLPREFIX); \
$(LDCONFIG) ; \
fi
if [ "$(shell id -u)" = "0" ]; then \
$(LDCONFIG) ; \
fi \
fi
#Install kernel modules only
@ -356,7 +357,7 @@ install_kmod:
endif
#Compile utilities only
all_util: install_inc all_lib
all_util: all_lib
$(MAKE) -C util all EXTRA_FLAGS="$(EXTRA_UTIL_FLAGS)" SYSINC="$(PWD)/$(WINCLUDE) -I $(PWD)/api/libsangoma/include" CC=$(CC) \
PREFIX=$(INSTALLPREFIX) HOSTCFLAGS="$(EXTRA_UTIL_FLAGS)" ARCH=$(WARCH)
$(MAKE) -C util all_wancfg EXTRA_FLAGS="$(EXTRA_UTIL_FLAGS)" SYSINC="$(PWD)/$(WINCLUDE) -I$(PWD)/api/libsangoma/include" CC=$(CC) \
@ -444,6 +445,7 @@ install_etc:
mkdir -p $(INSTALLPREFIX)/etc/wanpipe/scripts; \
fi
@\cp -rf wan_ec $(INSTALLPREFIX)/etc/wanpipe/
@\rm -f $(INSTALLPREFIX)/etc/wanpipe/api/Makefile*
@\cp -rf api $(INSTALLPREFIX)/etc/wanpipe/
@\cp -rf scripts $(INSTALLPREFIX)/etc/wanpipe/
@\cp -rf util/wan_aftup $(INSTALLPREFIX)/etc/wanpipe/util/

1068
README

File diff suppressed because it is too large Load Diff

13
README.changes Normal file
View File

@ -0,0 +1,13 @@
------------------------------------------------------------------------------
Linux WAN Router Utilities Package
------------------------------------------------------------------------------
Version beta5-2.3.4
Jul 20 2006
Author: Nenad Corbic <ncorbic@sangoma.com>
Copyright (c) 1995-2006 Sangoma Technologies Inc.
------------------------------------------------------------------------------
For latest docs please visit Sangoma Wiki
Sangoma Wiki: http://wiki.sangoma.com
------------------------------------------------------------------------------

57
Setup
View File

@ -1540,7 +1540,7 @@ create_mataconf()
fi
cat > $META_CONF << ENDOFTEXT
#!/bin/sh
#!/bin/bash
# router.rc WAN router meta-configuration file.
#
# This file defines variables used by the router shell scripts
@ -1952,7 +1952,27 @@ WARNING: The Linux source in $SOURCEDIR has not been configured.
pause
fi
eval "make install DESTDIR=$ROOT >> $CMP_LOG 2>> $CMP_LOG"
echo -n "Compiling WANPIPE LibStelephony API library ..."
cd ..
cd libstelephony
eval "./init-automake.sh >> $CMP_LOG 2>> $CMP_LOG"
eval "./configure --prefix=/usr >> $CMP_LOG 2>> $CMP_LOG"
eval "make clean >> $CMP_LOG 2>> $CMP_LOG"
eval "make CC=$CC DESTDIR=$ROOT >> $CMP_LOG 2>> $CMP_LOG"
if [ $? -eq 0 ]; then
echo -e "Done.\n\n"
else
echo -e "Failed. \n\n"
pause
fi
eval "make install DESTDIR=$ROOT >> $CMP_LOG 2>> $CMP_LOG"
cd ..
if [ $superuser = "YES" ] && [ -z $ROOT ]; then
eval "ldconfig"
fi
cd $PROD_HOME/util
@ -3684,7 +3704,7 @@ CFLAGS="$CC -Wp,-MD,.wanpipe.o.d -nostdinc -iwithprefix include -D__LINUX__ -Dli
cat <<ENDOFTEXT > $PROD_HOME/scripts/Compile_Setup.sh
#!/bin/sh
#!/bin/bash
if [ -e kdrvcmp ]; then
rm -rf kdrvcmp
@ -3718,7 +3738,7 @@ ENDOFTEXT
tmp=${CFLAGS/$CC/}
cat <<ENDOFTEXT > $PROD_HOME/scripts/Compile.sh
#!/bin/sh
#!/bin/bash
make CFLAGS="$tmp" PROTOCOL_DEFINES="$PROTOCOL_DEFINES"
@ -4464,7 +4484,7 @@ WANPIPE_OBJS=
cat <<ENDOFTEXT > $CMP_INSTALL
#!/bin/sh
#!/bin/bash
mv *.ko mod/ > /dev/null 2> /dev/null
@ -4509,7 +4529,7 @@ ENDOFTEXT
chmod 755 $CMP_INSTALL
cat <<ENDOFTEXT > .clean.$$
#!/bin/sh
#!/bin/bash
rm -f *.ko
rm -f tmp/*.*o
@ -7277,7 +7297,7 @@ KERNEL_UNAME=`uname -r`
PKG_NAME=wanpipe
DISTR_NAME="WANPIPE"
PROD=wanrouter
PROD_VER=3.5.23
PROD_VER=3.5.24
PROD_HOME=`pwd`
META_CONF=$PROD_HOME/$PROD.rc
WAN_INTR_DIR=$PROD_HOME/interfaces
@ -7836,6 +7856,31 @@ if [ "$PKG_NAME" != "wanpipe-lite" ]; then
exit 1;
fi
;;
--wanpipe_dev_alloc_cnt*)
WANPIPE_DEV_ALLOC_CNT="";
WANPIPE_DEV_ALLOC_CNT=`echo $arg | cut -d'=' -f2`;
echo "WANPIPE_DEV_ALLOC_CNT = $WANPIPE_DEV_ALLOC_CNT"
rc=0;
if [ "$WANPIPE_DEV_ALLOC_CNT" = "" ]; then
rc=1;
else
if [ $WANPIPE_DEV_ALLOC_CNT -ge 1 ] && [ $WANPIPE_DEV_ALLOC_CNT -le 128 ]; then
rc=0;
else
rc=1
fi
fi
if [ $rc -eq 1 ]; then
echo "Error: Invalid WANPIPE_DEV_ALLOC_CNT value: Must be number 1 to 128";
exit 1;
fi
PROTOCOL_DEFINES="$PROTOCOL_DEFINES -DWANPIPE_DEVICE_ALLOC_CNT=$WANPIPE_DEV_ALLOC_CNT "
;;
--split_rpms*)
SPLIT_RPMS="YES";
;;

View File

@ -1,765 +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_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <linux/sdla_aft_te1.h>
#include "lib_api.h"
#include <linux/wanpipe_events.h>
//#include "wanec_iface.h"
#include "wanec_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(int ,char**);
void sig_end(int sigid);
int sock;
FILE *tx_fd=NULL,*rx_fd=NULL;
#define WP_API_EVENT_MAX_RETRY 10
u_int8_t event_type;
int channel, tone_id = 1;
/***************************************************
* 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 );
}
static int dtmf_event_ctrl(u_int8_t mode, int channel)
{
api_tx_hdr_t api_tx_hdr;
int err, cnt=0;
/* Configure DTMF events */
printf("%s DTMF event on channel %d\n",
(mode==WP_API_EVENT_ENABLE) ? "Configure" : "Clear",
channel);
err = wanec_api_dtmf( card_name,
(mode==WP_API_EVENT_ENABLE) ? 1 : 0,
(1 << channel),
WAN_EC_CHANNEL_PORT_SOUT,
WAN_EC_TONE_PRESENT,
1);
if (err){
printf("ERROR: %s: Failed to execute DTMF configuration request!\n",
card_name);
return -EINVAL;
}
/* Enable DTMF events */
memset(&api_tx_hdr, 0, sizeof(api_tx_hdr_t));
printf("%s DTMF Event on channel %d...\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable",
channel);
api_tx_hdr.wp_api_tx_hdr_event_type = WP_API_EVENT_DTMF;
api_tx_hdr.wp_api_tx_hdr_event_mode = mode;
api_tx_hdr.wp_api_tx_hdr_event_channel = channel;
dtmf_try_again:
err = ioctl(sock,SIOC_WANPIPE_API,&api_tx_hdr);
if (err < 0){
usleep(10000);
if (cnt++ < WP_API_EVENT_MAX_RETRY) goto dtmf_try_again;
printf("ERROR: Failed to %s DTMF events!\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
return -EINVAL;
}
return 0;
}
static int rxhook_event_ctrl(u_int8_t mode, int channel)
{
api_tx_hdr_t api_tx_hdr;
int err, cnt=0;
/* Enable Rx-hook events */
memset(&api_tx_hdr, 0, sizeof(api_tx_hdr_t));
printf("%s Rx-hook Event...\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
api_tx_hdr.wp_api_tx_hdr_event_type = WP_API_EVENT_RXHOOK;
api_tx_hdr.wp_api_tx_hdr_event_mode = mode;
api_tx_hdr.wp_api_tx_hdr_event_channel = channel;
rxhook_try_again:
err = ioctl(sock,SIOC_WANPIPE_API,&api_tx_hdr);
if (err < 0){
usleep(10000);
if (cnt++ < WP_API_EVENT_MAX_RETRY) goto rxhook_try_again;
printf("ERROR: Failed to %s Rx-hook events (%d)!\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable",
cnt);
return -EINVAL;
}
return 0;
}
static int ring_event_ctrl(u_int8_t mode, int channel)
{
api_tx_hdr_t api_tx_hdr;
int err, cnt=0;
/* Enable Ring events */
memset(&api_tx_hdr, 0, sizeof(api_tx_hdr_t));
printf("%s Ring Event...\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
api_tx_hdr.wp_api_tx_hdr_event_type = WP_API_EVENT_RING;
api_tx_hdr.wp_api_tx_hdr_event_mode = mode;
api_tx_hdr.wp_api_tx_hdr_event_channel = channel;
ring_try_again:
err = ioctl(sock,SIOC_WANPIPE_API,&api_tx_hdr);
if (err < 0){
usleep(10000);
if (cnt++ < WP_API_EVENT_MAX_RETRY) goto ring_try_again;
printf("ERROR: Failed to %s Ring events!\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
return -EINVAL;
}
return 0;
}
static int tone_event_ctrl(u_int8_t mode, int channel, int tone)
{
api_tx_hdr_t api_tx_hdr;
int err, cnt=0;
/* Enable Tone events */
memset(&api_tx_hdr, 0, sizeof(api_tx_hdr_t));
printf("%s Tone Event...\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
api_tx_hdr.wp_api_tx_hdr_event_type = WP_API_EVENT_TONE;
api_tx_hdr.wp_api_tx_hdr_event_mode = mode;
api_tx_hdr.wp_api_tx_hdr_event_tone = tone;
api_tx_hdr.wp_api_tx_hdr_event_channel = channel;
tone_try_again:
err = ioctl(sock,SIOC_WANPIPE_API,&api_tx_hdr);
if (err < 0){
usleep(10000);
if (cnt++ < WP_API_EVENT_MAX_RETRY) goto tone_try_again;
printf("ERROR: Failed to %s Tone events!\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
return -EINVAL;
}
return 0;
}
static int ringdetect_event_ctrl(u_int8_t mode, int channel, int tone)
{
api_tx_hdr_t api_tx_hdr;
int err, cnt=0;
/* Enable Tone events */
memset(&api_tx_hdr, 0, sizeof(api_tx_hdr_t));
printf("%s Ring Detect Event...\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
api_tx_hdr.wp_api_tx_hdr_event_type = WP_API_EVENT_RING_DETECT;
api_tx_hdr.wp_api_tx_hdr_event_mode = mode;
api_tx_hdr.wp_api_tx_hdr_event_channel = channel;
ringdetect_try_again:
err = ioctl(sock,SIOC_WANPIPE_API,&api_tx_hdr);
if (err < 0){
usleep(10000);
if (cnt++ < WP_API_EVENT_MAX_RETRY) goto ringdetect_try_again;
printf("ERROR: Failed to %s Tone events!\n",
(mode==WP_API_EVENT_ENABLE) ? "Enable" : "Disable");
return -EINVAL;
}
return 0;
}
static int event_decode(api_rx_hdr_t *rx_hdr)
{
static int event_cnt = 0;
switch(rx_hdr->event_type){
case WP_API_EVENT_DTMF:
printf("%04d --> DTMF event: %c (%s:%s)\n",
event_cnt++,
rx_hdr->wp_api_rx_hdr_event_dtmf_digit,
(rx_hdr->wp_api_rx_hdr_event_dtmf_port == WAN_EC_CHANNEL_PORT_SOUT) ?
"SOUT" : "ROUT",
(rx_hdr->wp_api_rx_hdr_event_dtmf_type == WAN_EC_TONE_PRESENT) ?
"PRESENT" : "STOP");
break;
case WP_API_EVENT_RXHOOK:
printf("%04d --> Rx-hook: %s\n",
event_cnt++,
(rx_hdr->wp_api_rx_hdr_event_rxhook_state == WP_API_EVENT_RXHOOK_OFF) ?
"Off-hook" :
(rx_hdr->wp_api_rx_hdr_event_rxhook_state == WP_API_EVENT_RXHOOK_ON) ?
"On-hook" : "Unknown");
break;
case WP_API_EVENT_RING_DETECT:
printf("%04d --> Ring Detect: %s\n",
event_cnt++,
WAN_EVENT_RING_DECODE(rx_hdr->wp_api_rx_hdr_event_ringdetect_state));
break;
default:
printf("%04d --> Unknown event\n",
event_cnt++);
break;
}
return 0;
}
static int event_ctrl(u_int8_t mode, int argc, char* argv[])
{
int i=0;
for (i = 0; i < argc; i++){
if (!strcmp(argv[i],"-tone")){
if (i+2 > argc-1){
printf("ERROR: Invalid Interface Name!\n");
return WAN_FALSE;
}
if(!isdigit(argv[i+1][0])){
printf("ERROR: Invalid tone id!\n");
return WAN_FALSE;
}
event_type = WP_API_EVENT_TONE;
tone_id = atoi(argv[i+1]);
channel = atoi(argv[i+2]);
if (tone_event_ctrl(mode, channel, tone_id)){
return -1;
}
}
if (!strcmp(argv[i],"-ring")){
if (i+1 > argc-1){
printf("ERROR: Invalid Interface Name!\n");
return WAN_FALSE;
}
if(!isdigit(argv[i+1][0])){
printf("ERROR: Invalid ring command!\n");
return WAN_FALSE;
}
event_type = WP_API_EVENT_RING;
channel = atoi(argv[i+1]);
if (ring_event_ctrl(mode, channel)) return -1;
}
if (!strcmp(argv[i],"-rxhook")){
if (i+1 > argc-1){
printf("ERROR: Invalid Interface Name!\n");
return WAN_FALSE;
}
if(!isdigit(argv[i+1][0])){
printf("ERROR: Invalid ring command!\n");
return WAN_FALSE;
}
event_type = WP_API_EVENT_RXHOOK;
channel = atoi(argv[i+1]);
if (rxhook_event_ctrl(mode, channel)) return -1;
}
if (!strcmp(argv[i],"-dtmf")){
if (i+1 > argc-1){
printf("ERROR: Invalid Interface Name!\n");
return WAN_FALSE;
}
if(!isdigit(argv[i+1][0])){
printf("ERROR: Invalid ring command!\n");
return WAN_FALSE;
}
event_type = WP_API_EVENT_DTMF;
channel = atoi(argv[i+1]);
if (dtmf_event_ctrl(mode, channel)) return -1;
}
}
return 0;
}
/***************************************************
* HANDLE SOCKET
*
* o Read a socket
* o Cast data received to api_rx_element_t data type
* o The received packet contains sizeof(wp_api_hdr_t) bytes header
*
* ------------------------------------------
* | sizeof(wp_api_hdr_t) 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(int argc, char* argv[])
{
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;
#if 0
int stream_sync=0;
#endif
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 sizeof(wp_api_hdr_t) 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{
#if 0
api_tx_el->data[i] = (unsigned char)tx_data+(i%4);
#else
api_tx_el->data[i] = (unsigned char)tx_data;
#endif
}
}
}
write_enable = 1;
read_enable = 1;
if (event_ctrl(WP_API_EVENT_ENABLE, argc, argv)){
event_ctrl(WP_API_EVENT_DISABLE, argc, argv);
return;
}
/* 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)){
api_rx_hdr_t *rx_hdr;
/* An OOB event is pending, usually indicating
* a link level change */
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 CMD Exiting\n");
rx_hdr = (api_rx_hdr_t*)Rx_data;
event_decode(rx_hdr);
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 sizeof(wp_api_hdr_t) 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 0
if (api_rx_el->api_rx_hdr.error_flag){
printf("Data: ");
for(i=0;i<Rx_lgth; i ++) {
printf("0x%02X ", Rx_data[i+sizeof(wp_api_hdr_t)]);
}
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;
}
#endif
if (api_rx_el->api_rx_hdr.event_type){
event_decode(&api_rx_el->api_rx_hdr);
}
#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 {
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);
err=Tx_length + sizeof(api_tx_hdr_t);
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;
}
}
}
}
printf("Press any key...");
getchar();getchar();
event_ctrl(WP_API_EVENT_DISABLE, argc, argv);
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(argc, argv);
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);
}

View File

@ -1,596 +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_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <linux/sdla_aft_te1.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)
*/
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
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 );
}
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;
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;
return sendmsg(sock,&msg,flag);
}
/***************************************************
* HANDLE SOCKET
*
* o Read a socket
* o Cast data received to api_rx_element_t data type
* o The received packet contains sizeof(wp_api_hdr_t) bytes header
*
* ------------------------------------------
* | sizeof(wp_api_hdr_t) 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;
#if 0
int stream_sync=0;
#endif
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 sizeof(wp_api_hdr_t) 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{
#if 0
api_tx_el->data[i] = (unsigned char)tx_data+(i%4);
#else
api_tx_el->data[i] = (unsigned char)tx_data;
#endif
}
}
}
memset(api_tx_el->api_tx_hdr.wp_api_tx_hdr_hdlc_rpt_data,tx_data+1,4);
api_tx_el->api_tx_hdr.wp_api_tx_hdr_hdlc_rpt_len=4;
/* 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);
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 CMD Exiting\n");
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 sizeof(wp_api_hdr_t) byte header
* attached by the driver.
*
* 3. Check error_flag:
* CRC,Abort..etc
*/
memset(Rx_data, 0, sizeof(Rx_data));
#if 1
err = sangoma_readmsg_socket(sock,
Rx_data,sizeof(wp_api_hdr_t),
&Rx_data[sizeof(wp_api_hdr_t)], MAX_RX_DATA-sizeof(wp_api_hdr_t),
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) {
printf("\nError receiving data\n");
break;
}
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+sizeof(wp_api_hdr_t)]);
}
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;
//printf("RECEIVE:\n");
//print_packet(&Rx_data[sizeof(wp_api_hdr_t)],Rx_lgth);
if (Rx_lgth > 8) {
verbose=3;
} else {
if (verbose) {
verbose--;
}
}
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("%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)){
if (Tx_count == 0){
//printf("SEND: Len=%i\n",Tx_length);
//print_packet(&Tx_data[sizeof(wp_api_hdr_t)],Tx_length);
}
#if 1
err = sangoma_sendmsg_socket(sock,
Tx_data,sizeof(wp_api_hdr_t),
&Tx_data[sizeof(wp_api_hdr_t)], 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){
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 errno=%i len=%i \n",errno,Tx_length);
perror("Send: ");
break;
}
}else{
++Tx_count;
tx_data++;
memset(api_tx_el->data,tx_data,Tx_length);
memset(api_tx_el->api_tx_hdr.wp_api_tx_hdr_hdlc_rpt_data,tx_data+1,4);
api_tx_el->api_tx_hdr.wp_api_tx_hdr_hdlc_rpt_len=4;
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);
}

View File

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

View File

@ -1,51 +0,0 @@
Bitstream Apps
----------------
bitstrm_switch:
Implements the bitstreaming switch between two
interfaces.
All DS0 from first interface are transfered
to the second interface, plus DS1 and DS2 are
incremented by 1 and 2 respectively.
All DS0 from second interface are transfered
to the first interface, plus DS3 and DS4 are
incremented by 3 and 4 respectively.
Usage:
./bitstrm_switch -i <first if name> -c <first card name> \
-si <second if name > -sc <second card name> -r
eg:
./bitstrm_switch -i wp4bstrm1 -c wanpipe4 -si wp5bstrm1 -sc wanpipe5 -r
bitstrm_txrx:
The bitstrm_txrx sends and receives a binary file. Furthermore,
the rx binary file must contain numbers greater than 0x10.
The rx code will start receiving a binary stream once it
sees a first character greater than 0x10. The idle character
must be set to 0 in /etc/wanpipe/wanpipe#.conf.
Usage:
./bitstrm_txrx -i <if name> -c <card name> -r -w -rxfile <filename> \
-txfile <filename> -txsize 1000
eg:
./bitstrm_txrx -i wp1bstrm1 -c wanpipe1 -r -w -rxfile RXFILE \
-txfile tx_ch_file.b -txsize 1000
Note: Create the tx_ch_file.b using the te1/bstrm_gen_file application.
It is currently setup to create 2MB file containing all 0x10.

View File

@ -1,577 +0,0 @@
/*****************************************************************************
* chdlc_modem_cmd.c CHDLC API: Modem CMD Example
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2008 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_chdlc.h>
#include "lib_api.h"
#define FALSE 0
#define TRUE 1
#define LGTH_CRC_BYTES 2
#define MAX_TX_DATA 5000 /* Size of tx data */
#define MAX_RX_DATA MAX_TX_DATA
FILE *tx_fd=NULL,*rx_fd=NULL;
wan_mbox_t gmbox;
/*===================================================
* 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( (char*)sa.sll_device, if_name);
strcpy( (char*)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);
}
static int exec_cmd(int fd, wan_mbox_t * mb)
{
int err = ioctl(sock,SIOC_MBOX_CMD,mb);
if (err) {
perror("SIOC_MBOX_CMD");
return -1;
}
switch (mb->wan_return_code) {
case 0:
return 0;
default:
printf("Error: CMD returned 0x%0X\n",
mb->wan_return_code);
return -1;
}
return 0;
}
static unsigned char gstatus=0;
static int exec_read_modem_cmd(int fd, wan_mbox_t * mb)
{
MODEM_STATUS_STRUCT *mstat;
int err=0;
memset(mb,0,sizeof(wan_mbox_t));
mb->wan_data_len = 0;
mb->wan_command = READ_MODEM_STATUS;
err=exec_cmd(fd,mb);
if (err) {
return err;
}
mstat=(MODEM_STATUS_STRUCT*)mb->wan_data;
if (mstat->modem_status == gstatus) {
return 0;
}
gstatus = mstat->modem_status;
printf("MODEM CMD rc=0x%02X data_len=%i data=0x%02X\n",
mb->wan_return_code, mb->wan_data_len, mb->wan_data[0]);
mstat=(MODEM_STATUS_STRUCT*)mb->wan_data;
printf("MODEM STATUS (Data=0x%02X) DCD=%i CTS=%i\n",
mstat->modem_status,
(mstat->modem_status&MODEM_DCD_MASK)?1:0,
(mstat->modem_status&MODEM_CTS_MASK)?1:0);
return 0;
}
static int exec_set_modem_cmd(int fd, wan_mbox_t * mb, int dtr, int rts)
{
MODEM_STATUS_STRUCT *mstat=(MODEM_STATUS_STRUCT*)mb->wan_data;
int err=0;
memset(mb,0,sizeof(wan_mbox_t));
mb->wan_data_len = 0;
mb->wan_command = SET_MODEM_STATUS;
mb->wan_data_len = 1;
mstat->modem_status = 0;
if (dtr) {
mstat->modem_status |= SET_MODEM_DTR_HIGH;
}
if (rts) {
mstat->modem_status |= SET_MODEM_RTS_HIGH;
}
err=exec_cmd(fd,mb);
if (err) {
return err;
}
printf("MODEM CMD rc=0x%02X data_len=%i data=0x%02X (dtr=%i rts=%i)\n",
mb->wan_return_code, mb->wan_data_len, mb->wan_data[0],dtr,rts);
return 0;
}
/*===========================================================
* 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;
}
}
}
if (!write_enable) {
while (1) {
exec_read_modem_cmd(sock, &gmbox);
sleep(1);
}
}
sleep(4);
exec_set_modem_cmd(sock, &gmbox, 0, 0);
sleep(4);
exec_set_modem_cmd(sock, &gmbox, 1, 0);
sleep(4);
exec_set_modem_cmd(sock, &gmbox, 0, 1);
sleep(4);
exec_set_modem_cmd(sock, &gmbox, 1, 1);
sleep(4);
exit(1);
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;
}
switch (api_rx_el->wp_api_el_operation_status){
case 0:
/* Rx packet is good */
break;
case RX_FRM_ABORT:
/* Frame was aborted */
break;
case RX_FRM_CRC_ERROR:
/* Frame has crc error */
break;
case RX_FRM_OVERRUN_ERROR:
/* Frame has an overrun error */
break;
default:
/* Error with the rx packet
* handle it ... */
break;
}
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;
}
}
}
}
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;
};

View File

@ -1 +0,0 @@
./aft/aft_api: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped

View File

@ -13,7 +13,7 @@ DEBUG = 2
# Project file paths.
# Tools options.
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I../lib -I/usr/include/wanpipe
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I../lib
####### RULES ################################################################

4
api/legacy/xdlc/tx.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
kill -SIGUSR1 $(pidof xdlc_api)
echo "Tx Kicked"

View File

@ -143,10 +143,10 @@ int MakeConnection(void)
*
* o Read a socket
* o Cast data received to wan_api_rx_element_t data type
* o The received packet contains 16 bytes header
* o The received packet contains 64 bytes header
*
* ------------------------------------------
* | 16 bytes | X bytes ...
* | 64 bytes | X bytes ...
* ------------------------------------------
* Header Data
*
@ -197,7 +197,7 @@ void handle_socket(void)
}
/* Cast the Tx data packet with the tx element
* structure. We must insert a 16 byte
* structure. We must insert a 64 byte
* driver header, which driver will remove
* before passing packet out the physical port */
api_tx_el = (wan_api_tx_element_t*)&Tx_data[0];
@ -294,7 +294,8 @@ void handle_socket(void)
if (api_rx_el->wan_rxapi_xdlc_exception == EXCEP_SEC_SNRM_FRAME_RECEIVED){
printf("Enabling I Frames\n");
ioctl(sock,WAN_DEVPRIV_SIOC(SIOCS_XDLC_ENABLE_IFRAMES),NULL);
#endif }
}
#endif
Tx_count=0;
Rx_count=0;
@ -310,7 +311,7 @@ void handle_socket(void)
* buffer. Confirm len > 0
*
* 2: Cast Rx_data to the api_rx_element.
* Thus, removing a 16 byte header
* Thus, removing a 64 byte header
* attached by the driver.
*
* 3. Check error_flag:
@ -362,10 +363,8 @@ void handle_socket(void)
break;
}
bitstrm_skip_read:
}
bitstrm_skip_read:
if (FD_ISSET(sock,&write)){

View File

@ -3,7 +3,9 @@
*
*/
#include "wanpipe_hdlc.h"
#include <wanpipe_hdlc.h>
#include <string.h>
/*===================================================================
PROTOTYPES

View File

@ -17,10 +17,10 @@
#else
# include <ctype.h>
# include <unistd.h>
# include <string.h>
# include <errno.h>
# define wan_inline inline
#endif
#include <errno.h>
/*===================================================================
*

View File

@ -76,6 +76,7 @@ static int app_end=0;
static int gerr=0;
static int verbose=0;
static int timeout=0;
static int err_limit=4;
pthread_mutex_t g_lock;
void *process_con_tx(void *obj);
@ -89,7 +90,9 @@ static int log_printf(char *fmt, ...)
struct tm now;
time_t epoch;
if (!verbose) {
if (verbose < 0) {
/* Continue through */
} else if (!verbose) {
return 0;
}
@ -889,6 +892,12 @@ int main (int argc, char* argv[])
log_printf("Timeout = %i\n",timeout);
continue;
}
if (strcmp(argv[x+1], "-err_limit") == 0) {
x++;
err_limit=atoi(argv[x+1]);
log_printf("Error Limit = %i\n",err_limit);
continue;
}
sangoma_span_chan_fromif(argv[x+1],&span,&chan);
if (span > 0 && span <= 32 && chan > 0 && chan < 32) {
@ -939,6 +948,12 @@ int main (int argc, char* argv[])
}
}
#if 0
if (verbose < 0) {
verbose=0;
}
#endif
if (gerr==0) {
process_con_rx();
app_end=1;
@ -947,6 +962,7 @@ int main (int argc, char* argv[])
sleep(1);
}
while(1) {
active_check=0;
for (x=0;x<MAX_NUM_OF_TIMESLOTS;x++){
@ -969,6 +985,7 @@ int main (int argc, char* argv[])
printf("\nProduction Test Results\n");
for (x=0;x<MAX_NUM_OF_TIMESLOTS;x++){
timeslot_t *slot;
char str_status[100];
slot=&tslot_array[x];
if (slot->active) {
@ -983,17 +1000,23 @@ int main (int argc, char* argv[])
gerr++;
status++;
}
if (wanpipe_get_rx_hdlc_errors(slot->hdlc_eng) > 4) {
if (wanpipe_get_rx_hdlc_errors(slot->hdlc_eng) >= err_limit) {
gerr++;
status++;
}
if (slot->stats.errors > 4) {
if (slot->stats.errors >= err_limit) {
gerr++;
status++;
}
if (status) {
sprintf(str_status,"failed");
} else {
sprintf(str_status,"passed");
}
printf("|name=%-05s|span=%02i|chan=%02i|rx_frm=%04i|rx_hdlc_pkt=%04i|hdlc_err=%04i|h_c=%04i|h_a=%04i|h_f=%04i|drv_err=%04i|d_fifo=%04i|status=%s|",
printf("|name=%-05s|span=%02i|chan=%02i|rx_frm=%04i|rx_hdlc_pkt=%04i|hdlc_err=%04i|h_c=%04i|h_a=%04i|h_f=%04i|drv_err=%04i|d_fifo=%04i|status=%s|\n",
slot->if_name,
slot->span,slot->chan,
slot->frames,
@ -1004,7 +1027,7 @@ int main (int argc, char* argv[])
slot->hdlc_eng->decoder.stats.frame_overflow,
slot->stats.errors,
slot->stats.rx_fifo_errors,
status?"failed":"passed");
str_status);
if (slot->stats.errors) {
print_stats(slot);

View File

@ -62,7 +62,8 @@ CMD=$CMD" -timeout $timeout"
#echo "./hdlc_test $CMD"
eval "nice -n 20 ./hdlc_test $CMD"
#eval "nice -n 20 ./hdlc_test $CMD -err_limit 1"
eval "nice -n 20 ./hdlc_test $CMD "
rc=$?
exit $rc

View File

@ -0,0 +1,29 @@
CC=gcc
WANINC=$(WAN_VIRTUAL)/usr/include/wanpipe
WLINC=../../../patches/kdrivers/include
WEC=../../../patches/kdrivers/wanec
WECOCT=../../../patches/kdrivers/wanec/oct6100_api/include
INCLUDES=-I../ -I/usr/include -I/usr/src/libpri -I$(WLINC) -I$(WEC) -I$(WECOCT) -I$(WANINC) -I$(WANINC)/oct6100_api -I$(WANINC)/oct6100_api/oct6100api -I. -Ihdlc -I/usr/local/include
CFLAGS=-D__LINUX__ -D_REENTRANT -D_GNU_SOURCE -O2 -DWANPIPE_TDM_API
CCFLAGS=-Wall -Wstrict-prototypes -Wmissing-prototypes -g
all: sample_c
everything: sample_c hdlc_test.c
lib_api.o: lib_api.c
$(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -c -o lib_api.o lib_api.c
sample.o: sample.c
$(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -c -o sample.o sample.c
sample_c: sample.o lib_api.o
$(CC) $(CCFLAGS) $(INCLUDES) $(CFLAGS) -o sample_c sample.o lib_api.o -L. -lsangoma -lm
clean:
rm -fr sample_c *.o *.so *~ *core* *.so* *.a
distclean: clean
@echo OK

View File

@ -0,0 +1,26 @@
@echo off
set CURRENT_DIR=%cd%
set SANG_WP_DEVEL=d:\development
set SANG_WARNING_LEVEL=-W3 -WX
copy Makefile.Windows makefile
if %errorlevel% NEQ 0 goto failure
build -c -w
if %errorlevel% NEQ 0 goto failure
:ok
echo ********************
echo build was successful
echo ********************
goto end
:failure
echo !!!!!!!!!!!!!!!!!!!!!!!
echo build was UN-successful
echo !!!!!!!!!!!!!!!!!!!!!!!
:end
echo End

View File

@ -0,0 +1,514 @@
/*****************************************************************************
* lib_api.c Sangoma Command Line Arguments parsing library
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
* 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.
* ============================================================================
*/
#include "libsangoma.h"
#include "lib_api.h"
#define SINGLE_CHANNEL 0x2
#define RANGE_CHANNEL 0x1
char read_enable=0;
char write_enable=0;
char primary_enable=0;
int tx_cnt=0;
int rx_cnt=0;
int tx_size=10;
int tx_delay=0;
int tx_data=-1;
int buffer_multiplier=0;
int fe_read_cmd=0;
uint32_t fe_read_reg=0;
int fe_write_cmd=0;
uint32_t fe_write_reg=0;
uint32_t fe_write_data=0;
float rx_gain=0;
float tx_gain=0;
int rx_gain_cmd=0;
int tx_gain_cmd=0;
unsigned char tx_file[WAN_IFNAME_SZ];
unsigned char rx_file[WAN_IFNAME_SZ];
unsigned char daddr[TX_ADDR_STR_SZ];
unsigned char saddr[TX_ADDR_STR_SZ];
unsigned char udata[TX_ADDR_STR_SZ];
int files_used=0;
int verbose=0;
int tx_connections;
int ds_prot=0;
int ds_prot_opt=0;
int ds_max_mult_cnt=0;
unsigned int ds_active_ch=0;
int ds_7bit_hdlc=0;
int direction=-1;
int tx_channels=1;
int cause=0;
int diagn=0;
int wanpipe_port_no=0;
int wanpipe_if_no=0;
int dtmf_enable_octasic = 0;
int dtmf_enable_remora = 0;
int remora_hook = 0;
int usr_period = 0;
int set_codec_slinear = 0;
int set_codec_none = 0;
int rbs_events = 0;
int rx2tx = 0;
int flush_period=0;
int stats_period=0;
int stats_test=0;
int flush_stats_test=0;
int hdlc_repeat=0;
int ss7_cfg_status=0;
int fe_read_test=0;
int hw_pci_rescan=0;
int force_open=0;
unsigned long parse_active_channel(char* val);
int init_args(int argc, char *argv[])
{
int i;
int c_cnt=0;
sprintf((char*)daddr,"111");
sprintf((char*)saddr,"222");
sprintf((char*)udata,"C9");
for (i = 0; i < argc; i++){
if (!strcmp(argv[i],"-i") || !strcmp(argv[i],"-chan")){
if (i+1 > argc-1){
printf("ERROR: Number of Interfaces was NOT specified!\n");
return WAN_FALSE;
}
wanpipe_if_no = atoi(argv[i+1]);
}else if (!strcmp(argv[i],"-p") || !strcmp(argv[i],"-span")){
if (i+1 > argc-1){
printf("ERROR: Number of Ports was NOT specified!\n");
return WAN_FALSE;
}
wanpipe_port_no = atoi(argv[i+1]);
}else if (!strcmp(argv[i],"-r")){
read_enable=1;
c_cnt=1;
}else if (!strcmp(argv[i],"-w")){
write_enable=1;
c_cnt=1;
}else if (!strcmp(argv[i],"-hdlc_repeat")){
hdlc_repeat=1;
}else if (!strcmp(argv[i],"-stats_test")){
stats_test=1;
force_open=1;
c_cnt=1;
}else if (!strcmp(argv[i],"-flush_stats_test")){
flush_stats_test=1;
force_open=1;
c_cnt=1;
}else if (!strcmp(argv[i],"-ss7_cfg_status")){
ss7_cfg_status=1;
}else if (!strcmp(argv[i],"-fe_read_test")){
fe_read_test=1;
}else if (!strcmp(argv[i],"-hw_pci_rescan")){
hw_pci_rescan=1;
wanpipe_port_no=1;
wanpipe_if_no=1;
c_cnt=1;
}else if (!strcmp(argv[i],"-force_open")){
force_open=1;
}else if (!strcmp(argv[i],"-pri")){
primary_enable=1;
}else if (!strcmp(argv[i],"-txcnt")){
if (i+1 > argc-1){
printf("ERROR: Invalid tx cnt!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_cnt = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx cnt!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-rxcnt")){
if (i+1 > argc-1){
printf("ERROR: Invalid rx cnt!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
rx_cnt = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid rx cnt!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txsize")){
if (i+1 > argc-1){
printf("ERROR: Invalid tx size!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_size = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx size, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txdelay")){
if (i+1 > argc-1){
printf("ERROR: Invalid tx delay!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_delay = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx delay, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txdata")){
if (i+1 > argc-1){
printf("ERROR: Invalid tx data!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_data = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid tx data, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txfile")){
if (i+1 > argc-1){
printf("ERROR: Invalid Tx File Name!\n");
return WAN_FALSE;
}
strncpy((char*)tx_file, argv[i+1],WAN_IFNAME_SZ);
files_used |= TX_FILE_USED;
}else if (!strcmp(argv[i],"-rxfile")){
if (i+1 > argc-1){
printf("ERROR: Invalid Rx File Name!\n");
return WAN_FALSE;
}
strncpy((char*)rx_file, argv[i+1],WAN_IFNAME_SZ);
files_used |= RX_FILE_USED;
}else if (!strcmp(argv[i],"-daddr")){
if (i+1 > argc-1){
printf("ERROR: Invalid daddr str!\n");
return WAN_FALSE;
}
strncpy((char*)daddr, argv[i+1],TX_ADDR_STR_SZ);
}else if (!strcmp(argv[i],"-saddr")){
if (i+1 > argc-1){
printf("ERROR: Invalid saddr str!\n");
return WAN_FALSE;
}
strncpy((char*)saddr, argv[i+1],TX_ADDR_STR_SZ);
}else if (!strcmp(argv[i],"-udata")){
if (i+1 > argc-1){
printf("ERROR: Invalid udata str!\n");
return WAN_FALSE;
}
strncpy((char*)udata, argv[i+1],TX_ADDR_STR_SZ);
}else if (!strcmp(argv[i],"-verbose")){
verbose=1;
}else if (!strcmp(argv[i],"-buffer_multiplier")) {
if (i+1 > argc-1){
printf("ERROR: Invalid prot!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
buffer_multiplier = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid prot, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-prot")){
if (i+1 > argc-1){
printf("ERROR: Invalid prot!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
ds_prot = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid prot, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-prot_opt")){
if (i+1 > argc-1){
printf("ERROR: Invalid prot_opt!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
ds_prot_opt = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid prot_opt, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-max_mult_cnt")){
if (i+1 > argc-1){
printf("ERROR: Invalid max_mult_cnt!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
ds_max_mult_cnt = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid max_mult_cnt, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-txchan")){
if (i+1 > argc-1){
printf("ERROR: Invalid channels!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
tx_channels = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid channels, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-diagn")){
if (i+1 > argc-1){
printf("ERROR: Invalid diagn!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
diagn = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid diagn, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-cause")){
if (i+1 > argc-1){
printf("ERROR: Invalid cause!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
cause = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid cause, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-7bit_hdlc")){
if (i+1 > argc-1){
printf("ERROR: Invalid 7bit hdlc value!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
ds_7bit_hdlc = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid 7bit hdlc, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-dir")){
if (i+1 > argc-1){
printf("ERROR: Invalid direction value!\n");
return WAN_FALSE;
}
if(isdigit(argv[i+1][0])){
direction = atoi(argv[i+1]);
}else{
printf("ERROR: Invalid direction, must be a digit!\n");
return WAN_FALSE;
}
}else if (!strcmp(argv[i],"-dtmf_octasic")){
dtmf_enable_octasic = 1;
}else if (!strcmp(argv[i],"-dtmf_remora")){
dtmf_enable_remora = 1;
}else if(!strcmp(argv[i],"-usr_period")){
if (i+1 > argc-1){
printf("ERROR: Invalid 'usr_period' value!\n");
}else{
usr_period = atoi(argv[i+1]);
}
}else if(!strcmp(argv[i],"-flush_period")){
if (i+1 > argc-1){
printf("ERROR: Invalid 'flush_period' value!\n");
}else{
flush_period = atoi(argv[i+1]);
}
}else if(!strcmp(argv[i],"-stats_period")){
if (i+1 > argc-1){
printf("ERROR: Invalid 'stats_period' value!\n");
}else{
stats_period = atoi(argv[i+1]);
}
}else if(!strcmp(argv[i],"-rbs_events")){
rbs_events = 1;
}else if(!strcmp(argv[i],"-rx2tx")){
rx2tx = 1;
}else if(!strcmp(argv[i],"-fe_reg_read")) {
if (i+1 > argc-1){
printf("ERROR: Invalid 'flush_period' value!\n");
}else{
fe_read_cmd=1;
sscanf(argv[i+1],"%x",(uint32_t*)&fe_read_reg);
}
}else if(!strcmp(argv[i],"-fe_reg_write")) {
if (i+2 > argc-1){
printf("ERROR: Invalid 'flush_period' value!\n");
}else{
fe_write_cmd=1;
sscanf(argv[i+1],"%x",(uint32_t*)&fe_write_reg);
sscanf(argv[i+2],"%x",(uint32_t*)&fe_write_data);
}
}else if (!strcmp(argv[i],"-rx_gain")) {
if (i+1 > argc-1){
printf("ERROR: Invalid 'rx_gain' value!\n");
}else{
rx_gain_cmd=1;
sscanf(argv[i+1],"%f",&rx_gain);
}
}else if (!strcmp(argv[i],"-tx_gain")) {
if (i+1 > argc-1){
printf("ERROR: Invalid 'tx_gain' value!\n");
}else{
tx_gain_cmd=1;
sscanf(argv[i+1],"%f",&tx_gain);
}
}
}
if (!wanpipe_port_no || !wanpipe_if_no){
printf("ERROR: No Port Number AND No Interface Number! Both of them needed!\n");
return WAN_FALSE;
}
if (!c_cnt){
printf("Warning: No Read or Write Command\n");
}
return WAN_TRUE;
}
static char api_usage[]="\n"
"\n"
"<options>:\n"
" -span <port/span number> #port/span number\n"
" -chan <if/chan number> #if/chan number\n"
" -r #read enable\n"
" -w #write eable\n"
"\n"
" example 1: sangoma_c -span 1 -chan 1 -r -verbose\n"
" in this example Wanpipe span 1, Interface chan 1 will be used for reading data\n"
"\n"
"<extra options>\n"
" -txcnt <digit> #number of tx packets (Dflt: 1)\n"
" -txsize <digit> #tx packet size (Dflt: 10)\n"
" -txdelay <digit> #delay in sec after each tx packet (Dflt: 0)\n"
" -txdata <digit> #data to tx <1-255>\n"
" -rx2tx #transmit all received data\n"
"\n"
" -dtmf_octasic #Enable DTMF detection on Octasic chip\n"
" -dtmf_remora #Enable DTMF detection on A200 (SLIC) chip\n"
" -remora_hook #Enable On/Off hook events on A200\n"
" -set_codec_slinear #Enable SLINEAR codec\n"
" -set_codec_none #Disable codec\n"
" -rbs_events #Enable RBS change detection\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"
" #receives the rxcnt number of packets.\n"
" -hdlc_repeat #enable hdlc repeat on tx hdlc write.\n"
"\n"
" -verbose #Enable verbose mode\n"
"\n";
void usage(char *api_name)
{
printf ("\n\nAPI %s USAGE:\n\n%s <options> <extra options>\n\n%s\n",
api_name,api_name,api_usage);
}
/*============================================================================
* TE1
*/
#if 0
unsigned long get_active_channels(int channel_flag, int start_channel, int stop_channel)
{
int i = 0;
unsigned long tmp = 0, mask = 0;
if ((channel_flag & (SINGLE_CHANNEL | RANGE_CHANNEL)) == 0)
return tmp;
if (channel_flag & RANGE_CHANNEL) { /* Range of channels */
for(i = start_channel; i <= stop_channel; i++) {
mask = 1 << (i - 1);
tmp |=mask;
}
} else { /* Single channel */
mask = 1 << (stop_channel - 1);
tmp |= mask;
}
return tmp;
}
#endif

View File

@ -0,0 +1,89 @@
/*****************************************************************************
* lib_api.h Sangoma Command Line Arguments parsing library
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
* 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.
* ============================================================================
*/
#include "libsangoma.h"
extern char read_enable;
extern char write_enable;
extern char primary_enable;
extern int tx_cnt;
extern int rx_cnt;
extern int tx_size;
extern int tx_delay;
extern int tx_data;
extern int files_used;
extern int verbose;
extern int ds_prot;
extern int ds_prot_opt;
extern int ds_max_mult_cnt;
extern unsigned int ds_active_ch;
extern int ds_7bit_hdlc;
extern int direction;
extern int tx_channels;
extern int diagn;
extern int cause;
extern int wanpipe_port_no;
extern int wanpipe_if_no;
extern int dtmf_enable_octasic;
extern int dtmf_enable_remora;
extern int remora_hook;
extern int usr_period;
extern int set_codec_slinear;
extern int set_codec_none;
extern int rbs_events;
extern int rx2tx;
extern int flush_period;
extern int stats_period;
extern int hdlc_repeat;
extern int ss7_cfg_status;
extern int buffer_multiplier;
extern int fe_read_test;
extern int hw_pci_rescan;
extern int force_open;
extern int fe_read_cmd;
extern uint32_t fe_read_reg;
extern int fe_write_cmd;
extern uint32_t fe_write_reg;
extern uint32_t fe_write_data;
extern int stats_test;
extern int flush_stats_test;
extern float rx_gain;
extern float tx_gain;
extern int rx_gain_cmd;
extern int tx_gain_cmd;
extern unsigned char tx_file[WAN_IFNAME_SZ];
extern unsigned char rx_file[WAN_IFNAME_SZ];
#define TX_ADDR_STR_SZ 100
extern unsigned char daddr[TX_ADDR_STR_SZ];
extern unsigned char saddr[TX_ADDR_STR_SZ];
extern unsigned char udata[TX_ADDR_STR_SZ];
#define TX_FILE_USED 1
#define RX_FILE_USED 2
extern int init_args(int argc, char *argv[]);
extern void usage(char *api_name);
extern void u_delay(int usec);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
TARGETNAME=sample_c
TARGETPATH=obj
TARGETTYPE=PROGRAM
UMTYPE=console
UMENTRY=main
UMBASE=0x400000
USE_LIBCMT=1
#MSC_WARNING_LEVEL=$(SANG_WARNING_LEVEL)
MSC_WARNING_LEVEL=-W3
############################################################################################
C_DEFINES=$(C_DEFINES) /D__WINDOWS__
############################################################################################
INCLUDES=$(DDK_INC_PATH);\
$(SANG_WP_DEVEL)\wanpipe_common\include;\
$(SANG_WP_DEVEL)\wanpipe_common\include\aft_core;\
$(SANG_WP_DEVEL)\wanpipe_windows\include;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma\wanec;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\wanec_apilib;\
$(SANG_WP_DEVEL)\wanpipe_common\wanec;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\oct6100api;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\octdeviceapi\oct6100api;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\apilib\llman;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\apilib;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\octrpc;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\apilib\bt
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma\$(O)\libsangoma.lib
SOURCES=sample.c lib_api.c

View File

@ -0,0 +1,40 @@
# ============================================================================
# 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
LINK_ARGS= -lcurses -lpthread
WLINC=../../../patches/kdrivers/include
WEC=../../../patches/kdrivers/wanec
WECOCT=../../../patches/kdrivers/wanec/oct6100_api/include
# Tools options.
CFLAGS = -Wall -O2 -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_
CFLAGS += -I$(WLINC) -I$(WEC) -I$(WECOCT)
CFLAGS += -I$(WAN_VIRTUAL)/usr/include/wanpipe -I$(WAN_VIRTUAL)/usr/include/wanpipe/oct6100_api -I$(WAN_VIRTUAL)/usr/include/wanpipe/oct6100_api -I/usr/include
CFLAGS += $(EXTRA_FLAGS) -D__LINUX__
CFLAGS += -D_REENTRANT -DUSE_STELEPHONY_API -D_GNU_SOURCE -DWANPIPE_TDM_API
CXX=g++
TARGETS=sample_cpp
LIBS= sangoma_port.cpp sangoma_port_configurator.cpp sangoma_cthread.cpp sangoma_interface.cpp
####### RULES ################################################################
all: $(TARGETS)
@echo "Ok."
sample_cpp: sample.cpp $(LIBS) $(LIBS_STEL) $(LIBS_TONE)
$(CXX) $(CFLAGS) -o $@ $^ $(LINK_ARGS) -lsangoma -lstelephony -lm
clean:
rm -f $(TARGETS)

View File

@ -0,0 +1,26 @@
@echo off
set CURRENT_DIR=%cd%
set SANG_WP_DEVEL=d:\development_trunk
set SANG_WARNING_LEVEL=-W3 -WX
copy Makefile.Windows makefile
if %errorlevel% NEQ 0 goto failure
build -c -w
if %errorlevel% NEQ 0 goto failure
:ok
echo ********************
echo build was successful
echo ********************
goto end
:failure
echo !!!!!!!!!!!!!!!!!!!!!!!
echo build was UN-successful
echo !!!!!!!!!!!!!!!!!!!!!!!
:end
echo End

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,309 @@
/*
sample.h - common definitions used in this application.
*/
#ifndef _SAMPLE_H
#define _SAMPLE_H
#include <libsangoma.h>
#if USE_STELEPHONY_API
#include <libstelephony.h>
#endif
#define USE_WP_LOGGER 1
#define SAMPLE_CPP_MAX_PATH 1024
#define USE_BUFFER_MULTIPLIER 0
typedef struct{
unsigned int wanpipe_number;
unsigned int interface_number;
unsigned char silent;
uint16_t txlength;
unsigned char Rx_to_Tx_loopback;
unsigned char decode_fsk_cid;
unsigned char encode_fsk_cid;
unsigned char sw_dtmf;
unsigned char encode_sw_dtmf;
unsigned char voice_codec_alaw;
unsigned char decode_q931;
char szTxFileName[SAMPLE_CPP_MAX_PATH];
unsigned int txcount;
unsigned char driver_config;
unsigned char use_ctrl_dev;
unsigned char use_logger_dev;
int txgain;
int rxgain;
unsigned char use_hardware_echo_canceller;
unsigned char real_time;
unsigned char hwec_channel;
#if USE_BUFFER_MULTIPLIER
unsigned int buffer_multiplier;
#endif
}wp_program_settings_t;
#define DEV_NAME_LEN 100
extern void cli_out(unsigned int dbg_flag, void *pszFormat, ...);
extern unsigned int verbosity_level;
typedef struct{
//Recieved data
int (*got_rx_data)(void *sang_if_ptr, void *rxhdr, void *rx_data);
//TDM events
void (*got_tdm_api_event)(void *sang_if_ptr, void *event_data);
#if USE_STELEPHONY_API
//FSK Caller ID detected
void (*FSKCallerIDEvent)(void *sang_if_ptr, char * Name, char * CallerNumber, char * CalledNumber, char * DateTime);
//DTMF detected in SOFTWARE
void (*DTMFEvent)(void *sang_if_ptr, long Key);
//Q931 decoder events
void (*Q931Event)(void *callback_context, stelephony_q931_event *pQ931Event);
//FSK Caller ID buffer ready for transmission events
void (*FSKCallerIDTransmit)(void *callback_context, void* buffer);
//DTMF buffer ready for transmission events
void (*SwDtmfTransmit)(void *callback_context, void* buffer);
#endif
#if USE_WP_LOGGER
void (*got_logger_event)(void *sang_if_ptr, wp_logger_event_t *logger_event);
#endif
}callback_functions_t;
#if USE_BUFFER_MULTIPLIER
# define SAMPLE_CPP_MAX_DATA_LEN (MAX_BUFFER_MULTIPLIER_FACTOR*MAX_NO_DATA_BYTES_IN_FRAME)
#else
# define SAMPLE_CPP_MAX_DATA_LEN MAX_NO_DATA_BYTES_IN_FRAME
#endif
static void wp_print_rbs_cas_bits(unsigned int abcd)
{
printf("A:%1d B:%1d C:%1d D:%1d\n",
(abcd & WAN_RBS_SIG_A) ? 1 : 0,
(abcd & WAN_RBS_SIG_B) ? 1 : 0,
(abcd & WAN_RBS_SIG_C) ? 1 : 0,
(abcd & WAN_RBS_SIG_D) ? 1 : 0);
}
#if defined (__WINDOWS__)
static void DecodeLastError(LPSTR lpszFunction)
{
LPVOID lpMsgBuf;
DWORD dwLastErr = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwLastErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
printf("Last Error: %s (GetLastError() returned: %d)\n", (char*)lpMsgBuf, dwLastErr);
// Free the buffer.
LocalFree( lpMsgBuf );
}
#endif
//This Program interfaces directly to hardware, it should be real time.
static void sng_set_process_priority_to_real_time()
{
#if defined (__WINDOWS__)
if (!SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)) {
printf("Failed to set program priority!\n");
}
#else
//TODO: implement for Linux
#endif
}
//This Execution Thread interfaces directly to hardware, it should be real time.
static void sng_set_thread_priority_to_real_time()
{
#if defined (__WINDOWS__)
if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL)) {
printf("Failed to set thread priority!\n");
}
#else
//TODO: implement for Linux
#endif
}
/* This flag controls debugging of time difference between
* data receive indications. Disabled by default. */
#define DBG_TIMING 0
#if DBG_TIMING
#define DEBUG_HI_RES_PERF if(0)printf
typedef struct _wan_debug{
LARGE_INTEGER LastHiResolutionCounter;
int high_resolution_timediff_value;
unsigned int allowed_deviation_of_timediff_value;
unsigned int timediff_deviation_counter;
int highest_timediff;
int lowest_timediff;
int latest_timediff;
char *debug_name;//optional
}wan_debug_t;
/* Print contents of wan_debug_t structure:
1. TimeDiff info
2. More info will be added in future
*/
static
void
debug_print_dbg_struct(
wan_debug_t *wan_debug_ptr,
const char *caller_name
)
{
printf("timediff_deviation_counter: %d\n\tTimeDiff (ms) between '%s()':\n\tHighest:%d Lowest:%d Expected: %d Latest: %d allowed deviation:%d\n",
wan_debug_ptr->timediff_deviation_counter,
caller_name,
wan_debug_ptr->highest_timediff,
wan_debug_ptr->lowest_timediff,
wan_debug_ptr->high_resolution_timediff_value,
wan_debug_ptr->latest_timediff,
wan_debug_ptr->allowed_deviation_of_timediff_value);
}
/* Call this function to mesure TimeDiff between some function call. */
static
void
debug_update_timediff(
wan_debug_t *wan_debug_ptr,
const char *caller_name
)
{
LARGE_INTEGER CurrentHiResolutionCounter;
LARGE_INTEGER PerformanceFrequency;
unsigned int number_of_HiResCounterTicks_BETWEEN_function_calls;
int timediff_between_function_calls;
if(!wan_debug_ptr->high_resolution_timediff_value){
//TimeDiff debugging is disabled.
return;
}
QueryPerformanceFrequency(&PerformanceFrequency);
QueryPerformanceCounter(&CurrentHiResolutionCounter);
if( wan_debug_ptr->LastHiResolutionCounter.QuadPart == 0 ){
//It is the 1st time this function is running after TimeDiff debugging was enabled.
//Initialize wan_debug_ptr->LastHiResolutionCounter!
QueryPerformanceCounter(&wan_debug_ptr->LastHiResolutionCounter);
return;
}
#if 0
DEBUG_HI_RES_PERF("Frequency: %I64u\n", PerformanceFrequency);
DEBUG_HI_RES_PERF("hi res cnt difference: %I64u\n",
CurrentHiResolutionCounter.QuadPart - wan_debug_ptr->LastHiResolutionCounter.QuadPart);
#endif
////////////////////////////////////////////////////////////////
//Frequency: 1600000000
//hi res cnt difference: 32038864
//1600000000 / 32038864 = 49.939348661051153374227001306913
////////////////////////////////////////////////////////////////
if((CurrentHiResolutionCounter.QuadPart - wan_debug_ptr->LastHiResolutionCounter.QuadPart)){//check for division by zero
number_of_HiResCounterTicks_BETWEEN_function_calls = (unsigned int)
(PerformanceFrequency.QuadPart / (CurrentHiResolutionCounter.QuadPart - wan_debug_ptr->LastHiResolutionCounter.QuadPart));
}
//note that floating point calculations are not allowed in kernel!
if(number_of_HiResCounterTicks_BETWEEN_function_calls){//check for division by zero
timediff_between_function_calls = 1000 / number_of_HiResCounterTicks_BETWEEN_function_calls;
}
#if 0
if(number_of_HiResCounterTicks_BETWEEN_function_calls < 49 || number_of_HiResCounterTicks_BETWEEN_function_calls > 51){
printf("Warning: Invalid Number of SetEvent() calls per second %d!\n", number_of_HiResCounterTicks_BETWEEN_function_calls);
}
#endif
//if(timediff_between_function_calls < 19 || timediff_between_function_calls > 21){
if( timediff_between_function_calls <
(int)(wan_debug_ptr->high_resolution_timediff_value - wan_debug_ptr->allowed_deviation_of_timediff_value) ||
timediff_between_function_calls >
(int)(wan_debug_ptr->high_resolution_timediff_value + wan_debug_ptr->allowed_deviation_of_timediff_value)){
wan_debug_ptr->timediff_deviation_counter++;
// DEBUG_HI_RES_PERF("diff: %d, hi: %d, low: %d\n", timediff_between_function_calls,
// wan_debug_ptr->highest_timediff, wan_debug_ptr->lowest_timediff);
if(timediff_between_function_calls > 0){//because the FIRST timediff is always negative!
int current_time_diff_delta =
timediff_between_function_calls - wan_debug_ptr->high_resolution_timediff_value;
//negative (example: 10 - 20 = -10)
int lowest_time_diff_delta =
wan_debug_ptr->lowest_timediff - wan_debug_ptr->high_resolution_timediff_value;
//positive (example: 30 - 20 = +10)
int highest_time_diff_delta =
wan_debug_ptr->highest_timediff - wan_debug_ptr->high_resolution_timediff_value;
DEBUG_HI_RES_PERF("curr delta: %d, hi delta: %d, low delta: %d\n",
current_time_diff_delta, highest_time_diff_delta, lowest_time_diff_delta);
if(current_time_diff_delta < 0){
//TimeDiff is BELLOW expected
if( current_time_diff_delta < lowest_time_diff_delta ||
wan_debug_ptr->lowest_timediff == 0){
wan_debug_ptr->lowest_timediff = timediff_between_function_calls;
}
}
if(current_time_diff_delta > 0){
//TimeDiff is ABOVE expected
if(current_time_diff_delta > highest_time_diff_delta ||
wan_debug_ptr->highest_timediff == 0){
wan_debug_ptr->highest_timediff = timediff_between_function_calls;
}
}
}//if(timediff_between_function_calls > 0)
if(!(wan_debug_ptr->timediff_deviation_counter % 10)){
debug_print_dbg_struct(wan_debug_ptr, caller_name);
}
}//if( timediff_between_function_calls ...)
wan_debug_ptr->latest_timediff = timediff_between_function_calls;
//prepare for the NEXT call by storing CURRENT counter
QueryPerformanceCounter(&wan_debug_ptr->LastHiResolutionCounter);
}
/* Set (initialize) the TimeDiff part of wan_debug_t structure. */
static
void
debug_set_timing_info(
wan_debug_t *wan_debug_ptr,
int usr_period,
int allowed_deviation_of_timediff_value
)
{
wan_debug_ptr->high_resolution_timediff_value = usr_period;//in milliseconds. 0 - disable TimeDiff debugging.
if(wan_debug_ptr->high_resolution_timediff_value == 0){
wan_debug_ptr->LastHiResolutionCounter.QuadPart = 0;
}
wan_debug_ptr->highest_timediff = wan_debug_ptr->lowest_timediff = 0;
wan_debug_ptr->allowed_deviation_of_timediff_value = allowed_deviation_of_timediff_value;//milliseconds.
//for example: if 2 and high_resolution_timediff_value is 20,
//will result 18 < 20 < 22
}
/////////////////////////////////////////////////////////////////////////////////////
#endif//DBG_TIMING
#endif//_SAMPLE_H

View File

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample_cpp", "sample.vcproj", "{20071FBB-88EE-41D9-A728-68A883BFC68B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Win64|Win32 = Win64|Win32
Win64|x64 = Win64|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Debug|Win32.ActiveCfg = Debug|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Debug|Win32.Build.0 = Debug|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Debug|x64.ActiveCfg = Debug|x64
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Debug|x64.Build.0 = Debug|x64
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Release|Win32.ActiveCfg = Release|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Release|Win32.Build.0 = Release|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Release|x64.ActiveCfg = Release|x64
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Release|x64.Build.0 = Release|x64
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Win64|Win32.ActiveCfg = Win64|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Win64|Win32.Build.0 = Win64|Win32
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Win64|x64.ActiveCfg = Win64|x64
{20071FBB-88EE-41D9-A728-68A883BFC68B}.Win64|x64.Build.0 = Win64|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,873 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="sample_cpp"
ProjectGUID="{20071FBB-88EE-41D9-A728-68A883BFC68B}"
RootNamespace="sample_cpp"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\objchk_wxp_x86\i386"
IntermediateDirectory=".\objchk_wxp_x86\i386"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SANG_WP_DEVEL)\wanpipe_windows\releases\wanpipe_6_0_42_3\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\releases\wanpipe_6_0_42_3\api\miscellaneous\include_octasic&quot;"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;__WINDOWS__;_WIN32_WINNT=0x0500;NOMINMAX;USE_SANGOMA_ERRNO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/sample.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Setupapi.lib $(SANG_WP_DEVEL)\stelephony\objchk_wxp_x86\i386\stelephony.lib $(SANG_WP_DEVEL)\libsangoma\objchk_wxp_x86\i386\libsangoma.lib"
OutputFile=".\objchk_wxp_x86\i386/sample_cpp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/sample_cpp.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\Debug/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SANG_WP_DEVEL)\libsangoma&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include\aft_core&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\include&quot;;&quot;$(SANG_WP_DEVEL)\stelephony&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\HighResolutionTimer\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wantools\wanec_apilib&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wanec&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\releases\wanpipe_6_0_40_0\api\miscellaneous\include_octasic&quot;"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;__WINDOWS__;_WIN32_WINNT=0x0500;NOMINMAX;USE_SANGOMA_ERRNO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/sample.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Setupapi.lib $(SANG_WP_DEVEL)\stelephony\objchk_wnet_amd64\amd64\stelephony.lib $(SANG_WP_DEVEL)\libsangoma\objchk_wnet_amd64\amd64\libsangoma.lib"
OutputFile=".\objchk_wxp_x86\i386/sample_cpp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/sample_cpp.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/sample.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/sample.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/sample.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\Release/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/sample.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile=".\Release/sample.exe"
LinkIncremental="1"
SuppressStartupBanner="true"
ProgramDatabaseFile=".\Release/sample.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Win64|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SANG_WP_DEVEL)\libsangoma&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include\aft_core&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\include&quot;;&quot;$(SANG_WP_DEVEL)\stelephony&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\HighResolutionTimer\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wantools\wanec_apilib&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wanec&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\releases\wanpipe_6_0_40_0\api\miscellaneous\include_octasic&quot;"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;__WINDOWS__;_WIN32_WINNT=0x0500;NOMINMAX;USE_SANGOMA_ERRNO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/sample.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Setupapi.lib $(SANG_WP_DEVEL)\stelephony\objchk_wxp_x86\i386\stelephony.lib $(SANG_WP_DEVEL)\libsangoma\objchk_wxp_x86\i386\libsangoma.lib"
OutputFile=".\objchk_wxp_x86\i386/sample_cpp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/sample_cpp.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Win64|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
CommandLine=""
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\Debug/sample.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(SANG_WP_DEVEL)\libsangoma&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\include\aft_core&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\include&quot;;&quot;$(SANG_WP_DEVEL)\stelephony&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\HighResolutionTimer\include&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wantools\wanec_apilib&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_common\wanec&quot;;&quot;$(SANG_WP_DEVEL)\wanpipe_windows\releases\wanpipe_6_0_40_0\api\miscellaneous\include_octasic&quot;"
PreprocessorDefinitions="_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;__WINDOWS__;_WIN32_WINNT=0x0500;NOMINMAX;USE_SANGOMA_ERRNO"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/sample.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CallingConvention="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Setupapi.lib $(SANG_WP_DEVEL)\stelephony\objchk_wxp_x86\i386\stelephony.lib $(SANG_WP_DEVEL)\libsangoma\objchk_wxp_x86\i386\libsangoma.lib"
OutputFile=".\objchk_wxp_x86\i386/sample_cpp.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/sample_cpp.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/sample.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="source"
Filter="*.cpp;*.c"
>
<File
RelativePath="sample.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="sangoma_cthread.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="sangoma_interface.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="sangoma_port.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="sangoma_port_configurator.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|Win32"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Win64|x64"
>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="headers"
Filter="*.h"
>
<File
RelativePath="sample.h"
>
</File>
<File
RelativePath="sangoma_cthread.h"
>
</File>
<File
RelativePath="sangoma_interface.h"
>
</File>
<File
RelativePath="sangoma_port.h"
>
</File>
<File
RelativePath="sangoma_port_configurator.h"
>
</File>
</Filter>
<File
RelativePath=".\sources"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,62 @@
#ifndef __LINUX_COMPAT_H__
#define __LINUX_COMPAT_H__
#include <sys/time.h>
#include <pthread.h>
#define SYSTEMTIME struct tm
#define wMonth tm_mon
#define wDay tm_mday
#define wYear tm_year
#define wHour tm_hour
#define wMinute tm_min
#define wSecond tm_sec
#define LPCTSTR char *
#define STELAPI_CALL
#ifndef BOOL
#define BOOL bool
#endif
#ifndef CHAR
#define CHAR char
#endif
#define IN
#define OUT
#ifndef FALSE
#define FALSE 0
#ifndef TRUE
#define TRUE (!FALSE)
#endif
#endif
static __inline int GetLocalTime(SYSTEMTIME *tv)
{
time_t now = time(NULL);
*tv = *localtime(&now);
return 0;
}
#define CRITICAL_SECTION pthread_mutex_t
#define EnterCriticalSection(arg) pthread_mutex_lock(arg)
#define LeaveCriticalSection(arg) pthread_mutex_unlock(arg)
#define InitializeCriticalSection(arg) pthread_mutex_init(arg, NULL);
typedef struct _variant
{
int vt;
int intVal;
}variant_t;
#define VARIANT variant_t
#define VT_UI4 0
#define WFI_CCITT_ALaw_8kHzMono 1
#define WFI_CCITT_uLaw_8kHzMono 2
#endif /* __LINUX_COMPAT_H__ */

View File

@ -0,0 +1,105 @@
//////////////////////////////////////////////////////////////////////
// sangoma_cthread.cpp: generic C++ Execution Thread.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#if defined(__WINDOWS__)
# include <windows.h>
#else
# include <string.h>
# include <stdarg.h>
# include <stdlib.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <arpa/inet.h>
# include <netdb.h>
# include <stdio.h>
# include <unistd.h>
# include <fcntl.h>
# include <sys/time.h>
# include <poll.h>
# include <signal.h>
# include <pthread.h>
# define CTHREAD_STACK_SIZE 1024 * 240
#endif
# include "sangoma_cthread.h"
sangoma_cthread::sangoma_cthread ()
{
}
sangoma_cthread::~sangoma_cthread ()
{
}
bool sangoma_cthread::CreateThread (int iParam)
{
#if defined (__WINDOWS__)
ThreadParam *pParam = new ThreadParam;
pParam->pThread = this;
pParam->iParam = iParam;
hThread = ::CreateThread (NULL, 0, (unsigned long (__stdcall *)(void *))runThread, (void *)(pParam), 0, &dwThreadId);
if(hThread){
return true;
}else{
return false;
}
#else
pthread_t dwThreadId;
pthread_attr_t attr;
int result = -1;
ThreadParam *pParam = new ThreadParam;
pParam->pThread = this;
pParam->iParam = iParam;
result = pthread_attr_init(&attr);
//pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
//pthread_attr_setschedpolicy(&attr, SCHED_RR);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
pthread_attr_setstacksize(&attr, CTHREAD_STACK_SIZE);
result = pthread_create(&dwThreadId, &attr, runThread, pParam);
pthread_attr_destroy(&attr);
if (result) {
return false;
}
return true;
#endif
}
#if defined(__WINDOWS__)
int sangoma_cthread::runThread (void* Param)
#else
void *sangoma_cthread::runThread (void* Param)
#endif
{
sangoma_cthread *thread;
int tmp;
ThreadParam *pParam = (ThreadParam*)Param;
ThreadParam tmpParam;
thread = (sangoma_cthread*)pParam->pThread;
tmp = pParam->iParam;
memcpy(&tmpParam, Param, sizeof(ThreadParam));
delete ((ThreadParam*)Param);
#if defined(__WINDOWS__)
return thread->threadFunction(tmpParam);
#else
thread->threadFunction(tmpParam);
pthread_exit(NULL);
#endif
}

View File

@ -0,0 +1,40 @@
//////////////////////////////////////////////////////////////////////
// sangoma_cthread.h: generic C++ Execution Thread.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#ifndef _SANGOMA_CTHREAD_H
#define _SANGOMA_CTHREAD_H
struct ThreadParam;
class sangoma_cthread {
public:
sangoma_cthread();
virtual ~sangoma_cthread();
bool CreateThread (int iParam);
protected:
virtual unsigned long threadFunction(struct ThreadParam& thParam) = 0;
#if defined (__WINDOWS__)
DWORD dwThreadId;
HANDLE hThread;
#endif
private:
#if defined(__WINDOWS__)
static int runThread (void *p);
#else
static void *runThread (void *p);
#endif
};
struct ThreadParam {
sangoma_cthread* pThread;
int iParam;
};
#endif//_SANGOMA_CTHREAD_H

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,412 @@
/*******************************************************************************//**
* \file sangoma_interface.h
* \brief Used with Sample.cpp Code
* \brief Provides a C++ class that deals with channel IO (read/write/events)
*
* Author(s): David Rokhvarg
* Nenad Corbic
*
*
* Copyright: (c) 2005-2009 Sangoma Technologies
*
* * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Sangoma Technologies nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* ===============================================================================
*/
#ifndef SANGOMA_INTERFACE_H
#define SANGOMA_INTERFACE_H
#include <stdio.h>
#include <stddef.h> //for offsetof()
#include <stdlib.h>
#if defined(__WINDOWS__)
# include <windows.h>
# include <winioctl.h>
# include <conio.h>
# include "bit_win.h"
# include "wanpipe_time.h" //for wp_usleep()
#elif defined(__LINUX__)
/* Include headers */
# include <stddef.h>
# include <errno.h>
# include <fcntl.h>
# include <string.h>
# include <ctype.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <sys/types.h>
# include <dirent.h>
# include <unistd.h>
# include <sys/socket.h>
# include <netdb.h>
# include <sys/un.h>
# include <sys/wait.h>
# include <unistd.h>
# include <signal.h>
# include <time.h>
#else
# error "sangoma_interface.h: undefined OS type"
#endif
/*
* FSK CallerID and DTMF detection note:
* Stelephony.dll expects input BitStream (aLaw or uLaw audio) from a SINGLE timeslot.
* It is always the case for Analog cards, but not for the Digital cards, where
* API may provide input from a SINGLE or from MULTIPLE timeslots.
*/
#define USE_STELEPHONY_API 1 /* set to zero if don't need to compile
function calls to libstelephony.dll */
#include "wanpipe_api.h"
#include "sangoma_cthread.h"
#include "sample.h"
#include "libsangoma.h"
#if USE_STELEPHONY_API
# include "libstelephony.h"
#endif
/* sangoma_waitfor_many() can wait on an array of sangoma wait objects.
* In this example there is a single object in the array. */
#define SANGOMA_INTERFACE_NUMBER_OF_WAIT_OBJECTS 1
#define SANGOMA_TX_WAIT_OBJECT 0
#define SANGOMA_RX_AND_EVENT_WAIT_OBJECT 0
/*!
\class sangoma_interface
\brief Sangoma Interface Class that deals with span/chan IO (read/write/events)
*/
class sangoma_interface : public sangoma_cthread
{
protected:
/*! Sangoma IO device descriptor */
sng_fd_t sangoma_dev;
/*! wait object for an IO device */
sangoma_wait_obj_t *sng_wait_obj[SANGOMA_INTERFACE_NUMBER_OF_WAIT_OBJECTS];
//////////////////////////////////////////////////////////////////
//receive stuff
/*!< rx count statistic */
ULONG rx_frames_count;
/*! rx byte statistic */
ULONG rx_bytes_count;
//for counting frames with CRC/Abort errors
/*! corrupted frame count statistic */
ULONG bad_rx_frames_count;
/*! Rx thread id used for launching threads that handle rx path */
DWORD dwRxThreadId;
//////////////////////////////////////////////////////////////////
//transmit stuff
/*! tx byte statistic */
ULONG tx_bytes_count;
/*! tx frame statistic */
ULONG tx_frames_count;
/*! tx test byte sent statistic */
UCHAR tx_test_byte;
//////////////////////////////////////////////////////////////////
//IOCTL management structures and variables
/*! deprecated: ioctl management structure, used to execute management commands - one should use libsangoma directly */
wan_udp_hdr_t wan_udp;
/*! deprecated: Helper function to get data byte out of wan_udp structure */
unsigned char get_wan_udphdr_data_byte(unsigned char off);
/*! deprecated: Helper function to get data pointer out of wan_udp structure */
unsigned char *get_wan_udphdr_data_ptr(unsigned char off);
/*! deprecated: Helper function to set data pointer out of wan_udp structure */
unsigned char set_wan_udphdr_data_byte(unsigned char off, unsigned char data);
/*! deprecated: protocol command structure size */
int protocol_cb_size;
/*! device low level protocol (T1/E1...) currently running */
int wan_protocol;
/*! device adapter type */
unsigned char adapter_type;
/*! deprecated: API command structure used to execute API commands */
wanpipe_api_cmd_t tdm_api_cmd;
/*! API command structure used to execute API commands. This command structure is used with libsangoma library */
wanpipe_api_t wp_api;
/*! Rx Thread function */
void RxThreadFunc();
/*! Tx Thread function */
void TxThreadFunc();
/*! Rx Data handler function */
int read_data();
/*! Rx Event handler function */
virtual int read_event();
int write_data(wp_api_hdr_t *hdr, void *tx_buffer);
/*! Shutdown function to cleanup the class */
void cleanup();
/*! Get device span configuration */
int get_wan_config();
/*! Get interface chan configuration */
int get_interface_configuration(if_cfg_t *wanif_conf_ptr);
/*! Get front end type (T1/E1...) */
int get_fe_type(unsigned char* adapter_type);
/*! deprecated: Execute API command IOCTL - one should use libsangoma directly */
int wanpipe_api_ioctl(wan_cmd_api_t *api_cmd);
/*! Bert test pattern */
unsigned char wp_brt[256];
/*! deprecated: Generate bit reversal table - not used with new sangoma cards */
void generate_bit_rev_table();
/*! Flag indicating that rbs is enabled */
char is_rbs_monitoring_enabled;
#if USE_STELEPHONY_API
/*! Stelephony provides Analog CallierID and DTMF encoding/decoding */
stelephony_callback_functions_t scf;
void *stelObj;
void *DtmfBuffer;
void *FskCidBuffer;
void TxStelEncoderBuffer(void *pStelEncoderBuffer);
CRITICAL_SECTION StelTxCriticalSection;
#endif
//////////////////////////////////////////////////////////////////
//data
char terminate_tx_rx_threads;
/*! API header for rx data */
wp_api_hdr_t rxhdr;
/*! Data buffer to copy rx data into */
unsigned char rx_data[SAMPLE_CPP_MAX_DATA_LEN];
/*! API header for tx data */
wp_api_hdr_t txhdr;
/*! Data buffer to copy tx data into */
unsigned char tx_data[SAMPLE_CPP_MAX_DATA_LEN];
/*! Wanpipe Interface configuration structure to be populated on read configuration */
if_cfg_t wanif_conf_struct;
/*! Wanpipe Device number based on hardware probe device enumeration (SPAN) */
int WanpipeNumber;
/*! Wanpipe Interface number based on a channel in a SPAN */
int InterfaceNumber;
#if DBG_TIMING
wan_debug_t wan_debug_rx_timing;
#endif
/*! Callback functions used to call the application on IO events */
callback_functions_t callback_functions;
virtual unsigned long threadFunction(struct ThreadParam& thParam);
public:
char device_name[DEV_NAME_LEN];
char is_logger_dev;
//////////////////////////////////////////////////////////////////
//methods
sangoma_interface(int wanpipe_number, int interface_number);
virtual ~sangoma_interface();
int DoManagementCommand(sng_fd_t drv, wan_udp_hdr_t* packet);
virtual int init(callback_functions_t *callback_functions_ptr);
int run();
int stop();
/*! Write data to device */
int transmit(wp_api_hdr_t *hdr, void *data);
/*! Read data from device */
int receive (wp_api_hdr_t *hdr, void *data);
void bit_swap_a_buffer(unsigned char *data, int len);
void get_te1_56k_stat(void);
void set_lb_modes(unsigned char type, unsigned char mode);
int loopback_command(u_int8_t type, u_int8_t mode, u_int32_t chan_map);
int get_operational_stats(wanpipe_chan_stats_t *stats);
virtual int flush_operational_stats (void);
int CreateSwDtmfTxThread(void *buffer);
int CreateFskCidTxThread(void *buffer);
int enable_rbs_monitoring();
char get_rbs(rbs_management_t *rbs_management_ptr);
char set_rbs(rbs_management_t *rbs_management_ptr);
int tdm_enable_rbs_events(int polls_per_second);
int tdm_disable_rbs_events();
int set_tx_idle_flag(unsigned char new_idle_flag);
int get_open_handles_counter();
//remove all data from API driver's transmit queue
int flush_tx_buffers (void);
unsigned char get_adapter_type();
unsigned int get_sub_media();
void set_fe_debug_mode(sdla_fe_debug_t *fe_debug);
void get_api_driver_version(PDRIVER_VERSION version);
void get_card_customer_id(u_int8_t *customer_id);
#if USE_STELEPHONY_API
int resetFSKCID(void);
int sendCallerID(char *name, char *number);
int sendSwDTMF(char dtmf_char);
#endif
//////////////////////////////////////////////////////////////////
//TDM API calls
int tdm_enable_rxhook_events();
int tdm_disable_rxhook_events();
/* DTMF Detection on A200 Analog card (SLIC) chip */
int tdm_enable_rm_dtmf_events();
int tdm_disable_rm_dtmf_events();
/* DTMF Detection on Octasic chip */
int tdm_enable_dtmf_events(uint8_t channel);
int tdm_disable_dtmf_events(uint8_t channel);
int tdm_enable_ring_detect_events();
int tdm_disable_ring_detect_events();
int tdm_enable_ring_trip_detect_events();
int tdm_disable_ring_trip_detect_events();
int tdm_enable_ring_events();
int tdm_disable_ring_events();
int tdm_txsig_onhook();
int tdm_txsig_offhook();
int tdm_txsig_kewl();
/*To transmit data while FXS is on-hook */
/* Example: To transmit FSK Message Wait Indication (MWI)
to phone connected with FXS */
int tdm_txsig_onhooktransfer();
int tdm_enable_tone_events(uint16_t tone_id);
int tdm_disable_tone_events();
int tdm_front_end_activate();
int tdm_front_end_deactivate();
int tdm_control_flash_events(int rxflashtime);
/* To set tx/rx gain for analog FXS/FXO modules
Gain in dB = gainvalue / 10
For FXS: txgain/rxgain value could be -35 or 35
FXO: txgain/rxgain value ranges from -150 to 120
FXO/FXS: Set txgain/rxgain value 0 for default setting*/
int tdm_control_rm_txgain(int txgain);
int tdm_control_rm_rxgain(int rxgain);
/* Only valid for FXS module to Set Polarity on the line
polarity 0: Forward Polarity
1: Reverse Polarity */
int tdm_set_rm_polarity(int polarity);
/* get current state of the line - is it Connected or Disconnected */
int tdm_get_front_end_status(unsigned char *status);
int tdm_set_user_period(unsigned int usr_period);
//////////////////////////////////////////////////////////////////
int tdmv_api_ioctl(wanpipe_api_cmd_t *api_cmd);
int reset_interface_state();
int start_ring_tone();
int stop_ring_tone();
int start_congestion_tone();
int stop_congestion_tone();
int start_busy_tone();
int stop_busy_tone();
int stop_all_tones();
int start_dial_tone();
int stop_dial_tone();
int start_ringing_phone();
int stop_ringing_phone();
int fxo_go_off_hook();
int fxo_go_on_hook();
int fxs_txsig_offhook();
//BRI only:
int tdm_enable_bri_bchan_loopback(u_int8_t channel);
int tdm_disable_bri_bchan_loopback(u_int8_t channel);
};
class sangoma_api_ctrl_dev : public sangoma_interface
{
public:
sangoma_api_ctrl_dev(void);
~sangoma_api_ctrl_dev(void);
virtual int init(callback_functions_t *callback_functions_ptr);
};
class sangoma_api_logger_dev : public sangoma_interface
{
wp_logger_cmd_t logger_cmd;
public:
sangoma_api_logger_dev(void);
~sangoma_api_logger_dev(void);
virtual int init(callback_functions_t *callback_functions_ptr);
/*! Logger Event handler function */
virtual int read_event();
virtual int flush_operational_stats (void);
int get_logger_dev_operational_stats(wp_logger_stats_t *stats);
};
#endif//SANGOMA_INTERFACE_H

View File

@ -0,0 +1,191 @@
//////////////////////////////////////////////////////////////////////
// sangoma_port.cpp: implementation of the sangoma_port class.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#include "sangoma_port.h"
#define DBG_CFG if(0)printf("PORT:");if(1)printf
#define _DBG_CFG if(0)printf
#define INFO_CFG if(0)printf("PORT:");if(1)printf
#define _INFO_CFG if(0)printf
#define ERR_CFG if(1)printf("PORT:");if(1)printf
#define _ERR_CFG if(1)printf
//////////////////////////////////////////////////////////////////////
//common functions
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
sangoma_port::sangoma_port()
{
DBG_CFG("%s()\n", __FUNCTION__);
wp_handle = INVALID_HANDLE_VALUE;
}
sangoma_port::~sangoma_port()
{
DBG_CFG("%s()\n", __FUNCTION__);
cleanup();
}
int sangoma_port::init(uint16_t wanpipe_number)
{
DBG_CFG("%s()\n", __FUNCTION__);
wp_number = wanpipe_number;
wp_handle = sangoma_open_driver_ctrl(wanpipe_number);
if(wp_handle == INVALID_HANDLE_VALUE){
ERR_CFG("Error: failed to open wanpipe%d!!\n", wp_number);
return 1;
}
return 0;
}
void sangoma_port::cleanup()
{
DBG_CFG("%s()\n", __FUNCTION__);
if(wp_handle != INVALID_HANDLE_VALUE){
sangoma_close(&wp_handle);
wp_handle = INVALID_HANDLE_VALUE;
}
}
int sangoma_port::get_hardware_info(hardware_info_t *hardware_info)
{
port_management_struct_t port_management;
int err=sangoma_driver_get_hw_info(wp_handle,&port_management, wp_number);
if (err) {
ERR_CFG("Error: failed to get hw info for wanpipe%d!\n", wp_number);
err=1;
return err;
}
memcpy(hardware_info,port_management.data,sizeof(hardware_info_t));
return 0;
}
int sangoma_port::start_port()
{
port_management_struct_t port_mgmnt;
int err;
err=sangoma_driver_port_start(wp_handle,&port_mgmnt,wp_number);
INFO_CFG("%s(): return code: (%d)\n", __FUNCTION__, err);
return err;
}
int sangoma_port::stop_port()
{
port_management_struct_t port_mgmnt;
int err;
err = sangoma_driver_port_stop(wp_handle,&port_mgmnt,wp_number);
INFO_CFG("%s(): return code: (%d)\n", __FUNCTION__, err);
return err;
}
int sangoma_port::push_a_card_into_wanpipe_info_array(
wanpipe_instance_info_t *wanpipe_info_array,
hardware_info_t *new_hw_info)
{
unsigned int card_ind;
hardware_info_t *tmp_hw_info;
//check this card is not in the array already
for(card_ind = 0; card_ind < MAX_CARDS; card_ind++){
tmp_hw_info = &wanpipe_info_array[card_ind].hardware_info;
if( (new_hw_info->pci_bus_number == tmp_hw_info->pci_bus_number) &&
(new_hw_info->pci_slot_number == tmp_hw_info->pci_slot_number)){
//already in array. not an error.
DBG_CFG("already in array.\n");
return 1;
}
}
//find an empty slot in the array and place the new card there
for(card_ind = 0; card_ind < MAX_CARDS; card_ind++){
tmp_hw_info = &wanpipe_info_array[card_ind].hardware_info;
if(tmp_hw_info->card_model == -1){
//found an empty slot in array
memcpy(tmp_hw_info, new_hw_info, sizeof(hardware_info_t));
return 0;
}
}
//too many cards in the computer.
INFO_CFG("Warning: number of cards in the computer is greater than the maximum of %d.\n",
MAX_CARDS);
return 2;
}
//
//Scan all running wanpipes, check which ones are on the same card,
//figure out how many physical cards installed.
//
//Returns: -1 - if error.
// number of cards, starting from zero.
int sangoma_port::scan_for_sangoma_cards(wanpipe_instance_info_t *wanpipe_info_array, int card_model)
{
uint16_t card_counter = 0, wp_ind;
hardware_info_t hardware_info;
//initialize hardware information array.
memset(wanpipe_info_array, -1, sizeof(wanpipe_instance_info_t)*MAX_CARDS);
DBG_CFG("%s(): wanpipe_info_array: 0x%p\n", __FUNCTION__, wanpipe_info_array);
for(wp_ind = 0; wp_ind < (MAX_CARDS * MAX_PORTS_PER_CARD); wp_ind++){
if(init(wp_ind)){
continue;
}
if(get_hardware_info(&hardware_info)){
card_counter = -1;
break;
}
DBG_CFG("card_model : %s (0x%08X)\n",
SDLA_ADPTR_NAME(hardware_info.card_model), hardware_info.card_model);
DBG_CFG("firmware_version\t: 0x%02X\n", hardware_info.firmware_version);
DBG_CFG("pci_bus_number\t\t: %d\n", hardware_info.pci_bus_number);
DBG_CFG("pci_slot_number\t\t: %d\n", hardware_info.pci_slot_number);
DBG_CFG("port_number\t\t: %d\n", hardware_info.port_number);
DBG_CFG("max_hw_ec_chans\t\t: %d\n", hardware_info.max_hw_ec_chans);
if(card_model == hardware_info.card_model){
if(push_a_card_into_wanpipe_info_array(wanpipe_info_array, &hardware_info) == 0){
//At this point we know: 1. WANPIPE number, for example WANPIPE1.
// 2. Card type, for example A104.
//It allows to figure out Device Name of each port on the card.
//For example: for A104 it will be WANPIPE1, WANPIPE2, WANPIPE3, WANPIPE4
wanpipe_info_array[card_counter].wanpipe_number = wp_ind;
DBG_CFG("%s(): wp_ind: %u\n", __FUNCTION__, wp_ind);
card_counter++;
}
}else{
DBG_CFG("Found a Card but Card Model is different from what was searched for.\n");
}
//For each init() there MUST be cleanup(). Otherwise Open Handles will remain to the Port.
cleanup();
}//for()
return card_counter;
}

View File

@ -0,0 +1,93 @@
//////////////////////////////////////////////////////////////////////
// sangoma_port.h: interface for the sangoma_port class.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_DRIVER_CONFIGURATOR_H__115A6EC1_518C_45E9_AA55_148A8D999B61__INCLUDED_)
#define AFX_DRIVER_CONFIGURATOR_H__115A6EC1_518C_45E9_AA55_148A8D999B61__INCLUDED_
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#if defined(__WINDOWS__)
# include <windows.h>
# include <winioctl.h>
# include <conio.h>
# include "bit_win.h"
#elif defined(__LINUX__)
# include <errno.h>
# include <fcntl.h>
# include <string.h>
# include <ctype.h>
# include <sys/stat.h>
# include <sys/ioctl.h>
# include <sys/types.h>
# include <dirent.h>
# include <unistd.h>
# include <sys/socket.h>
# include <netdb.h>
# include <sys/un.h>
# include <sys/wait.h>
# include <unistd.h>
# include <signal.h>
# include <time.h>
# include <curses.h>
#else
# error "sangoma_port.h: undefined OS type"
#endif
#include "libsangoma.h"
#include "wanpipe_api.h"
#define MAX_CARDS 32
#define MAX_PORTS_PER_CARD 48
#if defined (__LINUX__)
static inline void CloseHandle(HANDLE handle)
{
if (handle >= 0) {
close(handle);
}
return;
}
#endif
/*!
\brief
*
*/
class sangoma_port
{
public:
int get_hardware_info(hardware_info_t *hardware_info);
int stop_port();
int start_port();
int init(uint16_t wanpipe_number);
void cleanup();
sangoma_port();
virtual ~sangoma_port();
int scan_for_sangoma_cards(wanpipe_instance_info_t *wanpipe_info_array, int card_model);
protected:
uint16_t wp_number;
sng_fd_t wp_handle;
int push_a_card_into_wanpipe_info_array(wanpipe_instance_info_t *wanpipe_info_array,
hardware_info_t *new_hw_info);
};
#endif // !defined(AFX_DRIVER_CONFIGURATOR_H__115A6EC1_518C_45E9_AA55_148A8D999B61__INCLUDED_)

View File

@ -0,0 +1,793 @@
//////////////////////////////////////////////////////////////////////
// sangoma_port_configurator.cpp: implementation of the sangoma_port_configurator class.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#include "sangoma_port_configurator.h"
#define DBG_CFG if(1)printf("PORTCFG:");if(1)printf
#define _DBG_CFG if(1)printf
#define INFO_CFG if(1)printf("PORTCFG:");if(1)printf
#define _INFO_CFG if(1)printf
#define ERR_CFG if(1)printf("%s():line:%d Error: ", __FUNCTION__, __LINE__);if(1)printf
#define _ERR_CFG if(1)printf
//////////////////////////////////////////////////////////////////////
//these are recommendations only:
#define MIN_RECOMMENDED_BITSTREAM_MTU 256
#define MIN_RECOMMENDED_HDLC_MTU 2048
/*!
\brief Brief description
*
*/
static int get_number_of_channels(unsigned int chan_bit_map)
{
int chan_counter = 0, i;
for(i = 0; i < (int)(sizeof(unsigned int)*8); i++){
if(chan_bit_map & (1 << i)){
chan_counter++;
}
}
return chan_counter;
}
/*!
\brief Brief description
*
*/
static int get_recommended_bitstream_mtu(int num_of_channels)
{
int recommended_mtu = num_of_channels * 32;//<--- will work well in most cases
//
//Smaller mtu will cause more interrupts.
//Recommend at least MIN_RECOMMENDED_BITSTREAM_MTU, user will set to smaller, if timing is important.
//
while(recommended_mtu < MIN_RECOMMENDED_BITSTREAM_MTU){
recommended_mtu = recommended_mtu * 2;
}
return recommended_mtu;
}
/*!
\brief Brief description
*
*/
static int check_mtu(int mtu, int hdlc_streaming, unsigned int channel_bitmap)
{
DBG_CFG("%s(): channel_bitmap: 0x%X\n", __FUNCTION__, channel_bitmap);
if(mtu % 4){
ERR_CFG("Invalid MTU (%d). Must be divizible by 4.\n", mtu);
return 1;
}
//if BitStream, check MTU is also divisible by the number of channels (timeslots) in the group
if(hdlc_streaming == WANOPT_NO){
int num_of_channels = get_number_of_channels(channel_bitmap);
DBG_CFG("num_of_channels in bitmap: %d\n", num_of_channels);
if(mtu % num_of_channels){
ERR_CFG("Invalid MTU. For 'BitStream' Must be divisible by 4 AND by the number of\n\
\tchannels in the group (%d). Recommended MTU: %d.\n",
num_of_channels, get_recommended_bitstream_mtu(num_of_channels));
return 2;
}
}//if()
return 0;
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
/*!
\brief Brief description
*
*/
sangoma_port_configurator::sangoma_port_configurator()
{
#if defined(__WINDOWS__)
hPortRegistryKey = (struct HKEY__ *)INVALID_HANDLE_VALUE;
#endif
}
/*!
\brief Brief description
*
*/
sangoma_port_configurator::~sangoma_port_configurator()
{
#if defined(__WINDOWS__)
if(hPortRegistryKey != (struct HKEY__ *)INVALID_HANDLE_VALUE){
RegCloseKey(hPortRegistryKey);
}
#endif
}
/*!
\brief SET new configuration of the API driver.
*
*/
int sangoma_port_configurator::SetPortVolatileConfigurationCommand(port_cfg_t *port_cfg)
{
int err = sangoma_driver_port_set_config(wp_handle, port_cfg, wp_number);
if (err) {
err = 1;
}
return err;
}
/*!
\brief Brief description
*
*/
int sangoma_port_configurator::get_configration(port_cfg_t *port_cfg)
{
int err = sangoma_driver_port_get_config(wp_handle, port_cfg, wp_number);
if (err) {
err = 1;
}
return err;
}
/*!
\brief Function to check correctness of 'port_cfg_t' structure.
*
*/
int sangoma_port_configurator::check_port_cfg_structure(port_cfg_t *port_cfg)
{
unsigned int i, rc = 0;
unsigned long tmp_active_ch = 0;
unsigned long cumulutive_active_ch = 0;
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
wanif_conf_t *wanif_conf;
DBG_CFG("%s()\n", __FUNCTION__);
INFO_CFG("Running Driver Configration structure check...\n");
if(port_cfg->num_of_ifs < 1 || port_cfg->num_of_ifs > NUM_OF_E1_TIMESLOTS){
_INFO_CFG("Invalid number of Timeslot Groups - %d! Should be between %d and %d (including).\n",
port_cfg->num_of_ifs, 1, NUM_OF_E1_TIMESLOTS);
return 1;
}
for(i = 0; i < port_cfg->num_of_ifs; i++){
//check all logic channels were configured
wanif_conf = &port_cfg->if_cfg[i];
if(wanif_conf->active_ch == 0){
_INFO_CFG("Group %d - no T1/E1 channels specified! Expecting a bitmap of channels.\n", i + 1);
rc = 1; break;
}
//check the channels are valid for media type.
if(sdla_fe_cfg->media == WAN_MEDIA_T1){
unsigned int t1_invalid_channels = ~T1_ALL_CHANNELS_BITMAP;
if(wanif_conf->active_ch & (t1_invalid_channels)){
_INFO_CFG("Group %d - Invalid channels in Channel BitMap (0x%08X)!\n", i + 1,
wanif_conf->active_ch & (t1_invalid_channels));
rc = 2; break;
}
}
//check channels are NOT in use already by another Group
if(wanif_conf->active_ch & cumulutive_active_ch){
_INFO_CFG("Group %d - one or more \"T1/E1 channels\" already used by another group!\n", i + 1);
rc = 3; break;
}
//update cumulative channels for the next iteration
cumulutive_active_ch |= wanif_conf->active_ch;
tmp_active_ch = wanif_conf->active_ch;
if(sdla_fe_cfg->media == WAN_MEDIA_E1 && sdla_fe_cfg->frame != WAN_FR_UNFRAMED){
//do not count the bit for channel 0! (valid only for Unframed E1)
tmp_active_ch &= (~0x1);
}
if(check_mtu(wanif_conf->mtu, wanif_conf->hdlc_streaming, tmp_active_ch)){
rc = 4; break;
}
}//for()
INFO_CFG("Driver Configration structure check - %s.\n", (rc == 0 ? "OK":"FAILED"));
return rc;
}
/*!
\brief Brief description
*
*/
int sangoma_port_configurator::print_port_cfg_structure(port_cfg_t *port_cfg)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
wanif_conf_t *wanif_conf = &port_cfg->if_cfg[0];
unsigned int i;
DBG_CFG("%s()\n", __FUNCTION__);
_INFO_CFG("\n================================================\n");
INFO_CFG("Card Type\t: %s(%d)\n", SDLA_DECODE_CARDTYPE(wandev_conf->card_type),
wandev_conf->card_type);/* Sangoma Card type - S514, S518 or AFT.*/
INFO_CFG("Number of TimeSlot Groups: %d\n", port_cfg->num_of_ifs);
INFO_CFG("MTU\t\t: %d\n", wandev_conf->mtu);
print_sdla_fe_cfg_t_structure(sdla_fe_cfg);
for(i = 0; i < port_cfg->num_of_ifs; i++){
_INFO_CFG("\n************************************************\n");
_INFO_CFG("Configration of Group Number %d:\n", i);
print_wanif_conf_t_structure(&wanif_conf[i]);
}
return 0;
}
/*!
\brief Brief description
*
*/
int sangoma_port_configurator::print_sdla_fe_cfg_t_structure(sdla_fe_cfg_t *sdla_fe_cfg)
{
_INFO_CFG("\n################################################\n");
INFO_CFG("MEDIA\t\t: %s\n", MEDIA_DECODE(sdla_fe_cfg));
if(FE_MEDIA(sdla_fe_cfg) == WAN_MEDIA_T1 || FE_MEDIA(sdla_fe_cfg) == WAN_MEDIA_E1){
INFO_CFG("Line CODE\t: %s\n", LCODE_DECODE(sdla_fe_cfg));
INFO_CFG("Framing\t\t: %s\n", FRAME_DECODE(sdla_fe_cfg));
INFO_CFG("Clock Mode\t: %s\n", TECLK_DECODE(sdla_fe_cfg));
INFO_CFG("Clock Reference port: %d (0 - not used)\n", FE_REFCLK(sdla_fe_cfg));
INFO_CFG("Signalling Insertion Mode: %s\n", TE1SIG_DECODE(sdla_fe_cfg));
INFO_CFG("High Impedance Mode: %s\n",
(FE_HIMPEDANCE_MODE(sdla_fe_cfg) == WANOPT_YES ? "Yes":"No"));
INFO_CFG("FE_RX_SLEVEL: %d\n", FE_RX_SLEVEL(sdla_fe_cfg));
}//if()
INFO_CFG("TDMV LAW\t: %s\n", (FE_TDMV_LAW(sdla_fe_cfg) == WAN_TDMV_MULAW ?"MuLaw":"ALaw"));
INFO_CFG("TDMV SYNC\t: %d\n", FE_NETWORK_SYNC(sdla_fe_cfg));
switch(FE_MEDIA(sdla_fe_cfg))
{
case WAN_MEDIA_T1:
INFO_CFG("LBO\t\t: %s\n", LBO_DECODE(sdla_fe_cfg));
break;
case WAN_MEDIA_E1:
break;
default:
break;
}
return 0;
}
/*!
\brief Brief port description
*
*/
int sangoma_port_configurator::print_wanif_conf_t_structure(wanif_conf_t *wanif_conf)
{
INFO_CFG("Operation Mode\t: %s\n", wanif_conf->usedby);
INFO_CFG("Timeslot BitMap\t: 0x%08X\n", wanif_conf->active_ch);
INFO_CFG("Line Mode\t: %s\n",
(wanif_conf->hdlc_streaming == WANOPT_YES ? "HDLC":"BitStream"));
INFO_CFG("MTU\\MRU\t\t: %d\n", wanif_conf->mtu);
return 0;
}
/*!
\brief Brief port description
*
*/
int sangoma_port_configurator::set_default_configuration(port_cfg_t *port_cfg)
{
return set_volatile_configration(port_cfg);
}
/*!
\brief Brief port description
*
*/
int sangoma_port_configurator::set_volatile_configration(port_cfg_t *port_cfg)
{
int rc;
DBG_CFG("%s()\n", __FUNCTION__);
//////////////////////////////////////////////////////////////////////////////////////////////////
#if 0
if(check_port_cfg_structure(port_cfg)){
ERR_CFG("Error(s) found in 'port_cfg_t' structure!\n");
return 1;
}
#endif
rc = SetPortVolatileConfigurationCommand(port_cfg);
if(rc){
//configration failed
INFO_CFG("%s(): Line: %d: return code: %s (%d)\n", __FUNCTION__, __LINE__, SDLA_DECODE_SANG_STATUS(rc), rc);
return 2;
}
INFO_CFG("%s(): return code: %s (%d)\n", __FUNCTION__,
SDLA_DECODE_SANG_STATUS(port_cfg->operation_status), port_cfg->operation_status);
switch(port_cfg->operation_status)
{
case SANG_STATUS_DEVICE_BUSY:
INFO_CFG("Error: open handles exist for 'wanpipe%d_if\?\?' interfaces!\n", wp_number);
return port_cfg->operation_status;
case SANG_STATUS_SUCCESS:
//OK
break;
default:
//error
return 5;
}
return 0;
}
/* optional optimization - single interrupt for both Rx and Tx audio streams */
#define SPAN_TX_ONLY_IRQ 0
/*!
\brief Example initialization for T1
*
*/
int sangoma_port_configurator::initialize_t1_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
//sdla_te_cfg_t *te_cfg = &sdla_fe_cfg->cfg.te_cfg;
wan_tdmv_conf_t *tdmv_cfg = &wandev_conf->tdmv_conf;
wanif_conf_t *wanif_cfg = &port_cfg->if_cfg[0];
wan_xilinx_conf_t *aft_cfg = &wandev_conf->u.aft;
// T1 parameters
FE_MEDIA(sdla_fe_cfg) = WAN_MEDIA_T1;
FE_LCODE(sdla_fe_cfg) = WAN_LCODE_B8ZS;
FE_FRAME(sdla_fe_cfg) = WAN_FR_ESF;
FE_LINENO(sdla_fe_cfg) = hardware_info->port_number;
FE_TDMV_LAW(sdla_fe_cfg) = WAN_TDMV_MULAW;
FE_NETWORK_SYNC(sdla_fe_cfg) = 0;
FE_LBO(sdla_fe_cfg) = WAN_T1_0_110;
FE_REFCLK(sdla_fe_cfg) = 0;
FE_HIMPEDANCE_MODE(sdla_fe_cfg) = 0;
FE_SIG_MODE(sdla_fe_cfg) = WAN_TE1_SIG_CCS;
FE_RX_SLEVEL(sdla_fe_cfg) = WAN_TE1_RX_SLEVEL_12_DB;
#if 1
FE_CLK(sdla_fe_cfg) = WAN_NORMAL_CLK;
#else
/* Use Master clock with a loopback cable or as Telco simulator. */
FE_CLK(sdla_fe_cfg) = WAN_MASTER_CLK;
#endif
// API parameters
port_cfg->num_of_ifs = 1;
wandev_conf->config_id = WANCONFIG_AFT_TE1;
wandev_conf->magic = ROUTER_MAGIC;
wandev_conf->mtu = 2048;
wandev_conf->PCI_slot_no = hardware_info->pci_slot_number;
wandev_conf->pci_bus_no = hardware_info->pci_bus_number;
wandev_conf->card_type = WANOPT_AFT; //m_DeviceInfoData.card_model;
#if SPAN_TX_ONLY_IRQ
aft_cfg->span_tx_only_irq = 1;
#else
aft_cfg->span_tx_only_irq = 0;
#endif
wanif_cfg->magic = ROUTER_MAGIC;
wanif_cfg->active_ch = 0x00FFFFFF;//channels 1-24 (starting from bit zero)
sprintf(wanif_cfg->usedby,"TDM_SPAN_VOICE_API");
wanif_cfg->u.aft.idle_flag=0xFF;
wanif_cfg->mtu = 160;
wanif_cfg->u.aft.mtu = 160;
wanif_cfg->u.aft.mru = 160;
sprintf(wanif_cfg->name,"w%dg1",span);
if (hardware_info->max_hw_ec_chans) {
/* wan_hwec_conf_t - HWEC configuration for Port */
/*wandev_conf->hwec_conf.dtmf = 1;*/
/* wan_hwec_if_conf_t - HWEC configuration for Interface */
wanif_cfg->hwec.enable = 1;
}
tdmv_cfg->span_no = (unsigned char)span;
/* DCHAN Configuration */
switch(FE_MEDIA(sdla_fe_cfg))
{
case WAN_MEDIA_T1:
tdmv_cfg->dchan = (1<<23);/* Channel 24. This is a bitmap, not a channel number. */
break;
default:
printf("%s(): Error: invalid media type!\n", __FUNCTION__);
return 1;
}
printf("T1: tdmv_cfg->dchan bitmap: 0x%X\n", tdmv_cfg->dchan);
return 0;
}
#define BUILD_FOR_PRI 1
int sangoma_port_configurator::initialize_e1_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
wan_tdmv_conf_t *tdmv_cfg = &wandev_conf->tdmv_conf;
wanif_conf_t *wanif_cfg = &port_cfg->if_cfg[0];
wan_xilinx_conf_t *aft_cfg = &wandev_conf->u.aft;
// E1 parameters
FE_MEDIA(sdla_fe_cfg) = WAN_MEDIA_E1;
FE_LCODE(sdla_fe_cfg) = WAN_LCODE_HDB3;
FE_FRAME(sdla_fe_cfg) = WAN_FR_CRC4;
FE_LINENO(sdla_fe_cfg) = hardware_info->port_number;
FE_TDMV_LAW(sdla_fe_cfg) = WAN_TDMV_ALAW;
FE_NETWORK_SYNC(sdla_fe_cfg) = 0;
FE_LBO(sdla_fe_cfg) = WAN_E1_120;
FE_REFCLK(sdla_fe_cfg) = 0;
FE_HIMPEDANCE_MODE(sdla_fe_cfg) = 0;
FE_SIG_MODE(sdla_fe_cfg) = WAN_TE1_SIG_CCS;
FE_RX_SLEVEL(sdla_fe_cfg) = WAN_TE1_RX_SLEVEL_12_DB;
#if 1
FE_CLK(sdla_fe_cfg) = WAN_NORMAL_CLK;
#else
/* Use Master clock with a loopback cable or as Telco simulator. */
FE_CLK(sdla_fe_cfg) = WAN_MASTER_CLK;
#endif
// API parameters
port_cfg->num_of_ifs = 1;
wandev_conf->config_id = WANCONFIG_AFT_TE1;
wandev_conf->magic = ROUTER_MAGIC;
wandev_conf->mtu = 2048;
wandev_conf->PCI_slot_no = hardware_info->pci_slot_number;
wandev_conf->pci_bus_no = hardware_info->pci_bus_number;
wandev_conf->card_type = WANOPT_AFT; //m_DeviceInfoData.card_model;
#if SPAN_TX_ONLY_IRQ
aft_cfg->span_tx_only_irq = 1;
#else
aft_cfg->span_tx_only_irq = 0;
#endif
wanif_cfg->magic = ROUTER_MAGIC;
#if BUILD_FOR_PRI
//PRI Signaling on chan 16
wanif_cfg->active_ch = 0x7FFFFFFF;// channels 1-31 (starting from bit zero)
#else
//CAS
wanif_cfg->active_ch = 0xFFFF7FFF;// channels 1-15.17-31 -> Active Ch Map :0xFFFEFFFE (in message log)
#endif
sprintf(wanif_cfg->usedby,"TDM_SPAN_VOICE_API");
wanif_cfg->u.aft.idle_flag=0xFF;
wanif_cfg->mtu = 160;
wanif_cfg->u.aft.mtu = 160;
wanif_cfg->u.aft.mru = 160;
sprintf(wanif_cfg->name,"w%dg1",span);
if (hardware_info->max_hw_ec_chans) {
/* wan_hwec_conf_t - HWEC configuration for Port */
/*wandev_conf->hwec_conf.dtmf = 1;*/
/* wan_hwec_if_conf_t - HWEC configuration for Interface */
wanif_cfg->hwec.enable = 1;
}
tdmv_cfg->span_no = (unsigned char)span;
#if BUILD_FOR_PRI
/* DCHAN Configuration */
switch(FE_MEDIA(sdla_fe_cfg))
{
case WAN_MEDIA_E1:
tdmv_cfg->dchan = (1<<15);/* Channel 16. This is a bitmap, not a channel number. */
break;
default:
printf("%s(): Error: invalid media type!\n", __FUNCTION__);
return 1;
}
#endif
printf("E1: tdmv_cfg->dchan bitmap: 0x%X\n", tdmv_cfg->dchan);
return 0;
}
int sangoma_port_configurator::initialize_bri_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
wan_tdmv_conf_t *tdmv_cfg = &wandev_conf->tdmv_conf;
wanif_conf_t *wanif_cfg = &port_cfg->if_cfg[0];
// BRI parameters
FE_MEDIA(sdla_fe_cfg) = WAN_MEDIA_BRI;
FE_LINENO(sdla_fe_cfg) = hardware_info->port_number;
FE_TDMV_LAW(sdla_fe_cfg) = WAN_TDMV_ALAW;
FE_NETWORK_SYNC(sdla_fe_cfg) = 0;
FE_REFCLK(sdla_fe_cfg) = 0;
#if 0
/*
* TE Module: WAN_NORMAL_CLK is the default.
* Clock recovered from the line will be used by this module and
* will be routed to ALL other BRI modules on the card which
* become "connected" after this module. That means at any
* time there is a single BRI line where the clock is recovered from
* and this clock is used for all other BRI lines.
*
* NT Module: always runs on internal oscillator clock.
*/
BRI_FE_CLK((*sdla_fe_cfg)) = WAN_NORMAL_CLK;
#else
/*
* TE Module: if WAN_MASTER_CLK, clock recovered from
* the line will be NOT be used by this module and
* will NOT be routed to ALL other BRI modules on the card.
* Instead, the module will use clock from internal oscillator.
*
* NT Module: WAN_MASTER_CLK will be ignored because NT should not
* recover clock from the line, it always runs on clock from
* internal oscillator.
*/
BRI_FE_CLK((*sdla_fe_cfg)) = WAN_MASTER_CLK;
#endif
/* Notes on BRI FE clock option:
The clock option is checked by the driver only
when TE becomes "Connected"/"Disconnected".
No check is done on Port start-up, it is always Master during start-up.
If TE becomes "Connected" and it's clock mode is Master,
in the wanpipelog the following message will appear from TE:
BRI Module: 3 connected!
If TE becomes "Connected" and it's clock mode is Normal,
in the wanpipelog the following messages will appear from TE:
BRI Module: 3 connected!
Setting Master Clock!
TE Clock line recovery Module=3 Port=1: Enabled
Module=3 Port=1: using 512khz from PLL
*/
port_cfg->num_of_ifs = 1;
wandev_conf->config_id = WANCONFIG_AFT_ISDN_BRI;
wandev_conf->magic = ROUTER_MAGIC;
wandev_conf->mtu = 2048;
wandev_conf->PCI_slot_no = hardware_info->pci_slot_number;
wandev_conf->pci_bus_no = hardware_info->pci_bus_number;
wandev_conf->card_type = WANOPT_AFT; //m_DeviceInfoData.card_model;
wanif_cfg->magic = ROUTER_MAGIC;
wanif_cfg->active_ch = 0xFFFFFFFF;
sprintf(wanif_cfg->usedby,"TDM_SPAN_VOICE_API");
wanif_cfg->u.aft.idle_flag=0xFF;
wanif_cfg->mtu = 160;
wanif_cfg->u.aft.mtu = 160;
wanif_cfg->u.aft.mru = 160;
sprintf(wanif_cfg->name,"w%dg1",span);
if (hardware_info->max_hw_ec_chans) {
/* wan_hwec_conf_t - HWEC configuration for Port */
/*wandev_conf->hwec_conf.dtmf = 1;*/
/* wan_hwec_if_conf_t - HWEC configuration for Interface */
wanif_cfg->hwec.enable = 1;
}
tdmv_cfg->span_no = (unsigned char)span;
/* There is no DCHAN Configuration on BRI because it is
* configured automatically by the driver. */
return 0;
}
int sangoma_port_configurator::initialize_serial_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
wan_tdmv_conf_t *tdmv_cfg = &wandev_conf->tdmv_conf;
wanif_conf_t *wanif_cfg = &port_cfg->if_cfg[0];
// Serial parameters
FE_MEDIA(sdla_fe_cfg) = WAN_MEDIA_SERIAL;
FE_LINENO(sdla_fe_cfg) = hardware_info->port_number;
wandev_conf->line_coding = WANOPT_NRZ;
/* WANOPT_V35/WANOPT_X21 are valid for card models:
* AFT_ADPTR_2SERIAL_V35X21 and AFT_ADPTR_4SERIAL_V35X21.
* WANOPT_RS232 valid for card models:
* AFT_ADPTR_2SERIAL_RS232 and AFT_ADPTR_4SERIAL_RS232.
*/
wandev_conf->electrical_interface = WANOPT_V35;
#if 1
wandev_conf->clocking = WANOPT_EXTERNAL;
wandev_conf->bps = 0;
#else
wandev_conf->clocking = WANOPT_INTERNAL;
wandev_conf->bps = 56000;
#endif
wandev_conf->connection = WANOPT_PERMANENT;//or WANOPT_SWITCHED
wandev_conf->line_idle = WANOPT_IDLE_FLAG;
// API parameters
port_cfg->num_of_ifs = 1;
wandev_conf->config_id = WANCONFIG_AFT_SERIAL;
wandev_conf->magic = ROUTER_MAGIC;
wandev_conf->mtu = 2048;
wandev_conf->PCI_slot_no = hardware_info->pci_slot_number;
wandev_conf->pci_bus_no = hardware_info->pci_bus_number;
wandev_conf->card_type = WANOPT_AFT; //m_DeviceInfoData.card_model;
wanif_cfg->magic = ROUTER_MAGIC;
wanif_cfg->active_ch = 0xFFFFFFFF;
sprintf(wanif_cfg->usedby,"API");
wanif_cfg->u.aft.idle_flag=0xFF;
wanif_cfg->mtu = 1600;
wanif_cfg->u.aft.mtu = 1600;
wanif_cfg->u.aft.mru = 1600;
sprintf(wanif_cfg->name,"w%dg1",span);
wanif_cfg->hdlc_streaming = WANOPT_YES;
return 0;
}
int sangoma_port_configurator::write_configration_on_persistent_storage(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span)
{
//all the work is done by libsangoma
return sangoma_write_port_config_on_persistent_storage(hardware_info, port_cfg, (unsigned short)span);
}
int sangoma_port_configurator::control_analog_rm_lcm(port_cfg_t *port_cfg, int control_val)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if (wandev_conf->card_type == WANOPT_AFT_ANALOG) { //Only valid for Analog cards
if (control_val == 1) {
INFO_CFG("%s(): enabling FXO Loop Current Monitoring.\n", __FUNCTION__);
sdla_fe_cfg->cfg.remora.rm_lcm = 1;
} else if(control_val == 0) {
INFO_CFG("%s(): disabling FXO Loop Current Monitoring.\n", __FUNCTION__);
sdla_fe_cfg->cfg.remora.rm_lcm = 0;
} else {
ERR_CFG("invalid parameter!\n");
return -EINVAL;
}
} else {
ERR_CFG("invalid card type: %d!\n", wandev_conf->card_type);
return -EINVAL;
}
return 0;
}
/**************************************************************/
/*********** Analog Global Gain Setting Functions**************/
/**************************************************************/
//Note: following gain settings are global. It requires drivers to
//restart the card.
//It is recommended to use dynamic analog txgain/rxgain functions
//from libsangoma library:sangoma_set_rm_tx_gain and sangoma_set_rm_rx_gain
int sangoma_port_configurator::set_analog_rm_fxo_txgain(port_cfg_t *port_cfg, int txgain)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if(wandev_conf->card_type == WANOPT_AFT_ANALOG){//Only valid for Analog cards
sdla_fe_cfg->cfg.remora.fxo_txgain = txgain;
} else{
return -EINVAL;
}
return 0;
}
int sangoma_port_configurator::set_analog_rm_fxo_rxgain(port_cfg_t *port_cfg, int rxgain)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if(wandev_conf->card_type == WANOPT_AFT_ANALOG){//Only valid for Analog cards
sdla_fe_cfg->cfg.remora.fxo_rxgain = rxgain;
} else{
return -EINVAL;
}
return 0;
}
int sangoma_port_configurator::set_analog_rm_fxs_txgain(port_cfg_t *port_cfg, int txgain)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if(wandev_conf->card_type == WANOPT_AFT_ANALOG){//Only valid for Analog cards
sdla_fe_cfg->cfg.remora.fxs_txgain = txgain;
} else{
return -EINVAL;
}
return 0;
}
int sangoma_port_configurator::set_analog_rm_fxs_rxgain(port_cfg_t *port_cfg, int rxgain)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if(wandev_conf->card_type == WANOPT_AFT_ANALOG){//Only valid for Analog cards
sdla_fe_cfg->cfg.remora.fxs_rxgain = rxgain;
} else{
return -EINVAL;
}
return 0;
}
/**************************************************************/
/*********** End of Analog Global Gain Setting Functions ******/
/**************************************************************/
int sangoma_port_configurator::set_analog_opermode(port_cfg_t *port_cfg, char *opermode)
{
wandev_conf_t *wandev_conf = &port_cfg->wandev_conf;
sdla_fe_cfg_t *sdla_fe_cfg = &wandev_conf->fe_cfg;
if(wandev_conf->card_type == WANOPT_AFT_ANALOG){ //Only valid for Analog cards
if(sizeof(sdla_fe_cfg->cfg.remora.opermode_name) < strlen(opermode))
return -EINVAL;
strcpy(sdla_fe_cfg->cfg.remora.opermode_name,opermode);
} else{
return -EINVAL;
}
return 0;
}
void sangoma_port_configurator::initialize_interface_mtu_mru(port_cfg_t *port_cfg, unsigned int mtu, unsigned int mru)
{
wanif_conf_t *wanif_cfg = &port_cfg->if_cfg[0];
INFO_CFG("%s(): new MTU: %d, new MRU: %d.\n", __FUNCTION__, mtu, mru);
wanif_cfg->mtu = mtu;
wanif_cfg->u.aft.mtu = mtu;
wanif_cfg->u.aft.mru = mru;
}

View File

@ -0,0 +1,115 @@
//////////////////////////////////////////////////////////////////////
// sangoma_port_configurator.h: interface for the sangoma_port_configurator class.
//
// Author : David Rokhvarg
//////////////////////////////////////////////////////////////////////
#if !defined(_SANGOMA_PORT_CONFIGURATOR_H)
#define _SANGOMA_PORT_CONFIGURATOR_H
#include "sangoma_port.h"
#define MAX_COMP_INSTID 2096
#define MAX_COMP_DESC 2096
#define MAX_FRIENDLY 2096
#define TMP_BUFFER_LEN 200
#define T1_ALL_CHANNELS_BITMAP 0xFFFFFF /* channels 1-24 */
/*!
\brief
*
*/
class sangoma_port_configurator : public sangoma_port
{
TCHAR name[MAX_FRIENDLY];
char szCompInstanceId[MAX_COMP_INSTID];
TCHAR szCompDescription[MAX_COMP_DESC];
TCHAR szFriendlyName[MAX_FRIENDLY];
DWORD dwRegType;
#ifdef __WINDOWS__
HKEY hPortRegistryKey;
#endif
port_cfg_t port_cfg;
//SET new configuration of the API driver
int SetPortVolatileConfigurationCommand(port_cfg_t *port_cfg);
public:
sangoma_port_configurator();
virtual ~sangoma_port_configurator();
int get_configration(port_cfg_t *port_cfg);
int set_default_configuration(port_cfg_t *port_cfg);
//Function to set Loop Current Measure (LCM) for analog FXO
//control_val 1: enable,0: disable
int control_analog_rm_lcm(port_cfg_t *port_cfg, int control_val);
//Function to set Operation mode for analog FXO
//opermode valid country name supported by Analog FXO
int set_analog_opermode(port_cfg_t *port_cfg, char *opermode);
/**************************************************************/
/*********** Analog Global Gain Setting Functions**************/
/**************************************************************/
//Note: following gain settings are global. It requires drivers to
//restart the card.
//It is recommended to use dynamic analog txgain/rxgain functions
//from libsangoma library:sangoma_set_rm_tx_gain and sangoma_set_rm_rx_gain
//Function to set FXO txgain
//FXO - txgain value ranges from -150 to 120
int set_analog_rm_fxo_txgain(port_cfg_t *port_cfg, int txgain);
//Function to set FXO rxgain
//FXO - rxgain value ranges from -150 to 120
int set_analog_rm_fxo_rxgain(port_cfg_t *port_cfg, int rxgain);
//Function to set FXS txgain
//FXO - txgain value can be -35 or 35
int set_analog_rm_fxs_txgain(port_cfg_t *port_cfg, int txgain);
//Function to set FXS rxgain
//FXO - rxgain value can be -35 or 35
int set_analog_rm_fxs_rxgain(port_cfg_t *port_cfg, int rxgain);
/**************************************************************/
/*********** End of Analog Global Gain Setting Functions ******/
/**************************************************************/
//Function to check correctness of 'port_cfg_t' structure.
int check_port_cfg_structure(port_cfg_t *port_cfg);
//Function to print contents of 'port_cfg_t' structure.
int print_port_cfg_structure(port_cfg_t *port_cfg);
//Function to print contents of 'sdla_fe_cfg_t' structure.
int print_sdla_fe_cfg_t_structure(sdla_fe_cfg_t *sdla_fe_cfg);
//Function to print contents of 'wanif_conf_t' structure.
int print_wanif_conf_t_structure(wanif_conf_t *wanif_conf);
int set_volatile_configration(port_cfg_t *port_cfg);
int initialize_t1_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span);
int initialize_e1_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span);
int initialize_bri_tdm_span_voice_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span);
int initialize_serial_api_configration_structure(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span);
int write_configration_on_persistent_storage(port_cfg_t *port_cfg, hardware_info_t *hardware_info, int span);
void initialize_interface_mtu_mru(port_cfg_t *port_cfg, unsigned int mtu, unsigned int mru);
};
#endif // !defined(_SANGOMA_PORT_CONFIGURATOR_H)

View File

@ -0,0 +1,56 @@
TARGETNAME=sample_cpp
TARGETTYPE=PROGRAM
UMTYPE=console
UMENTRY=main
UMBASE=0x400000
TARGETPATH=obj
USE_LIBCMT=1
USE_STL=1
#MSC_WARNING_LEVEL=$(SANG_WARNING_LEVEL)
MSC_WARNING_LEVEL=-W3
############################################################################################
C_DEFINES=$(C_DEFINES) /D__WINDOWS__ /DUSE_SANGOMA_ERRNO
############################################################################################
INCLUDES=$(DDK_INC_PATH);\
$(SANG_WP_DEVEL)\wanpipe_common\include;\
$(SANG_WP_DEVEL)\wanpipe_common\include\aft_core;\
$(SANG_WP_DEVEL)\wanpipe_windows\include;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\wanec_apilib;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma\wanec;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libstelephony;\
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libstelephony\stel_tone;\
$(SANG_WP_DEVEL)\wanpipe_common\wanec;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\oct6100api;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\octdeviceapi\oct6100api;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\apilib\llman;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\apilib;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\include\octrpc;\
$(SANG_WP_DEVEL)\$(OCTASIC_INCLUDE)\apilib\bt
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\gdi32.lib \
$(SDK_LIB_PATH)\winspool.lib \
$(SDK_LIB_PATH)\comdlg32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\shell32.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\uuid.lib \
$(SDK_LIB_PATH)\comctl32.lib \
$(SDK_LIB_PATH)\Setupapi.lib \
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libsangoma\$(O)\libsangoma.lib \
$(SANG_WP_DEVEL)\wanpipe_common\wantools\libstelephony\$(O)\stelephony.lib
SOURCES=sample.cpp \
sangoma_cthread.cpp \
sangoma_interface.cpp \
sangoma_port.cpp \
sangoma_port_configurator.cpp

View File

@ -1 +1 @@
libsangoma/sample_c
./libsangoma/sample_c

View File

@ -1 +1 @@
libsangoma/sample_cpp/
./libsangoma/sample_cpp

33
api/tdm_api/README Normal file
View File

@ -0,0 +1,33 @@
TDM API Sample Code
====================
1. aft_tdm_voice_api
- read/write data per span/chan
Usage:
./aft_tdm_voice_api -c <span number> -i <chan number> -r <enter>
./aft_tdm_voice_api -c <span number> -i <chan number> -r -verbose <enter>
1. aft_tdm_voice_api_rbs
- read/write data per span/chan
- read/write rbs data per span/chan
- setup a rbs event so driver calls the app on each rbs change.
Usage:
./aft_tdm_voice_api_rbs -c <span number> -i <chan number> -r <enter>
./aft_tdm_voice_api_rbs -c <span number> -i <chan number> -r -verbose <enter>
3. aft_tdm_hdlc_test
- Used to test each span/chan for data corruption, using an HDLC engine.
- This test will run over voice and DCHAN HW HDLC devices.
Usage:
./tdm_hdlc_test.sh <span> #Run HDLC engines on all chans in a span
./tdm_hdlc_test.sh <span> <chan> #Run HDLC engine on single span chan

View File

@ -0,0 +1,143 @@
/*****************************************************************************
* 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/wanpipe_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <libsangoma.h>
#include "lib_api.h"
/* Prototypes */
void handle_span_chan(int);
void sig_end(int sigid);
int dev_fd;
FILE *tx_fd=NULL,*rx_fd=NULL;
wanpipe_tdm_api_t tdm_api;
/***************************************************
* HANDLE SOCKET
*/
void handle_span_chan(int dev_fd)
{
fd_set oob;
int err;
/* Main Rx Tx OOB routine */
for(;;) {
/* Initialize all select() descriptors */
FD_ZERO(&oob);
FD_SET(dev_fd,&oob);
/* Select will block, until:
* 1: OOB event, link level change
* 2: Rx data available
* 3: Interface able to Tx */
err=select(dev_fd + 1,NULL, NULL, &oob, NULL);
if (err > 0){
fflush(stdout);
if (FD_ISSET(dev_fd,&oob)){
wp_tdm_api_event_t *rx_event;
/* An OOB event is pending, usually indicating
* a link level change */
err=sangoma_tdm_read_event(dev_fd,&tdm_api);
if(err < 0 ) {
printf("Failed to receive OOB %i\n", err);
break;
}
rx_event = &tdm_api.wp_tdm_cmd.event;
switch (rx_event->wp_tdm_api_event_type){
#if 0
case WP_TDMAPI_EVENT_ALARM:
printf("GOT ALARM EVENT 0x%0X Span=%i Chan=%i\n",
rx_event->wp_tdm_api_event_alarm,rx_event->span,rx_event->channel);
break;
#endif
case WP_TDMAPI_EVENT_LINK_STATUS:
printf("GOT LINK STATUS Span=%i Chan=%i State=%s\n",
rx_event->span,rx_event->channel,
rx_event->wp_tdm_api_event_link_status == WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED ? "Connected" : "Disconnected");
break;
default:
//printf("GOT UNKNOWN OOB %i \n",rx_event->wp_tdm_api_event_type);
break;
}
}
}
if (err < 0) {
printf("Device Down!\n");
fflush(stdout);
break;
}
}
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_span_chan(int dev_fd) to read the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int dev_fd;
memset(&tdm_api,0,sizeof(tdm_api));
dev_fd =-1;
dev_fd = sangoma_open_tdmapi_ctrl();
if( dev_fd < 0){
printf("Failed to open span chan\n");
exit (1);
}
handle_span_chan(dev_fd);
close(dev_fd);
return 0;
};

View File

@ -1,657 +0,0 @@
/*****************************************************************************
* bstrm_hdlc_test_multi.c: Multiple Bstrm Test Receive Module
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2006 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 <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#ifdef STANDALONE_ZAPATA
#include "kernel/zaptel.h"
#else
#include <zaptel/zaptel.h>
#endif
#include <wanpipe_hdlc.h>
#define FALSE 0
#define TRUE 1
/* Enable/Disable tx of random frames */
#define RAND_FRAME 0
#define MAX_NUM_OF_TIMESLOTS 32*32
#define LGTH_CRC_BYTES 2
#define MAX_TX_DATA 15000 //MAX_NUM_OF_TIMESLOTS*10 /* Size of tx data */
#define MAX_TX_FRAMES 1000000 /* Number of frames to transmit */
#define BLOCK_SIZE 160
#define WRITE 1
#define MAX_IF_NAME 20
typedef struct {
int sock;
int rx_cnt;
int tx_cnt;
int data;
int last_error;
int frames;
int bs;
ZT_PARAMS tp;
char if_name[MAX_IF_NAME+1];
wanpipe_hdlc_engine_t *hdlc_eng;
} timeslot_t;
timeslot_t tslot_array[MAX_NUM_OF_TIMESLOTS];
int tx_change_data=0, tx_change_data_cnt=0;
int end=0;
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
void sig_end(int sigid)
{
printf("%d: Got Signal %i\n",getpid(),sigid);
end=1;
}
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(int max_rand) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % max_rand);
}
void mysrand(unsigned seed) {
next = seed;
}
/*===================================================
* MakeConnection
*
* o Create a Socket
* o Bind a socket to a wanpipe network interface
* (Interface name is supplied by the user)
*==================================================*/
int MakeConnection(timeslot_t *slot, char *router_name )
{
int i;
slot->sock = open(slot->if_name, O_RDWR, 0600);
if( slot->sock < 0 ) {
perror("Open Span Chan: ");
return( FALSE );
}
slot->bs=BLOCK_SIZE;
if (ioctl(slot->sock, ZT_SET_BLOCKSIZE, &slot->bs)) {
fprintf(stderr, "Unable to set block size to %d: %s\n", slot->bs, strerror(errno));
return( FALSE );
}
if (ioctl(slot->sock, ZT_GET_PARAMS, &slot->tp)) {
fprintf(stderr, "Unable to get channel parameters\n");
return( FALSE );
}
ioctl(slot->sock, ZT_GETEVENT);
i = ZT_FLUSH_ALL;
if (ioctl(slot->sock,ZT_FLUSH,&i) == -1){
perror("tor_flush");
return( FALSE );
}
printf("Socket bound to dev=%s\n\n",slot->if_name);
return (TRUE);
}
int api_tdm_fe_alarms_callback(int fd, unsigned char alarm)
{
int fd_found=0;
int i;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock == fd) {
fd_found=1;
break;
}
}
if (fd_found) {
printf ("FE ALARMS Call back found device %i Alarm=%i \n",
fd,alarm);
} else {
printf ("FE ALARMS Call back no device Alarm=%i\n",alarm);
}
return 0;
}
#define ALL_OK 0
#define BOARD_UNDERRUN 1
#define TX_ISR_UNDERRUN 2
#define UNKNOWN_ERROR 4
void process_con_rx(void)
{
unsigned int Rx_count;
fd_set ready;
int err,serr,i,slots=0;
unsigned char Rx_data[BLOCK_SIZE];
int error_bit=0, error_crc=0, error_abort=0, error_frm=0;
struct timeval tv;
int frame=0;
int max_fd=0, packets=0;
timeslot_t *slot=NULL;
i=0;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
tslot_array[i].hdlc_eng = wanpipe_reg_hdlc_engine();
if (!tslot_array[i].hdlc_eng){
printf("ERROR: Failed to register HDLC Engine\n");
return;
}
if (tslot_array[i].sock > max_fd){
max_fd=tslot_array[i].sock;
}
}
i=0;
tv.tv_usec = 0;
tv.tv_sec = 10;
Rx_count = 0;
for(;;) {
FD_ZERO(&ready);
max_fd=0;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
FD_SET(tslot_array[i].sock,&ready);
if (tslot_array[i].sock > max_fd){
max_fd=tslot_array[i].sock;
}
}
tv.tv_usec = 0;
tv.tv_sec = 10;
if (end){
break;
}
/* The select function must be used to implement flow control.
* WANPIPE socket will block the user if the socket cannot send
* or there is nothing to receive.
*
* By using the last socket file descriptor +1 select will wait
* for all active sockets.
*/
slots=0;
if((serr=select(max_fd + 1, &ready, NULL, NULL, &tv))){
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
slots++;
slot=&tslot_array[i];
/* Check for rx packets */
if (FD_ISSET(slot->sock,&ready)){
err = read(slot->sock,
Rx_data,slot->bs);
//printf("RX DATA HDLC: Len=%i\n",err-sizeof(wp_api_hdr_t));
//print_packet(&Rx_data[sizeof(wp_api_hdr_t)],err-sizeof(wp_api_hdr_t));
/* err indicates bytes received */
if(err >= slot->bs) {
unsigned char *rx_frame =
(unsigned char *)&Rx_data[0];
int len = err;
/* Rx packet recevied OK
* Each rx packet will contain sizeof(wp_api_hdr_t) bytes of
* rx header, that must be removed. The
* first byte of the sizeof(wp_api_hdr_t) byte header will
* indicate an error condition.
*/
#if 0
printf("RX DATA: Len=%i\n",len);
print_packet(rx_frame,len);
frame++;
if ((frame % 100) == 0) {
sangoma_get_full_cfg(slot->sock, &tdm_api);
}
continue;
#endif
frame++;
slot->frames++;
wanpipe_hdlc_decode(slot->hdlc_eng,rx_frame,len);
packets+=wanpipe_get_rx_hdlc_packets(slot->hdlc_eng);
error_bit+=wanpipe_get_rx_hdlc_errors(slot->hdlc_eng);
error_crc+=slot->hdlc_eng->decoder.stats.crc;
error_abort+=slot->hdlc_eng->decoder.stats.abort;
error_frm+=slot->hdlc_eng->decoder.stats.frame_overflow;
#if 1
if (wanpipe_get_rx_hdlc_errors(slot->hdlc_eng) != slot->last_error){
slot->last_error = wanpipe_get_rx_hdlc_errors(slot->hdlc_eng);
if (slot->last_error > 1){
printf("\n%s: Errors = %i (crc=%i, abort=%i, frame=%i)\n",
slot->if_name,
wanpipe_get_rx_hdlc_errors(slot->hdlc_eng),
slot->hdlc_eng->decoder.stats.crc,
slot->hdlc_eng->decoder.stats.abort,
slot->hdlc_eng->decoder.stats.frame_overflow);
}
}
if ((slot->frames % 100) == 0 && packets == 0){
printf("\n%s: Frames=%i Rx Packets = %i (crc=%i, abort=%i, frame=%i)\n",
slot->if_name,
frame,
wanpipe_get_rx_hdlc_packets(slot->hdlc_eng),
slot->hdlc_eng->decoder.stats.crc,
slot->hdlc_eng->decoder.stats.abort,
slot->hdlc_eng->decoder.stats.frame_overflow);
}
#endif
#if 0
printf("%s: Received packet %i, length = %i : %s\n",
slot->if_name,++Rx_count, err,
((error_bit == 0)? "USR DATA OK" :
(error_bit&BOARD_UNDERRUN)? "BRD_UNDR" :
(error_bit&TX_ISR_UNDERRUN) ? "TX_UNDR" :
"UNKNOWN ERROR"));
#endif
} else {
//printf("\n%s: Error receiving data\n",slot->if_name);
}
} /* If rx */
} /* for all slots */
if (frame%500==0){
putchar('\r');
printf("Slots=%04i frame=%04i packets=%04i errors=%04i (crc=%04i abort=%04i frm=%04i)",
slots,
frame,
packets,
error_bit>slots?error_bit:0,
error_crc,
error_abort,
error_frm);
fflush(stdout);
}
packets=0;
error_bit=0;
error_crc=0;
error_abort=0;
error_frm=0;
} else {
printf("\n: Error selecting rx socket rc=0x%x errno=0x%x\n",
serr,errno);
perror("Select: ");
//break;
}
}
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].hdlc_eng) {
wanpipe_unreg_hdlc_engine(tslot_array[i].hdlc_eng);
}
}
printf("\nRx Unloading HDLC\n");
}
void process_con_tx(timeslot_t *slot)
{
unsigned int Tx_count, max_tx_len, Tx_offset=0, Tx_length,Tx_hdlc_len, Tx_encoded_hdlc_len;
fd_set fd_write;
int err=0,i,tx_ok=1;
unsigned char Tx_data[MAX_TX_DATA];
unsigned char Tx_hdlc_data[MAX_TX_DATA];
wanpipe_hdlc_engine_t *hdlc_eng;
unsigned char next_idle;
hdlc_eng = wanpipe_reg_hdlc_engine();
if (!hdlc_eng){
printf("ERROR: Failed to register HDLC Engine\n");
return;
}
Tx_count = 0;
Tx_length = max_tx_len = slot->bs;
/* Send double of max so that a single big frame gets separated into two actual packets */
Tx_hdlc_len=(max_tx_len*2);
Tx_hdlc_len*= 0.75;
printf("User MTU/MRU=%i Tx Len = %i \n",max_tx_len,Tx_hdlc_len);
/* If running HDLC_STREAMING then the received CRC bytes
* will be passed to the application as part of the
* received data. The CRC bytes will be appended as the
* last two bytes in the rx packet.
*/
memset(&Tx_data[0],0,MAX_TX_DATA);
slot->data=0;
for (i=0;i<Tx_hdlc_len;i++){
if (slot->data){
Tx_data[i] = slot->data;
}else{
Tx_data[i] = i;
}
}
/* If drivers has been configured in HDLC_STREAMING
* mode, the CRC bytes will be included into the
* rx packet. Thus, the application should remove
* the last two bytes of the frame.
*
* The no_CRC_bytes_Rx will indicate to the application
* how many bytes to cut from the end of the rx frame.
*
*/
printf("%s: Tx Starting to write on sock %i data (0x%X) f=%x l=%x \n",
slot->if_name,slot->sock,slot->data,Tx_data[0],Tx_data[Tx_hdlc_len-1]);
//pause();
for(;;) {
FD_ZERO(&fd_write);
FD_SET(slot->sock,&fd_write);
if (end){
break;
}
/* The select function must be used to implement flow control.
* WANPIPE socket will block the user if the socket cannot send
* or there is nothing to receive.
*
* By using the last socket file descriptor +1 select will wait
* for all active sockets.
*/
#if 1
/* If we got busy on last frame repeat the frame */
if (tx_ok == 1){
#if 0
printf("TX DATA ORIG: Len=%i\n",Tx_hdlc_len);
print_packet(&Tx_data[sizeof(wp_api_hdr_t)],Tx_hdlc_len);
#endif
wanpipe_hdlc_encode(hdlc_eng,&Tx_data[0],Tx_hdlc_len,&Tx_hdlc_data[0],&Tx_encoded_hdlc_len,&next_idle);
if (Tx_encoded_hdlc_len < (max_tx_len*2)){
int j;
for (j=0;j<((max_tx_len*2) - Tx_encoded_hdlc_len);j++){
Tx_hdlc_data[Tx_encoded_hdlc_len+j]=next_idle;
}
Tx_encoded_hdlc_len+=j;
}
#if 0
printf("TX DATA HDLC: Olen=%i Len=%i\n",Tx_hdlc_len,Tx_encoded_hdlc_len);
print_packet(&Tx_hdlc_data[sizeof(wp_api_hdr_t)],Tx_encoded_hdlc_len);
#endif
if (Tx_encoded_hdlc_len > (max_tx_len*2)){
printf("Tx hdlc len > max %i\n",Tx_encoded_hdlc_len);
continue;
}
Tx_length=max_tx_len;
Tx_offset=0;
//printf("INITIAL Fragment Chunk tx! %i Tx_encoded =%i \n", Tx_offset,Tx_encoded_hdlc_len);
#if 0
if ((Tx_count % 60) == 0){
Tx_hdlc_len++; /* Introduce Error */
}
#endif
#if 0
printf("Data %i\n",Tx_hdlc_len);
for (i=0;i<Tx_hdlc_len;i++){
printf(" 0x%X",Tx_hdlc_data[sizeof(wp_api_hdr_t)+i]);
}
printf("\n");
#endif
tx_ok=0;
}
#endif
if(select(slot->sock + 1,NULL, &fd_write, NULL, NULL)){
/* Check if the socket is ready to tx data */
if (FD_ISSET(slot->sock,&fd_write)){
err=write(slot->sock,&Tx_hdlc_data[Tx_offset],Tx_length);
if (err != Tx_length){
/* Packet sent ok */
//printf("\t\t%s:Packet sent: Len=%i Data=0x%x : %i\n",
// slot->if_name,err,slot->data,++Tx_count);
//putchar('T');
Tx_offset+=Tx_length;
if (Tx_offset >= Tx_encoded_hdlc_len){
//printf("LAST Chunk tx! %i \n", Tx_offset);
Tx_offset=0;
Tx_length=max_tx_len;
/* Last fragment transmitted */
/* pass throught */
} else {
Tx_length = Tx_encoded_hdlc_len - Tx_length;
if (Tx_length > max_tx_len) {
Tx_length=max_tx_len;
}
// printf("MIDDLE Fragment Chunk tx! %i \n", Tx_offset);
continue;
}
#if RAND_FRAME
if (Tx_count%10 == 0){
Tx_hdlc_len=myrand(max_tx_len*2*0.75);
for (i=0;i<Tx_hdlc_len;i++){
Tx_data[i+sizeof(wp_api_hdr_t)] = myrand(255);
}
mysrand(myrand(255));
}
#endif
Tx_count++;
tx_ok=1;
}else{
if (errno != EBUSY){
printf("Errno = %i EBUSY=%i\n",errno,-EBUSY);
perror("Send Failed: ");
break;
}
/* The driver is busy, we must requeue this
* tx packet, and try resending it again
* later. */
}
}else{
printf("Error Tx nothing IFFSET\n");
}
#if 0
if (Tx_count > MAX_TX_FRAMES){
break;
}
#endif
#if 0
if (Tx_count % 500){
slot->data=slot->data+1;
for (i=0;i<Tx_length;i++){
Tx_data[i+sizeof(wp_api_hdr_t)] = slot->data;
}
tx_change_data=1;
tx_change_data_cnt=0;
}
#endif
} else {
printf("\nError selecting socket\n");
break;
}
}
printf("\nTx Unloading HDLC\n");
wanpipe_unreg_hdlc_engine(hdlc_eng);
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call process_con() to read/write the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int proceed;
char router_name[20];
int x,i;
if (argc < 3){
printf("Usage: rec_wan_sock <router name> <interface name> <data> ...\n");
exit(0);
}
nice(-11);
signal(SIGINT,&sig_end);
signal(SIGTERM,&sig_end);
memset(&tslot_array,0,sizeof(tslot_array));
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
tslot_array[i].sock=-1;
}
strncpy(router_name,argv[1],(sizeof(router_name)-1));
for (x=1;x<argc-1;x++) {
strncpy(tslot_array[x].if_name, argv[x+1], MAX_IF_NAME);
printf("Connecting to IF=%s\n",tslot_array[x].if_name);
#if 1
proceed = MakeConnection(&tslot_array[x],router_name);
if( proceed == TRUE ){
printf("Creating %s with tx data 0x%x : Sock=%i : x=%i\n",
tslot_array[x].if_name,
tslot_array[x].data,
tslot_array[x].sock,
x);
if (!fork()){
signal(SIGINT,&sig_end);
signal(SIGTERM,&sig_end);
process_con_tx(&tslot_array[x]);
exit(0);
}
}else{
if (tslot_array[x].sock){
close(tslot_array[x].sock);
}
tslot_array[x].sock=-1;
}
#endif
}
process_con_rx();
for (x=0;x<MAX_NUM_OF_TIMESLOTS;x++){
if (tslot_array[x].sock){
close(tslot_array[x].sock);
tslot_array[x].sock=0;
}
}
/* Wait for the clear call children */
return 0;
};

View File

@ -0,0 +1,143 @@
/*****************************************************************************
* 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/wanpipe_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <libsangoma.h>
#include "lib_api.h"
/* Prototypes */
void handle_span_chan(int);
void sig_end(int sigid);
int dev_fd;
FILE *tx_fd=NULL,*rx_fd=NULL;
wanpipe_tdm_api_t tdm_api;
/***************************************************
* HANDLE SOCKET
*/
void handle_span_chan(int dev_fd)
{
fd_set oob;
int err;
/* Main Rx Tx OOB routine */
for(;;) {
/* Initialize all select() descriptors */
FD_ZERO(&oob);
FD_SET(dev_fd,&oob);
/* Select will block, until:
* 1: OOB event, link level change
* 2: Rx data available
* 3: Interface able to Tx */
err=select(dev_fd + 1,NULL, NULL, &oob, NULL);
if (err > 0){
fflush(stdout);
if (FD_ISSET(dev_fd,&oob)){
wp_tdm_api_event_t *rx_event;
/* An OOB event is pending, usually indicating
* a link level change */
err=sangoma_tdm_read_event(dev_fd,&tdm_api);
if(err < 0 ) {
printf("Failed to receive OOB %i\n", err);
break;
}
rx_event = &tdm_api.wp_tdm_cmd.event;
switch (rx_event->wp_tdm_api_event_type){
#if 0
case WP_TDMAPI_EVENT_ALARM:
printf("GOT ALARM EVENT 0x%0X Span=%i Chan=%i\n",
rx_event->wp_tdm_api_event_alarm,rx_event->span,rx_event->channel);
break;
#endif
case WP_TDMAPI_EVENT_LINK_STATUS:
printf("GOT LINK STATUS Span=%i Chan=%i State=%s\n",
rx_event->span,rx_event->channel,
rx_event->wp_tdm_api_event_link_status == WP_TDMAPI_EVENT_LINK_STATUS_CONNECTED ? "Connected" : "Disconnected");
break;
default:
//printf("GOT UNKNOWN OOB %i \n",rx_event->wp_tdm_api_event_type);
break;
}
}
}
if (err < 0) {
printf("Device Down!\n");
fflush(stdout);
break;
}
}
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_span_chan(int dev_fd) to read the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int dev_fd;
memset(&tdm_api,0,sizeof(tdm_api));
dev_fd =-1;
dev_fd = sangoma_open_tdmapi_ctrl();
if( dev_fd < 0){
printf("Failed to open span chan\n");
exit (1);
}
handle_span_chan(dev_fd);
close(dev_fd);
return 0;
};

View File

@ -289,7 +289,7 @@ void handle_span_chan(void)
}
}
sangoma_tdm_txsig_onhook(dev_fd, &tdm_api);
// sangoma_tdm_txsig_onhook(dev_fd, &tdm_api);
event_type=WP_TDMAPI_EVENT_RING_DETECT;
aft_tdm_api_event_ctrl(&tdm_api, 1);
@ -300,6 +300,11 @@ void handle_span_chan(void)
event_type=WP_TDMAPI_EVENT_RXHOOK;
aft_tdm_api_event_ctrl(&tdm_api, 1);
event_type=WP_TDMAPI_EVENT_RING;
aft_tdm_api_event_ctrl(&tdm_api, 1);
/* Main Rx Tx OOB routine */
for(;;) {

View File

@ -0,0 +1,375 @@
/*****************************************************************************
* bstrm_hdlc_test_multi.c: Multiple Bstrm Test Receive Module
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2006 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 <signal.h>
#include <wait.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <pthread.h>
#include <linux/wanpipe.h>
#include <linux/wanpipe_tdm_api.h>
#include <libsangoma.h>
#include <wanpipe_hdlc.h>
#define FALSE 0
#define TRUE 1
/* Enable/Disable tx of random frames */
#define RAND_FRAME 1
#define MAX_NUM_OF_TIMESLOTS 31*16
#define LGTH_CRC_BYTES 2
#define MAX_TX_DATA 1000 //MAX_NUM_OF_TIMESLOTS*10 /* Size of tx data */
#define MAX_TX_FRAMES 1000000 /* Number of frames to transmit */
#define WRITE 1
#define MAX_IF_NAME 20
typedef struct {
int sock;
int rx_cnt;
int tx_cnt;
int data;
int last_error;
int frames;
char if_name[MAX_IF_NAME+1];
} timeslot_t;
timeslot_t tslot_array[MAX_NUM_OF_TIMESLOTS];
int tx_change_data=0, tx_change_data_cnt=0;
int end=0;
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
void sig_end(int sigid)
{
printf("%d: Got Signal %i\n",getpid(),sigid);
end=1;
}
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(int max_rand) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % max_rand);
}
void mysrand(unsigned seed) {
next = seed;
}
/*===================================================
* MakeConnection
*
* o Create a Socket
* o Bind a socket to a wanpipe network interface
* (Interface name is supplied by the user)
*==================================================*/
int MakeConnection(timeslot_t *slot, char *router_name )
{
int span,chan;
sangoma_span_chan_fromif(slot->if_name,&span,&chan);
if (span > 0 && chan > 0) {
wanpipe_tdm_api_t tdm_api;
slot->sock = sangoma_open_tdmapi_span_chan(span,chan);
if( slot->sock < 0 ) {
perror("Open Span Chan: ");
return( FALSE );
}
sangoma_tdm_set_codec(slot->sock,&tdm_api,WP_NONE);
printf("Socket bound to Span=%i Chan=%i\n\n",span,chan);
return (TRUE);
}
return(FALSE);
}
int api_tdm_fe_alarms_callback(int fd, unsigned char alarm)
{
int fd_found=0;
int i;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock == fd) {
fd_found=1;
break;
}
}
if (fd_found) {
printf ("FE ALARMS Call back found device %i Alarm=%i \n",
fd,alarm);
} else {
printf ("FE ALARMS Call back no device Alarm=%i\n",alarm);
}
return 0;
}
#define ALL_OK 0
#define BOARD_UNDERRUN 1
#define TX_ISR_UNDERRUN 2
#define UNKNOWN_ERROR 4
void process_con_rx(void)
{
unsigned int Rx_count;
fd_set oob,ready;
int err,serr,i,slots=0;
unsigned char Rx_data[1600];
int error_bit=0, error_crc=0, error_abort=0, error_frm=0;
struct timeval tv;
int frame=0;
int max_fd=0, packets=0;
timeslot_t *slot=NULL;
wanpipe_tdm_api_t tdm_api;
memset(&tdm_api,0,sizeof(tdm_api));
tdm_api.wp_tdm_event.wp_fe_alarm_event = &api_tdm_fe_alarms_callback;
i=0;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
if (tslot_array[i].sock > max_fd){
max_fd=tslot_array[i].sock;
}
}
i=0;
tv.tv_usec = 0;
tv.tv_sec = 10;
Rx_count = 0;
for(;;) {
FD_ZERO(&ready);
FD_ZERO(&oob);
max_fd=0;
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
FD_SET(tslot_array[i].sock,&ready);
FD_SET(tslot_array[i].sock,&oob);
if (tslot_array[i].sock > max_fd){
max_fd=tslot_array[i].sock;
}
}
tv.tv_usec = 0;
tv.tv_sec = 10;
if (end){
break;
}
/* The select function must be used to implement flow control.
* WANPIPE socket will block the user if the socket cannot send
* or there is nothing to receive.
*
* By using the last socket file descriptor +1 select will wait
* for all active sockets.
*/
slots=0;
if((serr=select(max_fd + 1, &ready, NULL, &oob, &tv))){
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
if (tslot_array[i].sock < 0) {
continue;
}
slots++;
slot=&tslot_array[i];
if (FD_ISSET(slot->sock,&oob)){
sangoma_tdm_read_event(slot->sock,&tdm_api);
}
/* Check for rx packets */
if (FD_ISSET(slot->sock,&ready)){
err = sangoma_readmsg_tdm(slot->sock,
Rx_data,sizeof(wp_tdm_api_rx_hdr_t),
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
sizeof(Rx_data), 0);
/* err indicates bytes received */
if(err > 0) {
#if 0
sangoma_writemsg_tdm(tslot_array[i==1?2:1].sock,
Rx_data,sizeof(wp_tdm_api_rx_hdr_t),
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
err, 0);
#else
sangoma_writemsg_tdm(tslot_array[i].sock,
Rx_data,sizeof(wp_tdm_api_rx_hdr_t),
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
err, 0);
#endif
} else {
printf("\n%s: Error receiving data\n",slot->if_name);
}
} /* If rx */
} /* for all slots */
} else {
printf("\n: Error selecting rx socket rc=0x%x errno=0x%x\n",
serr,errno);
perror("Select: ");
//break;
}
}
printf("\nRx Unloading HDLC\n");
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call process_con() to read/write the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int proceed;
char router_name[20];
int x,i;
if (argc < 1){
printf("Usage: rec_wan_sock <router name> <interface name> ...\n");
exit(0);
}
nice(-11);
signal(SIGINT,&sig_end);
signal(SIGTERM,&sig_end);
memset(&tslot_array,0,sizeof(tslot_array));
for (i=0;i<MAX_NUM_OF_TIMESLOTS;i++){
tslot_array[i].sock=-1;
}
strncpy(router_name,argv[1],(sizeof(router_name)-1));
for (x=1;x<argc-1;x++) {
strncpy(tslot_array[x].if_name, argv[x+1], MAX_IF_NAME);
printf("Connecting to IF=%s\n",tslot_array[x].if_name);
#if 1
proceed = MakeConnection(&tslot_array[x],router_name);
if( proceed == TRUE ){
printf("Creating %s with tx data 0x%x : Sock=%i : x=%i\n",
tslot_array[x].if_name,
tslot_array[x].data,
tslot_array[x].sock,
x);
}else{
if (tslot_array[x].sock){
close(tslot_array[x].sock);
}
tslot_array[x].sock=-1;
}
#endif
}
process_con_rx();
for (x=0;x<MAX_NUM_OF_TIMESLOTS;x++){
if (tslot_array[x].sock){
close(tslot_array[x].sock);
tslot_array[x].sock=0;
}
}
/* Wait for the clear call children */
return 0;
};

View File

@ -0,0 +1,506 @@
/*****************************************************************************
* 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/wanpipe_defines.h>
#include <linux/wanpipe_cfg.h>
#include <linux/wanpipe.h>
#include <libsangoma.h>
#include "lib_api.h"
#define MAX_TX_DATA 15000 /* Size of tx data */
#define MAX_FRAMES 5000 /* Number of frames to transmit */
#define MAX_RX_DATA 15000
unsigned short Rx_lgth;
unsigned char Rx_data[MAX_RX_DATA];
unsigned char Tx_data[MAX_TX_DATA + sizeof(wp_tdm_api_rx_hdr_t)];
/* Prototypes */
int MakeConnection(void);
void handle_span_chan( void);
void sig_end(int sigid);
int dev_fd;
FILE *tx_fd=NULL,*rx_fd=NULL;
wanpipe_tdm_api_t tdm_api;
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
/***************************************************
* 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
*
* ------------------------------------------
* | sizeof(wp_api_hdr_t) bytes | X bytes ...
* ------------------------------------------
* Header Data
*
* o Data structures:
* ------------------
* typedef struct {
* union {
* struct {
* unsigned char _event_type;
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_event;
* struct {
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_rx;
* unsigned char reserved[sizeof(wp_api_hdr_t)];
* }wp_rx_hdr_u;
* #define wp_api_event_type wp_rx_hdr_u.wp_event._event_type
* #define wp_api_event_rbs_rx_bits wp_rx_hdr_u.wp_event._rbs_rx_bits
* #define wp_api_event_time_stamp wp_rx_hdr_u.wp_event._time_stamp
* } wp_tdm_api_rx_hdr_t;
*
* typedef struct {
* wp_tdm_api_rx_hdr_t hdr;
* unsigned char data[1];
* } wp_tdm_api_rx_element_t;
*
* typedef struct {
* union {
* struct {
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_tx;
* unsigned char reserved[sizeof(wp_api_hdr_t)];
* }wp_tx_hdr_u;
* #define wp_api_time_stamp wp_tx_hdr_u.wp_tx._time_stamp
* } wp_tdm_api_tx_hdr_t;
*
* typedef struct {
* wp_tdm_api_tx_hdr_t hdr;
* unsigned char data[1];
* } wp_tdm_api_tx_element_t;
*
* #define WPTDM_A_BIT 0x08
* #define WPTDM_B_BIT 0x04
* #define WPTDM_C_BIT 0x02
* #define WPTDM_D_BIT 0x01
*
*/
void handle_span_chan(void)
{
unsigned int Rx_count,Tx_count,Tx_length;
wp_tdm_api_rx_element_t* api_rx_el;
wp_tdm_api_tx_element_t * api_tx_el;
fd_set ready,write,oob;
int err,i;
unsigned char rx_sync=0;
unsigned char tx_sync=0;
#if 0
int rlen;
int stream_sync=0;
#endif
Rx_count = 0;
Tx_count = 0;
if (tdm_api.wp_tdm_cmd.hdlc) {
Tx_length = tx_size;
} else {
Tx_length = tdm_api.wp_tdm_cmd.usr_mtu_mru;
}
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(wp_tdm_api_rx_hdr_t));
/* Cast the Tx data packet with the tx element
* structure. We must insert a sizeof(wp_api_hdr_t) byte
* driver header, which driver will remove
* before passing packet out the physical port */
api_tx_el = (wp_tdm_api_tx_element_t*)&Tx_data[0];
/* 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)tx_sync++;
}else{
#if 0
api_tx_el->data[i] = (unsigned char)tx_data+(i%4);
#else
api_tx_el->data[i] = (unsigned char)tx_data;
#endif
}
}
/* Main Rx Tx OOB routine */
for(;;) {
/* Initialize all select() descriptors */
FD_ZERO(&ready);
FD_ZERO(&write);
FD_ZERO(&oob);
FD_SET(dev_fd,&oob);
FD_SET(dev_fd,&ready);
if (write_enable){
FD_SET(dev_fd,&write);
}
/* Select will block, until:
* 1: OOB event, link level change
* 2: Rx data available
* 3: Interface able to Tx */
if(select(dev_fd + 1,&ready, &write, &oob, NULL)){
fflush(stdout);
if (FD_ISSET(dev_fd,&oob)){
/* An OOB event is pending, usually indicating
* a link level change */
err=sangoma_tdm_read_event(dev_fd,&tdm_api);
if(err < 0 ) {
printf("Failed to receive OOB %i , %i\n", Rx_count, err);
err = ioctl(dev_fd,SIOC_WANPIPE_SOCK_STATE,0);
printf("Sock state is %s\n",
(err == 0) ? "CONNECTED" :
(err == 1) ? "DISCONNECTED" :
"CONNECTING");
break;
}
printf("GOT OOB EXCEPTION CMD Exiting\n");
}
if (FD_ISSET(dev_fd,&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 sizeof(wp_api_hdr_t) byte header
* attached by the driver.
*
* 3. Check error_flag:
* CRC,Abort..etc
*/
memset(Rx_data, 0, sizeof(Rx_data));
err = sangoma_readmsg_tdm(dev_fd,
Rx_data,
sizeof(wp_tdm_api_rx_hdr_t),
&Rx_data[sizeof(wp_tdm_api_rx_hdr_t)],
MAX_RX_DATA, 0);
if (!read_enable){
goto bitstrm_skip_read;
}
/* err indicates bytes received */
if(err <= 0) {
printf("\nError receiving data\n");
break;
}
api_rx_el = (wp_tdm_api_rx_element_t*)&Rx_data[0];
/* Check the packet length */
Rx_lgth = err;
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
#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
++Rx_count;
if (verbose){
printf("Received %i Length = %i\n",
Rx_count,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');
}
err=0;
for(i=0;i<Rx_lgth; i++) {
if (rx_sync != api_rx_el->data[i]){
printf("Sync Error: Expecting %02x got %02x len=%i frame=%i diff=%i\n",
rx_sync, api_rx_el->data[i],i,Rx_count,abs(rx_sync-api_rx_el->data[i]));
rx_sync=api_rx_el->data[i];
err++;
}
rx_sync++;
}
if (err) {
print_packet(&api_rx_el->data[0],Rx_lgth);
}
#if 0
if (Rx_count == 100){
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_SLINEAR);
sangoma_get_full_cfg(dev_fd, &tdm_api);
}
if (Rx_count == 200){
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_NONE);
sangoma_get_full_cfg(dev_fd, &tdm_api);
}
if (Rx_count == 300){
sangoma_tdm_set_usr_period(dev_fd,&tdm_api,20);
sangoma_get_full_cfg(dev_fd, &tdm_api);
}
if (Rx_count == 400){
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_SLINEAR);
sangoma_get_full_cfg(dev_fd, &tdm_api);
}
if (Rx_count == 500){
sangoma_tdm_set_usr_period(dev_fd,&tdm_api,10);
sangoma_get_full_cfg(dev_fd, &tdm_api);
}
memset(Rx_data,0,Rx_lgth+sizeof(wp_tdm_api_rx_hdr_t));
sangoma_writemsg_tdm(dev_fd,
Rx_data,sizeof(wp_api_hdr_t),
&Rx_data[sizeof(wp_api_hdr_t)], Rx_lgth,
0);
#endif
#if 0
if (Rx_count == 200){
sangoma_tdm_set_codec(dev_fd,WP_SLINEAR);
sangoma_get_full_cfg(dev_fd);
}
if (Rx_count == 400){
sangoma_tdm_set_hw_period(dev_fd,20);
sangoma_get_full_cfg(dev_fd);
}
if (Rx_count == 600){
sangoma_tdm_set_codec(dev_fd,WP_NONE);
sangoma_get_full_cfg(dev_fd);
}
#endif
if (rx_cnt > 0 && Rx_count >= rx_cnt){
break;
}
bitstrm_skip_read:
;
}
if (FD_ISSET(dev_fd,&write)){
err = sangoma_writemsg_tdm(dev_fd,
Tx_data,sizeof(wp_api_hdr_t),
&Tx_data[sizeof(wp_api_hdr_t)], Tx_length,
0);
if (err <= 0){
if (errno == EBUSY){
if (verbose){
printf("Sock busy try again!\n");
}
/* Socket busy try sending again !*/
}else{
printf("Faild to send %i \n",errno);
perror("Send: ");
break;
}
}else{
for (i=0;i<Tx_length;i++){
if (tx_data == -1){
api_tx_el->data[i] = (unsigned char)tx_sync++;
}else{
api_tx_el->data[i] = (unsigned char)tx_data;
}
}
++Tx_count;
if (verbose){
printf("Packet sent: Sent %i : %i\n",
err,Tx_count);
}else{
//putchar('T');
}
}
}
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 (dev_fd);
}
int rbs_event (int fd, unsigned char rbs_bits)
{
printf("%d: GOT RBS EVENT: RBS BITS=0x%X\n",
fd,rbs_bits);
return 0;
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_span_chan() 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);
memset(&tdm_api,0,sizeof(tdm_api));
dev_fd =-1;
dev_fd = sangoma_open_tdmapi_span_chan(atoi(card_name),atoi(if_name));
if( dev_fd < 0){
printf("Failed to open span chan\n");
exit (1);
}
printf("HANDLING SPAN %i CHAN %i FD=%i\n",
atoi(card_name),atoi(if_name),dev_fd);
sangoma_tdm_set_codec(dev_fd,&tdm_api,WP_NONE);
sangoma_get_full_cfg(dev_fd, &tdm_api);
handle_span_chan();
close(dev_fd);
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 (dev_fd){
close (dev_fd);
}
exit(1);
}

View File

@ -0,0 +1,510 @@
/*****************************************************************************
* 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.
* ============================================================================
*/
#if 0
#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>
#endif
#define WAN_IFNAME_SZ 100
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include <time.h>
#include "lib_api.h"
#define DAHDI_ISSUES 1
#include "zapcompat_user.h"
#define MAX_TX_DATA 15000 /* Size of tx data */
#define MAX_FRAMES 5000 /* Number of frames to transmit */
#define MAX_RX_DATA 15000
#define BLOCK_SIZE 160
unsigned short Rx_lgth;
unsigned char Rx_data[MAX_RX_DATA];
unsigned char Tx_data[MAX_TX_DATA ];
ZT_PARAMS tp;
/* Prototypes */
int MakeConnection(int);
void handle_span_chan( void);
void sig_end(int sigid);
int dev_fd;
FILE *tx_fd=NULL,*rx_fd=NULL;
int zap_ec_ctrl(int sock, int tap)
{
struct dahdi_echocanparams ecp = { .tap_length = tap };
int res;
res=ioctl(sock, DAHDI_ECHOCANCEL_PARAMS, &ecp);
if (res) {
fprintf(stderr, "Failed to configure ec tap=%i: %s\n", tap, strerror(errno));
}
return res;
}
/***************************************************
* 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
*
* ------------------------------------------
* | sizeof(wp_api_hdr_t) bytes | X bytes ...
* ------------------------------------------
* Header Data
*
* o Data structures:
* ------------------
* typedef struct {
* union {
* struct {
* unsigned char _event_type;
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_event;
* struct {
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_rx;
* unsigned char reserved[sizeof(wp_api_hdr_t)];
* }wp_rx_hdr_u;
* #define wp_api_event_type wp_rx_hdr_u.wp_event._event_type
* #define wp_api_event_rbs_rx_bits wp_rx_hdr_u.wp_event._rbs_rx_bits
* #define wp_api_event_time_stamp wp_rx_hdr_u.wp_event._time_stamp
* } wp_tdm_api_rx_hdr_t;
*
* typedef struct {
* wp_tdm_api_rx_hdr_t hdr;
* unsigned char data[1];
* } wp_tdm_api_rx_element_t;
*
* typedef struct {
* union {
* struct {
* unsigned char _rbs_rx_bits;
* unsigned int _time_stamp;
* }wp_tx;
* unsigned char reserved[sizeof(wp_api_hdr_t)];
* }wp_tx_hdr_u;
* #define wp_api_time_stamp wp_tx_hdr_u.wp_tx._time_stamp
* } wp_tdm_api_tx_hdr_t;
*
* typedef struct {
* wp_tdm_api_tx_hdr_t hdr;
* unsigned char data[1];
* } wp_tdm_api_tx_element_t;
*
* #define WPTDM_A_BIT 0x08
* #define WPTDM_B_BIT 0x04
* #define WPTDM_C_BIT 0x02
* #define WPTDM_D_BIT 0x01
*
*/
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
void handle_span_chan(void)
{
unsigned int Rx_count,Tx_count,Tx_length;
fd_set ready,fd_write,oob;
int err,i;
#if 0
int rlen;
int stream_sync=0;
#endif
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 );
/* Cast the Tx data packet with the tx element
* structure. We must insert a sizeof(wp_api_hdr_t) byte
* driver header, which driver will remove
* before passing packet out the physical port */
/* 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){
Tx_data[i] = (unsigned char)i;
}else{
#if 0
Tx_data[i] = (unsigned char)tx_data+(i%4);
#else
Tx_data[i] = (unsigned char)tx_data;
#endif
}
}
/* Main Rx Tx OOB routine */
for(;;) {
/* Initialize all select() descriptors */
FD_ZERO(&ready);
FD_ZERO(&fd_write);
FD_ZERO(&oob);
FD_SET(dev_fd,&oob);
FD_SET(dev_fd,&ready);
if (write_enable){
FD_SET(dev_fd,&fd_write);
}
/* Select will block, until:
* 1: OOB event, link level change
* 2: Rx data available
* 3: Interface able to Tx */
if(select(dev_fd + 1,&ready, &fd_write, &oob, NULL)){
fflush(stdout);
if (FD_ISSET(dev_fd,&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 sizeof(wp_api_hdr_t) byte header
* attached by the driver.
*
* 3. Check error_flag:
* CRC,Abort..etc
*/
memset(Rx_data, 0, sizeof(Rx_data));
err = read(dev_fd, Rx_data, sizeof(Rx_data));
if (!read_enable){
goto bitstrm_skip_read;
}
/* err indicates bytes received */
if(err <= 0) {
printf("\nError receiving data\n");
break;
}
/* Check the packet length */
Rx_lgth = err;
if(Rx_lgth<=0) {
printf("\nShort frame received (%d)\n",
Rx_lgth);
return;
}
#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
++Rx_count;
if (verbose){
printf("Received %i Length = %i\n",
Rx_count,Rx_lgth);
printf("Data: ");
print_packet(Rx_data,Rx_lgth);
}else{
//putchar('R');
}
if (rx_cnt > 0 && Rx_count >= rx_cnt){
break;
}
bitstrm_skip_read:
;
}
if (FD_ISSET(dev_fd,&fd_write)){
err = write(dev_fd,Tx_data,Tx_length);
if (err <= 0){
if (errno == EBUSY){
if (verbose){
printf("Sock busy try again!\n");
}
/* Socket busy try sending again !*/
}else{
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 (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 (dev_fd);
}
int rbs_event (int fd, unsigned char rbs_bits)
{
printf("%d: GOT RBS EVENT: RBS BITS=0x%X\n",
fd,rbs_bits);
return 0;
}
int MakeConnection(int chan)
{
int i;
int sock;
ZT_BUFFERINFO bi;
char chan_name[100];
#ifdef DAHDI_ISSUES
sprintf(chan_name,"/dev/dahdi/%d",chan);
#else
sprintf(chan_name,"/dev/zap/%d",chan);
#endif
printf("Opening chan %i %s\n",chan,chan_name);
#ifdef DAHDI_ISSUES
sock = open("/dev/dahdi/channel", O_RDWR | O_NONBLOCK, 0600);
#else
sock = open("/dev/zap/channel", O_RDWR | O_NONBLOCK, 0600);
#endif
if( sock < 0 ) {
perror("Open Span Chan: ");
return -1 ;
}
if (ioctl(sock, ZT_SPECIFY, &chan)) {
perror("Open Span Chan: ");
close(sock);
sock=-1;
return -1;
}
if (tp.sigtype != ZT_SIG_HARDHDLC) {
if (ioctl(sock, ZT_SET_BLOCKSIZE, &tx_size)) {
fprintf(stderr, "Unable to set block size to %d: %s\n", tx_size, strerror(errno));
return -1;
}
}
if (ioctl(sock, ZT_GET_PARAMS, &tp)) {
fprintf(stderr, "Unable to get channel parameters\n");
return -1;
}
if (tp.sigtype == ZT_SIG_HARDHDLC) {
printf("HARDWARE HDLC %s\n",chan_name);
bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
bi.numbufs = 32;
bi.bufsize = 1024;
if (ioctl(sock, ZT_SET_BUFINFO, &bi)) {
fprintf(stderr, "Unable to set appropriate buffering on channel %s\n", chan_name);
return -1;
}
}
ioctl(sock, ZT_GETEVENT);
i = ZT_FLUSH_ALL;
if (ioctl(sock,ZT_FLUSH,&i) == -1){
perror("tor_flush");
return -1;
}
#if 0
if (tp.sigtype != ZT_SIG_HARDHDLC) {
printf("Setting AUDIO MODE\n");
if (ioctl(sock, DAHDI_AUDIOMODE, &i)) {
printf("Error Failed to set Auido mode %s\n\n",chan_name);
return -1;
}
zap_ec_ctrl(sock,0);
if (zap_ec_ctrl(sock,32) != 0) {
return -1;
}
printf("dev=%s ec enabled\n\n",chan_name);
}
#endif
printf("Socket bound to dev=%s\n\n",chan_name);
return sock;
}
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call handle_span_chan() to read the socket
*
**************************************************************/
int main(int argc, char* argv[])
{
int proceed;
int span,chan;
proceed=init_args(argc,argv);
if (proceed != 1){
usage(argv[0]);
return -1;
}
if (tx_size < 160) {
tx_size = 160;
}
signal(SIGINT,&sig_end);
dev_fd =-1;
span=atoi(card_name);
chan=atoi(if_name);
chan=(span-1)*31+chan;
dev_fd = MakeConnection(chan);
if( dev_fd < 0){
printf("Failed to open span chan\n");
exit (1);
}
printf("HANDLING SPAN %i CHAN %i FD=%i\n",
atoi(card_name),atoi(if_name),dev_fd);
handle_span_chan();
zap_ec_ctrl(dev_fd,0);
close(dev_fd);
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 (dev_fd){
close (dev_fd);
}
exit(1);
}

48
api/tdm_api/dahdi_hdlc_test.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/sh
echo "ARGS $1 $2"
ARG1=$1;
ARG2=$2;
if [ "$ARG1" != "" ]; then
WANPIPES="$ARG1"
else
WANPIPES="1"
fi
IFACES="$ARG2"
IFACE_START=1
IFACE_STOP=31
CMD="wanpipe1"
for wanpipe_num in $WANPIPES
do
num=$((wanpipe_num-1))
if [ "$IFACES" = "" ]; then
for ((i=$IFACE_START;i<=$IFACE_STOP;i+=1)); do
#CMD=$CMD" w"$wanpipe_num"g"$i
if [ $i -eq 16 ]; then
continue
fi
chan=$((num*31+$i))
CMD=$CMD" /dev/dahdi/"$chan
done
else
for if_num in $IFACES
do
chan=$((num*31+if_num))
CMD=$CMD" /dev/dahdi/"$chan
done
fi
done
echo "./aft_tdm_hdlc_test $CMD"
nice -n 20 ./aft_tdm_hdlc_test_zap $CMD

File diff suppressed because it is too large Load Diff

276
api/tdm_api/hdlc_decode.c Normal file
View File

@ -0,0 +1,276 @@
/*****************************************************************************
* bstrm_hdlc_test_multi.c: Multiple Bstrm Test Receive Module
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
*
* Copyright: (c) 1995-2006 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 <signal.h>
#include <wait.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <pthread.h>
#include <linux/wanpipe.h>
#include <linux/wanpipe_tdm_api.h>
#include <libsangoma.h>
#include <wanpipe_hdlc.h>
#define FALSE 0
#define TRUE 1
/* Enable/Disable tx of random frames */
#define RAND_FRAME 0
#define MAX_NUM_OF_TIMESLOTS 32*32
#define LGTH_CRC_BYTES 2
#define MAX_TX_DATA 15000 //MAX_NUM_OF_TIMESLOTS*10 /* Size of tx data */
#define MAX_TX_FRAMES 1000000 /* Number of frames to transmit */
#define WRITE 1
#define MAX_IF_NAME 20
typedef struct {
int sock;
int rx_cnt;
int tx_cnt;
int data;
int last_error;
int frames;
char if_name[MAX_IF_NAME+1];
wanpipe_hdlc_engine_t *hdlc_eng;
} timeslot_t;
timeslot_t tslot_array[MAX_NUM_OF_TIMESLOTS];
int tx_change_data=0, tx_change_data_cnt=0;
int end=0;
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ | ");
for (x=0;x<len;x++){
if (x && x%24 == 0){
printf("\n ");
}
if (x && x%8 == 0)
printf(" | ");
printf("%02x ",buf[x]);
}
printf("}\n");
}
void sig_end(int sigid)
{
//printf("%d: Got Signal %i\n",getpid(),sigid);
end=1;
}
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(int max_rand) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % max_rand);
}
void mysrand(unsigned seed) {
next = seed;
}
/*===================================================
* MakeConnection
*
* o Create a Socket
* o Bind a socket to a wanpipe network interface
* (Interface name is supplied by the user)
*==================================================*/
/***************************************************************
* Main:
*
* o Make a socket connection to the driver.
* o Call process_con() to read/write the socket
*
**************************************************************/
typedef unsigned int guint32;
typedef int gint32;
typedef unsigned short guint16;
static int trace_aft_hdlc_data(wanpipe_hdlc_engine_t *hdlc_eng, void *data, int len)
{
printf("GOT HDLC DATA Len=%i\n",len);
print_packet(data,len);
}
#pragma pack(1)
typedef struct pcap_hdr_s {
guint32 magic_number; /* magic number */
guint16 version_major; /* major version number */
guint16 version_minor; /* minor version number */
gint32 thiszone; /* GMT to local correction */
guint32 sigfigs; /* accuracy of timestamps */
guint32 snaplen; /* max length of captured packets, in octets */
guint32 network; /* data link type */
} pcap_hdr_t;
#if 0
typedef struct pcaprec_hdr_s {
unsigned int ts_sec; /* timestamp seconds */
unsigned int ts_usec; /* timestamp microseconds */
unsigned short incl_len;
} pcaprec_hdr_t;
#else
typedef struct pcaprec_hdr_s {
guint32 ts_sec; /* timestamp seconds */
guint32 ts_usec; /* timestamp microseconds */
guint32 incl_len; /* number of octets of packet saved in file */
guint32 orig_len; /* actual length of packet */
} pcaprec_hdr_t;
#endif
#pragma pack()
int main(int argc, char* argv[])
{
int proceed;
char router_name[20];
char file_name[100];
unsigned char line[80];
FILE *file;
int x=0,i=0;
int err;
int packets=0,error_bit=0,error_crc=0,error_abort=0,error_frm=0;
pcap_hdr_t *global_hdr;
pcaprec_hdr_t *packet_hdr;
int plen=sizeof(*packet_hdr);
wanpipe_hdlc_engine_t *hdlc_eng;
int offset=14+20+8;
int len;
nice(-11);
signal(SIGINT,&sig_end);
signal(SIGTERM,&sig_end);
sprintf(file_name, argv[1]);
file=fopen(file_name, "rb");
if (!file) {
printf("Failed to open file %s ",file_name);
return -1;
}
hdlc_eng = wanpipe_reg_hdlc_engine();
hdlc_eng->hdlc_data = trace_aft_hdlc_data;
err=fread(line, 1, sizeof(*global_hdr), file);
global_hdr=(pcap_hdr_t*)&line[0];
if (global_hdr->magic_number == 0xa1b2c3d4) {
printf("Got Indetical\n");
} else if (global_hdr->magic_number == 0xd4c3b2a1) {
printf("Got Swaped\n");
} else {
printf("Not a pcap file\n");
exit (1);
}
printf("Snap len = %i global=%i packet=%i err=%i vmj=%i vmin=%i\n",
global_hdr->snaplen,sizeof(*global_hdr),sizeof(*packet_hdr),err,
global_hdr->version_major,global_hdr->version_minor);
print_packet(line,err);
printf("Size of Packet =%i\n",sizeof(pcaprec_hdr_t));
while (i++ < 100) {
err=fread(line, 1, plen, file);
if (err != plen) {
printf("Error: failed to read expecting=%i read=%i\n",
plen,err);
exit(1);
}
packet_hdr=(pcaprec_hdr_t*)&line[0];
print_packet(line,err);
len=packet_hdr->incl_len-offset;
printf("Packet(%i) Len=%i Olen=%i data=%i \n",
plen,packet_hdr->incl_len,packet_hdr->orig_len, len);
/* Ethernet + TCP + UDP */
err=fread(line, 1, offset, file);
if (err != offset) {
printf("Error: failed to read expecting=%i read=%i\n",
packet_hdr->incl_len,err);
break;
}
err=fread(line, 1, len, file);
#if 0
if (x==0 && *(unsigned int*)&line[0] != 0x7e7e7e7e) {
continue;
}
#endif
print_packet(line,err);
x=1;
wanpipe_hdlc_decode(hdlc_eng,line,err);
packets+=wanpipe_get_rx_hdlc_packets(hdlc_eng);
error_bit+=wanpipe_get_rx_hdlc_errors(hdlc_eng);
error_crc+=hdlc_eng->decoder.stats.crc;
error_abort+=hdlc_eng->decoder.stats.abort;
error_frm+=hdlc_eng->decoder.stats.frame_overflow;
printf("Status: Read=%i packet=%i crc=%i abort=%i frm=%i error=%i\n",
err,packets,error_crc,error_abort,error_frm,error_bit);
}
wanpipe_unreg_hdlc_engine(hdlc_eng);
return 0;
};

View File

@ -1,17 +0,0 @@
#!/bin/sh
cmd=$1
if [ -z $cmd ]; then
echo "ERROR usage"
exit 1
fi
devs="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16"
for dev in $devs
do
wan_ec_client wanpipe$dev $cmd all
done

View File

@ -1,137 +0,0 @@
/*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
* any of the maintainers of this project for assistance;
* the project provides a web site, mailing lists and IRC
* channels for your use.
*
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2 as published by the
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#ifdef STANDALONE_ZAPATA
#include "kernel/zaptel.h"
#else
#include <zaptel/zaptel.h>
#endif
#define BLOCK_SIZE 2039
void print_packet(unsigned char *buf, int len)
{
int x;
printf("{ ");
for (x=0;x<len;x++)
printf("%02x ",buf[x]);
printf("}\n");
}
int main(int argc, char *argv[])
{
int fd;
int res, x;
int i;
ZT_PARAMS tp;
int bs = BLOCK_SIZE;
int skipcount = 10;
unsigned char c=0,c1=0;
unsigned char inbuf[BLOCK_SIZE];
unsigned char outbuf[BLOCK_SIZE];
int setup=0;
int errors=0;
int bytes=0;
int timeout=0;
time_t start_time=0;
if (argc < 2 || argc > 3 ) {
fprintf(stderr, "Usage: %s <zaptel device> [timeout]\n",argv[0]);
exit(1);
}
fd = open(argv[1], O_RDWR, 0600);
if (fd < 0) {
fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno));
exit(1);
}
if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs)) {
fprintf(stderr, "Unable to set block size to %d: %s\n", bs, strerror(errno));
exit(1);
}
if (ioctl(fd, ZT_GET_PARAMS, &tp)) {
fprintf(stderr, "Unable to get channel parameters\n");
exit(1);
}
ioctl(fd, ZT_GETEVENT);
i = ZT_FLUSH_ALL;
if (ioctl(fd,ZT_FLUSH,&i) == -1)
{
perror("tor_flush");
exit(255);
}
if(argc==3){
timeout=atoi(argv[2]);
start_time=time(NULL);
printf("Using Timeout of %d Seconds\n",timeout);
}
for(;;) {
res = bs;
for (x=0;x<bs;x++)
outbuf[x] = c1++;
res = write(fd,outbuf,bs);
if (res != bs)
{
printf("Res is %d: %s\n", res, strerror(errno));
ioctl(fd, ZT_GETEVENT, &x);
printf("Event: %d\n", x);
exit(1);
}
if (skipcount)
{
if (skipcount > 1) read(fd,inbuf,bs);
skipcount--;
if (!skipcount) puts("Going for it...");
continue;
}
res = read(fd, inbuf, bs);
if (res < bs) {
printf("Res is %d\n", res);
exit(1);
}
if (!setup) {
c = inbuf[0];
setup++;
}
for (x=0;x<bs;x++) {
if (inbuf[x] != c) {
printf("(Error %d): Unexpected result, %d != %d, %d bytes since last error.\n", ++errors, inbuf[x],c, bytes);
c = inbuf[x];
bytes=0;
}
c++;
bytes++;
}
#if 0
printf("(%d) Wrote %d bytes\n", packets++, res);
#endif
if(timeout && (time(NULL)-start_time)>timeout){
printf("Timeout achieved Ending Program\n");
return errors;
}
}
}

View File

@ -1,5 +0,0 @@
#!/bin/sh
nice -n -20 ./tdm_hdlc_test.sh "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16"
#nice -n -20 ./tdm_hdlc_test.sh "1 2 4 5 6 7 8 9 10 12 13 14 15 16"
#./tdm_hdlc_test.sh "1 2 9 10 "

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,9 @@ do
if [ "$IFACES" = "" ]; then
for ((i=$IFACE_START;i<=$IFACE_STOP;i+=1)); do
if [ $i -eq 16 ]; then
continue
fi
#CMD=$CMD" w"$wanpipe_num"g"$i
CMD=$CMD" s"$wanpipe_num"c"$i
done

45
api/tdm_api/zap_hdlc_test.sh Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
echo "ARGS $1 $2"
ARG1=$1;
ARG2=$2;
if [ "$ARG1" != "" ]; then
WANPIPES="$ARG1"
else
WANPIPES="1"
fi
IFACES="$ARG2"
IFACE_START=1
IFACE_STOP=31
CMD="wanpipe1"
for wanpipe_num in $WANPIPES
do
num=$((wanpipe_num-1))
if [ "$IFACES" = "" ]; then
for ((i=$IFACE_START;i<=$IFACE_STOP;i+=1)); do
#CMD=$CMD" w"$wanpipe_num"g"$i
chan=$((num*31+$i))
CMD=$CMD" /dev/zap/"$chan
done
else
for if_num in $IFACES
do
chan=$((num*31+if_num))
CMD=$CMD" /dev/zap/"$chan
done
fi
done
echo "./aft_tdm_hdlc_test $CMD"
nice -n 20 ./aft_tdm_hdlc_test_zap $CMD

View File

@ -0,0 +1,92 @@
/******************************************************************************
* zapcompat.h
*
* Author: Moises Silva <moises.silva@gmail.com>
*
* Copyright: (c) 2008 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.
* ============================================================================
* Sep 06, 2008 Moises Silva Initial Version
******************************************************************************
*/
// Simple compat header to compile with Zaptel or DAHDI
#ifndef __ZAPCOMPAT_H
# define __ZAPCOMPAT_H
// for DAHDI we need to map values and functions from user ZT_XX to DAHDI_XX
#if defined (DAHDI_ISSUES)
#include <sys/types.h>
#include <dahdi/user.h>
#define ZT_LAW_MULAW DAHDI_LAW_MULAW
#define ZT_LAW_ALAW DAHDI_LAW_ALAW
#define ZT_LAW_DEFAULT DAHDI_LAW_DEFAULT
#define ZT_MAX_SPANS DAHDI_MAX_SPANS
#define ZT_MAX_CHANNELS DAHDI_MAX_CHANNELS
#define ZT_SIG_EM DAHDI_SIG_EM
#define ZT_SIG_EM_E1 DAHDI_SIG_EM_E1
#define ZT_SIG_FXSLS DAHDI_SIG_FXSLS
#define ZT_SIG_FXSGS DAHDI_SIG_FXSGS
#define ZT_SIG_FXSKS DAHDI_SIG_FXSKS
#define ZT_SIG_FXOLS DAHDI_SIG_FXOLS
#define ZT_SIG_FXOGS DAHDI_SIG_FXOGS
#define ZT_SIG_FXOKS DAHDI_SIG_FXOKS
#define ZT_SIG_CAS DAHDI_SIG_CAS
#define ZT_SIG_DACS DAHDI_SIG_DACS
#define __ZT_SIG_DACS __DAHDI_SIG_DACS
#define ZT_SIG_DACS_RBS DAHDI_SIG_DACS_RBS
#define ZT_SIG_CLEAR DAHDI_SIG_CLEAR
#define ZT_SIG_SLAVE DAHDI_SIG_SLAVE
#define ZT_SIG_HDLCRAW DAHDI_SIG_HDLCRAW
#define ZT_SIG_HDLCFCS DAHDI_SIG_HDLCFCS
#define ZT_SIG_HDLCNET DAHDI_SIG_HDLCNET
#define ZT_SIG_MTP2 DAHDI_SIG_MPT2
#define ZT_ABIT DAHDI_ABIT
#define ZT_BBIT DAHDI_BBIT
#define ZT_CBIT DAHDI_CBIT
#define ZT_DBIT DAHDI_DBIT
#define ZT_CONFIG_NOTOPEN DAHDI_CONFIG_NOTOPEN
#define ZT_CONFIG_HDB3 DAHDI_CONFIG_HDB3
#define ZT_CONFIG_CCS DAHDI_CONFIG_CCS
#define ZT_CONFIG_CRC4 DAHDI_CONFIG_CRC4
#define ZT_CONFIG_AMI DAHDI_CONFIG_AMI
#define ZT_CONFIG_B8ZS DAHDI_CONFIG_B8ZS
#define ZT_CONFIG_D4 DAHDI_CONFIG_D4
#define ZT_CONFIG_ESF DAHDI_CONFIG_ESF
#define ZT_PARAMS struct dahdi_params
#define ZT_BUFFERINFO struct dahdi_bufferinfo
#define ZT_SPECIFY DAHDI_SPECIFY
#define ZT_SIG_HARDHDLC DAHDI_SIG_HARDHDLC
#define ZT_SET_BLOCKSIZE DAHDI_SET_BLOCKSIZE
#define ZT_GET_PARAMS DAHDI_GET_PARAMS
#define ZT_POLICY_IMMEDIATE DAHDI_POLICY_IMMEDIATE
#define ZT_SET_BUFINFO DAHDI_SET_BUFINFO
#define ZT_GETEVENT DAHDI_GETEVENT
#define ZT_FLUSH_ALL DAHDI_FLUSH_ALL
#define ZT_FLUSH DAHDI_FLUSH
// data types
#define zt_lineconfig dahdi_lineconfig
#define zt_dynamic_span dahdi_dynamic_span
#define zt_chanconfig dahdi_chanconfig
#else
// zaptel is present
// we will keep the same old names in wanpipe code, I thought of changing them
// to something like WP_XX instead of ZT_XX, but I don't see any benefit on it
// and would make this file bigger
#include <zaptel.h>
#endif
#endif /* __ZAPCOMPAT_H */

View File

@ -1,37 +0,0 @@
# ============================================================================
# Makefile Make script for building SS7 MTP2 API
# ----------------------------------------------------------------------------
# Author: Nenad Corbic <ncorbic@sangoma.com>
# Copyright (c) 2008 Sangoma Technologies Inc. All Rights Reserved.
# ============================================================================
####### MACROS ###############################################################
# Build options.
OS_TYPE = __LINUX__
DEBUG = 2
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 -O0 -g -D$(OS_TYPE) -D_DEBUG_=$(DEBUG) -D_GNUC_ -I$(SYSINC)
TARGETS=mtp2api
####### RULES ################################################################
all: $(TARGETS)
@echo "Ok."
mtp2api: mtp2api.c libxmtp2.c
$(CC) $(CFLAGS) -o $@ $^
clean:
rm -f $(TARGETS)
rm -f *.o
rm -f *.*~
rm -f diff

View File

@ -1,224 +0,0 @@
MTP2 API
For Latest Info Visit
http://wiki.sangoma.com/wanpipe-aft-ss7-mtp2-api
Introduction
The Wanpipe MTP2 API provides a custom ss7 developer access to Sangoma's Kernel SS7 MTP2 stack that runs over Sangoma AFT Series T1/E1 cards. The MTP2 API is written as a library in C and works in conjunction with wanpipe mtp2 kernel drivers.
MTP2 API contains the following files:
mtp2api.c -> example main code
libxmtp2.c -> mtp2 api library
libxmtp2.y -> mtp2 api library header
Architecture
mtp2api # custom ss7 application
|
/dev/xmtp20 # kernel device
|
| xmtp2km | # MTP2 Stack / kernel module
|
| wanpipe | # Wanpipe Device Driver - Core
|
| AFT | # Sangoma AFT T1/E1 Hardware
Installation
1. Download latest Wanpipe MTP2 Release From:
-> ftp.sangoma.com/linux/custom/mtp2api
2. Untar wanpipe-<version>.tgz
3. cd wanpipe-<version>
4. ./Setup install
-> proceed with default options until COMPILATION
-> specify compilation mode 4 (SMG/SS7)
-> proceed with default options for rest of installation
5. To confirm successful install
-> wanrouter hwprobe
6. Download MTP2API Library / Sample code from
-> ftp.sangoma.com/linux/custom/mtp2api
Configuration
From the above architectural diagram one needs to configure the following:
1. Wanpipe AFT T1/E1 timeslot configuration per devices per link
Each T1/E1 port/timeslot is configued using /etc/wanpipe/wanpipe#.conf configuration file.
The wanpipe#.conf configuration files are created using wancfg_smg configurator.
The AFT T1/E1 cards be configured for
-> MTP2 API T1/E1 channels Only
-> MTP2 API T1/E1 channels + TDM API Voice Channels
2. MTP2 Stack configuration for each mtp2 link
The MTP2 stack configuration is done via MTP2 API, in custom ss7 application
Configuration Sequence
1. Configure wanpipe device driver + AFT hardware T1/E1 time slots
-> use: wancfg_smg configurator
2. Develop mtp2api custom application that will configure the xmtp2km kernel stack
for each mtp2 link that is associated to the T1/E1 time slot.
Wanpipe AFT T1/E1 time slot configuration
MTP2 API T1/E1 channels only
1. Use: wancfg_smg configurator
-> wancfg_smg
-> For each port specify T1/E1/Clocking
-> Select XMTP2 Only Configuration
-> MTP2 channels for each T1/E1 timeslot
2. Please consult your telco on line configuration.
3. The wanpipe configuration files will be saved in
-> /etc/wanpipe/wanpipe#.conf where # = { 1, 2, 3 .. }
MTP2 API T1/E1 channels + TDM API Voice Channels
1. Run wancfg_smg configurator
-> wancfg_smg
-> For each port specify T1/E1/Clocking
-> Select XMTP2 + Voice Configuration
-> MTP2 channels for each T1/E1 timeslot
2. Please consult your telco on line configuration.
3. The wanpipe configuration files will be saved in
-> /etc/wanpipe/wanpipe#.conf where # = { 1, 2, 3 .. }
Operation
Once the wanpipe devices are configured for MTP2, for each T1/E1 time slot, one must develop the mtp2api application to configure each MTP2 link in the kernel xmtp2km stack.
The mtp2api application MUST be started before starting wanpipe devices! The reason for this is that MTP2 links must be configured before physical devics are started.
1. Edit mtp2api.c file and configure the XMTP2 ports based on above wancfg_smg configuration.
2. Search for: /* MTP2 Configuration based on wancfg_smg configurator */
You will see MTP2 configuration for each link and each wanpipe card device.
/* MTP2 Configuration based on wancfg_smg configuration */
for (i=0;i<16;i++) {
/* Initialize Local MTP2 Device Structure: Likset 0 Link 0 */
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(0,i)];
memset(mtp2dev,0,sizeof(mtp2_dev_t));
mtp2dev->init=1;
mtp2dev->state=LINK_NOT_CONNECTED;
mtp2dev->cfg.card=1; /* Number corresponding to wanpipe config file number: wanpipe1.conf */
mtp2dev->cfg.slot=i; /* T1/E1 timeslot/interface number -> corresponds to interface number
in wanpipe interface name - w1g1 in wanpipe1.conf */
mtp2dev->cfg.clear_ch=1; /* 1=8bit hdlc 0=7bit hdlc */
mtp2dev->cfg.linkset=0; /* LinkSet number */
mtp2dev->cfg.link=i; /* Link in LinkSet */
mtp2dev->cfg.mtu=80*1; /* Block size per timeslot configured */
/* Configure MTP2 Timters */
mtp2dev->cfg.cfg_T1 = MTP2_SEC_MS(13.0);
mtp2dev->cfg.cfg_T2 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T3 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T4Pe = MTP2_SEC_MS(0.6);
mtp2dev->cfg.cfg_T4Pn = MTP2_SEC_MS(2.30);
mtp2dev->cfg.cfg_T5 = MTP2_SEC_MS(0.12);
mtp2dev->cfg.cfg_T6 = MTP2_SEC_MS(3.0);
mtp2dev->cfg.cfg_T7 = MTP2_SEC_MS(1.0);
mtp2dev->rx_msu=mtp2_rx_msu;
mtp2dev->state_change=mtp2_state_change;
mtp2dev->fd=fd;
/* Stop current MTP2 Link */
err=xmtp2_stop_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Configure MTP2 Link */
err=xmtp2_conf_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Power ON MTP2 Link */
err=xmtp2_cmd (fd, mtp2dev->cfg.linkset, mtp2dev->cfg.link, LSC_CAUSE_POWER_ON, MGMT);
if (err) {
exit(-1);
}
/* Start physical T1/E1 channel for the configured MTP2 Link
If the port is already running this command will be skipped,
The /etc/wanpipe/wanpipe#.conf file must be properly configured */
err=xmtp2_start_facility(mtp2dev->cfg.card,mtp2dev->cfg.slot);
if (err) {
exit (-1);
}
mtp2dev=NULL;
}
3. The above configuration must match for each wanpipe#.conf file created
using wancfg_smg.
Based on above configuration mtp2api.c will start each wanpipe channel device
on application start. This done in:
/* Stop wanpipe devices associated with MTP2 Links */
xmtp2_start_facility(card,slot);
section of the code.
Once the mtp2api.c application starts it will
1. Load xmtp2km module
2. Configure each linkset and link in the module
3. Start all wanpipe devices related to linkset and link
4. Once the T1/E1 link comes up
5. The mtp2api will try to bring the links into SERVICE
6. Once Link is in SERVICE mtp2api will start transmitting
MSU of 10 bytes long every 10 seconds on each MTP2 linkset/link.
Based on this application one can develop other SS7 Stacks over the XMTP2 API.
Contact
=======
For more info contact
Nenad Corbic

View File

@ -1,636 +0,0 @@
/*****************************************************************************
* libxmtp2.c SS7 MTP2 API Library
*
* Author(s): Mike Mueller <ss7box@gmail.com
* Nenad Corbic <ncorbic@sangoma.com>
*
*
* Copyright: (c) 2010 Xygnada Technologies
* Sangoma Technologies Inc.
*
* ============================================================================
* 1.6 Nenad Corbic <ncorbic@sangoma.com>
* May 28 2010
* Updated for 8 E1 worth of links.
* Synched up with latest xmtp2 code
*
* 1.5 Nenad Corbic <ncorbic@sangoma.com>
* Sep 02 2009
* Updated for full t1/e1 config
* update freame_per_packet to cfg->mtu
*
* 1.4 Nenad Corbic <ncorbic@sangoma.com>
* Aug 19 2009
* Updated for full t1/e1 config
*
* 1.3 Nenad Corbic <ncorbic@sangoma.com>
* Jun 3 2008
* Fixed spelling mistake in function names
* xmtp2_restart_facility
* xmtp2_start_facility
*
* 1.2 Nenad Corbic <ncorbic@sangoma.com>
* May 21 2008
* Updated so mtp2 links can be configured and
* reconfigured on the fly.
*
* 1.1 Nenad Corbic <ncorbic@sangoma.com>
* May 1 2008
* Updated MTP2 Timer configuration
*
* 1.0 Nenad Corbic <ncorbic@sangoma.com>
* May 1 2008
* Initial Version
*/
#include "libxmtp2.h"
static t_fac_Sangoma_v2 fac_Sangoma[MAX_FACILITIES];
/*===================================================================
*
*==================================================================*/
void info_u (
const char * object,
const char * location,
int group,
const char * cause,
const unsigned int detail
)
{
printf ("I:%s:%s:%s:%u\n",
object,
location,
cause,
detail);
}
/*===================================================================
*
*==================================================================*/
void xmtp2_link_util_report (
const unsigned int ls,
const unsigned int link,
const unsigned int msu_octet_count,
const unsigned int total_octet_count
)
{
int util;
if (total_octet_count != 0)
{
util = 100 * (msu_octet_count / total_octet_count);
}
else
{
util = -1;
}
printf ("R:link util:ls %d:link %d:msu oc %u:tot oc %u:util %d\n",
ls,
link,
msu_octet_count,
total_octet_count,
util);
}
/*===================================================================
*
*==================================================================*/
int xmtp2_load(void)
{
int r = system ("./xmtp2km_in");
if (r < 0) {
info_u (__FILE__, __FUNCTION__,0,
"failed to start xmtp2km:return value follows", r);
return r;
}
return r;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_unload(void)
{
int rc=system ("modprobe -r xmtp2km");
//printf("%s:%d: RC=%i\n",__FUNCTION__,__LINE__,rc);
return rc;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_init(void)
{
memset(&fac_Sangoma,0,sizeof(fac_Sangoma));
return 0;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_open (void)
{
/* install and open /dev/xmtp2km */
int xmtp2km_fd;
xmtp2km_fd = open ("/dev/xmtp2km0", O_RDWR, 0);
if (xmtp2km_fd < 0) {
info_u (__FILE__, __FUNCTION__,0,
"failed:open /dev/xmtp2km:xmtp2km_fd follows", xmtp2km_fd);
}
return xmtp2km_fd;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_close(int fd)
{
if (fd >= 0) {
close(fd);
}
return 0;
}
/*===================================================================
*
*==================================================================*/
static int xmtp2_config (int xmtp2km_fd)
{
/* pass /dev/xmtp2km its configuration parms */
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCS_OPSPARMS, &fac_Sangoma);
if (r) {
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCS_OPSPARMS:retval follows", r);
}
return r;
}
/*===================================================================
*
*==================================================================*/
static int xmtp2_unconfig (int xmtp2km_fd)
{
/* pass /dev/xmtp2km its configuration parms */
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCS_STOP_FAC, &fac_Sangoma);
if (r) {
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCS_OPSPARMS:retval follows", r);
}
return r;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_stop_link (int fd, xmtp_cfg_link_info_t *cfg)
{
/* enter the fi and si into the mtp2_link_info table for use later during init */
int fi = cfg->card-1;
int si = cfg->slot;
memset(fac_Sangoma,0,sizeof(fac_Sangoma));
fac_Sangoma[fi].card_name_number=cfg->card;
sprintf (fac_Sangoma[fi].card_name, "wanpipe%u", fac_Sangoma[fi].card_name_number);
fac_Sangoma[fi].frames_in_packet= cfg->mtu ? cfg->mtu : 80;
fac_Sangoma[fi].clear_channel= cfg->clear_ch;
fac_Sangoma[fi].configured = MARK;
/* derived interface name: wXgY where X is the numeral in the card name
* and Y is si + 1 */
sprintf (fac_Sangoma[fi].link_cfg[si].if_name, "w%ug%u", fac_Sangoma[fi].card_name_number, si + 1);
/* get linkset and link index */
fac_Sangoma[fi].link_cfg[si].linkset = cfg->linkset;
fac_Sangoma[fi].link_cfg[si].link = cfg->link;
/* read and apply timer values */
fac_Sangoma[fi].link_cfg[si].cfg_T1 = cfg->cfg_T1 ? cfg->cfg_T1 : MTP2_SEC_MS(13.0);
fac_Sangoma[fi].link_cfg[si].cfg_T2 = cfg->cfg_T2 ? cfg->cfg_T2 : MTP2_SEC_MS(11.5);
fac_Sangoma[fi].link_cfg[si].cfg_T3 = cfg->cfg_T3 ? cfg->cfg_T3 : MTP2_SEC_MS(11.5);
fac_Sangoma[fi].link_cfg[si].cfg_T4Pe = cfg->cfg_T4Pe ? cfg->cfg_T4Pe : MTP2_SEC_MS(0.6);
fac_Sangoma[fi].link_cfg[si].cfg_T4Pn = cfg->cfg_T4Pn ? cfg->cfg_T4Pn : MTP2_SEC_MS(2.3);
fac_Sangoma[fi].link_cfg[si].cfg_T5 = cfg->cfg_T5 ? cfg->cfg_T5 : MTP2_SEC_MS(0.12);
fac_Sangoma[fi].link_cfg[si].cfg_T6 = cfg->cfg_T6 ? cfg->cfg_T6 : MTP2_SEC_MS(3.0);
fac_Sangoma[fi].link_cfg[si].cfg_T7 = cfg->cfg_T7 ? cfg->cfg_T7 : MTP2_SEC_MS(1.0);
fac_Sangoma[fi].link_cfg[si].configured = MARK;
printf("Stopping fi=%i si=%i linkset=%i link=%i\n",
fi,si,cfg->linkset,cfg->link);
cfg->facility=fi;
return xmtp2_unconfig (fd);
}
int xmtp2_conf_link (int fd, xmtp_cfg_link_info_t *cfg)
{
/* enter the fi and si into the mtp2_link_info table for use later during init */
int fi = cfg->card-1;
int si = cfg->slot;
memset(fac_Sangoma,0,sizeof(fac_Sangoma));
fac_Sangoma[fi].card_name_number=cfg->card;
sprintf (fac_Sangoma[fi].card_name, "wanpipe%u", fac_Sangoma[fi].card_name_number);
fac_Sangoma[fi].frames_in_packet=cfg->mtu;
fac_Sangoma[fi].clear_channel= cfg->clear_ch;
fac_Sangoma[fi].configured = MARK;
/* derived interface name: wXgY where X is the numeral in the card name
* and Y is si + 1 */
sprintf (fac_Sangoma[fi].link_cfg[si].if_name, "w%ug%u", fac_Sangoma[fi].card_name_number, si + 1);
/* get linkset and link index */
fac_Sangoma[fi].link_cfg[si].linkset = cfg->linkset;
fac_Sangoma[fi].link_cfg[si].link = cfg->link;
/* read and apply timer values */
fac_Sangoma[fi].link_cfg[si].cfg_T1 = cfg->cfg_T1 ? cfg->cfg_T1 : MTP2_SEC_MS(13.0);
fac_Sangoma[fi].link_cfg[si].cfg_T2 = cfg->cfg_T2 ? cfg->cfg_T2 : MTP2_SEC_MS(11.5);
fac_Sangoma[fi].link_cfg[si].cfg_T3 = cfg->cfg_T3 ? cfg->cfg_T3 : MTP2_SEC_MS(11.5);
fac_Sangoma[fi].link_cfg[si].cfg_T4Pe = cfg->cfg_T4Pe ? cfg->cfg_T4Pe : MTP2_SEC_MS(0.6);
fac_Sangoma[fi].link_cfg[si].cfg_T4Pn = cfg->cfg_T4Pn ? cfg->cfg_T4Pn : MTP2_SEC_MS(2.3);
fac_Sangoma[fi].link_cfg[si].cfg_T5 = cfg->cfg_T5 ? cfg->cfg_T5 : MTP2_SEC_MS(0.12);
fac_Sangoma[fi].link_cfg[si].cfg_T6 = cfg->cfg_T6 ? cfg->cfg_T6 : MTP2_SEC_MS(3.0);
fac_Sangoma[fi].link_cfg[si].cfg_T7 = cfg->cfg_T7 ? cfg->cfg_T7 : MTP2_SEC_MS(1.0);
fac_Sangoma[fi].link_cfg[si].configured = MARK;
printf("Configuring fi=%i si=%i linkset=%i link=%i\n",
fi,si,cfg->linkset,cfg->link);
cfg->facility=fi;
return xmtp2_config (fd);
}
/*===================================================================
* xmtp2_cmd
*==================================================================*/
int xmtp2_cmd (
int xmtp2km_fd,
const unsigned int linkset,
const unsigned int link,
const unsigned int cause,
const unsigned int caller)
{
unsigned int cmd = 0;
int r=-1;
t_linkset_link linkset_link;
linkset_link.linkset = linkset;
linkset_link.link = link;
linkset_link.caller = caller;
switch (cause)
{
case LSC_CAUSE_POWER_ON:
cmd = XMTP2KM_IOCS_PWR_ON;
break;
case LSC_CAUSE_EMERGENCY:
cmd = XMTP2KM_IOCS_EMERGENCY;
break;
case LSC_CAUSE_EMERGENCY_CEASES:
cmd = XMTP2KM_IOCS_EMERGENCY_CEASES;
break;
case LSC_CAUSE_START:
cmd = XMTP2KM_IOCS_STARTLINK;
break;
case LSC_CAUSE_STOP:
cmd = XMTP2KM_IOCS_STOPLINK;
break;
default:
info_u (__FILE__, __FUNCTION__,0, "lsc invalid cause ",cause);
return 1;
}
r = ioctl (xmtp2km_fd, cmd, &linkset_link);
if (r)
{
info_u (__FILE__, __FUNCTION__,0,
"ioctl failed:retval/cause follows", r);
return r;
}
info_u (__FILE__, __FUNCTION__, 3,
"cause follows", cause);
return r;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_power_on_links (int fd)
{
int i;
int err=-1;
for (i = 0; i < MAX_FACILITIES; i++)
{
if (!fac_Sangoma[i].configured) continue;
info_u (__FILE__, __FUNCTION__, 0,
"facility configured:facility index follows", i);
int j;
for (j=0; j<E1_CHANNELS_IN_FRAME; j++)
{
if (fac_Sangoma[i].link_cfg[j].configured)
{
int ls = fac_Sangoma[i].link_cfg[j].linkset;
int lnk = fac_Sangoma[i].link_cfg[j].link;
err = xmtp2_cmd (fd, ls, lnk, LSC_CAUSE_POWER_ON, MGMT);
if (err) {
printf("Error: Failed power on i=%i j=%i ls=%i lnk=%i\n",
i,j,ls,lnk);
return err;
}
printf("Power on i=%i j=%i ls=%i lnk=%i\n",
i, j, ls,lnk);
#if 0
info_u (__FILE__, __FUNCTION__, 0,
"link being powered on:facility/channel/linkset/link follow", lnk);
#endif
}
}
}
return err;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_sangoma_start (int fi)
{
char cmd_string_start[64]="wanrouter start ";
strcat (cmd_string_start, fac_Sangoma[fi].card_name);
return system (cmd_string_start);
}
/*===================================================================
*
*==================================================================*/
int xmtp2_start_facilities (void)
{
int i;
int err;
for (i = 0; i < MAX_FACILITIES; i++)
{
if (! fac_Sangoma[i].configured) {
continue;
}
printf("Starting Facility %i\n",
i);
err=xmtp2_sangoma_start (i);
if (err) {
return err;
}
}
return 0;
}
int xmtp2_restart_facility (int card, int slot)
{
char cmd_string_start[64];
/* Interface not running */
sprintf(cmd_string_start,"wanrouter stop w%ig%i",card,slot+1);
system (cmd_string_start);
sprintf(cmd_string_start,"wanrouter start w%ig%i",card,slot+1);
return system (cmd_string_start);
}
int xmtp2_start_facility (int card, int slot)
{
char cmd_string_ifstatus[64];
char cmd_string_start[64];
int err;
sprintf(cmd_string_ifstatus,"ifconfig w%ig%i 2> /dev/null > /dev/null",card,slot+1);
err=system (cmd_string_ifstatus);
if (err) {
/* Interface not running */
sprintf(cmd_string_start,"wanrouter start wanpipe%i w%ig%i",card,card,slot+1);
system (cmd_string_start);
return system (cmd_string_ifstatus);
} else {
/* Interface already running */
return 0;
}
}
/*===================================================================
*
*==================================================================*/
void xmtp2_sangoma_stop (int fi)
{
char cmd_string_stop[64]="wanrouter stop ";
strcat (cmd_string_stop, fac_Sangoma[fi].card_name);
system (cmd_string_stop);
}
/*===================================================================
*
*==================================================================*/
void xmtp2_stop_facilities (void)
{
int i;
for (i = 0; i < MAX_FACILITIES; i++)
{
if (! fac_Sangoma[i].configured) continue;
xmtp2_sangoma_stop (i);
}
}
/*===================================================================
*
*==================================================================*/
int xmtp2_report_link_load (int xmtp2km_fd, t_link_opm *opm_table)
{
opm_table[0].ls = -1;
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCG_GETOPM, (uint8_t *)opm_table);
if (r < 0)
{
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCG_GETOPM,:retval follows", r);
return r;
}
int i;
for (i=0; i < MAX_MTP2LINKS; i++)
{
if (opm_table[i].ls < 0) break;
xmtp2_link_util_report (
opm_table[i].ls,
opm_table[i].link,
opm_table[i].msu_octet_count,
opm_table[i].total_octet_count);
}
return 0;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_retrieve_bsnt (
int xmtp2km_fd,
const unsigned int linkset,
const unsigned int link,
const unsigned int caller)
{
t_bsnt retrieve_bsnt_msg;
retrieve_bsnt_msg.ls = linkset;
retrieve_bsnt_msg.link = link;
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCX_GETBSNT, (uint8_t *)&retrieve_bsnt_msg);
if (r < 0)
{
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCX_GETBSNT:retval follows", r);
return r;
}
if (retrieve_bsnt_msg.bsnt_retrieved == BSNT_RETRIEVED) {
/* local bsnt retrieved */
} else {
/* local bsnt canceled */
}
/* retrieve_bsnt_msg.bsnt; */
return retrieve_bsnt_msg.bsnt_retrieved;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_send_msu (int xmtp2km_fd, t_su_buf * p_msu)
{
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCS_PUTMSU, p_msu);
if (r < 0)
{
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCS_PUTMSU:retval follows", r);
return r;
}
return 0;
}
/*===================================================================
*
*==================================================================*/
int xmtp2_read_msu(int xmtp2km_fd, t_su_buf * p_msu)
{
int r = ioctl (xmtp2km_fd, XMTP2KM_IOCG_GETMSU, p_msu);
if (r < 0){
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCG_GETMSU:retval and p_msu follow", r);
return -1;
}
return r;
}
/*===================================================================
*
*==================================================================*/
void xmtp2_print_mem_hex_ascii (FILE * p_fd, uint8_t *buff, int len)
{
int i=0, j=0, c=0, printnext = 1;
fprintf (p_fd, "\tMARK < >\n");
fprintf (p_fd, "-------------------------------------------------------------------------\n");
if (len)
{
if (len % 16) c = len + (16 - len % 16);
else c = len;
}
else c = len;
for (i = 0; i < c; i++)
{
if (printnext) { printnext--; fprintf (p_fd, "%.4x ", i & 0xffff); }
if (i < len) fprintf (p_fd, "%3.2x", buff[i]&0xff);
else fprintf (p_fd, " ");
if (!((i+1)%8))
{
if ((i+1)%16) fprintf (p_fd, " -");
else
{
fprintf (p_fd, " ");
for(j = i - 15; j <= i; j++)
{
if (j < len)
{
if ( (buff[j] & 0xff) >= 0x20 && (buff[j] & 0xff) <= 0x7e)
fprintf (p_fd, "%c", buff[j]&0xff);
else fprintf (p_fd, ".");
}
else fprintf (p_fd, " ");
}
fprintf (p_fd, "\n");
printnext = 1;
}
}
}
fprintf (p_fd, "-------------------------------------------------------------------------\n\n");
}
/*===================================================================
*
*==================================================================*/
void xmtp2_print_msu (t_su_buf * p_msu2)
{
xmtp2_print_mem_hex_ascii (stdout, p_msu2->su_buf, p_msu2->hdr.su_octet_count);
fflush (stdout);
}

View File

@ -1,481 +0,0 @@
/*****************************************************************************
* libxmtp2.h SS7 MTP2 API Library
*
* Author(s): Mike Mueller <ss7box@gmail.com
* Nenad Corbic <ncorbic@sangoma.com>
*
*
* Copyright: (c) 2008 Xygnada Technologies
* Sangoma Technologies Inc.
*
* ============================================================================
*/
#ifndef _LIBXMTP2_
#define _LIBXMTP2_
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.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>
#define MARK 1
#define MTP2_SEC_MS(sec) (sec*1000000)
#define XMTP2_VERSION 1.6
/*=================================================================
* Ioctl definitions
*===============================================================*/
/* needed for the _IOW etc stuff used later */
#include <linux/ioctl.h>
/* Use '7' as magic number */
#define XMTP2KM_IOC_MAGIC '7'
#define XMTP2KM_IOCRESET _IO(XMTP2KM_IOC_MAGIC, 0)
/*
* S means "Set" through a ptr,
* T means "Tell" directly with the argument value
* G means "Get": reply by setting through a pointer
* Q means "Query": response is on the return value
* X means "eXchange": G and S atomically
* H means "sHift": T and Q atomically
*/
#define XMTP2KM_IOCS_BINIT _IOW (XMTP2KM_IOC_MAGIC, 1, uint8_t *)
#define XMTP2KM_IOCS_OPSPARMS _IOW (XMTP2KM_IOC_MAGIC, 2, uint8_t *)
#define XMTP2KM_IOCS_PWR_ON _IOW (XMTP2KM_IOC_MAGIC, 3, uint8_t *)
#define XMTP2KM_IOCS_EMERGENCY _IOW (XMTP2KM_IOC_MAGIC, 4, uint8_t *)
#define XMTP2KM_IOCS_EMERGENCY_CEASES _IOW (XMTP2KM_IOC_MAGIC, 5, uint8_t *)
#define XMTP2KM_IOCS_STARTLINK _IOW (XMTP2KM_IOC_MAGIC, 6, uint8_t *)
#define XMTP2KM_IOCG_GETMSU _IOR (XMTP2KM_IOC_MAGIC, 7, uint8_t *)
#define XMTP2KM_IOCS_PUTMSU _IOW (XMTP2KM_IOC_MAGIC, 8, uint8_t *)
#define XMTP2KM_IOCX_GETTBQ _IOWR(XMTP2KM_IOC_MAGIC, 9, uint8_t *)
#define XMTP2KM_IOCS_LNKRCVY _IOW (XMTP2KM_IOC_MAGIC, 10, uint32_t)
#define XMTP2KM_IOCX_GETBSNT _IOWR(XMTP2KM_IOC_MAGIC, 11, uint8_t *)
#define XMTP2KM_IOCS_STOPLINK _IOW (XMTP2KM_IOC_MAGIC, 12, uint8_t *)
#define XMTP2KM_IOCG_GETOPM _IOR (XMTP2KM_IOC_MAGIC, 13, uint8_t *)
#define XMTP2KM_IOCS_STOP_FAC _IOR (XMTP2KM_IOC_MAGIC, 14, uint8_t *)
/*
* The other entities only have "Tell" and "Query", because they're
* not printed in the book, and there's no need to have all six.
* (The previous stuff was only there to show different ways to do it.
*/
/* ... more to come */
#define XMTP2KM_IOCHARDRESET _IO(XMTP2KM_IOC_MAGIC, 15) /* debugging tool */
#define XMTP2KM_IOC_MAXNR 15
/*=================================================================
* Config defines
*===============================================================*/
enum e_parser_controls
{
NEW_LINE,
CURRENT_LINE,
};
enum e_protocol_types
{
PT_MTP3 = 1,
PT_M3UA = 2,
};
enum facility_types
{
FACILITY_TYPE_NONE = 0,
FACILITY_TYPE_T1 = 1,
FACILITY_TYPE_E1 = 2,
FACILITY_TYPE_DDS = 3,
FACILITY_TYPE_UDP = 4,
FACILITY_TYPE_ATMII = 5,
};
/*=================================================================
* Facilities defines
*===============================================================*/
#define MAX_CHANNELS_IN_FRAME 32
#define T1_CHANNELS_IN_FRAME 24
#define E1_CHANNELS_IN_FRAME 31
#define DDS_CHANNELS_IN_FRAME 1
#define MAX_RX_DATA 1024 * 16
#define CARD_IF_NAME_LEN 31
#define NUM_CHAN_T1 24
#define NUM_CHAN_E1 31
#define MAX_TRUNK_GROUPS 16
#define MAX_SPAN_PER_TG 16
#define MAX_CHANS_PER_SPAN NUM_CHAN_E1
#define MAX_CHAN_INDEX MAX_CHANS_PER_SPAN - 1
#define MAX_SPANS 16
#define MAX_SPAN_INDEX MAX_SPANS - 1
#define MAX_CHANS MAX_CHANS_PER_SPAN * MAX_SPANS
//#define MAX_NON_VOICE_CHAN_PER_SPAN 10
//#define NUM_CHAN_T3 672
//#define NUM_CHAN_E3 512
//#define MAX_SPANS MAX_SPAN_PER_TG * MAX_TRUNK_GROUPS
//#define DOUBLE_MAX_CHAN MAX_CHAN * 2
enum ss7box_system_limits
{
MAX_FACILITIES = 8,
MAX_MTP2LINKS = 248, /* 8 E1 fully loaded with signalling */
MAX_MTP3LINKSETS = 248,
MAX_PATHS = 248,
MAX_MTP3SLS = 32,
MAX_MTP3_LINKS_IN_LSET = 16,
MAX_ROUTEPATHS = 248,
MAX_ROUTES = 248,
MAX_UDPLINKS = 2,
};
/* for each link define 128 buffers for rx, 128 for tx, and 128 for retransmission */
#define NUM_BFRS_PER_LINK 3 * 128
/* double the buffer pool size: one pool each for MTP3 and MTP2 */
#define B_POOL_SIZE 2 * MAX_MTP2LINKS * NUM_BFRS_PER_LINK
/*=================================================================
* Facilities definitions
*===============================================================*/
typedef struct
{
uint32_t configured;
uint32_t linkset;
uint32_t link;
char if_name[CARD_IF_NAME_LEN];
uint32_t cfg_T1;
uint32_t cfg_T2;
uint32_t cfg_T3;
uint32_t cfg_T4Pn;
uint32_t cfg_T4Pe;
uint32_t cfg_T5;
uint32_t cfg_T6;
uint32_t cfg_T7;
} t_link_cfg_v2;
typedef struct
{
int linkset;
int link;
int caller;
} t_linkset_link;
typedef struct
{
int enabled;
void *dev;
int (*frame)(void *ptr, int slot, int dir, unsigned char *data, int len);
}t_fac_trace_tap;
typedef struct
{
int configured;
int status;
int delay;
int distress_counter;
int type;
int frames_in_packet;
//int channels_in_frame;
int clear_channel;
int card_name_number;
char card_name[CARD_IF_NAME_LEN];
t_link_cfg_v2 link_cfg[E1_CHANNELS_IN_FRAME];
unsigned int bs_block_lost_warning_limit;
t_fac_trace_tap tap; /* For internal use not to be used by api */
int pcr_error_correction; /* Enable pcr error correction */
} t_fac_Sangoma_v2;
enum e_link_recovery_commands
{
LNKRCVY_ON = -1,
LNKRCVY_OFF = 0
};
enum e_bsnt_retrieved_indicators
{
BSNT_RETRIEVED =2,
BSNT_NOT_RETRIEVED =3
};
#pragma pack(1)
/* PACKED STRUCTURE */
typedef struct
{
uint8_t cmd ;
uint8_t fi ;
uint8_t si ;
uint8_t spare ;
} t_lnkrcvy;
/* PACKED STRUCTURE */
typedef struct
{
uint8_t ls ;
uint8_t link ;
uint8_t bsnt ;
uint8_t bsnt_retrieved ;
} t_bsnt;
#pragma pack()
/*=================================================================
* SU Buffer definitions
*===============================================================*/
#define SU_BFR_SIZE 300
typedef struct
{
unsigned int facility;
unsigned int slot;
unsigned int linkset;
unsigned int link;
unsigned int clear_ch;
unsigned int card;
unsigned int mtu;
uint32_t cfg_T1;
uint32_t cfg_T2;
uint32_t cfg_T3;
uint32_t cfg_T4Pn;
uint32_t cfg_T4Pe;
uint32_t cfg_T5;
uint32_t cfg_T6;
uint32_t cfg_T7;
}xmtp_cfg_link_info_t;
typedef struct
{
/* if anything is changed from here to... */
void * p_next; /* buffer pool linked list pointer */
int inuse;
int from_crosslink;
char ac[48];
unsigned int facility;
unsigned int slot;
unsigned int linkset;
unsigned int link;
unsigned int called;
unsigned int caller;
unsigned int msg_type; /* see e_mtp2_mtp3_interface_causes below */
unsigned int su_octet_count; /* includes the BSN, FSN , LI and
CHKSUM (2 bytes) = 5 bytes */
} t_su_buf_hdr;
typedef struct
{
t_su_buf_hdr hdr;
uint8_t su_buf[SU_BFR_SIZE];
} t_su_buf;
enum e_functional_entities
{
MGMT = -1,
L3 = 1,
LSC = 2,
IAC = 3,
RXC = 4,
TXC = 5,
DAEDR = 6,
DAEDT = 7,
SUERM = 8,
AERM = 9,
TIMER = 10,
FAC_SANGOMA = 11,
TXC_1 = 12,
FAC_ADAX = 13,
ATM_SAAL = 14
};
enum e_mtp2_mtp3_interface_causes
{
/* MTP3->MTP2 Generic values */
TX_MESSAGE =100,
EMERGENCY =101,
EMERGENCY_CEASE =102,
START =103,
STOP =104,
RETRIEVE_BSNT =105,
RETRIEVAL_REQUEST_AND_FSNC =106,
RESUME =107,
CLEAR_BUFFERS =108,
/* MTP2->MTP3 Generic values */
IN_SERVICE =300,
OUT_OF_SERVICE =301,
REMOTE_PROCESSOR_OUTAGE =302,
REMOTE_PROCESSOR_RECOVERED =303,
RTB_CLEARED =304,
RX_MESSAGE =305,
RX_BUF_CLEARED =306,
BSNT =307,
RETRIEVED_MESSAGES =308,
RETRIEVAL_COMPLETE =309,
LINK_CONGESTION_ONSET_TX =310,
LINK_CONGESTION_ONSET_RX =311,
LINK_CONGESTION_CEASE_TX =312,
LINK_CONGESTION_CEASE_RX =313,
LINK_CONNECTED =314,
LINK_NOT_CONNECTED =315,
};
enum e_mtp2_lsc_causes
{
LSC_CAUSE_POWER_ON = 0,
LSC_CAUSE_START = 1,
LSC_CAUSE_STOP = 2,
LSC_CAUSE_RETRIEVE_BSNT = 3,
LSC_CAUSE_RETRIEVAL_REQUEST_AND_FSNC = 4,
LSC_CAUSE_EMERGENCY = 5,
LSC_CAUSE_EMERGENCY_CEASES = 6,
LSC_CAUSE_LOCAL_PROCESSOR_OUTAGE = 7,
LSC_CAUSE_RESUME = 8,
LSC_CAUSE_CLEAR_BUFFERS = 9,
LSC_CAUSE_ALIGNMENT_COMPLETE = 10,
LSC_CAUSE_ALIGNMENT_NOT_POSSIBLE = 11,
LSC_CAUSE_LINK_FAILURE = 12,
LSC_CAUSE_FISU_MSU_RECEIVED = 13,
LSC_CAUSE_SIPO = 14,
LSC_CAUSE_SIO = 15,
LSC_CAUSE_SIN = 16,
LSC_CAUSE_SIE = 17,
LSC_CAUSE_SIOS = 18,
LSC_CAUSE_T1_EXPIRY = 19,
LSC_CAUSE_CLEAR_RTB = 20,
LSC_CAUSE_CLEAR_RTB_COMPLETE = 21,
};
typedef struct
{
int32_t ls;
int32_t link;
uint32_t total_octet_count;
uint32_t msu_octet_count;
} t_link_opm;
enum e_mtp3_entities
{
/* SMH */
HMDC = 0 + 100,
HMDT = 1 + 100,
HMRT = 2 + 100,
HMCG = 3 + 100,
/* STM */
TSFC = 4 + 100,
TCRC = 5 + 100,
TFRC = 6 + 100,
TRCC = 7 + 100,
TCBC = 8 + 100,
TCOC = 9 + 100,
TPRC = 10 + 100,
TSRC = 11 + 100,
TLAC = 12 + 100,
/* SLM */
LLSC = 13 + 100,
LSAC = 14 + 100,
#if 0
LSLA = 15 + 100, /* not used in this implementation */
LSLR = 16 + 100, /* not used in this implementation */
LSLD = 17 + 100, /* not used in this implementation */
LSDA = 18 + 100, /* not used in this implementation */
LSTA = 19 + 100, /* not used in this implementation */
#endif
/* SRM */
RTRC = 20 + 100,
RTPC = 21 + 100,
RSRT = 22 + 100,
RTAC = 23 + 100,
/* SLTC */
SLTC = 24 + 100,
/* Level 4 */
LVL4 = 25 + 100,
/* MTP3 timer facility */
MTP3_TIMER = 26 + 100,
/* Crosslink */
CROSSLINK = 27 + 100,
};
typedef struct
{
int fi;
int si;
} mtp2link_info_t;
/*=================================================================
* Prototypes
*===============================================================*/
void info_u (
const char * object,
const char * location,
int group,
const char * cause,
const unsigned int detail
);
void xmtp2_link_util_report (
const unsigned int ls,
const unsigned int link,
const unsigned int msu_octet_count,
const unsigned int total_octet_count
);
int xmtp2_init(void);
int xmtp2_load(void);
int xmtp2_open (void);
int xmtp2_conf_link (int fd, xmtp_cfg_link_info_t *cfg);
int xmtp2_stop_link (int fd, xmtp_cfg_link_info_t *cfg);
int xmtp2_cmd (
int xmtp2km_fd,
const unsigned int linkset,
const unsigned int link,
const unsigned int cause,
const unsigned int caller);
int xmtp2_power_on_links (int fd);
int xmtp2_sangoma_start (int fi);
int xmtp2_start_facilities (void);
void xmtp2_sangoma_stop (int fi);
void xmtp2_stop_facilities (void);
int xmtp2_start_facility (int card, int slot);
int xmtp2_restart_facility (int card, int slot);
int xmtp2_report_link_load (int xmtp2km_fd, t_link_opm *opm_table);
int xmtp2_retrieve_bsnt (int xmtp2km_fd, const unsigned int linkset,
const unsigned int link, const unsigned int caller);
int xmtp2_send_msu (int xmtp2km_fd, t_su_buf * p_msu);
int xmtp2_read_msu(int xmtp2km_fd, t_su_buf * p_msu);
void xmtp2_print_msu (t_su_buf * p_msu2);
int xmtp2_unload(void);
int xmtp2_close(int fd);
#endif

View File

@ -1,634 +0,0 @@
/*****************************************************************************
* mpt2api.c SS7 MTP2 API Example Code
*
* Author(s): Nenad Corbic <ncorbic@sangoma.com>
* Michael Mueller <mmueller@gmail.com>
*
* Copyright: (c) 2003-2010 Sangoma Technologies Inc.
* Xygnada Technologies.
* ============================================================================
*
* 1.6 Nenad Corbic <ncorbic@sangoma.com>
* May 28 2010
* Updated for 8 E1 worth of links.
* Synched up with latest xmtp2 code
*
* 1.5 Nenad Corbic <ncorbic@sangoma.com>
* Sep 02 2009
* Updated for full t1/e1 config
*
* 1.4 Nenad Corbic <ncorbic@sangoma.com>
* Aug 19 2009
* Updated for full t1/e1 config
*
* 1.2 Nenad Corbic <ncorbic@sangoma.com>
* May 21 2008
* Updated so mtp2 links can be configured and
* reconfigured on the fly.
*
* 1.1 Nenad Corbic <ncorbic@sangoma.com>
* May 1 2008
* Updated MTP2 Timer configuration
*
* 1.0 Nenad Corbic <ncorbic@sangoma.com>
* May 1 2008
* Initial Version
*/
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/time.h>
#include <time.h>
#include <sys/socket.h>
#include <netinet/in.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 "libxmtp2.h"
/*===================================================================
* Local Defines
*==================================================================*/
static int mtp2api_exit=0;
static int mtp2api_reconfig=0;
#define MAX_MTP2_DEVS 0xFFFF
#define MTP2_DEV_KEY(_lset,_link) ((_lset&0xFF) << 8 | (_link&0xFF))
typedef struct mtp2_dev
{
xmtp_cfg_link_info_t cfg;
int state;
int init;
int fd;
int (*rx_msu)(struct mtp2_dev *dev, t_su_buf * p_msu);
int (*state_change)(struct mtp2_dev *dev, int state);
} mtp2_dev_t;
mtp2_dev_t mtp2_dev_idx[MAX_MTP2_DEVS];
/*===================================================================
* state_change : callback function
*
* Change of MTP2 State
*
*==================================================================*/
int mtp2_state_change (struct mtp2_dev *dev, int state)
{
printf("MTP2 LinkSet %i Link %i State Change %i\n",
dev->cfg.linkset, dev->cfg.link, state);
/* FIXME: Do something with state change */
dev->state = state;
return 0;
}
/*===================================================================
* rx_msu : callback function
*
* Received MSU packet.
* Return 0: This function takes control over p_msu
* Return Non 0: Lower layer will free p_msu
*==================================================================*/
int mtp2_rx_msu (struct mtp2_dev *dev, t_su_buf * p_msu)
{
int data_len;
unsigned char *data;
printf("MTP2 LinkSet %i Link %i Received MSU Len=%i\n",
dev->cfg.linkset, dev->cfg.link,p_msu->hdr.su_octet_count);
/* The su_octet_count contains 3 bytes header and 2 bytes crc
* To get true data len we must decrement the octet_cout by 5 */
data_len = p_msu->hdr.su_octet_count - 5;
/* First 3 bytes are mtp2 header and last 2 are crc */
data = (unsigned char*)&p_msu->su_buf[3];
/* FIXME: Do something with received MSU */
xmtp2_print_msu(p_msu);
free(p_msu);
return 0;
}
/*===================================================================
* transfer_L2_to_L3
*
* Read xmtp2 packets and determine the packet type
*==================================================================*/
int transfer_L2_to_L3 (int xmtp2km_fd)
{
t_su_buf * p_msu;
int r;
mtp2_dev_t *mtp2dev;
X4_MTP2_TO_MTP3:
p_msu = malloc(sizeof(t_su_buf));
if (!p_msu) {
return -1;
}
memset(p_msu,0,sizeof(t_su_buf));
r = xmtp2_read_msu(xmtp2km_fd,p_msu);
if (r < 0){
info_u (__FILE__, __FUNCTION__,0,
"failed:ioctl XMTP2KM_IOCG_GETMSU:retval and p_msu follow", r);
return -1;
}
if (r == 0){
free (p_msu);
return r;
}
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(p_msu->hdr.linkset,p_msu->hdr.link)];
if (!mtp2dev->init) {
printf("Error: Device for Linkset %i and Link %i Not inialized!\n",
p_msu->hdr.linkset,p_msu->hdr.link);
free (p_msu);
return r;
}
/* distribute messages and indicators from L2 to L3 */
switch (p_msu->hdr.msg_type)
{
case LINK_CONNECTED:
info_u (__FILE__, __FUNCTION__,0,
"facility LINK_CONNECTED:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
xmtp2_cmd (xmtp2km_fd, p_msu->hdr.linkset, p_msu->hdr.link, LSC_CAUSE_START, LSAC);
break;
case LINK_NOT_CONNECTED:
info_u (__FILE__, __FUNCTION__,0,
"facility LINK_NOT_CONNECTED:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
break;
case IN_SERVICE:
info_u (__FILE__, __FUNCTION__,0,
"facility IN_SERVICE:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
break;
case OUT_OF_SERVICE:
info_u (__FILE__, __FUNCTION__,0,
"facility OUT_OF_SERVICE:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
xmtp2_cmd (xmtp2km_fd, p_msu->hdr.linkset, p_msu->hdr.link, LSC_CAUSE_START, LSAC);
break;
case REMOTE_PROCESSOR_OUTAGE:
info_u (__FILE__, __FUNCTION__,0,
"facility REMOTE_PROCESSOR_OUTAGE:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
break;
case REMOTE_PROCESSOR_RECOVERED:
info_u (__FILE__, __FUNCTION__,0,
"facility REMOTE_PROCESSOR_RECOVERED:facility/slot follow", p_msu->hdr.facility);
if (mtp2dev->state_change) {
mtp2dev->state_change(mtp2dev,p_msu->hdr.msg_type);
}
break;
case RTB_CLEARED:
info_u ( __FILE__, __FUNCTION__,0,
"RTB_CLEARED msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case RX_MESSAGE:
info_u ( __FILE__, __FUNCTION__,0,
"RX_MESSAGE msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
if (mtp2dev->rx_msu) {
int err=mtp2dev->rx_msu(mtp2dev,p_msu);
if (err == 0) {
/* The higher layer has the p_msu */
p_msu=NULL;
}
}
break;
case RX_BUF_CLEARED:
info_u ( __FILE__, __FUNCTION__,0,
"RX_BUF_CLEARED msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case BSNT:
info_u ( __FILE__, __FUNCTION__,0,
"BSNT msg not handled with reply msg:fac/slot/ls/link follow",
p_msu->hdr.facility);
/* ERROR */
break;
case RETRIEVED_MESSAGES:
info_u ( __FILE__, __FUNCTION__,0,
"RETRIEVED_MESSAGES msg not handled with reply msg:fac/slot/ls/link follow",
p_msu->hdr.facility);
/* ERROR */
break;
case RETRIEVAL_COMPLETE:
info_u ( __FILE__, __FUNCTION__,0,
"RETRIEVAL_COMPLETE msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case LINK_CONGESTION_ONSET_TX:
info_u ( __FILE__, __FUNCTION__,0,
"LINK_CONGESTION_ONSET_TX msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case LINK_CONGESTION_ONSET_RX:
info_u ( __FILE__, __FUNCTION__,0,
"LINK_CONGESTION_ONSET_RX msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case LINK_CONGESTION_CEASE_TX:
info_u ( __FILE__, __FUNCTION__,0,
"LINK_CONGESTION_CEASE_TX msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
case LINK_CONGESTION_CEASE_RX:
info_u ( __FILE__, __FUNCTION__,0,
"LINK_CONGESTION_CEASE_RX msg :fac/slot/ls/link follow",
p_msu->hdr.facility);
break;
default:
info_u ( __FILE__, __FUNCTION__,0,
"msg invalid msg :fac/slot/ls/link follow",
p_msu->hdr.msg_type);
/* ERROR */
break;
} /* switch */
if (p_msu) {
free (p_msu);
}
goto X4_MTP2_TO_MTP3;
}
/*===================================================================
*
*==================================================================*/
int wait_for_input (int fd, int ms)
{
struct timeval t;
//FD_ZERO (&read_socks);
//FD_ZERO (&write_socks);
//FD_ZERO (&oob_socks);
/* blocking select */
t.tv_sec = 0;
t.tv_usec = ms*1000;
//select(maxsock + 1, &read_socks, &write_socks, &oob_socks, &t);
select(fd + 1, NULL, NULL, NULL, &t);
return 0;
}
/*===================================================================
* tx_msu
*
* Example of how to send msu packet
*==================================================================*/
int tx_msu(struct mtp2_dev *dev)
{
int i;
t_su_buf t_msu;
int data_len=10;
memset(&t_msu,0,sizeof(t_msu));
if (dev->state != IN_SERVICE) {
return -1;
}
/* Specify where the msu is going */
t_msu.hdr.facility =dev->cfg.facility;
t_msu.hdr.slot =dev->cfg.slot;
t_msu.hdr.linkset =dev->cfg.linkset;
t_msu.hdr.link =dev->cfg.link;
/* Specify msu len and data
* First 3 bytes will be overwritten by lower layer
* start data on the 4th octet */
t_msu.hdr.su_octet_count=data_len;
for (i=0;i<t_msu.hdr.su_octet_count;i++) {
t_msu.su_buf[i+3]=i;
}
/* We must add 5 bytes to octet count to account for
* 3 byte header and 2 byte crc tail -> this is explained in libxmtp2.h */
t_msu.hdr.su_octet_count+=5;
printf("LINK TX MSU f=%i,slot=%i,ls=%i,l=%i,mt=%i\n",
t_msu.hdr.facility,t_msu.hdr.slot,t_msu.hdr.linkset,
t_msu.hdr.link,t_msu.hdr.msg_type);
/* Transmit MSU */
return xmtp2_send_msu(dev->fd,&t_msu);
}
/*===================================================================
* Signal Handlers
*
* Example of how to send msu packet
*==================================================================*/
static int do_shut(int sig)
{
mtp2api_exit=1;
return 0;
}
static int do_ignore(int sig)
{
mtp2api_reconfig=1;
return 0;
}
/*===================================================================
* Main Code
*==================================================================*/
int main(int argc, char* argv[])
{
int fd;
int err;
int cnt=0;
int i;
mtp2_dev_t *mtp2dev;
/* FIXME: Used to obain full link status reports */
t_link_opm opm_table[MAX_MTP2LINKS];
memset(opm_table,0,sizeof(opm_table));
(void) signal(SIGINT,(void *) do_shut);
(void) signal(SIGPIPE,(void *) do_ignore);
(void) signal(SIGUSR1,(void *) do_ignore);
(void) signal(SIGHUP,(void *) do_shut);
xmtp2_init();
err=xmtp2_load();
if (err < 0) {
exit (-1);
}
fd = xmtp2_open();
if (fd < 0) {
exit (-1);
}
reconfig:
/* MTP2 Configuration based on wancfg_smg configurator */
#if 1
/* Configuration per T1/E1 timeslot, where a mtp2 link exists
on a singel timeslot of a T1/E1 port. In this example
we are configuring 16 mtp2 links. However, this example
can be rewritten per user config
Sample wanpipe config file: wanpipe/wanpipe1.conf.16_channels_e1
*/
for (i=0;i<16;i++) {
/* Initialize Local MTP2 Device Structure: Likset 0 Link 0 */
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(0,i)];
memset(mtp2dev,0,sizeof(mtp2_dev_t));
mtp2dev->init=1;
mtp2dev->state=LINK_NOT_CONNECTED;
mtp2dev->cfg.card=1; /* Number corresponding to wanpipe config file number: wanpipe1.conf */
mtp2dev->cfg.slot=i; /* T1/E1 timeslot/interface number -> corresponds to interface number
in wanpipe interface name - w1g1 in wanpipe1.conf */
mtp2dev->cfg.clear_ch=1; /* 1=8bit hdlc 0=7bit hdlc */
mtp2dev->cfg.linkset=0; /* LinkSet number */
mtp2dev->cfg.link=i; /* Link in LinkSet */
mtp2dev->cfg.mtu=80*1; /* Block size per timeslot configured */
/* Configure MTP2 Timters */
mtp2dev->cfg.cfg_T1 = MTP2_SEC_MS(13.0);
mtp2dev->cfg.cfg_T2 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T3 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T4Pe = MTP2_SEC_MS(0.6);
mtp2dev->cfg.cfg_T4Pn = MTP2_SEC_MS(2.30);
mtp2dev->cfg.cfg_T5 = MTP2_SEC_MS(0.12);
mtp2dev->cfg.cfg_T6 = MTP2_SEC_MS(3.0);
mtp2dev->cfg.cfg_T7 = MTP2_SEC_MS(1.0);
mtp2dev->rx_msu=mtp2_rx_msu;
mtp2dev->state_change=mtp2_state_change;
mtp2dev->fd=fd;
/* Stop current MTP2 Link */
err=xmtp2_stop_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Configure MTP2 Link */
err=xmtp2_conf_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Power ON MTP2 Link */
err=xmtp2_cmd (fd, mtp2dev->cfg.linkset, mtp2dev->cfg.link, LSC_CAUSE_POWER_ON, MGMT);
if (err) {
exit(-1);
}
/* Start physical T1/E1 channel for the configured MTP2 Link
If the port is already running this command will be skipped,
The /etc/wanpipe/wanpipe#.conf file must be properly configured */
err=xmtp2_start_facility(mtp2dev->cfg.card,mtp2dev->cfg.slot);
if (err) {
exit (-1);
}
mtp2dev=NULL;
}
#else
/* Configuration for FULL T1/E1 port, where a mtp2 link exists
on all timeslot of a T1/E1 port. In this example
we are configuring 1 mtp2 link over full T1/E1.
Sample wanpipe config file: wanpipe/wanpipe1.conf.full_e1
*/
for (i=0;i<1;i++) {
/* Initialize Local MTP2 Device Structure: Likset 0 Link 0 */
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(0,i)];
memset(mtp2dev,0,sizeof(mtp2_dev_t));
mtp2dev->init=1;
mtp2dev->state=LINK_NOT_CONNECTED;
mtp2dev->cfg.card=1; /* Number corresponding to wanpipe config file number: wanpipe1.conf */
mtp2dev->cfg.slot=i; /* T1/E1 timeslot/interface number -> corresponds to interface number
in wanpipe interface name - w1g1 in wanpipe1.conf */
mtp2dev->cfg.clear_ch=1; /* 1=8bit hdlc 0=7bit hdlc */
mtp2dev->cfg.linkset=0; /* LinkSet number */
mtp2dev->cfg.link=i; /* Link in LinkSet */
mtp2dev->cfg.mtu=80*31; /* Block size per timeslot configured.
In this example its all 31 timeslosts
IMPORTANTA: wanpipe1.conf must be configured with ACTIVE_CH=ALL */
/* Configure MTP2 Timters */
mtp2dev->cfg.cfg_T1 = MTP2_SEC_MS(13.0);
mtp2dev->cfg.cfg_T2 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T3 = MTP2_SEC_MS(11.5);
mtp2dev->cfg.cfg_T4Pe = MTP2_SEC_MS(0.6);
mtp2dev->cfg.cfg_T4Pn = MTP2_SEC_MS(2.30);
mtp2dev->cfg.cfg_T5 = MTP2_SEC_MS(0.12);
mtp2dev->cfg.cfg_T6 = MTP2_SEC_MS(3.0);
mtp2dev->cfg.cfg_T7 = MTP2_SEC_MS(1.0);
mtp2dev->rx_msu=mtp2_rx_msu;
mtp2dev->state_change=mtp2_state_change;
mtp2dev->fd=fd;
/* Stop current MTP2 Link */
err=xmtp2_stop_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Configure MTP2 Link */
err=xmtp2_conf_link (fd, &mtp2dev->cfg);
if (err) {
exit(-1);
}
/* Power ON MTP2 Link */
err=xmtp2_cmd (fd, mtp2dev->cfg.linkset, mtp2dev->cfg.link, LSC_CAUSE_POWER_ON, MGMT);
if (err) {
exit(-1);
}
/* Start physical T1/E1 channel for the configured MTP2 Link
If the port is already running this command will be skipped,
The /etc/wanpipe/wanpipe#.conf file must be properly configured */
err=xmtp2_start_facility(mtp2dev->cfg.card,mtp2dev->cfg.slot);
if (err) {
exit (-1);
}
mtp2dev=NULL;
}
#endif
/* Print out full link Report */
err=xmtp2_report_link_load(fd,opm_table);
if (err) {
exit (-1);
}
/* Start the Main Loop */
for (;;) {
/* Check for any MTP2 events */
err=transfer_L2_to_L3(fd);
if (err < 0) {
exit(1);
}
/* Delay 100ms */
wait_for_input (fd,100);
/* Print out link report every 10 sec */
if (++cnt % 100 == 0) {
cnt=0;
xmtp2_report_link_load(fd,opm_table);
/* FIXME: This is just an example one would spawn a tx thread
or put the tx_msu function as part of higher state machine */
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(0,0)];
if (mtp2dev->init) {
tx_msu(mtp2dev);
}
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(1,0)];
if (mtp2dev->init) {
tx_msu(mtp2dev);
}
}
#if 0
/* Transmit each time */
mtp2dev = &mtp2_dev_idx[MTP2_DEV_KEY(0,0)];
if (mtp2dev->init) {
tx_msu(mtp2dev);
}
#endif
if (mtp2api_exit){
break;
}
if (mtp2api_reconfig){
mtp2api_reconfig=0;
goto reconfig;
}
}
xmtp2_close(fd);
#if 0
xmtp2_stop_facilities();
xmtp2_unload();
#endif
return 0;
}

View File

@ -1,56 +0,0 @@
#================================================
# WANPIPE1 Configuration File
#================================================
#
# Date: Tue Apr 29 09:32:38 UYT 2008
#
# Note: This file was generated automatically
# by /usr/sbin/wancfg program.
#
# If you want to edit this file, it is
# recommended that you use wancfg program
# to do so.
#================================================
# Sangoma Technologies Inc.
#================================================
[devices]
wanpipe1 = WAN_AFT_TE1, Comment
[interfaces]
w1g1 = wanpipe1, , XMTP2_API, Comment
[wanpipe1]
CARD_TYPE = AFT
S514CPU = A
CommPort = PRI
AUTO_PCISLOT = NO
PCISLOT = 4
PCIBUS = 5
FE_MEDIA = E1
FE_LCODE = HDB3
FE_FRAME = NCRC4
FE_LINE = 1
TE_CLOCK = MASTER
TE_REF_CLOCK = 0
TE_HIGHIMPEDANCE = NO
TE_RX_SLEVEL = 120
LBO = 120OH
TE_SIG_MODE = CCS
FE_TXTRISTATE = NO
MTU = 80
UDPPORT = 9000
TTL = 255
IGNORE_FRONT_END = NO
TDMV_HW_DTMF = NO
[w1g1]
HDLC_STREAMING = NO
ACTIVE_CH = 1
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO

View File

@ -1,238 +0,0 @@
#================================================
# WANPIPE1 Configuration File
#================================================
#
# Date: Tue Apr 29 09:32:38 UYT 2008
#
# Note: This file was generated automatically
# by /usr/sbin/wancfg program.
#
# If you want to edit this file, it is
# recommended that you use wancfg program
# to do so.
#================================================
# Sangoma Technologies Inc.
#================================================
[devices]
wanpipe1 = WAN_AFT_TE1, Comment
[interfaces]
w1g1 = wanpipe1, , XMTP2_API, Comment
w1g2 = wanpipe1, , XMTP2_API, Comment
w1g3 = wanpipe1, , XMTP2_API, Comment
w1g4 = wanpipe1, , XMTP2_API, Comment
w1g5 = wanpipe1, , XMTP2_API, Comment
w1g6 = wanpipe1, , XMTP2_API, Comment
w1g7 = wanpipe1, , XMTP2_API, Comment
w1g8 = wanpipe1, , XMTP2_API, Comment
w1g9 = wanpipe1, , XMTP2_API, Comment
w1g10 = wanpipe1, , XMTP2_API, Comment
w1g11 = wanpipe1, , XMTP2_API, Comment
w1g12 = wanpipe1, , XMTP2_API, Comment
w1g13 = wanpipe1, , XMTP2_API, Comment
w1g14 = wanpipe1, , XMTP2_API, Comment
w1g15 = wanpipe1, , XMTP2_API, Comment
w1g16 = wanpipe1, , XMTP2_API, Comment
[wanpipe1]
CARD_TYPE = AFT
S514CPU = A
CommPort = PRI
AUTO_PCISLOT = NO
PCISLOT = 4
PCIBUS = 5
FE_MEDIA = E1
FE_LCODE = HDB3
FE_FRAME = NCRC4
FE_LINE = 1
TE_CLOCK = MASTER
TE_REF_CLOCK = 0
TE_HIGHIMPEDANCE = NO
TE_RX_SLEVEL = 120
LBO = 120OH
TE_SIG_MODE = CCS
FE_TXTRISTATE = NO
MTU = 80
UDPPORT = 9000
TTL = 255
IGNORE_FRONT_END = NO
TDMV_HW_DTMF = NO
[w1g24.xmtp2]
[w1g1]
HDLC_STREAMING = NO
ACTIVE_CH = 1
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g2]
HDLC_STREAMING = NO
ACTIVE_CH = 2
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g3]
HDLC_STREAMING = NO
ACTIVE_CH = 3
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g4]
HDLC_STREAMING = NO
ACTIVE_CH = 4
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g5]
HDLC_STREAMING = NO
ACTIVE_CH = 5
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g6]
HDLC_STREAMING = NO
ACTIVE_CH = 6
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g7]
HDLC_STREAMING = NO
ACTIVE_CH = 7
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g8]
HDLC_STREAMING = NO
ACTIVE_CH = 8
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g9]
HDLC_STREAMING = NO
ACTIVE_CH = 9
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g10]
HDLC_STREAMING = NO
ACTIVE_CH = 10
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g11]
HDLC_STREAMING = NO
ACTIVE_CH = 11
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g12]
HDLC_STREAMING = NO
ACTIVE_CH = 12
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g13]
HDLC_STREAMING = NO
ACTIVE_CH = 13
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g14]
HDLC_STREAMING = NO
ACTIVE_CH = 14
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g15]
HDLC_STREAMING = NO
ACTIVE_CH = 15
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO
[w1g16]
HDLC_STREAMING = NO
ACTIVE_CH = 16
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO

View File

@ -1,56 +0,0 @@
#================================================
# WANPIPE1 Configuration File
#================================================
#
# Date: Tue Apr 29 09:32:38 UYT 2008
#
# Note: This file was generated automatically
# by /usr/sbin/wancfg program.
#
# If you want to edit this file, it is
# recommended that you use wancfg program
# to do so.
#================================================
# Sangoma Technologies Inc.
#================================================
[devices]
wanpipe1 = WAN_AFT_TE1, Comment
[interfaces]
w1g1 = wanpipe1, , XMTP2_API, Comment
[wanpipe1]
CARD_TYPE = AFT
S514CPU = A
CommPort = PRI
AUTO_PCISLOT = NO
PCISLOT = 4
PCIBUS = 5
FE_MEDIA = E1
FE_LCODE = HDB3
FE_FRAME = NCRC4
FE_LINE = 1
TE_CLOCK = MASTER
TE_REF_CLOCK = 0
TE_HIGHIMPEDANCE = NO
TE_RX_SLEVEL = 120
LBO = 120OH
TE_SIG_MODE = CCS
FE_TXTRISTATE = NO
MTU = 80
UDPPORT = 9000
TTL = 255
IGNORE_FRONT_END = NO
TDMV_HW_DTMF = NO
[w1g1]
HDLC_STREAMING = NO
ACTIVE_CH = 1
MTU = 80
MRU = 80
DATA_MUX = NO
TDMV_HWEC = NO
TRUE_ENCODING_TYPE = NO

View File

@ -1,61 +0,0 @@
#================================================
# WANPIPE1 Configuration File
#================================================
#
# Date: Tue June 12 18:18:28 EST 2007
#
# Note: This file was generated automatically
# by /usr/sbin/wancfg program.
#
# If you want to edit this file, it is
# recommended that you use wancfg program
# to do so.
#================================================
# Sangoma Technologies Inc.
#================================================
[devices]
wanpipe2 = WAN_AFT_TE1, Comment
[interfaces]
w2g1 = wanpipe2, , TDM_VOICE_API, Comment
w2g24 = wanpipe2, , XMTP2_API, Comment
[wanpipe2]
CARD_TYPE = AFT
S514CPU = A
CommPort = PRI
AUTO_PCISLOT = NO
PCISLOT = 4
PCIBUS = 5
FE_MEDIA = T1
FE_LCODE = B8ZS
FE_FRAME = ESF
FE_LINE = 2
TE_CLOCK = MASTER
TE_REF_CLOCK = 0
TE_HIGHIMPEDANCE = NO
LBO = 0DB
FE_TXTRISTATE = NO
MTU = 1500
UDPPORT = 9000
TTL = 255
IGNORE_FRONT_END = NO
TDMV_SPAN = 2
TDMV_DCHAN = 0
[w2g1]
ACTIVE_CH = 1-23
TDMV_ECHO_OFF = NO
TDMV_HWEC = no
MTU = 80
[w2g24]
ACTIVE_CH = 24
MTU = 80
MRU = 80
TDMV_ECHO_OFF = NO
TDMV_HWEC = NO

View File

@ -1,48 +0,0 @@
#!/bin/sh
#
# xmtp2km_in: xmtp2km installer
#
# Derivation: Copyright (C) 2005 Xygnada Technology, Inc.
# Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet
# Copyright (C) 2001 O'Reilly & Associates
#
# The source code in this file can be freely used, adapted,
# and redistributed in source or binary form, so long as an
# acknowledgment appears in derived source files. The citation
# should list that the code comes from the book "Linux Device
# Drivers" by Alessandro Rubini and Jonathan Corbet, published
# by O'Reilly & Associates. No warranty is attached;
# we cannot take responsibility for errors or fitness for use.
#
#
# $Id: xmtp2km_in,v 1.1 2005/12/05 17:48:45 mike01 Exp $
module="xmtp2km"
device="xmtp2km"
mode="664"
path=/lib/modules/`uname -r`/kernel/drivers/net/wan
# Group: since distributions do it differently, look for wheel or use staff
if grep -q '^staff:' /etc/group; then
group="staff"
else
group="wheel"
fi
# invoke insmod with all arguments we got
# and use a pathname, as insmod doesn't look in . by default
#/sbin/insmod ./$module.ko $* || exit 1
#/sbin/insmod /usr/src/xmtp2km/$module.ko $* || exit 1
/sbin/insmod $path/$module.ko $* || exit 1
# retrieve major number
major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
# Remove stale nodes and replace them, then give gid and perms
rm -f /dev/${device}0
mknod /dev/${device}0 c $major 0
ln -sf ${device}0 /dev/${device}
chgrp $group /dev/${device}0
chmod $mode /dev/${device}0
exit 23

View File

@ -1,237 +0,0 @@
#!/bin/sh
function adsl_get_std_item () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Standard Item \
"
menu_options="'ADSL_T1_413' 'T1.413' \
'ADSL_G_LITE' 'G.lite (G992.2)' \
'ADSL_G_DMT' 'G.dmt (G992.1)' \
'ADSL_ALCATEL_1_4' 'Alcatel 1.4' \
'ADSL_ALCATEL' 'Alcatel' \
'ADSL_ADI' 'ADI' \
'ADSL_MULTIMODE' 'Multimode (default)' \
'ADSL_T1_413_AUTO' 'T1.413 Auto' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL STANDARD ITEM " "$menu_options" 7 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_Standard=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_standard_item"
adsl_get_standard_item
;;
*) return 1
;;
esac
}
function adsl_get_trellis () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Trellis \
"
menu_options="'ADSL_TRELLIS_ENABLE' 'Enable (default)' \
'ADSL_TRELLIS_DISABLE' 'Disable' \
'ADSL_TRELLIS_LITE_ONLY_DISABLE' 'Lite only disable' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL TRELLIS " "$menu_options" 3 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_Trellis=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_trellis"
adsl_get_trellis
;;
*) return 1
;;
esac
}
function adsl_get_codinggain () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Coding Gain \
"
menu_options="'ADSL_0DB_CODING_GAIN' '0dB' \
'ADSL_1DB_CODING_GAIN' '1dB' \
'ADSL_2DB_CODING_GAIN' '2dB' \
'ADSL_3DB_CODING_GAIN' '3dB' \
'ADSL_4DB_CODING_GAIN' '4dB' \
'ADSL_5DB_CODING_GAIN' '5dB' \
'ADSL_6DB_CODING_GAIN' '6dB' \
'ADSL_7DB_CODING_GAIN' '7dB' \
'ADSL_AUTO_CODING_GAIN' 'Auto Coding Gain (default)' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL CODING GAIN " "$menu_options" 9 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_CodingGain=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_codinggain"
adsl_get_codinggain
;;
*) return 1
;;
esac
}
function adsl_get_rxbinadjust () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Rx BIN Adjust \
"
menu_options="'ADSL_RX_BIN_DISABLE' 'Disable (default)' \
'ADSL_RX_BIN_ENABLE' 'Enable' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL RX BIN ADJUST " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_RxBinAdjust=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_rxbinadjust"
adsl_get_rxbinadjust
;;
*) return 1
;;
esac
}
function adsl_get_framingtype () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Framing Structure Type \
"
menu_options="'ADSL_FRAMING_TYPE_0' 'Type 0' \
'ADSL_FRAMING_TYPE_1' 'Type 1' \
'ADSL_FRAMING_TYPE_2' 'Type 2' \
'ADSL_FRAMING_TYPE_3' 'Type 3 (default)' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL FRAMING STRUCTURE TYPE " "$menu_options" 4 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_FramingStruct=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_framingtype"
adsl_get_framingtype
;;
*) return 1
;;
esac
}
function adsl_get_expandedexchange () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Expanded Exchange \
"
menu_options="'ADSL_EXPANDED_EXCHANGE' 'Expanded (default)' \
'ADSL_SHORT_EXCHANGE' 'Short' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL Expanded Exchange " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_ExpandedExchange=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_expandedexchange"
adsl_get_expandedexchange
;;
*) return 1
;;
esac
}
function adsl_get_clocktype () {
local menu_options
local rc
local choice
menu_instr="Please specify ADSL Clock Type \
"
menu_options="'ADSL_CLOCK_CRYSTAL' 'Crystal (default)' \
'ADSL_CLOCK_OSCILLATOR' 'Oscillator' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} ADSL CLOCK TYPE " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) ADSL_ClockType=$choice #Choice is a command
return 0
;;
2) device_setup_help "adsl_get_clocktype"
adsl_get_clocktype
;;
*) return 1
;;
esac
}

File diff suppressed because it is too large Load Diff

View File

@ -1,102 +0,0 @@
function atm_interface_init()
{
local num="$1"
atm_oam_loopback[$num]=${atm_oam_loopback[$num]:-NO}
atm_oam_loopback_int[$num]=${atm_oam_loopback_int[$num]:-5}
atm_oam_cc_check[$num]=${atm_oam_cc_check[$num]:-NO}
atm_oam_cc_check_int[$num]=${atm_oam_cc_check_int[$num]:-2}
atm_arp[$num]=${atm_arp[$num]:-NO}
atm_arp_int[$num]=${atm_arp_int[$num]:-15}
}
function atm_interface_setup()
{
local rc
local num="$1"
local choice
local menu_options
atm_interface_init $num
menu_options="'atm_oam_loopback' 'OAM Loopback -----------> ${atm_oam_loopback[$num]}' \
'atm_oam_loopback_int' 'OAM Loopback Interval --> ${atm_oam_loopback_int[$num]}' \
'atm_oam_cc_check' 'OAM Continuity Check ---> ${atm_oam_cc_check[$num]}' \
'atm_oam_cc_check_int' 'OAM Continuity Interval-> ${atm_oam_cc_check_int[$num]}' \
'again' ' ' \
'atm_arp' 'ATM ARP ----------------> ${atm_arp[$num]}' \
'atm_arp_int' 'ATMARP_INT -------------> ${atm_arp_int[$num]}' 2> $MENU_TMP"
menu_instr="Please specify the ${IF_NAME[$num]}: ATM protocol parameters below \
"
menu_name "ATM ${IF_NAME[$num]} PROTOCOL SETUP" "$menu_options" 12 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
atm_oam_loopback)
warning "atm_oam_loopback"
if [ $? -eq 0 ]; then
atm_oam_loopback[$num]=YES
else
atm_oam_loopback[$num]=NO
fi
;;
atm_oam_loopback_int)
get_string "Please specify ATM OAM Loopback interval" "${atm_oam_loopback_int[$num]}"
atm_oam_loopback_int[$num]=$($GET_RC)
;;
atm_oam_cc_check)
warning "atm_oam_cc_check"
if [ $? -eq 0 ]; then
atm_oam_cc_check[$num]=YES
else
atm_oam_cc_check[$num]=NO
fi
;;
atm_oam_cc_check_int)
get_string "Please specify ATM Continuity Interval" "${atm_oam_cc_check_int[$num]}"
atm_oam_cc_check_int[$num]=$($GET_RC)
;;
atm_arp)
warning "atm_arp"
if [ $? -eq 0 ]; then
atm_arp[$num]=YES
else
atm_arp[$num]=NO
fi
;;
atm_arp_int)
get_string "Please specify ATM ARP Interval" "${atm_arp_int[$num]}"
atm_arp_int[$num]=$($GET_RC)
;;
*)
$choice #Choice is a command
;;
esac
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*)
return 1
;;
esac
}

View File

@ -1,463 +0,0 @@
#!/bin/sh
function chdlc_interface_init () {
local num=$1
if [ -z "${MULTICAST[$num]}" ]; then
MULTICAST[$num]=NO
fi
if [ -z "${DCD[$num]}" ]; then
DCD[$num]=NO
fi
if [ -z "${CTS[$num]}" ]; then
CTS[$num]=NO
fi
if [ -z "${KEEP[$num]}" ]; then
KEEP[$num]=NO
fi
if [ -z "${STREAM[$num]}" ]; then
STREAM[$num]=NO
fi
if [ -z "${TXTIME[$num]}" ]; then
TXTIME[$num]=10000
fi
if [ -z "${RXTIME[$num]}" ]; then
RXTIME[$num]=11000
fi
if [ -z "${ERR[$num]}" ]; then
ERR[$num]=5
fi
if [ -z "${SLARP[$num]}" ]; then
SLARP[$num]=0
fi
if [ -z "${TRUE_ENCODING[$num]}" ]; then
TRUE_ENCODING[$num]=NO
fi
if [ $PROTOCOL = WAN_MULTPPP ] || [ $PROTOCOL = WAN_MULTPROT ]; then
STREAM[$num]=YES
DCD[$num]=NO
CTS[$num]=NO
KEEP[$num]=YES
SLARP[$num]=0
fi
}
function chdlc_interface_setup () {
local rc
local num="$1"
local choice
local menu_options
chdlc_interface_init $num
if [ -z "${CHDLC_IPMODE[$num]}" ]; then
CHDLC_IPMODE[$num]=NO;
SLARP[$num]=0;
fi
if [ $PROTOCOL = WAN_CHDLC ]; then
menu_options="'get_slarp' 'Dynamic IP Addressing ----> ${CHDLC_IPMODE[$num]}' \
'get_multicast' 'Multicast ---------------> ${MULTICAST[$num]}' \
'get_ig_dcd' 'Ignore DCD --------------> ${DCD[$num]}' \
'get_ig_cts' 'Ignore CTS --------------> ${CTS[$num]}' \
'get_ig_keep' 'Ignore Keepalive ---------> ${KEEP[$num]}' \
'get_stream' 'HDLC Streaming -----------> ${STREAM[$num]}' \
'get_tx_time' 'Keep Alive Tx Timer ------> ${TXTIME[$num]}' \
'get_rx_time' 'Keep Alive Rx Timer ------> ${RXTIME[$num]}' \
'get_err_mar' 'Keep Alive Error Margin --> ${ERR[$num]}' \
'get_encoding' 'True_Encoding_Type -------> ${TRUE_ENCODING[$num]}' 2> $MENU_TMP"
else
menu_options="'no_opt' 'NO OPTIONS' 2> $MENU_TMP"
fi
menu_instr="Please specify the ${IF_NAME[$num]}: CHDLC protocol parameters below\
"
menu_name "CHDLC ${IF_NAME[$num]} PROTOCOL SETUP" "$menu_options" 9 "$menu_instr" "$BACK" 20
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
get_tx_time)
get_integer "Please specify the Keepalive Tx Timer" "10000" "0" "60000" "interface_setup_help get_tx_time"
TXTIME[$num]=$($GET_RC)
;;
get_rx_time)
get_integer "Please specify the Keepalive Rx Timer" "11000" "10" "60000" "interface_setup_help get_rx_time"
RXTIME[$num]=$($GET_RC)
;;
get_err_mar)
get_integer "Please specify the Keepalive Error Margin" "5" "1" "20" "interface_setup_help get_err_mar"
ERR[$num]=$($GET_RC)
;;
get_slarp)
warning get_slarp
if [ $? -eq 0 ]; then
CHDLC_IPMODE[$num]=YES
SLARP[$num]=1000
else
CHDLC_IPMODE[$num]=NO
SLARP[$num]=0
fi
;;
*)
$choice "$num" #Choice is a command
;;
esac
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*)
return 1
;;
esac
}
function get_commport () {
local menu_options
local rc
local choice
if [ $PROTOCOL = WAN_TTYPPP -a $TTY_MODE = ASYNC ]; then
menu_options="'SEC' 'Secondary' 2> $MENU_TMP"
else
menu_options="'PRI' 'Primary (default)' \
'SEC' 'Secondary' 2> $MENU_TMP"
fi
menu_instr="Please select the CHDLC Communication Port \
"
menu_name "${IF_NAME[$num]} COMM PORT CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) COMMPORT=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_commport"
get_commport
;;
*) return 1
;;
esac
}
function get_connection ()
{
local menu_options
local rc
local choice
menu_instr="Please select the CHDLC Connection Type \
"
menu_options="'Permanent' 'Permanent (default)' \
'Switched' 'Switched' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} CONNECTION TYPE " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) CONNECTION=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_connection"
get_connection
;;
*) return 1
;;
esac
}
function get_linecode () {
local menu_options
local rc
local choice
menu_instr="Please select the CHDLC Line Coding Type \
"
menu_options="'NRZ' 'NRZ (default)' \
'NRZI' 'NRZI' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} LINE CODING TYPE " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LINECODING=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_linecode"
get_linecode
;;
*) return 1
;;
esac
}
function get_lineidle () {
local menu_options
local rc
local choice
menu_instr="Please select the CHDLC Line Idle Type \
"
menu_options="'FLAG' 'Idle Flag (default)' \
'MARK' 'Idle Mark' 2> $MENU_TMP"
menu_name "${IF_NAME[$num]} LINE IDLE CONFIG " "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LINEIDLE=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_lineidle"
get_lineidle
;;
*) return 1
;;
esac
}
function get_rec_only () {
local menu_options
local rc
local choice
menu_options="'NO' 'Disable Receive Only Comm. (default)' \
'YES' 'Enable Receive Only Comm.' 2> $MENU_TMP"
menu_instr="Enable or Disable Receive Only Communications \
"
menu_name "${IF_NAME[$num]} RECEIVE ONLY CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) REC_ONLY=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_rec_only"
get_commport
;;
*) return 1
;;
esac
}
function get_ig_dcd () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Monitor Modem DCD (Default)' \
'YES' 'Ignore Modem DCD' 2> $MENU_TMP"
menu_instr="Enable or Disable DCD Monitoring \
"
menu_name "${IF_NAME[$num]}: DCD MONITORING SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) DCD[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_ig_dcd"
get_ig_dcd "$1"
;;
*) return 1
;;
esac
}
function get_ig_cts () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Monitor Modem CTS (Default)' \
'YES' 'Ignore Modem CTS' 2> $MENU_TMP"
menu_instr="Enable or Disable CTS Monitoring \
"
menu_name "${IF_NAME[$num]} CTS MONITORING SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) CTS[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_ig_cts"
get_ig_cts "$1"
;;
*) return 1
;;
esac
}
function get_modem_ignore () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'YES' 'Ignore Modem Status (Default)' \
'NO' 'Reset Protocol on Modem change' 2> $MENU_TMP"
menu_instr="Enable or Disable Modem Monitoring \
"
menu_name "${IF_NAME[$num]}: MODEM MONITORING SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) MPPP_MODEM_IGNORE[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_modem_ignore"
get_modem_ignore "$1"
;;
*) return 1
;;
esac
}
function get_ig_keep () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Activate Keep Alive (Default)' \
'YES' 'Ignore Keep Alive' 2> $MENU_TMP"
menu_instr="Enable or Disable Keep Alive Monitoring \
"
menu_name "${IF_NAME[$num]} KEEP ALIVE SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) KEEP[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_ig_keep"
get_ig_keep "$1"
;;
*) return 1
;;
esac
}
function get_stream () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Disable HDLC Streaming (Default)' \
'YES' 'Enable HDLC Streaming' 2> $MENU_TMP"
menu_instr="Enable or Disable HDLC Streaming \
"
menu_name "${IF_NAME[$num]}: HDLC STREAMING CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) STREAM[$num]=$choice #Choice is a command
if [ $choice = YES ]; then
DCD[$num]=YES
CTS[$num]=YES
KEEP[$num]=YES
else
DCD[$num]=NO
CTS[$num]=NO
KEEP[$num]=NO
fi
return 0
;;
2) interface_setup_help "get_stream"
get_stream "$1"
;;
*) return 1
;;
esac
}

View File

@ -1,370 +0,0 @@
# TE1 Select media connection for T1/E1 board.
function get_media_type () {
local choice
local rc
menu_options="'T1' 'T1 connection' \
'E1' 'E1 connection' 2> $MENU_TMP"
menu_instr="Please specify connection type. Refer to User Manual \
"
menu_name "CONNECTION TYPE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ $MEDIA != $choice ]; then
MEDIA=$choice #Choice is a command
if [ $MEDIA = T1 ]; then
LCODE="B8ZS"
FRAME="ESF"
else
LCODE="HDB3"
FRAME="NCRC4"
fi
fi
;;
2) device_setup_help "get_media_type"
get_media_type
;;
*) return 1
;;
esac
}
# TE1 Select line decoding for T1/E1 board.
function get_lcode_type () {
local choice
local rc
if [ $MEDIA = T1 ]; then
menu_options="'AMI' 'AMI line decoding' \
'B8ZS' 'B8ZS line decoding' 2> $MENU_TMP"
else
menu_options="'AMI' 'AMI line decoding' \
'HDB3' 'HDB3 line decoding' 2> $MENU_TMP"
fi
menu_instr="Please specify line decoding. Refer to User Manual \
"
menu_name "LINE DECODING" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LCODE=$choice #Choice is a command
;;
2) device_setup_help "get_lcode_type"
get_lcode_type
;;
*) return 1
;;
esac
}
# TE1 Select frame type for T1/E1 board.
function get_frame_type () {
local choice
local rc
if [ $MEDIA = T1 ]; then
menu_options="'D4' 'D4 framing format' \
'ESF' 'ESF framing format' \
'UNFRAMED' 'Unframed format' 2> $MENU_TMP"
else
menu_options="'NCRC4' 'non-CRC4 framing format' \
'CRC4' 'CRC4 framing format' \
'UNFRAMED' 'Unframed format' 2> $MENU_TMP"
fi
menu_instr="Please specify frame mode. Refer to User Manual \
"
menu_name "FRAMING FORMAT" "$menu_options" 3 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) FRAME=$choice #Choice is a command
if [ $FRAME = "UNFRAMED" ]; then
if [ $PROTOCOL = WAN_BITSTRM ]; then
init_bstrm_opt
fi
fi
;;
2) device_setup_help "get_frame_type"
get_frame_type
;;
*) return 1
;;
esac
}
# TE1 Select clock mode for T1/E1 mode.
function get_te_clock () {
local choice
local rc
menu_options="'NORMAL' 'Normal (default)' \
'MASTER' 'Master' 2> $MENU_TMP"
menu_instr="Please specify T1/E1 clock mode. Refer to User Manual \
"
menu_name "T1/E1 CLOCK MODE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) TE_CLOCK=$choice #Choice is a command
;;
2) device_setup_help "get_te_clock"
get_te_clock
;;
*) return 1
;;
esac
}
# TE1 Select LBO type for T1/E1 board (only T1 connection).
function get_lbo_type () {
local choice
local rc
menu_options="'0dB' 'CSU: 0dB' \
'7.5dB' 'CSU: 7.5dB' \
'15dB' 'CSU: 15dB' \
'22.5dB' 'CSU: 22.5dB' \
'0-110ft' 'DSX: 0-110ft' \
'110-220ft' 'DSX: 110-220ft' \
'220-330ft' 'DSX: 220-330ft' \
'330-440ft' 'DSX: 330-440ft' \
'440-550ft' 'DSX: 440-550ft' \
'550-660ft' 'DSX: 550-660ft' 2> $MENU_TMP"
menu_instr="Please specify line build out type. Refer to User Manual \
"
menu_name "LINE BUILD OUT" "$menu_options" 10 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LBO=$choice #Choice is a command
;;
2) device_setup_help "get_lbo_type"
get_lbo_type
;;
*) return 1
;;
esac
}
function get_highimpedance_type () {
local choice
local rc
menu_options="'NO' 'Disable High-Impedance mode (default)' \
'YES' 'Enable High-Impedance mode' 2> $MENU_TMP"
menu_instr="Enable or Disable High-Impedance Mode \
"
menu_name "HIGH-IMPEDANCE MODE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) HIGHIMPEDANCE=$choice #Choice is a command
;;
2) device_setup_help "get_highimpedance_type"
get_highimpedance_type
;;
*) return 1
;;
esac
}
function get_encoding () {
local choice
local rc
local num=$1
menu_options="'NO' 'RAW-Pure IP interface type' \
'YES' 'True interface encoding typy' 2> $MENU_TMP"
menu_instr="Please specify the WANPIPE interface type setting \
"
menu_name "WANPIPE INTERFACE TYPE OPTION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) TRUE_ENCODING[$num]=$choice #Choice is a command
;;
2) interface_setup_help "get_encoding"
get_encoding $num
;;
*) return 1
;;
esac
}
#------ TE3 ---------------------
# TE1 Select media connection for T1/E1 board.
function get_media_te3_type () {
local choice
local rc
menu_options="'DS3' 'DS3/T3 connection' \
'E3' 'E3 connection' 2> $MENU_TMP"
menu_instr="Please specify connection type. Refer to User Manual \
"
menu_name "CONNECTION TYPE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ $MEDIA != $choice ]; then
MEDIA=$choice #Choice is a command
if [ $MEDIA = DS3 ]; then
LCODE="B3ZS"
FRAME="C-BIT"
else
LCODE="HDB3"
FRAME="G.751"
fi
fi
;;
2) device_setup_help "get_media_te3_type"
get_media_te3_type
;;
*) return 1
;;
esac
}
# TE1 Select line decoding for T1/E1 board.
function get_lcode_te3_type () {
local choice
local rc
if [ $MEDIA = DS3 ]; then
menu_options="'B3ZS' 'B3ZS line decoding' \
'AMI' 'AMI line decoding' 2> $MENU_TMP"
else
menu_options="'HDB3' 'HDB3 line decoding' \
'AMI' 'AMI line decoding' 2> $MENU_TMP"
fi
menu_instr="Please specify line decoding. Refer to User Manual \
"
menu_name "LINE DECODING" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LCODE=$choice #Choice is a command
;;
2) device_setup_help "get_lcode_te3_type"
get_lcode_te3_type
;;
*) return 1
;;
esac
}
# TE1 Select frame type for T1/E1 board.
function get_frame_te3_type () {
local choice
local rc
if [ $MEDIA = DS3 ]; then
menu_options="'C-BIT' 'C-BIT framing format' \
'M13' 'M13 framing format' 2> $MENU_TMP"
else
menu_options="'G.751' 'G.751 framing format' \
'G.832' 'G.832 framing format' 2> $MENU_TMP"
fi
menu_instr="Please specify frame mode. Refer to User Manual \
"
menu_name "FRAMING FORMAT" "$menu_options" 3 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) FRAME=$choice #Choice is a command
;;
2) device_setup_help "get_frame_te3_type"
get_frame_te3_type
;;
*) return 1
;;
esac
}
# TE1 Select media connection for T1/E1 board.
function get_TE3_FCS () {
local choice
local rc
menu_options="'16' 'CRC 16' \
'32' 'CRC 32' 2> $MENU_TMP"
menu_instr="Please specify CRC type. Refer to User Manual \
"
menu_name "CRC/FCS TYPE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) TE3_FCS=$choice
;;
2) device_setup_help "get_TE3_FCS"
get_TE3_FCS
;;
*) return 1
;;
esac
}

View File

@ -1,448 +0,0 @@
#!/bin/sh
function fr_interface_setup () {
local rc
local num="$1"
local choice
local menu_options
if [ -z "${CIR[$num]}" ]; then
CIR[$num]=NO
fi
if [ -z "${BC[$num]}" ]; then
BC[$num]=NO
fi
if [ -z "${BE[$num]}" ]; then
BE[$num]=NO
fi
if [ -z "${MULTICAST[$num]}" ]; then
MULTICAST[$num]=NO
fi
if [ -z "${INARP[$num]}" ]; then
INARP[$num]=NO
fi
if [ -z "${INARP_INT[$num]}" ]; then
INARP_INT[$num]=0
fi
if [ -z "${TRUE_ENCODING[$num]}" ]; then
TRUE_ENCODING[$num]=NO
fi
INARP_RX[$num]=${INARP_RX[$num]:-NO}
IPX[$num]=${IPX[$num]:-NO}
NETWORK[$num]=${NETWORK[$num]:-0xDEADBEEF}
if [ ${CIR[$num]} = NO ]; then
menu_options="'get_cir' 'CIR -----------> ${CIR[$num]}' \
'get_multicast' 'MULTICAST -----------> ${MULTICAST[$num]}' \
'get_inarp' 'TX INARP -----------> ${INARP[$num]}' \
'get_inarp_int' 'INARP_INT ----------> ${INARP_INT[$num]}' \
'get_inarp_rx' 'RX INARP ------------> ${INARP_RX[$num]}' \
'get_ipx' 'IPX Support ---------> ${IPX[$num]}' \
'get_network' 'IPX Network Addr ----> ${NETWORK[$num]}' \
'get_encoding' 'True_Encoding_Type --> ${TRUE_ENCODING[$num]}' 2> $MENU_TMP"
menu_size=8
else
menu_options="'get_cir' 'CIR ----------> ${CIR[$num]}' \
'get_bc' 'BC ----------> ${BC[$num]}' \
'get_be' 'BE ----------> ${BE[$num]}' \
'get_multicast' 'MULTICAST ----------> ${MULTICAST[$num]}' \
'get_inarp' 'TX INARP ----------> ${INARP[$num]}' \
'get_inarp_int' 'INARP_INT ----------> ${INARP_INT[$num]}' \
'get_inarp_rx' 'RX INARP ------------> ${INARP_RX[$num]}' \
'get_ipx' 'IPX Support ---------> ${IPX[$num]}' \
'get_network' 'IPX Network Addr ----> ${NETWORK[$num]}' \
'get_encoding' 'True_Encoding_Type --> ${TRUE_ENCODING[$num]}' 2> $MENU_TMP"
menu_size=10
fi
menu_instr="Please configure ${IF_NAME[$num]}: Frame Relay parameters below
"
menu_name "${IF_NAME[$num]}: FRAME RELAY PROTOCOL SETUP" "$menu_options" "$menu_size" "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0)
case $choice in
get_network*)
get_string "Please specify you IPX Network Number" "0xABCDEFAB"
NETWORK[$num]=$($GET_RC)
;;
get_inarp_int*)
if [ ${INARP[$num]} = YES ]; then
arp_dflt=10
else
arp_dflt=0
fi
get_integer "Please specify InARP interval" "$arp_dflt" "0" "100" "interface_setup_help get_inarp_int"
INARP_INT[$num]=$($GET_RC)
;;
*)
$choice "$num" #Choice is a command
;;
esac
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*) if [ ${CIR[$num]} != NO ]; then
if [ ${BC[$num]} = NO ]; then
error "CIR_BC" $num
return 0
fi
if [ ${BE[$num]} = NO ]; then
error "CIR_BE" $num
return 0
fi
fi
return 1
;;
esac
}
function get_fs_issue () {
local menu_options
local rc
local choice
local num="$1"
menu_options="'YES' 'Issue Full Status on startup (default)' \
'NO' 'Disable Full Status on startup' 2> $MENU_TMP"
menu_instr="Please Enable or Disable: Frame Relay full status issue on startup \
"
menu_name "${IF_NAME[$num]}: FULL STATUS ON STARTUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) FR_ISSUE_FS=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_fs_issue"
get_fs_issue "$1"
;;
*) return 1
;;
esac
}
function get_inarp () {
local menu_options
local rc
local choice
local num="$1"
menu_options="'NO' 'Disable Inverse Arp (default)' \
'YES' 'Enable Inverse Arp' 2> $MENU_TMP"
menu_instr="Please Enable or Disable Inverse ARP Option \
"
menu_name "${IF_NAME[$num]}: INVERSE ARP SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) INARP[$num]=$choice #Choice is a command
if [ "$choice" = YES ]; then
INARP_RX[$num]=YES
INARP_INT[$num]=10
else
INARP_RX[$num]=NO
fi
return 0
;;
2) interface_setup_help "get_inarp"
get_inarp "$1"
;;
*) return 1
;;
esac
}
function get_inarp_rx () {
local menu_options
local rc
local choice
local num="$1"
menu_options="'NO' 'Ignore Incoming Inverse Arps (default)' \
'YES' 'Handle Incoming Inverse Arps' 2> $MENU_TMP"
menu_instr="Please Enable or Disable Incoming Inverse ARP Support \
"
menu_name "${IF_NAME[$num]}: INVERSE ARP RECEPTION SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ ${INARP[$num]} != YES ]; then
INARP_RX[$num]=$choice #Choice is a command
else
INARP_RX[$num]=YES
fi
return 0
;;
2) interface_setup_help "get_inarp_rx"
get_inarp "$1"
;;
*) return 1
;;
esac
}
function get_be () {
local menu_options
local rc
local choice
local num="$1"
menu_options="'NO' 'Disable BE (Default)' \
'custom' 'Custom Config' 2> $MENU_TMP"
menu_instr="Please Enable or Disable BE Option\
"
menu_name "${IF_NAME[$num]}: BE CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
custom)
get_integer "Please specify BE in Kpbs" "0" "0" "512" "interface_setup_help get_be"
choice=$($GET_RC)
;;
esac
BE[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_be"
get_be "$1"
;;
*) return 1
;;
esac
}
function get_bc () {
local menu_options
local rc
local choice
local num="$1"
menu_options="'NO' 'Disable BC (Default)' \
'custom' 'Custom Config' 2> $MENU_TMP"
menu_instr="Please Enable or Disable BC Option \
"
menu_name "${IF_NAME[$num]}: BC CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0)
case $choice in
custom)
get_integer "Please specify BC in Kpbs" "64" "16" "512" "interface_setup_help get_bc"
choice=$($GET_RC)
;;
esac
BC[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_bc"
get_bc "$1"
;;
*) return 1
;;
esac
}
function get_cir () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Disable CIR (Default)' \
'custom' 'Custom Configure' 2> $MENU_TMP"
menu_instr="Please Enable or Disable CIR Option \
"
menu_name "${IF_NAME[$num]}: CIR CONFIGURATION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
custom)
get_integer "Please specify CIR in Kpbs" "64" "16" "512" "interface_setup_help get_cir"
choice=$($GET_RC)
;;
esac
CIR[$num]=$choice #Choice is a command
if [ $choice = NO ]; then
BC[$num]=$choice;
BE[$num]=$choice;
fi
return 0
;;
2) interface_setup_help "get_cir"
get_cir "$1"
;;
*) return 1
;;
esac
}
function get_station () {
local menu_options
local rc
local choice
local num=$1
menu_options="'CPE' 'CPE' \
'NODE' 'Node (switch emulation)' 2> $MENU_TMP"
menu_instr="Please specify the Frame Relay Station Type \
"
menu_name "FRAME RELAY STATION SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ -z $num ]; then
STATION=$choice #Choice is a command
else
STATION_IF[$num]=$choice
fi
return 0
;;
2)
device_setup_help "get_station"
get_station
;;
*) return 1
;;
esac
}
function get_signal () {
local menu_options
local rc
local choice
local num=$1
local node=NO
if [ -z $num ]; then
if [ $STATION = NODE ]; then
node=YES
fi
else
if [ ${STATION_IF[$num]} = NODE ]; then
node=YES
fi
fi
if [ $node = YES ]; then
menu_options="'ANSI' 'ANSI' \
'LMI' 'LMI' \
'Q933' 'Q933' \
'NO' 'No signalling' 2> $MENU_TMP"
else
if [ -z $num ]; then
menu_options="'ANSI' 'ANSI' \
'LMI' 'LMI' \
'Q933' 'Q933' 2> $MENU_TMP"
else
menu_options="'AUTO' 'Auto Detect' \
'ANSI' 'ANSI' \
'LMI' 'LMI' \
'Q933' 'Q933' 2> $MENU_TMP"
fi
fi
menu_instr="Please specify Frame Relay Signalling \
"
menu_name "FRAME RELAY SIGNALLING CONFIGURATION" "$menu_options" 4 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ -z $num ]; then
SIGNAL=$choice #Choice is a command
else
SIGNAL_IF[$num]=$choice
fi
return 0
;;
2)
device_setup_help "get_signal"
get_signal
;;
*) return 1
;;
esac
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,569 +0,0 @@
#!/bin/sh
#################################################################
######## L I N U X #########
#################################################################
init_pppd_scripts ()
{
if [ $OS_SYSTEM != "Linux" ]; then
return 1;
fi
if [ $PROTOCOL = WAN_ADSL ]; then
get_string "Please specify PAP/CHAP User Name" ""
PAPCHAP_UNAME=$($GET_RC)
get_string "Please specify PAP/CHAP Password" ""
PAPCHAP_PASSWD=$($GET_RC)
warning "PAPCHAP_SECRETS_UPDATE"
if [ $? -eq 0 ]; then
if [ ! -d /etc/ppp/ ]; then
warning "PPP_DIR_NOT_FOUND"
if [ $? -eq 0 ]; then
\mkdir -p /etc/ppp
else
return 1;
fi
fi
if [ -e /etc/ppp/pap-secrets ]; then
mv /etc/ppp/pap-secrets /etc/ppp/pap-secrets.orig
fi
if [ -e /etc/ppp/chap-secrets ]; then
mv /etc/ppp/chap-secrets /etc/ppp/chap-secrets.orig
fi
echo -e "\"$PAPCHAP_UNAME\"\t*\t$PAPCHAP_PASSWD\t*" > /etc/ppp/pap-secrets
chmod 600 /etc/ppp/pap-secrets
echo -e "\"$PAPCHAP_UNAME\"\t*\t$PAPCHAP_PASSWD\t*" > /etc/ppp/chap-secrets
chmod 600 /etc/ppp/chap-secrets
fi
PPPD_OPTION="
# ---------------------------------------------
# PPPD Daemon SYNC configuration file
# ---------------------------------------------
# options.ttyWP$TTY_MINOR
#
# - PPPD daemon must bind to device /dev/ttyWP$TTY_MINOR
# - The /dev/ttyWP$TTY_MINOR is binded to wanpipe$DEVICE_NUM
#
# Created automatically by /usr/sbin/wancfg
# Date: `date`
#
name \"$PAPCHAP_UNAME\"
debug
-detach
noipdefault
defaultroute
ipcp-accept-remote
ipcp-accept-local
nobsdcomp
nodeflate
nopcomp
novj
novjccomp
noaccomp -am
"
PPPD_CALL="
#------------------------------------------------
# PPPD Call SYNC Script
#------------------------------------------------
# This call script will call /etc/ppp/options.ttyWP$TTY_MINOR
# to setup the PPPD dameon.
#
# It will start PPPD SYNC protocol.
#
# Created automatically by /usr/local/wanrouter/wancfg
# Date: `date`
#
ttyWP$TTY_MINOR #Bind to WANPIPE device wanpipe3
sync #Connect in sync mode
lcp-echo-failure 0 #No link verification messages
"
return 0;
fi
MULTILINK=NO
MULTILINK_MODE=SLAVE
warning "MULTILINK_OPT"
if [ $? -eq 0 ]; then
MULTILINK=YES
warning "MULTILINK_MASTER"
if [ $? -eq 0 ]; then
MULTILINK_MODE=MASTER
fi
fi
if [ $TTY_MODE = Sync ]; then
PPPD_OPTION="
# ---------------------------------------------
# PPPD Daemon SYNC configuration file
# ---------------------------------------------
# options.ttyWP$TTY_MINOR
#
# - PPPD daemon must bind to device /dev/ttyWP$TTY_MINOR
# - The /dev/ttyWP$TTY_MINOR is binded to wanpipe$DEVICE_NUM
#
# Created automatically by /usr/sbin/wancfg
# Date: `date`
#
asyncmap 0
debug #PPPD will output connection information
nodetach #Do not detach into background
defaultroute #This interface will be a default gateway.
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.
# Read pppd(8) for more information.
# Read /usr/local/wanrouter/PPP-HOWTO for more info.
"
PPPD_CALL="
#------------------------------------------------
# PPPD Call SYNC Script
#------------------------------------------------
# This call script will call /etc/ppp/options.ttyWP$TTY_MINOR
# to setup the PPPD dameon.
#
# It will start PPPD SYNC protocol.
#
# Created automatically by /usr/local/wanrouter/wancfg
# Date: `date`
#
ttyWP$TTY_MINOR #Bind to WANPIPE device wanpipe$DEVICE_NUM
sync #Connect in sync mode
lcp-echo-failure 0 #No link verification messages
"
if [ $MULTILINK = YES ]; then
PPPD_CALL=$PPPD_CALL"
multilink #Enable Multilink Protocol
"
if [ $MULTILINK_MODE = SLAVE ]; then
PPPD_CALL=$PPPD_CALL"
noip #No IP addresses for a slave
"
fi
fi
if [ $MULTILINK = NO ] || [ $MULTILINK_MODE = MASTER ]; then
get_string "Please specify the Local IP Address" "" "IP_ADDR"
L_IP=$($GET_RC)
get_string "Please specify the Point-to-Point IP Address" "" "IP_ADDR"
R_IP=$($GET_RC)
PPPD_CALL=$PPPD_CALL"
$L_IP:$R_IP #Local and remote IP addresses
#STATIC IP mode.
"
fi
else
PPPD_OPTION="
# ---------------------------------------------
# PPPD Daemon ASYNC configuration file
# ---------------------------------------------
# options.ttyWP$TTY_MINOR
#
# - PPPD daemon must bind to device /dev/ttyWP$TTY_MINOR
# - The /dev/ttyWP$TTY_MINOR is binded to wanpipe$DEVICE_NUM
#
# Created automatically by /usr/local/wanrouter/wancfg
# Date: `date`
#
asyncmap 0
modem #Interface to a modem
debug #PPPD will output connection information
crtscts #Enable hardware flow control
noipdefault #Enable dynamice IP addressing
#Obtaint Local and Remote IP addresses from
#peer.
-detach #Do not detach into background
defaultroute #This interface will be a default gateway.
#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.
persist #If the link goes down, keep retrying to connect
# Read pppd(8) for more information.
# Read /usr/local/wanrouter/PPP-HOWTO for more info.
"
get_integer "Please specify the Baud Rate in bps" "38400" "64" "4096000" "device_setup_help get_baudrate"
BAUDRATE=$($GET_RC)
PPPD_CALL="
#------------------------------------------------
# PPPD Call ASYNC Script
#------------------------------------------------
# This call script will call /etc/ppp/options.ttyWP$TTY_MINOR
# to setup the PPPD dameon.
#
# It will start PPPD ASYNC protocol.
#
# Created automatically by /usr/local/wanrouter/wancfg
# Date: `date`
#
ttyWP$TTY_MINOR #Bind to WANPIPE device wanpipe$DEVICE_NUM
$BAUDRATE #Baud rate of the PPP link
connect '/etc/ppp/redialer'
"
if [ $MULTILINK = YES ]; then
PPPD_CALL=$PPPD_CALL"
multilink #Enable Multilink Protocol
"
if [ $MULTILINK_MODE = SLAVE ]; then
PPPD_CALL=$PPPD_CALL"
noip #No IP addresses for a slave
"
fi
fi
fi
return 0;
}
function create_multilink_ppp_linux_cfg() {
if [ ! -e "/dev/ttyWP$TTY_MINOR" ]; then
warning "CREATE_TTYDEV"
if [ $? -eq 0 ]; then
eval "mknod -m 666 /dev/ttyWP$TTY_MINOR c 240 $TTY_MINOR 2> /dev/null"
if [ $? -eq 0 ]; then
error "CREATE_TTYOK"
else
error "CREATE_TTYFAIL"
fi
fi
fi
warning "CREATE_PPPDOPT"
if [ $? -eq 0 ]; then
if [ -f "/etc/ppp/options.ttyWP$TTY_MINOR" ]; then
mv /etc/ppp/options.ttyWP$TTY_MINOR /etc/ppp/options.ttyWP$TTY_MINOR.old
fi
if [ "$TTY_MODE" = Sync ] || [ $PROTOCOL = WAN_ADSL ]; then
init_pppd_scripts
if [ $? -eq 0 ]; then
echo "$PPPD_OPTION" > /etc/ppp/options.ttyWP$TTY_MINOR
echo "$PPPD_CALL" > /etc/ppp/peers/isp_wanpipe$DEVICE_NUM
fi
else
eval "$PPPCONFIG --ttyport /dev/ttyWP$TTY_MINOR --provider isp_wanpipe$DEVICE_NUM"
fi
error "CREATE_PPPDOK"
fi
}
#################################################################
######## F R E E B S D / O P E N B S D #########
#################################################################
MPD_CONF_DIR="/usr/local/etc/mpd"
MPD_CONF="mpd.conf"
MPD_LINKS="mpd.links"
MPD_SECRET="mpd.secret"
MPD_SCRIPT="mpd.script"
# Function: parse_mpd_conf_file
# $1 - bundle name
# $2 - link name
# $3 - auto bundle loading (YES|NO)
function parse_mpd_conf_file() {
local bundle_config=$1_config
local bundle_configured=0
local bundle_configuring=0
local new_cmd_bundle=0
local set_iface_addr_cmd=0
local lip
local rip
if [ ! -f $MPD_CONF_DIR/$MPD_CONF ]; then
cat << EOM >> $MPD_CONF_DIR/$MPD_CONF
#################################################################
#
# MPD configuration file
#
# This file defines the configuration for mpd: what the
# bundles are, what the links are in those bundles, how
# the interface should be configured, various PPP parameters,
# etc. It contains commands just as you would type them
# in at the console. A blank line ends an entry. Lines
# starting with a "#" are comments and get completely
# ignored.
#
# $Id: mlinkppp_lib.sh,v 1.2 2004-01-28 17:14:48 sangoma Exp $
#
#################################################################
EOM
fi
while read line
do
if [ $bundle_configuring -eq 0 ]; then
if [ "$line" = "$bundle_config:" ]; then
# Bundle already configured
bundle_configured=1
bundle_configuring=1
echo "$line" >> tmp.$$
else
cmd=`echo $line | cut -d' ' -f1`
case $cmd in
[#]*)
echo "$line" >> tmp.$$
;;
[a-zA-Z0-9]*:)
echo "$line" >> tmp.$$
;;
*)
echo " $line" >> tmp.$$
;;
esac
fi
else
cmd=`echo $line | cut -d' ' -f1`
case $cmd in
[#]*)
echo "$line" >> tmp.$$
;;
[a-zA-Z0-9]*:)
# End of bundle configuration
bundle_configuring=0
echo " $line" >> tmp.$$
;;
new*)
new_cmd_bundle=1
line1=${line/$2/""}
if [ "$line1" = "$line" ]; then
echo " $line $2" >> tmp.$$
else
echo " $line" >> tmp.$$
fi
;;
*)
echo " $line" >> tmp.$$
;;
esac
fi
done < $MPD_CONF_DIR/$MPD_CONF
if [ $bundle_configured -eq 0 ]; then
get_string "Please specify the Local IP Address for the Bundle $1" "" "IP_ADDR"
lip=$($GET_RC)
get_string "Please specify the Point-to-Point IP Address for the Bundle $1" "" "IP_ADDR"
rip=$($GET_RC)
cat << EOM >> tmp.$$
$bundle_config:
new $1 $2
set iface addrs $lip $rip
open iface
EOM
fi
mv tmp.$$ $MPD_CONF_DIR/$MPD_CONF
}
# Function: parse_mpd_links_file
# $1 - link name
# $2 - device number
function parse_mpd_links_file() {
local nodename=wanpipe$2
local link_configured=0
local link_configuring=0
if [ ! -f $MPD_CONF_DIR/$MPD_LINKS ]; then
cat << EOM > $MPD_CONF_DIR/$MPD_LINKS
#################################################################
#
# MPD links file
#
# In this file you define the various "links" that comprise
# a bundle. Each link corresponds to a single serial device.
# These are commands that could be typed into the console directly.
#
# This file should only contain configuration for a link if
# that configuration is specific to that particular link. That
# is, things like device name and bandwidth. Other generic link
# options like LCP parameters belong in "mpd.conf".
#
# The first command for each link should be "set link type ..."
#
# $Id: mlinkppp_lib.sh,v 1.2 2004-01-28 17:14:48 sangoma Exp $
#
#################################################################
EOM
fi
while read line
do
if [ $link_configuring -eq 0 ]; then
if [ "$line" = "$1:" ]; then
# Bundle already configured
link_configured=1
link_configuring=1
echo "$line" >> tmp.$$
else
cmd=`echo $line | cut -d' ' -f1`
case $cmd in
[#]*)
echo "$line" >> tmp.$$
;;
[a-zA-Z0-9]*:)
echo "$line" >> tmp.$$
;;
*)
echo " $line" >> tmp.$$
;;
esac
fi
else
cmd=`echo $line | cut -d' ' -f1`
case $cmd in
[#]*)
echo "$line" >> tmp.$$
;;
[a-zA-Z0-9]*:)
# End of links configuration
link_configuring=0
echo "$line" >> tmp.$$
;;
*)
line1=${line#set[ ]*ng[ ]*node[ ]*}
if [ "$line1" != "$line" ]; then
line2=${line1/$nodename:/""}
if [ "$line1" = "$line2" ]; then
echo " set ng node $nodename:" >> tmp.$$
else
echo " $line" >> tmp.$$
fi
else
echo " $line" >> tmp.$$
fi
esac
fi
done < $MPD_CONF_DIR/$MPD_LINKS
if [ $link_configured -eq 0 ]; then
cat << EOM >> tmp.$$
$1:
set link type ng
set ng node $nodename:
set ng hook rawdata
EOM
fi
mv tmp.$$ $MPD_CONF_DIR/$MPD_LINKS
}
# Function: create_multilink_ppp_bsd_cfg
# $1 - device number
function create_multilink_ppp_bsd_cfg() {
local auto_bundle_load
local bundle_name
local link_name
local lip
local rip
get_string "Please specify the MPD configuration directory" "$MPD_CONF_DIR"
MPD_CONF_DIR=$($GET_RC)
# Make current bundle default
#warning mlinkppp_bundle
#if [ $? -eq 0 ]; then
# auto_bundle_load=YES
#else
# auto_bundle_load=NO
#fi
get_string "Please specify Bundle Name" ""
bundle_name=$($GET_RC)
get_string "Please specify Link Name" ""
link_name=$($GET_RC)
parse_mpd_conf_file $bundle_name $link_name $auto_bundle_load
parse_mpd_links_file $link_name $1
# Create security file
return 0
}
function create_multilink_ppp_cfg() {
local err
if [ $OS_SYSTEM = "Linux" ]; then
create_multilink_ppp_linux_cfg $1
elif [ $OS_SYSTEM = "FreeBSD" ]; then
create_multilink_ppp_bsd_cfg $1
fi
return 0
}

View File

@ -1,271 +0,0 @@
#!/bin/sh
function ppp_interface_setup () {
local rc
local num="$1"
local choice
local menu_options
local menu_size
if [ -z "${MULTICAST[$num]}" ]; then
MULTICAST[$num]=NO
fi
if [ -z "${IPX[$num]}" ]; then
IPX[$num]=NO
fi
if [ -z "${PAP[$num]}" ]; then
PAP[$num]=NO
fi
if [ -z "${CHAP[$num]}" ]; then
CHAP[$num]=NO
fi
echo "'get_multicast' 'MULTICAST---> ${MULTICAST[$num]}' \\" > ppp_opt_temp.$$
echo "'get_pap' 'PAP --------> ${PAP[$num]}' \\" >> ppp_opt_temp.$$
echo "'get_chap' 'CHAP--------> ${CHAP[$num]}' \\" >> ppp_opt_temp.$$
echo "'get_ipx' 'IPX -------> ${IPX[$num]}' \\" >> ppp_opt_temp.$$
menu_size=4
if [ ${IPX[$num]} = YES ]; then
echo "'get_network' 'NETWORK ----> ${NETWORK[$num]}' \\" >> ppp_opt_temp.$$
menu_size=$((menu_size+1))
fi
if [ ${PAP[$num]} = YES -o ${CHAP[$num]} = YES ]; then
echo "'get_userid' 'USERID -----> ${USERID[$num]}' \\" >> ppp_opt_temp.$$
echo "'get_passwd' 'PASSWD -----> ${PASSWD[$num]}' \\" >> ppp_opt_temp.$$
echo "'get_sysname' 'SYSNAME ----> ${SYSNAME[$num]}'\\" >> ppp_opt_temp.$$
menu_size=$((menu_size+3))
fi
echo " 2> $MENU_TMP" >> ppp_opt_temp.$$
menu_options=`cat ppp_opt_temp.$$`
rm -f ppp_opt_temp.$$
menu_instr="Please configure ${IF_NAME[$num]} Interface \
"
menu_name "PPP ${IF_NAME[$num]} Setup" "$menu_options" "$menu_size" "$menu_instr" "$BACK" 20
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
get_network)
get_string "Please specify you IPX Network Number" "0xABCDEFAB"
NETWORK[$num]=$($GET_RC)
;;
get_userid)
get_string "Please specify you User Id"
USERID[$num]=$($GET_RC)
;;
get_passwd)
get_string "Please specify you Password"
PASSWD[$num]=$($GET_RC)
;;
get_sysname)
get_string "Please specify you System Name"
SYSNAME[$num]=$($GET_RC)
;;
*)
$choice "$num" #Choice is a command
;;
esac
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*) return 1
;;
esac
}
function get_ipmode () {
local menu_options
local rc
local choice
menu_options="'STATIC' 'Static IP addressing, STATIC(default)' \
'HOST' 'Host IP addressing, HOST' \
'PEER' 'Dynamic IP addressing, PEER' 2> $MENU_TMP"
menu_instr="Please select PPP IP Addressing Mode \
"
menu_name "${IF_NAME[$num]} IP Mode Configuration" "$menu_options" 3 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) IPMODE=$choice #Choice is a command
return 0
;;
2) device_setup_help "get_ipmode"
get_ipmode
;;
*) return 1
;;
esac
}
function get_ipx () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Disable IPX (Default)' \
'YES' 'Enable IPX' 2> $MENU_TMP"
menu_instr="Please Enable or Disable IPX Routing \
"
menu_name "${IF_NAME[$num]} IPX Configuration" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) IPX[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_ipx"
get_ipx "$1"
;;
*) return 1
;;
esac
}
function get_pap () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Disable PAP (Default)' \
'YES' 'Enable PAP' 2> $MENU_TMP"
menu_instr="Please Enable or Disable PAP Auth. Protocol \
"
menu_name "PAP Configuration" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0)
PAP[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_pap"
get_pap $num
;;
*) return 1
;;
esac
}
function get_chap () {
local menu_options
local rc
local choice
local num=$1;
menu_options="'NO' 'Disable CHAP (Default)' \
'YES' 'Enable CHAP' 2> $MENU_TMP"
menu_instr="Please Enable or Disable CHAP Auth. Protocol \
"
menu_name "CHAP Configuration" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0)
CHAP[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_chap"
get_chap $num
;;
*) return 1
;;
esac
}
function get_ppp_chdlc_mode ()
{
local menu_options
local rc
local choice
local num=$1;
local menu_size=2
if [ $PROTOCOL = WAN_AFT ]; then
if [ $OS_SYSTEM = "Linux" ]; then
menu_options="'MP_FR' 'Frame Relay Protocol (Default)' \
'MP_PPP' 'PPP Protocol' \
'MP_CHDLC' 'Cisco HDLC Protocol' \
'HDLC' 'RAW HDLC Protocol' 2> $MENU_TMP"
menu_size=4
else
menu_options="'MP_CHDLC' 'Cisco HDLC Protocol (Default)' \
'MP_PPP' 'PPP Protocol' 2> $MENU_TMP"
menu_size=2
fi
elif [ $PROTOCOL = WAN_BITSTRM ]; then
menu_options="'HDLC' 'RAW HDLC Protocol (Default)' \
'MP_PPP' 'PPP Protocol' \
'MP_CHDLC' 'Cisco HDLC Protocol' 2> $MENU_TMP"
menu_size=3
else
menu_options="'MP_PPP' 'PPP Protocol (Default)' \
'MP_CHDLC' 'Cisco HDLC Protocol' 2> $MENU_TMP"
fi
menu_instr="Please Select MultiPort Protocol \
"
menu_name "${IF_NAME[$num]} MultiPort Protocol Configuration" "$menu_options" $menu_size "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) MPPP_PROT[$num]=$choice #Choice is a command
return 0
;;
2) interface_setup_help "get_ppp_chdlc_mode"
get_ppp_chdlc_mode "$1"
;;
*) return 1
;;
esac
}

View File

@ -1,258 +0,0 @@
function ss7_interface_init () {
LINE_CONFIG_OPTIONS=${LINE_CONFIG_OPTIONS:-0x0001}
MODEM_CONFIG_OPTIONS=${MODEM_CONFIG_OPTIONS:-0x0000}
MODEM_STATUS_TIMER=${MODEM_STATUS_TIMER:-500}
API_OPTIONS=${API_OPTIONS:-0x0000}
PROTOCOL_OPTIONS=${PROTOCOL_OPTIONS:-0x0000}
PROTOCOL_SPECIFICATION=${PROTOCOL_SPECIFICATION:-ANSI}
STATS_HISTORY_OPTIONS=${STATS_HISTORY_OPTIONS:-0x001F}
MAX_LENGTH_MSU_SIF=${MAX_LENGTH_MSU_SIF:-272}
MAX_UNACKED_TX_MSUS=${MAX_UNACKED_TX_MSUS:-10}
LINK_INACTIVITY_TIMER=${LINK_INACTIVITY_TIMER:-5}
T1_TIMER=${T1_TIMER:-1300}
T2_TIMER=${T2_TIMER:-1150}
T3_TIMER=${T3_TIMER:-1150}
T4_TIMER_EMERGENCY=${T4_TIMER_EMERGENCY:-60}
T4_TIMER_NORMAL=${T4_TIMER_NORMAL:-230}
T5_TIMER=${T5_TIMER:-10}
T6_TIMER=${T6_TIMER:-400}
T7_TIMER=${T7_TIMER:-100}
T8_TIMER=${T8_TIMER:-100}
N1=${N1:-1}
N2=${N2:-2}
TIN=${TIN:-10}
TIE=${TIE:-11}
SUERM_ERROR_THRESHOLD=${SUERM_ERROR_THRESHOLD:-20}
SUERM_NUMBER_OCTETS=${SUERM_NUMBER_OCTETS:-21}
SUERM_NUMBER_SUS=${SUERM_NUMBER_SUS:-1024}
SIE_INTERVAL_TIMER=${SIE_INTERVAL_TIMER:-30}
SIO_INTERVAL_TIMER=${SIO_INTERVAL_TIMER:-31}
SIOS_INTERVAL_TIMER=${SIOS_INTERVAL_TIMER:-32}
FISU_INTERVAL_TIMER=${FISU_INTERVAL_TIMER:-33}
}
function ss7_interface_setup () {
local rc
local num="$1"
local choice
local menu_options
ss7_interface_init $num
menu_options="'get_LINE_CONFIG_OPTIONS' 'Line Config --------> $LINE_CONFIG_OPTIONS' \
'get_MODEM_CONFIG_OPTION' 'Modem Config -------> $MODEM_CONFIG_OPTIONS' \
'get_MODEM_STATUS_TIMER' 'Modem Status Timer -> $MODEM_STATUS_TIMER' \
'get_API_OPTIONS' 'Api Options --------> $API_OPTIONS' \
'get_PROTOCOL_OPTIONS' 'Protocol Options ---> $PROTOCOL_OPTIONS' \
'get_ss7_signal' 'Protocol Spec. -----> $PROTOCOL_SPECIFICATION' \
'get_STATS_HISTORY' 'Status History -----> $STATS_HISTORY_OPTIONS' \
'get_MAX_LENGTH_MSU_SIF' 'Max MSU SIF Length -> $MAX_LENGTH_MSU_SIF' \
'get_MAX_UNACKED_TX_MSUS' 'Max Unacked Tx MSU -> $MAX_UNACKED_TX_MSUS' \
'get_LINK_INACT_TIMER' 'Link Inact. Timer --> $LINK_INACTIVITY_TIMER' \
'get_T1_TIMER' 'T1 Timer -----------> $T1_TIMER' \
'get_T2_TIMER' 'T2 Timer -----------> $T2_TIMER' \
'get_T3_TIMER' 'T3 Timer -----------> $T3_TIMER' \
'get_T4_TIMER_EMERG' 'T4 Timer Emergency -> $T4_TIMER_EMERGENCY' \
'get_T4_TIMER_NORMAL' 'T4 Timer Normal ----> $T4_TIMER_NORMAL' \
'get_T5_TIMER' 'T5 Timer -----------> $T5_TIMER' \
'get_T6_TIMER' 'T6 Timer -----------> $T6_TIMER' \
'get_T7_TIMER' 'T7 Timer -----------> $T7_TIMER' \
'get_T8_TIMER' 'T8 Timer -----------> $T8_TIMER' \
'get_N1' 'N1 -----------------> $N1' \
'get_N2' 'N2 -----------------> $N2' \
'get_TIN' 'TIN ----------------> $TIN' \
'get_TIE' 'TIE ----------------> $TIE' \
'get_SUERM_ERROR_THR' 'Suerm Err Thresh. --> $SUERM_ERROR_THRESHOLD' \
'get_SUERM_NUMBER_OCTETS' 'Suerm Num Octects --> $SUERM_NUMBER_OCTETS' \
'get_SUERM_NUMBER_SUS' 'Suerm Num Sus ------> $SUERM_NUMBER_SUS' \
'get_SIE_INTERVAL_TIMER' 'Sie Interval Timer -> $SIE_INTERVAL_TIMER' \
'get_SIO_INTERVAL_TIMER' 'Sio Interval Timer -> $SIO_INTERVAL_TIMER' \
'get_SIOS_INTERVAL_TIMER' 'Sios Interv. Timer -> $SIOS_INTERVAL_TIMER' \
'get_FISU_INTERVAL_TIMER' 'Fisu Interv. Timer -> $FISU_INTERVAL_TIMER' 2> $MENU_TMP"
menu_instr="Please specify the ${IF_NAME[$num]}: SS7 protocol parameters below\
"
menu_name "SS7 ${IF_NAME[$num]} PROTOCOL SETUP" "$menu_options" 12 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) case $choice in
get_LINE_CONFIG_OPTIONS)
get_string "Please specify Line Config Options" "$LINE_CONFIG_OPTIONS"
LINE_CONFIG_OPTIONS=$($GET_RC)
;;
get_MODEM_CONFIG_OPTION)
get_string "Please specify MODEM_CONFIG_OPTIONS" "$MODEM_CONFIG_OPTIONS"
MODEM_CONFIG_OPTIONS=$($GET_RC)
;;
get_MODEM_STATUS_TIMER)
get_string "Please specify MODEM_STATUS_TIMER" "$MODEM_STATUS_TIMER"
MODEM_STATUS_TIMER=$($GET_RC)
;;
get_API_OPTIONS)
get_string "Please specify API_OPTIONS" "$API_OPTIONS"
API_OPTIONS=$($GET_RC)
;;
get_PROTOCOL_OPTIONS)
get_string "Please specify PROTOCOL_OPTIONS" "$PROTOCOL_OPTIONS"
PROTOCOL_OPTIONS=$($GET_RC)
;;
get_STATS_HISTORY)
get_string "Please specify STATS_HISTORY_OPTIONS" "$STATS_HISTORY_OPTIONS"
STATS_HISTORY_OPTIONS=$($GET_RC)
;;
get_MAX_LENGTH_MSU_SIF)
get_string "Please specify MAX_LENGTH_MSU_SIF" "$MAX_LENGTH_MSU_SIF"
MAX_LENGTH_MSU_SIF=$($GET_RC)
;;
get_MAX_UNACKED_TX_MSUS)
get_string "Please specify MAX_UNACKED_TX_MSUS" "$MAX_UNACKED_TX_MSUS"
MAX_UNACKED_TX_MSUS=$($GET_RC)
;;
get_LINK_INACT_TIMER)
get_string "Please specify LINK_INACTIVITY_TIMER" "$LINK_INACTIVITY_TIMER"
LINK_INACTIVITY_TIMER=$($GET_RC)
;;
get_T1_TIMER)
get_string "Please specify T1_TIMER" "$T1_TIMER"
T1_TIMER=$($GET_RC)
;;
get_T2_TIMER)
get_string "Please specify T2_TIMER" "$T2_TIMER"
T2_TIMER=$($GET_RC)
;;
get_T3_TIMER)
get_string "Please specify T3_TIMER" "$T3_TIMER"
T3_TIMER=$($GET_RC)
;;
get_T4_TIMER_EMERG)
get_string "Please specify T4_TIMER_EMERGENCY" "$T4_TIMER_EMERGENCY"
T4_TIMER_EMERGENCY=$($GET_RC)
;;
get_T4_TIMER_NORMAL)
get_string "Please specify T4_TIMER_NORMAL" "$T4_TIMER_NORMAL"
T4_TIMER_NORMAL=$($GET_RC)
;;
get_T5_TIMER)
get_string "Please specify T5_TIMER" "$T5_TIMER"
T5_TIMER=$($GET_RC)
;;
get_T6_TIMER)
get_string "Please specify T6_TIMER" "$T6_TIMER"
T6_TIMER=$($GET_RC)
;;
get_T7_TIMER)
get_string "Please specify T7_TIMER" "$T7_TIMER"
T7_TIMER=$($GET_RC)
;;
get_T8_TIMER)
get_string "Please specify T8_TIMER" "$T8_TIMER"
T8_TIMER=$($GET_RC)
;;
get_N1)
get_string "Please specify N1" "$N1"
N1=$($GET_RC)
;;
get_N2)
get_string "Please specify N2" "$N2"
N2=$($GET_RC)
;;
get_TIN)
get_string "Please specify TIN" "$TIN"
TIN=$($GET_RC)
;;
get_TIE)
get_string "Please specify TIE" "$TIE"
TIE=$($GET_RC)
;;
get_SUERM_ERROR_THR)
get_string "Please specify SUERM_ERROR_THRESHOLD" "$SUERM_ERROR_THRESHOLD"
SUERM_ERROR_THRESHOLD=$($GET_RC)
;;
get_SUERM_NUMBER_OCTETS)
get_string "Please specify SUERM_NUMBER_OCTETS" "$SUERM_NUMBER_OCTETS"
SUERM_NUMBER_OCTETS=$($GET_RC)
;;
get_SUERM_NUMBER_SUS)
get_string "Please specify SUERM_NUMBER_SUS" "$SUERM_NUMBER_SUS"
SUERM_NUMBER_SUS=$($GET_RC)
;;
get_SIE_INTERVAL_TIMER)
get_string "Please specify SIE_INTERVAL_TIMER" "$SIE_INTERVAL_TIMER"
SIE_INTERVAL_TIMER=$($GET_RC)
;;
get_SIO_INTERVAL_TIMER)
get_string "Please specify SIO_INTERVAL_TIMER" "$SIO_INTERVAL_TIMER"
SIO_INTERVAL_TIMER=$($GET_RC)
;;
get_SIOS_INTERVAL_TIMER)
get_string "Please specify SIOS_INTERVAL_TIMER" "$SIOS_INTERVAL_TIMER"
SIOS_INTERVAL_TIMER=$($GET_RC)
;;
get_FISU_INTERVAL_TIMER)
get_string "Please specify FISU_INTERVAL_TIMER" "$FISU_INTERVAL_TIMER"
FISU_INTERVAL_TIMER=$($GET_RC)
;;
*)
$choice #Choice is a command
;;
esac
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*)
return 1
;;
esac
}
function get_ss7_signal () {
local menu_options
local rc
local choice
menu_options="'ANSI' 'ANSI' \
'ITU' 'ITU' \
'NTT' 'NTT' 2> $MENU_TMP"
menu_instr="Please specify SS7 Signalling \
"
menu_name "SS7 SIGNALLING CONFIGURATION" "$menu_options" 4 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) PROTOCOL_SPECIFICATION=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_ss7_signal"
get_ss7_signal
;;
*) return 1
;;
esac
}

View File

@ -1,252 +0,0 @@
#!/bin/sh
function x25_interface_setup () {
local rc
local num="$1"
local choice
local menu_options
IDLE_TIMEOUT[$num]=${IDLE_TIMEOUT[$num]:-90}
HOLD_TIMEOUT[$num]=${HOLD_TIMEOUT[$num]:-10}
SRC_ADDR[$num]=${SRC_ADDR[$num]}
menu_options="'get_idle_timeout' 'Idle Timeout -------> ${IDLE_TIMEOUT[$num]}' \
'get_hold_timeout' 'Hold Timeout -------> ${HOLD_TIMEOUT[$num]}' 2> $MENU_TMP"
menu_size=2
menu_instr="Please configure ${IF_NAME[$num]}: X25 parameters below"
menu_name "${IF_NAME[$num]}: X25 PROTOCOL SETUP" "$menu_options" "$menu_size" "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) if [ $choice = get_idle_timeout ]; then
get_integer "Please specify x25 idle timeout" "90" "1" "500"
IDLE_TIMEOUT[$num]=$($GET_RC)
fi
if [ $choice = get_hold_timeout ]; then
get_integer "Please specify x25 hold timeout" "10" "1" "500"
HOLD_TIMEOUT[$num]=$($GET_RC)
fi
return 0
;;
2) choice=${choice%\"*\"}
choice=${choice// /}
interface_setup_help $choice
return 0
;;
*)
return 1
;;
esac
}
function get_hdlc_station () {
local menu_options
local rc
local choice
menu_options="'DTE' 'DTE' \
'DCE' 'DCE' 2> $MENU_TMP"
menu_instr="Please specify the X25 Station Type \
"
menu_name "X25 STATION SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) STATION=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_hdlc_station"
get_hdlc_station
;;
*) return 1
;;
esac
}
function get_ccitt () {
local menu_options
local rc
local choice
menu_options="'1988' '1988 (Default)' \
'1984' '1984' \
'1980' '1980' 2> $MENU_TMP"
menu_instr="Please specify the X25 CCITT Compatibility \
"
menu_name "X25 CCITT SETUP" "$menu_options" 3 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) CCITT=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_ccitt"
get_ccitt
;;
*) return 1
;;
esac
}
function get_hdlc_only () {
local menu_options
local rc
local choice
menu_options="'NO' 'Full X25/HDLC Support (Default)' \
'YES' 'LAPB HDLC Support Only' 2> $MENU_TMP"
menu_instr="Please select the desired protocol level\
"
menu_name "X25 PROTOCOL SELECTION" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) LAPB_HDLC_ONLY=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_hdlc_only"
get_hdlc_only
;;
*) return 1
;;
esac
}
function get_logging () {
local menu_options
local rc
local choice
menu_options="'YES' 'Enable Channel Setup Logging (Default)' \
'NO' 'Disable Logging' 2> $MENU_TMP"
menu_instr="Please enable or disable channel setup logging \
"
menu_name "X25 CHANNEL SETUP LOGGING" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) CALL_LOGGING=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_logging"
get_logging
;;
*) return 1
;;
esac
}
function get_oob_modem () {
local menu_options
local rc
local choice
menu_options="'NO' 'Disable modem status OOB messages (Default)' \
'YES' 'Enable modem status OOB messages' 2> $MENU_TMP"
menu_instr="Please enable or disable modem status messaging \
"
menu_name "X25 OOB MODEM MSG SETUP" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) OOB_ON_MODEM=$choice #Choice is a command
return 0
;;
2)
device_setup_help "get_oob_modem"
get_oob_modem
;;
*) return 1
;;
esac
}
function get_channel_type () {
local num=$1
local menu_options
local rc
local choice
menu_options="'SVC' 'SVC Link (Default)' \
'PVC' 'PVC Link' 2> $MENU_TMP"
menu_instr="Please specify the channel type\
"
menu_name "X25 CHANNEL TYPE" "$menu_options" 2 "$menu_instr" "$BACK"
rc=$?
choice=`cat $MENU_TMP`
rm -f $MENU_TMP
case $rc in
0) CH_TYPE[$num]=$choice #Choice is a command
return 0
;;
2)
interface_menu_help "get_channel_type"
get_channel_type $num
;;
*) return 1
;;
esac
}

View File

@ -1,50 +0,0 @@
#!/bin/sh
OSYSTEM=`uname -s`
RELEASE=`uname -r`
if [ $OSYSTEM = "Linux" ]; then
MODULE_STAT=lsmod
WAN_DRIVERS="wan_aften"
MODULE_LOAD=modprobe
MODULE_UNLOAD="modprobe -r"
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "FreeBSD" ]; then
major_ver=${RELEASE%%.*}
MODULE_STAT=kldstat
MODULE_LOAD=kldload
MODULE_UNLOAD=kldunload
if [ "$major_ver" = "5" ]; then
MODULE_DIR=/boot/modules
else
MODULE_DIR=/modules
fi
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "OpenBSD" ]; then
MODULE_STAT=modstat
MODULE_LOAD=modload
MODULE_UNLOAD=modunload
MODULE_DIR=/usr/lkm
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "NetBSD" ]; then
MODULE_STAT=modstat
MODULE_LOAD=modload
MODULE_UNLOAD=modunload
MODULE_DIR=/usr/lkm
WAN_AFTEN_DRV="wan_aften"
fi
if [ $OSYSTEM = "Linux" ]; then
echo "$MODULE_LOAD $WAN_AFTEN_DRV > /dev/null"
$MODULE_LOAD $WAN_AFTEN_DRV > /dev/null
err=$?
elif [ $OSYSTEM = "FreeBSD" ]; then
err=`$MODULE_LOAD ${WAN_AFTEN_DRV} >/dev/null`
elif [ $OSYSTEM = "OpenBSD" -o $OSYSTEM = "NetBSD" ]; then
err=`$MODULE_LOAD -o $MODULE_DIR/${WAN_AFTEN_DRV}1.out -e${WAN_AFTEN_DRV} $MODULE_DIR/${WAN_AFTEN_DRV}.o 1> /dev/null`
fi
echo "AFT card enabled"
#ifconfig whdlc0 up
exit $err

View File

@ -1,49 +0,0 @@
#!/bin/sh
CMD=$1
OSYSTEM=`uname -s`
RELEASE=`uname -r`
if [ $OSYSTEM = "Linux" ]; then
MODULE_STAT=lsmod
WAN_DRIVERS="wan_aften"
MODULE_LOAD=modprobe
MODULE_UNLOAD="modprobe -r"
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "FreeBSD" ]; then
major_ver=${RELEASE%%.*}
MODULE_STAT=kldstat
MODULE_LOAD=kldload
MODULE_UNLOAD=kldunload
if [ "$major_ver" = "5" ]; then
MODULE_DIR=/boot/modules
else
MODULE_DIR=/modules
fi
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "OpenBSD" ]; then
MODULE_STAT=modstat
MODULE_LOAD=modload
MODULE_UNLOAD=modunload
MODULE_DIR=/usr/lkm
WAN_AFTEN_DRV="wan_aften"
elif [ $OSYSTEM = "NetBSD" ]; then
MODULE_STAT=modstat
MODULE_LOAD=modload
MODULE_UNLOAD=modunload
MODULE_DIR=/usr/lkm
WAN_AFTEN_DRV="wan_aften"
fi
#ifconfig whdlc0 down
if [ $OSYSTEM = "OpenBSD" -o $OSYSTEM = "NetBSD" ]; then
\rm -rf $MODULE_DIR/${WAN_AFTEN_DRV}.out
err=`$MODULE_UNLOAD -n ${WAN_AFTEN_DRV} 2> /dev/null`
else
echo "$MODULE_UNLOAD ${WAN_AFTEN_DRV}"
err=`$MODULE_UNLOAD ${WAN_AFTEN_DRV} 2> /dev/null`
fi
echo "AFT card disabled"
exit $err

View File

@ -1,35 +0,0 @@
#!/bin/sh
cmd=$1;
if [ ! -e wan_aftup ]; then
eval "make clean > /dev/null"
eval "make > /dev/null"
fi
if [ -e /proc/net/wanrouter ]; then
echo
echo "Warning: Wanpipe modules loaded"
echo " Please remove wanpipe modules from the kernel"
echo
echo " eg: wanrouter stop"
echo
exit 1
fi
trap '' 2
eval "./scripts/load.sh"
if [ "$cmd" == "auto" ]; then
eval "./wan_aftup -auto"
else
eval "./wan_aftup "
fi
eval "./scripts/unload.sh"

View File

@ -1,675 +0,0 @@
#class A10u
#for A101/2/u/c series cards
package A10u;
use Card;
use strict;
#constructor
sub new {
my ($class) = @_;
my $self = {
_is_tdm_api => undef,
_card => undef,
_fe_line => undef,
_fe_media => 'T1',
_fe_lcode => 'B8ZS',
_fe_frame => 'ESF',
_fe_clock => 'NORMAL',
_te_sig_mode => undef,
_te_ref_clock => '0',
_signalling => 'PRI_CPE',
_pri_switchtype => 'national',
_rx_slevel => '360',
_hw_dchan => '0',
_frac_chanfirst => '0',
_frac_chanlast => '0',
_ss7_sigchan => undef,
_ss7_option => undef,
_ss7_tdmchan => undef,
_ss7_subinterface => undef,
_ss7_tdminterface => undef,
_smg_sig_mode => '1',
_old_a10u => undef,
};
bless $self, $class;
return $self;
}
sub card {
my ( $self, $card ) = @_;
$self->{_card} = $card if defined($card);
return $self->{_card};
}
sub fe_line {
my ( $self, $fe_line ) = @_;
$self->{_fe_line} = $fe_line if defined($fe_line);
return $self->{_fe_line};
}
sub frac_chan_first {
my ( $self, $frac_chan_first ) = @_;
$self->{_frac_chan_first} = $frac_chan_first if defined($frac_chan_first);
return $self->{_frac_chan_first};
}
sub frac_chan_last {
my ( $self, $frac_chan_last ) = @_;
$self->{_frac_chan_last} = $frac_chan_last if defined($frac_chan_last);
return $self->{_frac_chan_last};
}
sub te_ref_clock {
my ( $self, $te_ref_clock ) = @_;
$self->{_te_ref_clock} = $te_ref_clock if defined($te_ref_clock);
return $self->{_te_ref_clock};
}
sub signalling {
my ( $self, $signalling ) = @_;
$self->{_signalling} = $signalling if defined($signalling);
return $self->{_signalling};
}
sub hw_dchan {
my ( $self, $hw_dchan ) = @_;
$self->{_hw_dchan} = $hw_dchan if defined($hw_dchan);
return $self->{_hw_dchan};
}
sub fe_media {
my ( $self, $fe_media ) = @_;
$self->{_fe_media} = $fe_media if defined($fe_media);
return $self->{_fe_media};
}
sub fe_lcode {
my ( $self, $fe_lcode) = @_;
$self->{_fe_lcode} = $fe_lcode if defined($fe_lcode);
return $self->{_fe_lcode};
}
sub te_sig_mode {
my ( $self, $te_sig_mode ) = @_;
$self->{_te_sig_mode} = $te_sig_mode if defined($te_sig_mode);
return $self->{_te_sig_mode};
}
sub fe_frame {
my ( $self, $fe_frame ) = @_;
$self->{_fe_frame} = $fe_frame if defined($fe_frame);
return $self->{_fe_frame};
}
sub fe_clock {
my ( $self, $fe_clock ) = @_;
$self->{_fe_clock} = $fe_clock if defined($fe_clock);
return $self->{_fe_clock};
}
sub pri_switchtype {
my ( $self, $pri_switchtype ) = @_;
$self->{_pri_switchtype} = $pri_switchtype if defined($pri_switchtype);
return $self->{_pri_switchtype};
}
sub ss7_option {
my ( $self, $ss7_option ) = @_;
$self->{_ss7_option} = $ss7_option if defined($ss7_option);
return $self->{_ss7_option};
}
sub ss7_sigchan {
my ( $self, $ss7_sigchan ) = @_;
$self->{_ss7_sigchan} = $ss7_sigchan if defined($ss7_sigchan);
return $self->{_ss7_sigchan};
}
sub ss7_tdmchan {
my ( $self, $ss7_tdmchan ) = @_;
$self->{_ss7_tdmchan} = $ss7_tdmchan if defined($ss7_tdmchan);
return $self->{_ss7_tdmchan};
}
sub ss7_subinterface {
my ( $self, $ss7_subinterface ) = @_;
$self->{_ss7_subinterface} = $ss7_subinterface if defined($ss7_subinterface);
return $self->{_ss7_subinterface};
}
sub ss7_tdminterface {
my ( $self, $ss7_tdminterface ) = @_;
$self->{_ss7_tdminterface} = $ss7_tdminterface if defined($ss7_tdminterface);
return $self->{_ss7_tdminterface};
}
sub is_tdm_api {
my ( $self, $is_tdm_api ) = @_;
$self->{_is_tdm_api} = $is_tdm_api if defined($is_tdm_api);
return $self->{_is_tdm_api};
}
sub smg_sig_mode {
my ( $self, $smg_sig_mode ) = @_;
$self->{_smg_sig_mode} = $smg_sig_mode if defined($smg_sig_mode);
return $self->{_smg_sig_mode};
}
sub rx_slevel {
my ( $self, $rx_slevel ) = @_;
$self->{_rx_slevel} = $rx_slevel if defined($rx_slevel);
return $self->{_rx_slevel};
}
sub prompt_user{
my($promptString, $defaultValue) = @_;
if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}
}
sub prompt_user_list{
my @list = @_;
my $i;
my $valid = 0;
for $i (0..$#list) {
printf(" %s\. %s\n",$i+1, @list[$i]);
}
while ($valid == 0){
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ( $_ =~ /(\d+)/ ){
if ( $1 > $#list+1) {
print "Invalid option: Value out of range \n";
} else {
return $1-1 ;
}
} else {
print "Invalid option: Input an integer\n";
}
}
}
sub old_a10u {
my ( $self, $old_a10u ) = @_;
$self->{_old_a10u} = $old_a10u if defined($old_a10u);
return $self->{_old_a10u};
}
sub print {
my ($self) = @_;
$self->card->print();
printf (" fe_line: %s\n fe_media: %s\n fe_lcode: %s\n fe_frame: %s \n fe_clock:%s\n ", $self->fe_line, $self->fe_media, $self->fe_lcode, $self->fe_frame, $self->fe_clock);
}
sub get_alpha_from_num {
my ($num) = @_;
my $alpha_str="";
my $alpha_char="";
my $i;
my @chars = split(//, $num);
for $i (0..$#chars) {
if ( $i == 0 ) {
$alpha_char=chr(ord(@chars[$i])+48);
} else {
$alpha_char=chr(ord(@chars[$i])+49);
}
$alpha_str=$alpha_str."".$alpha_char;
}
return $alpha_str;
}
sub gen_wanpipe_ss7_subinterfaces{
my ($self) = @_;
my $wanpipe_ss7_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
my $ss7_sigchan = $self->ss7_sigchan;
my $tdmv_span_no = $self->card->tdmv_span_no;
my $device_no = $self->card->device_no;
my $ss7_subinterface = $self->ss7_subinterface;
my $ss7_tdmchan = $self->ss7_tdmchan;
my $hwec_mode = $self->card->hwec_mode;
my $ss7_tdminterface = $self->ss7_tdminterface;
my $rx_slevel= $self->rx_slevel;
my $wanpipe_ss7_interfaces_template = $self->card->current_dir."/templates/ss7_a10u/wanpipe.ss7.$ss7_subinterface";
open(FH, $wanpipe_ss7_interfaces_template) or die "Can't open $wanpipe_ss7_interfaces_template";
my $wp_file='';
while (<FH>) {
if (!(($ss7_tdminterface == ' ') && (($wanpipe_ss7_interfaces_template =~ m/2/) || ($wanpipe_ss7_interfaces_template =~ m/5/)))){
$wp_file .= $_;
}
}
close (FH);
open(FH, ">>$wanpipe_ss7_conf_file") or die "Cant open $wanpipe_ss7_conf_file";
$wp_file =~ s/DEVNUM/$device_no/g;
$wp_file =~ s/SS7SIGCHAN/$ss7_sigchan/g;
$wp_file =~ s/TDMVOICECHAN/$ss7_tdmchan/g;
$wp_file =~ s/VOICEINTERFACE/$ss7_tdminterface/g;
$wp_file =~ s/RXSLEVEL/$rx_slevel/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
print FH $wp_file;
close (FH);
}
sub gen_wanpipe_conf{
my ($self, $is_freebsd) = @_;
my $wanpipe_conf_template = $self->card->current_dir."/templates/wanpipe.tdm.a10u";
my $wanpipe_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
my $tdmv_span_no = $self->card->tdmv_span_no;
my $device_no = $self->card->device_no;
my $pci_slot = $self->card->pci_slot;
my $pci_bus = $self->card->pci_bus;
my $fe_media = $self->fe_media;
my $fe_lcode = $self->fe_lcode;
my $fe_frame = $self->fe_frame;
my $fe_line = $self->fe_line;
my $te_sig_mode = $self->te_sig_mode;
my $fe_clock = $self->fe_clock;
my $ss7_option = $self->ss7_option;
my $dchan = 0;
my $fe_lbo;
my $fe_cpu;
my $tdm_voice_op_mode = "TDM_VOICE";
my $rx_slevel= $self->rx_slevel;
my $device_alpha = &get_alpha_from_num($device_no);
my $te_sig_mode_line='';
if ($ss7_option == 1){
$wanpipe_conf_template = $self->card->current_dir."/templates/ss7_a10u/wanpipe.ss7.4";
} elsif ($ss7_option == 2){
$wanpipe_conf_template = $self->card->current_dir."/templates/ss7_a10u/wanpipe.tdmvoiceapi.a10u";
}
if ($self->fe_line eq '1'){
$fe_cpu='A';
}elsif($self->fe_line eq '2'){
$fe_cpu='B';
}else{
print "Error: Invalid port on A101-2u\n";
exit 1;
}
$dchan = 0;
if(!$is_freebsd){
if ($self->signalling =~ m/PRI/ | $self->signalling =~ m/SS7/ ){
if(($self->fe_media eq 'T1')){
$dchan=24;
}else{
$dchan=16;
}
}
}
if($self->fe_media eq 'T1'){
$te_sig_mode_line='';
$fe_lbo='0DB';
}else{
$fe_lbo='120OH';
$te_sig_mode_line= 'TE_SIG_MODE = '.$te_sig_mode;
}
if($self->signalling eq 'TDM API'){
$tdm_voice_op_mode = "TDM_VOICE_API";
#for tdm_api hw_dchan is set by user
$dchan = $self->hw_dchan;
}
open(FH, $wanpipe_conf_template ) or die "Cannot open $wanpipe_conf_template";
my $wp_file='';
while (<FH>) {
$wp_file .= $_;
}
close (FH);
open(FH, ">>$wanpipe_conf_file") or die "Cant open $wanpipe_conf_file";
$wp_file =~ s/DEVNUM/$device_no/g;
if ( $is_freebsd ) {
$wp_file =~ s/IFNUM/$device_alpha/g;
} else {
$wp_file =~ s/IFNUM/$device_no/g;
}
$wp_file =~ s/TDM_VOICE_OP_MODE/$tdm_voice_op_mode/g;
$wp_file =~ s/SLOTNUM/$pci_slot/g;
$wp_file =~ s/BUSNUM/$pci_bus/g;
$wp_file =~ s/FEMEDIA/$fe_media/g;
$wp_file =~ s/FELCODE/$fe_lcode/g;
$wp_file =~ s/TESIGMODE/$te_sig_mode_line/g;
$wp_file =~ s/FEFRAME/$fe_frame/g;
$wp_file =~ s/FECPU/$fe_cpu/g;
$wp_file =~ s/FECLOCK/$fe_clock/g;
$wp_file =~ s/FELBO/$fe_lbo/g;
$wp_file =~ s/RXSLEVEL/$rx_slevel/g;
$wp_file =~ s/TDMVDCHAN/$dchan/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
print FH $wp_file;
close (FH);
# print "\n created $fname for A$card_model $devnum SLOT $slot BUS $bus HWEC $hwec_mode\n";
}
sub gen_zaptel_conf{
my ($self, $dchan_str) = @_;
my $zap_lcode;
my $zap_frame;
my $zap_crc4;
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
my $dahdi_echo = $self->card->dahdi_echo;
if ( $self->fe_lcode eq 'B8ZS' ){
$zap_lcode='b8zs';
} elsif ( $self->fe_lcode eq 'AMI' ){
$zap_lcode='ami';
} elsif ( $self->fe_lcode eq 'HDB3' ){
$zap_lcode='hdb3';
} else {
printf("Error: invalid line coding %s\n", $self->fe_lcode);
exit;
}
if ( $self->fe_frame eq 'ESF' ){
$zap_frame='esf';
} elsif ( $self->fe_frame eq 'D4' ){
$zap_frame='d4';
} elsif ( $self->fe_frame eq 'CRC4' ){
$zap_frame='ccs';
$zap_crc4=',crc4';
} elsif ( $self->fe_frame eq 'NCRC4' ){
$zap_frame='ccs';
} else {
printf("Error: invalid line framing %s\n", $self->fe_frame);
exit;
}
my $zp_file='';
$zp_file.="\n\#Sangoma A".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
$zp_file.="span=".$self->card->tdmv_span_no.",".$self->card->tdmv_span_no.",0,".$zap_frame.",".$zap_lcode.$zap_crc4."\n";
if ( $self->signalling =~ m/PRI/ ){
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
if($self->frac_chan_last == 24){
$self->frac_chan_last(23);
}
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="bchan=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+23)."\n";
} else {
$zp_file.="bchan=".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+23)."\n";
}
} else {
if($self->frac_chan_first() != 0){
if($self->frac_chan_last() == 16){
$self->frac_chan_last(15);
}
if($self->frac_chan_first() == 16){
$self->frac_chan_first(17);
}
if($self->frac_chan_last() > 15){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
my $mid_ch1=$self->card->first_chan + 14;
my $mid_ch2=$self->card->first_chan + 16;
$zp_file.="bchan=".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="bchan=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
}
} else {
$zp_file.="bchan=".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
}
}
} else {
my $zap_signal;
if ( $self->signalling eq 'Zaptel/Dahdi - E & M' | $self->signalling eq 'Zaptel/Dahdi - E & M Wink' ){
$zap_signal='e&m';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Loop Start' ){
$zap_signal='fxsls';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Ground Start' ){
$zap_signal='fxsgs';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Kewl Start' ){
$zap_signal='fxsks';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Loop Start' ){
$zap_signal='fxols';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Ground Start' ){
$zap_signal='fxogs';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Kewl Start' ){
$zap_signal='fxoks';
} else {
printf("Error: invalid signalling %s\n", $self->card->signalling);
}
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.=$zap_signal."=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
}
} else {
$zp_file.=$zap_signal."=".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=".$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
}
}
}
} else {
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.=$zap_signal."=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
}
} else {
$zp_file.=$zap_signal."=".$self->card->first_chan."-".($self->card->first_chan+30)."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=".$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+30)."\n";
}
}
}
}
}
return $zp_file;
}
sub gen_zapata_conf{
my ($self) = @_;
my $zp_file='';
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
$zp_file.="\n\;Sangoma A".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
# $zp_file.="\n\;Sangoma A".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span: ".$self->card->span_no."]\n";
if ( $self->signalling =~ m/PRI/ ){
$zp_file.="switchtype=".$self->pri_switchtype."\n";
}
$zp_file.="context=".$self->card->zap_context."\n";
$zp_file.="group=".$self->card->zap_group."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocancel=yes\n";
}
if ( $self->signalling eq 'Zaptel/Dahdi - PRI NET' ){
$zp_file.="signalling=pri_net\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - PRI CPE' ){
$zp_file.="signalling=pri_cpe\n";
} elsif ( $self->signalling eq 'E & M' ){
$zp_file.="signalling=em\n";
} elsif ($self->signalling eq 'E & M Wink' ){
$zp_file.="signalling=em_w\n";
} elsif ( $self->signalling eq 'FXS - Loop Start' ){
$zp_file.="signalling=fxs_ls\n";
} elsif ( $self->signalling eq 'FXS - Ground Start' ){
$zp_file.="signalling=fxs_gs\n";
} elsif ( $self->signalling eq 'FXS - Kewl Start' ){
$zp_file.="signalling=fxs_ks\n";
} elsif ( $self->signalling eq 'FX0 - Loop Start' ){
$zp_file.="signalling=fxo_ls\n";
} elsif ( $self->signalling eq 'FX0 - Ground Start' ){
$zp_file.="signalling=fxo_gs\n";
} elsif ( $self->signalling eq 'FX0 - Kewl Start' ){
$zp_file.="signalling=fxo_ks\n";
} else {
printf("Error: invalid signalling %s\n", $self->signalling);
}
if ( $self->signalling eq 'PRI NET' | $self->signalling eq 'PRI CPE' ){
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
if($self->frac_chan_last == 24){
$self->frac_chan_last(23);
}
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
} else {
$zp_file.="channel =>".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
}
}else{
if($self->frac_chan_first() != 0){
if($self->frac_chan_last() == 16){
$self->frac_chan_last(15);
}
if($self->frac_chan_first() == 16){
$self->frac_chan_first(17);
}
if($self->frac_chan_last() > 15){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
my $mid_ch1=$self->card->first_chan + 14;
my $mid_ch2=$self->card->first_chan + 16;
$zp_file.="channel =>".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
}
} else {
$zp_file.="channel =>".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
}
}
} else {
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
} else {
$zp_file.="channel => ".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
}
} else {
if($self->frac_chan_first() != 0){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
} else {
$zp_file.="channel => ".$self->card->first_chan."-".($self->card->first_chan+30)."\n";
}
}
}
return $zp_file;
}
sub gen_pri_conf{
my ($self ,$span_no,$span_type, $group_no, $switch_type,$trunk_type,$sig_mode) = @_;
my $pri_file='';
$pri_file.="\n";
#$pri_file.="link=$trunk_type\n";
if ($sig_mode =~ m/CPE/ ){
$pri_file.="signalling=pri_cpe\n";
} elsif ( $sig_mode =~ m/NET/ ){
$pri_file.="signalling=pri_net\n";
}
$pri_file.="switchtype=$switch_type\n";
$pri_file.="group=$group_no\n";
$pri_file.="spans=$span_no\n";
#$pri_file.="operator=$operator\n";
return $pri_file;
}
sub gen_woomera_conf{
my ($self, $group, $context) = @_;
my $woomera_file='';
$woomera_file.="\n";
$woomera_file.="context=$context\n";
$woomera_file.="group=$group\n";
return $woomera_file;
}
1;

View File

@ -1,811 +0,0 @@
#class A10x
#for A10x-sh series cards
package A10x;
use Card;
use strict;
#constructor
sub new {
my ($class) = @_;
my $self = {
_is_tdm_api => undef,
_current_dir => undef,
_card => undef,
_fe_line => undef,
_fe_media => 'T1',
_fe_lcode => 'B8ZS',
_fe_frame => 'ESF',
_fe_clock => 'NORMAL',
_te_sig_mode => undef,
_te_ref_clock => '0',
_signalling => 'PRI_CPE',
_pri_switchtype => 'national',
_rx_slevel => '360',
_hw_dchan => '0',
_frac_chanfirst => '0',
_frac_chanlast => '0',
_ss7_sigchan => undef,
_ss7_option => undef,
_ss7_tdmchan => undef,
_ss7_subinterface => undef,
_ss7_tdminterface => undef,
_hp_option => undef,
_mtu_mru => undef,
_old_a10u => undef,
_smg_sig_mode => '1',
};
bless $self, $class;
return $self;
}
sub card {
my ( $self, $card ) = @_;
$self->{_card} = $card if defined($card);
return $self->{_card};
}
sub fe_line {
my ( $self, $fe_line ) = @_;
$self->{_fe_line} = $fe_line if defined($fe_line);
return $self->{_fe_line};
}
sub frac_chan_first {
my ( $self, $frac_chan_first ) = @_;
$self->{_frac_chan_first} = $frac_chan_first if defined($frac_chan_first);
return $self->{_frac_chan_first};
}
sub frac_chan_last {
my ( $self, $frac_chan_last ) = @_;
$self->{_frac_chan_last} = $frac_chan_last if defined($frac_chan_last);
return $self->{_frac_chan_last};
}
sub te_ref_clock {
my ( $self, $te_ref_clock ) = @_;
$self->{_te_ref_clock} = $te_ref_clock if defined($te_ref_clock);
return $self->{_te_ref_clock};
}
sub signalling {
my ( $self, $signalling ) = @_;
$self->{_signalling} = $signalling if defined($signalling);
return $self->{_signalling};
}
sub fe_media {
my ( $self, $fe_media ) = @_;
$self->{_fe_media} = $fe_media if defined($fe_media);
return $self->{_fe_media};
}
sub fe_lcode {
my ( $self, $fe_lcode) = @_;
$self->{_fe_lcode} = $fe_lcode if defined($fe_lcode);
return $self->{_fe_lcode};
}
sub fe_frame {
my ( $self, $fe_frame ) = @_;
$self->{_fe_frame} = $fe_frame if defined($fe_frame);
return $self->{_fe_frame};
}
sub hw_dchan {
my ( $self, $hw_dchan ) = @_;
$self->{_hw_dchan} = $hw_dchan if defined($hw_dchan);
return $self->{_hw_dchan};
}
sub fe_clock {
my ( $self, $fe_clock ) = @_;
$self->{_fe_clock} = $fe_clock if defined($fe_clock);
return $self->{_fe_clock};
}
sub te_sig_mode {
my ( $self, $te_sig_mode ) = @_;
$self->{_te_sig_mode} = $te_sig_mode if defined($te_sig_mode);
return $self->{_te_sig_mode};
}
sub pri_switchtype {
my ( $self, $pri_switchtype ) = @_;
$self->{_pri_switchtype} = $pri_switchtype if defined($pri_switchtype);
return $self->{_pri_switchtype};
}
sub current_dir {
my ( $self, $current_dir ) = @_;
$self->{_current_dir} = $current_dir if defined($current_dir);
return $self->{_current_dir};
}
sub ss7_option {
my ( $self, $ss7_option ) = @_;
$self->{_ss7_option} = $ss7_option if defined($ss7_option);
return $self->{_ss7_option};
}
sub hp_option {
my ( $self, $hp_option ) = @_;
$self->{_hp_option} = $hp_option if defined($hp_option);
return $self->{_hp_option};
}
sub ss7_sigchan {
my ( $self, $ss7_sigchan ) = @_;
$self->{_ss7_sigchan} = $ss7_sigchan if defined($ss7_sigchan);
return $self->{_ss7_sigchan};
}
sub ss7_tdmchan {
my ( $self, $ss7_tdmchan ) = @_;
$self->{_ss7_tdmchan} = $ss7_tdmchan if defined($ss7_tdmchan);
return $self->{_ss7_tdmchan};
}
sub ss7_subinterface {
my ( $self, $ss7_subinterface ) = @_;
$self->{_ss7_subinterface} = $ss7_subinterface if defined($ss7_subinterface);
return $self->{_ss7_subinterface};
}
sub ss7_tdminterface {
my ( $self, $ss7_tdminterface ) = @_;
$self->{_ss7_tdminterface} = $ss7_tdminterface if defined($ss7_tdminterface);
return $self->{_ss7_tdminterface};
}
sub mtu_mru {
my ( $self, $mtu_mru ) = @_;
$self->{_mtu_mru} = $mtu_mru if defined($mtu_mru);
return $self->{_mtu_mru};
}
sub is_tdm_api {
my ( $self, $is_tdm_api ) = @_;
$self->{_is_tdm_api} = $is_tdm_api if defined($is_tdm_api);
return $self->{_is_tdm_api};
}
sub old_a10u {
my ( $self, $old_a10u ) = @_;
$self->{_old_a10u} = $old_a10u if defined($old_a10u);
return $self->{_old_a10u};
}
sub rx_slevel {
my ( $self, $rx_slevel ) = @_;
$self->{_rx_slevel} = $rx_slevel if defined($rx_slevel);
return $self->{_rx_slevel};
}
sub prompt_user{
my($promptString, $defaultValue) = @_;
if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}
}
sub smg_sig_mode {
my ( $self, $smg_sig_mode ) = @_;
$self->{_smg_sig_mode} = $smg_sig_mode if defined($smg_sig_mode);
return $self->{_smg_sig_mode};
}
sub prompt_user_list{
my @list = @_;
my $i;
my $valid = 0;
for $i (0..$#list) {
printf(" %s\. %s\n",$i+1, @list[$i]);
}
while ($valid == 0){
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ( $_ =~ /(\d+)/ ){
if ( $1 > $#list+1) {
print "Invalid option: Value out of range \n";
} else {
return $1-1 ;
}
} else {
print "Invalid option: Input an integer\n";
}
}
}
sub print {
my ($self) = @_;
$self->card->print();
printf (" fe_line: %s\n fe_media: %s\n fe_lcode: %s\n fe_frame: %s \n fe_clock:%s\n ", $self->fe_line, $self->fe_media, $self->fe_lcode, $self->fe_frame, $self->fe_clock);
}
sub get_alpha_from_num {
my ($num) = @_;
my $alpha_str="";
my $alpha_char="";
my $i;
my @chars = split(//, $num);
for $i (0..$#chars) {
if ( $i == 0 ) {
$alpha_char=chr(ord(@chars[$i])+48);
} else {
$alpha_char=chr(ord(@chars[$i])+49);
}
$alpha_str=$alpha_str."".$alpha_char;
}
return $alpha_str;
}
sub gen_wanpipe_ss7_subinterfaces{
my ($self) = @_;
my $wanpipe_ss7_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
my $ss7_sigchan = $self->ss7_sigchan;
my $tdmv_span_no = $self->card->tdmv_span_no;
my $device_no = $self->card->device_no;
my $ss7_subinterface = $self->ss7_subinterface;
my $ss7_tdmchan = $self->ss7_tdmchan;
my $mtu_mru = $self->mtu_mru;
my $hwec_mode = $self->card->hwec_mode;
my $ss7_tdminterface = $self->ss7_tdminterface;
my $hp_option = $self->hp_option;
my $card_type="WAN_AFT_TE1";
my $old_a10u = $self->old_a10u;
my $rx_slevel= $self->rx_slevel;
my $wanpipe_ss7_interfaces_template = $self->card->current_dir."/templates/ss7_a100/wanpipe.ss7.$ss7_subinterface";
if (!($hp_option == ' ')) {
#for hp tdmapi change templates
$wanpipe_ss7_interfaces_template = $self->card->current_dir."/templates/hp_a100/wanpipe.hp.$ss7_subinterface";
}
if(($old_a10u =~ m/YES/)){
$card_type="WAN_AFT";
}
my $hw_dtmf = $self->card->hw_dtmf;
my $hw_fax = $self->card->hw_fax;
open(FH, $wanpipe_ss7_interfaces_template) or die "Can't open $wanpipe_ss7_interfaces_template";
my $wp_file='';
while (<FH>) {
if (!(($ss7_tdminterface == ' ') && (($wanpipe_ss7_interfaces_template =~ m/2/) || ($wanpipe_ss7_interfaces_template =~ m/5/)))){
$wp_file .= $_;
}
}
close (FH);
open(FH, ">>$wanpipe_ss7_conf_file") or die "Cant open $wanpipe_ss7_conf_file";
$wp_file =~ s/WAN_AFT_TYPE/$card_type/g;
$wp_file =~ s/DEVNUM/$device_no/g;
$wp_file =~ s/SS7SIGCHAN/$ss7_sigchan/g;
$wp_file =~ s/TDMVOICECHAN/$ss7_tdmchan/g;
$wp_file =~ s/HWECMODE/$hwec_mode/g;
$wp_file =~ s/RXSLEVEL/$rx_slevel/g;
$wp_file =~ s/CHUNKTIME/$mtu_mru/g;
$wp_file =~ s/VOICEINTERFACE/$ss7_tdminterface/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
$wp_file =~ s/HWDTMF/$hw_dtmf/g;
$wp_file =~ s/HWFAX/$hw_fax/g;
print FH $wp_file;
close (FH);
}
sub gen_wanpipe_conf{
my ($self, $is_freebsd) = @_;
my $wanpipe_conf_template = $self->card->current_dir."/templates/wanpipe.tdm.a100";
my $wanpipe_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
my $device_no = $self->card->device_no;
my $tdmv_span_no = $self->card->tdmv_span_no;
my $pci_slot = $self->card->pci_slot;
my $pci_bus = $self->card->pci_bus;
my $fe_media = $self->fe_media;
my $fe_lcode = $self->fe_lcode;
my $fe_frame = $self->fe_frame;
my $fe_line = $self->fe_line;
my $fe_clock = $self->fe_clock;
my $te_ref_clock = $self->te_ref_clock;
my $te_sig_mode = $self->te_sig_mode;
my $hwec_mode = $self->card->hwec_mode;
my $hw_dtmf = $self->card->hw_dtmf;
my $hw_fax = $self->card->hw_fax;
my $ss7_option = $self->ss7_option;
my $hp_option = $self->hp_option;
my $dchan = $self->hw_dchan;
my $fe_lbo;
my $old_a10u = $self->old_a10u;
my $fe_cpu = "A";
my $card_type="WAN_AFT_TE1";
my $tdm_voice_op_mode = "TDM_VOICE";
my $mtu_size='8';
my $device_alpha = &get_alpha_from_num($device_no);
my $te_sig_mode_line='';
my $card_model = $self->card->card_model;
my $rx_slevel= $self->rx_slevel;
if ($ss7_option == 1){
$wanpipe_conf_template = $self->card->current_dir."/templates/ss7_a100/wanpipe.ss7.4";
} elsif ($ss7_option == 2){
$wanpipe_conf_template = $self->card->current_dir."/templates/ss7_a100/wanpipe.tdmvoiceapi.a100";
} elsif ($hp_option == 1){
$wanpipe_conf_template = $self->card->current_dir."/templates/hp_a100/wanpipe.hp.4";
}
if(($old_a10u =~ m/YES/)){
#Set card type and CPU for old card in for hpdmapi
$card_type="WAN_AFT";
if ($self->fe_line eq '1'){
$fe_cpu='A';
}elsif($self->fe_line eq '2'){
$fe_cpu='B';
}else{
print "Error: Invalid port on A101-2u\n";
exit 1;
}
}
if($is_freebsd){
$dchan = 0;
}
if(!$is_freebsd){
if ($self->signalling =~ m/PRI/ | $self->signalling =~ m/SS7/ ){
if(($self->fe_media eq 'T1')){
$dchan=24;
}else{
$dchan=16;
}
}
}
if($card_model eq '601'){
#601 doesn't have hardware HDLC support
$dchan = '0';
}
if($self->fe_media eq 'T1'){
$te_sig_mode_line='';
$fe_lbo='0DB';
}else{
$fe_lbo='120OH';
$te_sig_mode_line= 'TE_SIG_MODE = '.$te_sig_mode;
}
if($self->is_tdm_api eq '0') {
$tdm_voice_op_mode = "TDM_VOICE_API";
#for tdm_api hw_dchan is set by user
$dchan = $self->hw_dchan;
$mtu_size='80';
}
open(FH, $wanpipe_conf_template) or die "Can't open $wanpipe_conf_template";
my $wp_file='';
while (<FH>) {
$wp_file .= $_;
}
close (FH);
open(FH, ">>$wanpipe_conf_file") or die "Cant open $wanpipe_conf_file";
$wp_file =~ s/DEVNUM/$device_no/g;
if ( $is_freebsd ) {
$wp_file =~ s/IFNUM/$device_alpha/g;
} else {
$wp_file =~ s/IFNUM/$device_no/g;
}
$wp_file =~ s/TDM_VOICE_OP_MODE/$tdm_voice_op_mode/g;
$wp_file =~ s/FECPU/$fe_cpu/g;
$wp_file =~ s/WAN_AFT_TYPE/$card_type/g;
$wp_file =~ s/SLOTNUM/$pci_slot/g;
$wp_file =~ s/BUSNUM/$pci_bus/g;
$wp_file =~ s/FEMEDIA/$fe_media/g;
$wp_file =~ s/FELCODE/$fe_lcode/g;
$wp_file =~ s/FEFRAME/$fe_frame/g;
$wp_file =~ s/FELINE/$fe_line/g;
$wp_file =~ s/TESIGMODE/$te_sig_mode_line/g;
$wp_file =~ s/FECLOCK/$fe_clock/g;
$wp_file =~ s/TEREFCLOCK/$te_ref_clock/g;
$wp_file =~ s/RXSLEVEL/$rx_slevel/g;
$wp_file =~ s/FELBO/$fe_lbo/g;
$wp_file =~ s/TDMVDCHAN/$dchan/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
$wp_file =~ s/HWECMODE/$hwec_mode/g;
$wp_file =~ s/HWDTMF/$hw_dtmf/g;
$wp_file =~ s/HWFAX/$hw_fax/g;
$wp_file =~ s/MTUSIZE/$mtu_size/g;
print FH $wp_file;
close (FH);
# print "\n created $fname for A$card_model $devnum SLOT $slot BUS $bus HWEC $hwec_mode\n";
}
sub gen_zaptel_conf{
my ($self, $dchan_str) = @_;
my $zap_lcode;
my $zap_frame;
my $zap_crc4;
my $zp_file="";
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
my $dahdi_echo = $self->card->dahdi_echo;
my $card_model = $self->card->card_model;
if($card_model eq '601'){
#601 doesn't have hardware HDLC support
$dchan_str = 'dchan';
}
if ( $self->fe_lcode eq 'B8ZS' ){
$zap_lcode='b8zs';
} elsif ( $self->fe_lcode eq 'AMI' ){
$zap_lcode='ami';
} elsif ( $self->fe_lcode eq 'HDB3' ){
$zap_lcode='hdb3';
} else {
printf("Error: invalid line coding %s\n", $self->fe_lcode);
exit;
}
if ( $self->fe_frame eq 'ESF' ){
$zap_frame='esf';
} elsif ( $self->fe_frame eq 'D4' ){
$zap_frame='d4';
} elsif ( $self->fe_frame eq 'CRC4' ){
$zap_frame='ccs';
$zap_crc4=',crc4';
} elsif ( $self->fe_frame eq 'NCRC4' ){
$zap_frame='ccs';
} else {
printf("Error: invalid line framing %s\n", $self->fe_frame);
exit;
}
$zp_file.="\n\#Sangoma A".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
$zp_file.="span=".$self->card->tdmv_span_no.",".$self->card->tdmv_span_no.",0,".$zap_frame.",".$zap_lcode.$zap_crc4."\n";
if ( $self->signalling =~ /PRI/ ){
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="bchan=".$first_ch."\n";
if($dahdi_conf eq 'YES') {
if($hwec_mode eq 'NO' ) {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."\n";
}
}
$zp_file.=$dchan_str."=".($self->card->first_chan+23)."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
if($self->frac_chan_last == 24){
$self->frac_chan_last(23);
}
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="bchan=".$first_ch."-".$last_ch."\n";
#$zp_file.="echocanceller=mg2".$first_ch."-".$last_ch."\n";
#dahdi software echo canellation conf
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+23)."\n";
}
} else {
$zp_file.="bchan=".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+23)."\n";
}
} else {
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
if ($self->frac_chan_first == 16) {
print "Warning: You will not have any b-channels configured for this port";
print "Would you like to continue?";
if (&prompt_user_list(("YES","EXIT","")) eq 'EXIT'){
exit(1);
}
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="bchan=".$first_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
}
} else {
if($self->frac_chan_last() == 16){
$self->frac_chan_last(15);
}
if($self->frac_chan_first() == 16){
$self->frac_chan_first(17);
}
if($self->frac_chan_last() > 15){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
my $mid_ch1=$self->card->first_chan + 14;
my $mid_ch2=$self->card->first_chan + 16;
$zp_file.="bchan=".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="bchan=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
}
}
} else {
$zp_file.="bchan=".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
}
$zp_file.=$dchan_str."=".($self->card->first_chan+15)."\n";
}
}
} else {
my $zap_signal;
if ( $self->signalling eq 'Zaptel/Dahdi - E & M' | $self->signalling eq 'Zaptel/Dahdi - E & M Wink' ){
$zap_signal='e&m';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Loop Start' ){
$zap_signal='fxsls';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Ground Start' ){
$zap_signal='fxsgs';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Kewl Start' ){
$zap_signal='fxsks';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Loop Start' ){
$zap_signal='fxols';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Ground Start' ){
$zap_signal='fxogs';
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Kewl Start' ){
$zap_signal='fxoks';
} else {
printf("Error: invalid signalling %s\n", $self->card->signalling);
}
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.=$zap_signal."=".$first_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."\n";
}
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.=$zap_signal."=".$first_ch."-".$last_ch."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$first_ch."-".$last_ch."\n";
}
}
} else {
$zp_file.=$zap_signal."=".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=".$dahdi_echo.",".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
}
}
} else {
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.=$zap_signal."=".$first_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.=$zap_signal."=".$first_ch."-".$last_ch."\n";
}
} else {
$zp_file.=$zap_signal."=".$self->card->first_chan."-".($self->card->first_chan+30)."\n";
}
}
}
return $zp_file;
}
sub gen_zapata_conf{
my ($self) = @_;
my $zp_file='';
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
my $fax_detect = $self->card->hw_fax;
$zp_file.="\n\;Sangoma A".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
if ( $self->signalling =~ m/PRI/ ){
$zp_file.="switchtype=".$self->pri_switchtype."\n";
}
$zp_file.="context=".$self->card->zap_context."\n";
$zp_file.="group=".$self->card->zap_group."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocancel=yes\n";
}
if($fax_detect eq 'YES'){
$zp_file.="faxdetect=incoming\n";
}
if ( $self->signalling eq 'Zaptel/Dahdi - PRI NET' ){
$zp_file.="signalling=pri_net\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - PRI CPE' ){
$zp_file.="signalling=pri_cpe\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - E & M' ){
$zp_file.="signalling=em\n";
} elsif ($self->signalling eq 'Zaptel/Dahdi - E & M Wink' ){
$zp_file.="signalling=em_w\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Loop Start' ){
$zp_file.="signalling=fxs_ls\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Ground Start' ){
$zp_file.="signalling=fxs_gs\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FXS - Kewl Start' ){
$zp_file.="signalling=fxs_ks\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Loop Start' ){
$zp_file.="signalling=fxo_ls\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Ground Start' ){
$zp_file.="signalling=fxo_gs\n";
} elsif ( $self->signalling eq 'Zaptel/Dahdi - FX0 - Kewl Start' ){
$zp_file.="signalling=fxo_ks\n";
} else {
printf("Error: invalid signalling %s\n", $self->signalling);
}
if ( $self->signalling eq 'Zaptel/Dahdi - PRI NET' | $self->signalling eq 'Zaptel/Dahdi - PRI CPE' ){
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="channel =>".$first_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
if($self->frac_chan_last == 24){
$self->frac_chan_last(23);
}
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
}
} else {
$zp_file.="channel =>".$self->card->first_chan."-".($self->card->first_chan+22)."\n";
}
}else{
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
#already sent warning on gen_zaptel_conf
if ($self->frac_chan_first != 16) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="channel =>".$first_ch."\n";
}
} else {
if($self->frac_chan_last() == 16){
$self->frac_chan_last(15);
}
if($self->frac_chan_first() == 16){
$self->frac_chan_first(17);
}
if($self->frac_chan_last() > 15){
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
my $mid_ch1=$self->card->first_chan + 14;
my $mid_ch2=$self->card->first_chan + 16;
$zp_file.="channel =>".$first_ch."-".$mid_ch1.",".$mid_ch2."-".$last_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
}
}
} else {
$zp_file.="channel =>".$self->card->first_chan."-".($self->card->first_chan+14).",".($self->card->first_chan+16)."-".($self->card->first_chan+30)."\n";
}
}
} else {
if ( $self->fe_media eq 'T1' ){
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="channel =>".$first_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
}
} else {
$zp_file.="channel => ".$self->card->first_chan."-".($self->card->first_chan+23)."\n";
}
} else {
if($self->frac_chan_first() != 0){
if ($self->frac_chan_first == $self->frac_chan_last) {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
$zp_file.="channel =>".$first_ch."\n";
} else {
my $first_ch=$self->card->first_chan + $self->frac_chan_first-1;
my $last_ch=$self->card->first_chan + $self->frac_chan_last-1;
$zp_file.="channel =>".$first_ch."-".$last_ch."\n";
}
} else {
$zp_file.="channel => ".$self->card->first_chan."-".($self->card->first_chan+30)."\n";
}
}
}
return $zp_file;
}
sub gen_pri_conf{
my ($self ,$span_no,$span_type, $group_no, $switch_type,$trunk_type,$sig_mode) = @_;
my $pri_file='';
$pri_file.="\n";
#$pri_file.="link=$trunk_type\n";
if ($sig_mode =~ m/CPE/ ){
$pri_file.="signalling=pri_cpe\n";
} elsif ( $sig_mode =~ m/NET/ ){
$pri_file.="signalling=pri_net\n";
}
$pri_file.="switchtype=$switch_type\n";
$pri_file.="group=$group_no\n";
$pri_file.="spans=$span_no\n";
#$pri_file.="operator=$operator\n";
return $pri_file;
}
sub gen_woomera_conf{
my ($self, $group, $context) = @_;
my $woomera_file='';
$woomera_file.="\n";
$woomera_file.="context=$context\n";
$woomera_file.="group=$group\n";
return $woomera_file;
}
1;

View File

@ -1,227 +0,0 @@
#class A20x
#for A200 series cards
package A20x;
use Card;
use strict;
#constructor
sub new {
my ($class) = @_;
my $self = {
_is_tdm_api => undef,
_card => undef,
_tdm_opermode => 'FCC',
_tdm_law => 'MULAW',
_rm_network_sync => 'NO',
_analog_modules => undef,
};
bless $self, $class;
return $self;
}
sub card {
my ( $self, $card ) = @_;
$self->{_card} = $card if defined($card);
return $self->{_card};
}
sub tdm_opermode {
my ( $self, $tdm_opermode ) = @_;
$self->{_tdm_opermode} = $tdm_opermode if defined($tdm_opermode);
return $self->{_tdm_opermode};
}
sub tdm_law {
my ( $self, $tdm_law ) = @_;
$self->{_tdm_law} = $tdm_law if defined($tdm_law);
return $self->{_tdm_law};
}
sub rm_network_sync {
my ( $self, $rm_network_sync ) = @_;
$self->{_rm_network_sync} = $rm_network_sync if defined($rm_network_sync);
return $self->{_rm_network_sync};
}
sub is_tdm_api {
my ( $self, $is_tdm_api ) = @_;
$self->{_is_tdm_api} = $is_tdm_api if defined($is_tdm_api);
return $self->{_is_tdm_api};
}
sub analog_modules {
my ( $self, $analog_modules ) = @_;
$self->{_analog_modules} = $analog_modules if defined($analog_modules);
return $self->{_analog_modules};
}
sub prompt_user{
my($promptString, $defaultValue) = @_;
if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}
}
sub prompt_user_list{
my @list = @_;
my $i;
my $valid = 0;
for $i (0..$#list) {
printf(" %s\. %s\n",$i+1, @list[$i]);
}
while ($valid == 0){
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ( $_ =~ /(\d+)/ ){
if ( $1 > $#list+1) {
print "Invalid option: Value out of range \n";
} else {
return $1-1 ;
}
} else {
print "Invalid option: Input an integer\n";
}
}
}
sub print {
my ($self) = @_;
$self->card->print();
}
sub get_alpha_from_num {
my ($num) = @_;
my $alpha_str="";
my $alpha_char="";
my $i;
my @chars = split(//, $num);
for $i (0..$#chars) {
if ( $i == 0 ) {
$alpha_char=chr(ord(@chars[$i])+48);
} else {
$alpha_char=chr(ord(@chars[$i])+49);
}
$alpha_str=$alpha_str."".$alpha_char;
}
return $alpha_str;
}
sub gen_wanpipe_conf{
my ($self, $is_freebsd) = @_;
my $wanpipe_conf_template = $self->card->current_dir."/templates/wanpipe.tdm.a200";
my $wanpipe_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
my $device_no = $self->card->device_no;
my $tdmv_span_no = $self->card->tdmv_span_no;
my $pci_slot = $self->card->pci_slot;
my $pci_bus = $self->card->pci_bus;
my $tdm_law = $self->tdm_law;
my $tdm_opermode = $self->tdm_opermode;
my $rm_network_sync = $self->rm_network_sync;
my $hwec_mode = $self->card->hwec_mode;
my $hw_dtmf = $self->card->hw_dtmf;
my $hw_fax = $self->card->hw_fax;
my $is_tdm_api = $self->is_tdm_api;
my $tdm_voice_op_mode = "TDM_VOICE";
my $device_alpha = &get_alpha_from_num($device_no);
if($self->is_tdm_api eq '0') {
$tdm_voice_op_mode = "TDM_VOICE_API";
}
open(FH, $wanpipe_conf_template) or die "Can open $wanpipe_conf_template";
my $wp_file='';
while (<FH>) {
$wp_file .= $_;
}
close (FH);
open(FH, ">$wanpipe_conf_file") or die "Cant open $wanpipe_conf_file";
$wp_file =~ s/DEVNUM/$device_no/g;
if ( $is_freebsd ) {
$wp_file =~ s/IFNUM/$device_alpha/g;
} else {
$wp_file =~ s/IFNUM/$device_no/g;
}
$wp_file =~ s/TDM_VOICE_OP_MODE/$tdm_voice_op_mode/g;
$wp_file =~ s/SLOTNUM/$pci_slot/g;
$wp_file =~ s/BUSNUM/$pci_bus/g;
$wp_file =~ s/TDM_LAW/$tdm_law/g;
$wp_file =~ s/RMNETSYNC/$rm_network_sync/g;
$wp_file =~ s/TDM_OPERMODE/$tdm_opermode/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
$wp_file =~ s/HWECMODE/$hwec_mode/g;
$wp_file =~ s/HWDTMF/$hw_dtmf/g;
$wp_file =~ s/HWFAX/$hw_fax/g;
print FH $wp_file;
close (FH);
# print "\n created $fname for A$card_model $devnum SLOT $slot BUS $bus HWEC $hwec_mode\n";
}
sub gen_zaptel_conf{
my ($self, $channel, $type) = @_;
my $zp_file='';
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
my $dahdi_echo = $self->card->dahdi_echo;
if ( $type eq 'fxo'){
#this is an FXS module
$zp_file.="fxoks=$channel\n";
}else{
$zp_file.="fxsks=$channel\n";
}
if($dahdi_conf eq 'YES') {
$zp_file.="echocanceller=" .$dahdi_echo.",".$channel."\n";
}
return $zp_file;
}
sub gen_zapata_conf{
my ($self, $channel, $type) = @_;
my $dahdi_conf = $self->card->dahdi_conf;
my $hwec_mode = $self->card->hwec_mode;
my $dahdi_echo = $self->card->dahdi_echo;
my $fax_detect = $self->card->hw_fax;
my $zp_file='';
$zp_file.="context=".$self->card->zap_context."\n";
$zp_file.="group=".$self->card->zap_group."\n";
if($dahdi_conf eq 'YES') {
$zp_file.="echocancel=yes\n";
}
if($fax_detect eq 'YES'){
$zp_file.="faxdetect=incoming\n";
}
if ( $type eq 'fxo'){
#this is an FXS module
$zp_file.="signalling = fxo_ks\n";
}else{
$zp_file.="signalling = fxs_ks\n";
}
$zp_file.="channel => $channel\n\n";
return $zp_file;
}
1;

View File

@ -1,261 +0,0 @@
#class A50x
#for A50x-sh series cards
package A50x;
use Card;
use strict;
#constructor
sub new {
my ($class) = @_;
my $self = {
_current_dir => undef,
_card => undef,
_fe_line => undef,
_fe_media => 'BRI',
_bri_switchtype => 'etsi',
_bri_country => 'europe',
_signalling => 'NT',
};
bless $self, $class;
return $self;
}
sub card {
my ( $self, $card ) = @_;
$self->{_card} = $card if defined($card);
return $self->{_card};
}
sub fe_line {
my ( $self, $fe_line ) = @_;
$self->{_fe_line} = $fe_line if defined($fe_line);
return $self->{_fe_line};
}
sub fe_media {
my ( $self, $fe_media ) = @_;
$self->{_fe_media} = $fe_media if defined($fe_media);
return $self->{_fe_media};
}
sub bri_switchtype {
my ( $self, $bri_switchtype ) = @_;
$self->{_bri_switchtype} = $bri_switchtype if defined($bri_switchtype);
return $self->{_bri_switchtype};
}
sub current_dir {
my ( $self, $current_dir ) = @_;
$self->{_current_dir} = $current_dir if defined($current_dir);
return $self->{_current_dir};
}
sub prompt_user{
my($promptString, $defaultValue) = @_;
if ($defaultValue) {
print $promptString, "[", $defaultValue, "]: ";
} else {
print $promptString, ": ";
}
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ("$defaultValue") {
return $_ ? $_ : $defaultValue; # return $_ if it has a value
} else {
return $_;
}
}
sub prompt_user_list{
my @list = @_;
my $i;
my $valid = 0;
for $i (0..$#list) {
printf(" %s\. %s\n",$i+1, @list[$i]);
}
while ($valid == 0){
$| = 1; # force a flush after our print
$_ = <STDIN>; # get the input from STDIN (presumably the keyboard)
chomp;
if ( $_ =~ /(\d+)/ ){
if ( $1 > $#list+1) {
print "Invalid option: Value out of range \n";
} else {
return $1-1 ;
}
} else {
print "Invalid option: Input an integer\n";
}
}
}
sub get_alpha_from_num {
my ($num) = @_;
my $alpha_str="";
my $alpha_char="";
my $i;
my @chars = split(//, $num);
for $i (0..$#chars) {
if ( $i == 0 ) {
$alpha_char=chr(ord(@chars[$i])+48);
} else {
$alpha_char=chr(ord(@chars[$i])+49);
}
$alpha_str=$alpha_str."".$alpha_char;
}
return $alpha_str;
}
sub gen_wanpipe_conf{
my ($self, $is_freebsd) = @_;
my $wanpipe_conf_template = $self->card->current_dir."/templates/wanpipe.tdm_api.a500";
my $wanpipe_conf_file = $self->card->current_dir."/".$self->card->cfg_dir."/wanpipe".$self->card->device_no.".conf";
if ($self->card->dahdi_conf eq 'YES') {
$wanpipe_conf_template = $self->card->current_dir."/templates/wanpipe.tdm.a500";
}
my $device_no = $self->card->device_no;
my $tdmv_span_no = $self->card->tdmv_span_no;
my $pci_slot = $self->card->pci_slot;
my $pci_bus = $self->card->pci_bus;
my $fe_media = $self->fe_media;
my $fe_line = $self->fe_line;
my $hwec_mode = $self->card->hwec_mode;
my $hw_dtmf = $self->card->hw_dtmf;
my $hw_fax = $self->card->hw_fax;
my $device_alpha = &get_alpha_from_num($device_no);
open(FH, $wanpipe_conf_template) or die "Can't open $wanpipe_conf_template";
my $wp_file='';
while (<FH>) {
$wp_file .= $_;
}
close (FH);
open(FH, ">>$wanpipe_conf_file") or die "Cant open $wanpipe_conf_file";
$wp_file =~ s/DEVNUM/$device_no/g;
if ( $is_freebsd ) {
$wp_file =~ s/IFNUM/$device_alpha/g;
} else {
$wp_file =~ s/IFNUM/$device_no/g;
}
$wp_file =~ s/SLOTNUM/$pci_slot/g;
$wp_file =~ s/BUSNUM/$pci_bus/g;
$wp_file =~ s/FEMEDIA/$fe_media/g;
$wp_file =~ s/FELINE/$fe_line/g;
$wp_file =~ s/TDMVSPANNO/$tdmv_span_no/g;
$wp_file =~ s/HWECMODE/$hwec_mode/g;
$wp_file =~ s/HWDTMF/$hw_dtmf/g;
$wp_file =~ s/HWFAX/$hw_fax/g;
print FH $wp_file;
close (FH);
}
sub gen_bri_conf{
my ($self, $span, $type, $group, $country, $operator, $conn_type, $default_tei) = @_;
my $bri_file='';
$bri_file.="\n";
$bri_file.="group=$group\n";
$bri_file.="country=$country\n";
$bri_file.="operator=$operator\n";
$bri_file.="connection_type=$conn_type\n";
if ( $type eq 'bri_nt') {
$bri_file.="signalling=bri_nt\n";
} else {
$bri_file.="signalling=bri_te\n";
}
if ( ! $default_tei eq ''){
$bri_file.="default_tei=$default_tei\n";
}
$bri_file.="spans=$span\n";
return $bri_file;
}
sub gen_woomera_conf{
my ($self, $group, $context) = @_;
my $woomera_file='';
$woomera_file.="\n";
$woomera_file.="context=$context\n";
$woomera_file.="group=$group\n";
return $woomera_file;
}
sub gen_zaptel_conf{
my ($self) = @_;
my $zp_file='';
my $tmpchan=1;
my $tmpstr='';
$zp_file.="\n\#Sangoma AFT-B".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
$zp_file.="span=".$self->card->tdmv_span_no.",0,0,ccs,ami\n";
$tmpchan = $self->card->first_chan+1;
$zp_file.="bchan=".$self->card->first_chan.",".$tmpchan."\n";
$tmpchan = $self->card->first_chan+1;
$tmpstr.="echocanceller=mg2,".$self->card->first_chan."-".$tmpchan."\n";
if ($self->card->dahdi_echo eq 'NO') {
$zp_file.="#";
}
$zp_file.=$tmpstr;
$tmpchan=$self->card->first_chan+2;
$zp_file.="hardhdlc=".$tmpchan."\n";
return $zp_file;
}
sub gen_zapata_conf{
my ($self) = @_;
my $zp_file='';
my $tmpchan=1;
$zp_file.="\n\;Sangoma AFT-B".$self->card->card_model." port ".$self->fe_line." [slot:".$self->card->pci_slot." bus:".$self->card->pci_bus." span:".$self->card->tdmv_span_no."] <wanpipe".$self->card->device_no.">\n";
# $zp_file.="switchtype=".$self->bri_switchtype."\n";
$zp_file.="context=".$self->card->zap_context."\n";
$zp_file.="group=".$self->card->zap_group."\n";
if ($self->card->dahdi_echo eq 'NO') {
$zp_file.="echocancel=no\n";
} else {
$zp_file.="echocancel=yes\n";
}
if ( $self->signalling eq 'NT' ){
$zp_file.="signalling=bri_net\n";
} elsif ( $self->signalling eq 'TEM' ){
$zp_file.="signalling=bri_cpe_ptmp\n";
} else {
$zp_file.="signalling=bri_cpe\n";
}
$tmpchan = $self->card->first_chan+1;
$zp_file.="channel =>".$self->card->first_chan."-".$tmpchan."\n";
return $zp_file;
}
sub signalling {
my ( $self, $signalling ) = @_;
$self->{_signalling} = $signalling if defined($signalling);
return $self->{_signalling};
}
1;

View File

@ -1,138 +0,0 @@
package Card;
use strict;
#constructor
sub new {
my ($class) = @_;
my $self = {
_current_dir => undef,
_cfg_dir => undef,
_device_no => undef,
_tdmv_span_no => undef,
_card_model => undef,
_pci_slot => undef,
_pci_bus => undef,
_fe_cpu => 'A',
_hwec_mode => 'NO',
_hw_dtmf => 'NO',
_hw_fax => 'NO',
_first_chan => '0',
_zap_context => undef,
_zap_group => undef,
_dahdi_conf => 'NO',
_dahdi_echo => 'mg2'
};
bless $self, $class;
return $self;
}
sub device_no {
my ( $self, $device_no ) = @_;
$self->{_device_no} = $device_no if defined($device_no);
return $self->{_device_no};
}
sub tdmv_span_no {
my ( $self, $tdmv_span_no ) = @_;
$self->{_tdmv_span_no} = $tdmv_span_no if defined($tdmv_span_no);
return $self->{_tdmv_span_no};
}
sub card_model {
my ( $self, $card_model ) = @_;
$self->{_card_model} = $card_model if defined($card_model);
return $self->{_card_model};
}
sub pci_slot {
my ( $self, $pci_slot ) = @_;
$self->{_pci_slot} = $pci_slot if defined($pci_slot);
return $self->{_pci_slot};
}
sub pci_bus {
my ( $self, $pci_bus ) = @_;
$self->{_pci_bus} = $pci_bus if defined($pci_bus);
return $self->{_pci_bus};
}
sub fe_cpu {
my ( $self, $fe_cpu ) = @_;
$self->{_fe_cpu } = $fe_cpu if defined($fe_cpu);
return $self->{_fe_cpu};
}
sub hwec_mode {
my ( $self, $hwec_mode ) = @_;
$self->{_hwec_mode} = $hwec_mode if defined($hwec_mode);
return $self->{_hwec_mode};
}
sub hw_dtmf {
my ( $self, $hw_dtmf ) = @_;
$self->{_hw_dtmf} = $hw_dtmf if defined($hw_dtmf);
return $self->{_hw_dtmf};
}
sub hw_fax {
my ( $self, $hw_fax ) = @_;
$self->{_hw_fax} = $hw_fax if defined($hw_fax);
return $self->{_hw_fax};
}
sub signalling {
my ( $self, $signalling ) = @_;
$self->{_signalling} = $signalling if defined($signalling);
return $self->{_signalling};
}
sub first_chan {
my ( $self, $first_chan ) = @_;
$self->{_first_chan} = $first_chan if defined($first_chan);
return $self->{_first_chan};
}
sub zap_context {
my ( $self, $zap_context ) = @_;
$self->{_zap_context} = $zap_context if defined($zap_context);
return $self->{_zap_context};
}
sub zap_group {
my ( $self, $zap_group ) = @_;
$self->{_zap_group} = $zap_group if defined($zap_group);
return $self->{_zap_group};
}
sub dahdi_conf {
my ( $self, $dahdi_conf ) = @_;
$self->{_dahdi_conf} = $dahdi_conf if defined($dahdi_conf);
return $self->{_dahdi_conf};
}
sub dahdi_echo {
my ( $self, $dahdi_echo ) = @_;
$self->{_dahdi_echo} = $dahdi_echo if defined($dahdi_echo);
return $self->{_dahdi_echo};
}
sub current_dir {
my ( $self, $current_dir ) = @_;
$self->{_current_dir} = $current_dir if defined($current_dir);
return $self->{_current_dir};
}
sub cfg_dir {
my ( $self, $cfg_dir ) = @_;
$self->{_cfg_dir} = $cfg_dir if defined($cfg_dir);
return $self->{_cfg_dir};
}
sub print {
my ($self) = @_;
printf (" span_no: %s\n card_model: %s\n pci_slot: %s\n pci_bus: %s\n hwec_mode: %s\n signalling %s\n first_chan: %s\n", $self->span_no, $self->card_model, $self->pci_slot, $self->pci_bus, $self->hwec_mode, $self->signalling, $self->first_chan);
}
1;

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